Nmap Development mailing list archives
Re: Nsock unconnected sockets
From: David Fifield <david () bamsoftware com>
Date: Mon, 4 Oct 2010 08:52:08 -0700
On Sun, Oct 03, 2010 at 10:03:41PM -0500, Kris Katterjohn wrote:
On 10/03/2010 08:03 PM, David Fifield wrote:Some questions: 1. What do you think of the names nsock_setup_udp and sock:setup? The way to understand how it works is to know that "setup" is what you use instead of "connect" when you want an unconnected socket. Is there a name other than "setup" that conveys that better?I don't particularly like "setup" because with a name like that it sounds like you should call it for every socket, not just for unconnected ones. I can't think of a better separate function name right now either, but an API change of something like nmap.new_socket(<proto>, <family>) with optional arguments is what I first thought of as an alternative because your "setup" is akin to an actual socket() call anyway.
Yes, that's a good interface. It is more magical though. Normally after calling new_socket you have only an Nsock iod, not a real socket that you can start sending on. The socket doesn't appear until you connect. I'm afraid that adding parameters to new_socket will make people think that they should do s = nmap.new_socket("tcp") s:connect(host, port, "tcp") when that would be wrong and would actually have created a socket twice.
However, I'm not sure if setup() can be called multiple times or not, or if new sockets should be created (in fact, I'm not sure about connect either).
I think that connect and setup both leak a socket if you call them twice without closing. But that can be fixed.
2. What do you think of the NSE API, s:setup("udp") s:setup("udp", "ipv4") s:setup("udp", "ipv6") We have a precedent for using "udp" as a protocol identifier. I think that the strings "ipv4" and "ipv6" are better than constants like nmap.AF_INET and nmap.AF_INET6. Another possibility would be "in" and "in6" but I think the ones I've chosen are easier to remember.Using "udp" sounds good, but my resolve() and address_family() functions use "inet" and "inet6", which I like best (I considered "ipv4" and "ipv6" for them, too). I don't like the nmap.AF_INET constants either, but using "inet" in there just seems better to me.
Thanks, that's just what I was looking for. I didn't know that there was already a convention. David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Nsock unconnected sockets David Fifield (Oct 03)
- Re: Nsock unconnected sockets Kris Katterjohn (Oct 03)
- Re: Nsock unconnected sockets David Fifield (Oct 04)
- Re: Nsock unconnected sockets Kris Katterjohn (Oct 04)
- Re: Nsock unconnected sockets David Fifield (Oct 04)
- Re: Nsock unconnected sockets Kris Katterjohn (Oct 04)
- Re: Nsock unconnected sockets David Fifield (Oct 05)
- Re: Nsock unconnected sockets David Fifield (Oct 09)
- Re: Nsock unconnected sockets Kris Katterjohn (Oct 10)
- Re: Nsock unconnected sockets Ron (Oct 14)
- Re: Nsock unconnected sockets David Fifield (Oct 15)
- Re: Nsock unconnected sockets Patrik Karlsson (Oct 15)
- Re: Nsock unconnected sockets David Fifield (Oct 04)
- Re: Nsock unconnected sockets Kris Katterjohn (Oct 03)