netcat: Local socket support

Ingo van Lil inguin at gmx.de
Thu Apr 23 21:34:36 UTC 2009


Denys Vlasenko wrote:

> Basically, you need to teach these guys how to parse special names
> and produce corresponding lsa's:
> 
> len_and_sockaddr* host2sockaddr(const char *host, int port) FAST_FUNC;
> len_and_sockaddr* xhost2sockaddr(const char *host, int port) FAST_FUNC;
> len_and_sockaddr* xdotted2sockaddr(const char *host, int port) FAST_FUNC;
> len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af) FAST_FUNC;
> len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af) FAST_FUNC;
> 
> Don't worry, they all share only one function inside. :)

Ok, let's try that again: The attached patch introduces a new config
option (FEATURE_UNIX_LOCAL) and teaches str2sockaddr() to handle
"local:" socket addresses if it is enabled. Additionally it changes nc.c
to use create_and_bind_stream_or_die() instead of manually creating and
binding the socket.

As a result the code size is slightly increased if the feature is
enabled, and reduced a little more otherwise:

* With FEATURE_UNIX_LOCAL:
rumo:~/Coding/busybox> scripts/bloat-o-meter busybox_old busybox_unstripped
function                                             old     new   delta
str2sockaddr                                         431     505     +74
.rodata                                           125568  125575      +7
xsocket_stream                                        12       -     -12
nc_main                                             1090    1036     -54
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/1 up/down: 81/-66)             Total: 15
bytes

* Without FEATURE_UNIX_LOCAL:
rumo:~/Coding/busybox> scripts/bloat-o-meter busybox_old busybox_unstripped
function                                             old     new   delta
xsocket_stream                                        12       -     -12
nc_main                                             1090    1036     -54
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-66)             Total: -66
bytes

Regards,
Ingo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: busybox-local-socket-support.patch
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090423/ffbc92e0/attachment.diff>


More information about the busybox mailing list