[Toybox] Notes about netcat toy

orc orc at sibserver.ru
Wed Jun 20 23:23:50 PDT 2012


On Wed, 20 Jun 2012 19:21:31 -0500
Rob Landley <rob at landley.net> wrote:

> On 06/19/2012 06:18 AM, orc wrote:
> > Hm, seems to be that toybox netcat does not support udp mode and
> > ipv6.
> 
> Yup.  Those are todo items.
> 
> Genericizing the code so I can use the same engine for telnet would be
> nice too.
> 
> > I'm using ipv6 for internal purposes so I see that if I want
> > ipv6-aware netcat in toybox I need to follow one of two ways here:
> 
> I want udp support so I can do:
> 
> http://sarah.thesharps.us/2009-02-22-09-00

Yes, for this too.

> 
> I'd also like to resolve this command line argument incompatability:
> 
> http://lists.busybox.net/pipermail/busybox/2009-July/069920.html
> 
> http://landley.net/hg/aboriginal/rev/1218
> 
> > - Rewrite current netcat.c logic that it will support ipv6
> 
> It's on my todo list, and not actually that big a code change.

Yes. But changes seems to be incompatible a bit with current code. Or I
did not get how to work properly when implementing a
protocol-independent program.

> 
> > - Port openbsd's netcat.c into toybox (much work needed plus
> > stripping unneeded code, 3-clause BSD)
> >
> > (Another way is to use openbsd netcat.c directly)
> 
> In which case how is toybox involved?

Uh, nevermind :-)
Just for many years I stuck with openbsd netcat.

> 
> > I have dirty (with #if 0 parts) code that supports ipv6 in current
> > toybox netcat via getaddrinfo, but with udp mode I'm stuck.
> 
> If you send me the patch and I can probably clean it up.

Of course. See attached diff.
Unfortunately I don't know how to deal with poll and other things like
that, so with udp I'm stuck here. (udp mode here was just a new command
line option plus if() switch that set ai_socktype to SOCK_DGRAM and
ai_protocol to IPPROTO_UDP)
Review it, give some suggestions. Maybe it will help.

> 
> > Implementing udp option will be useful too.
> > Rob, do you have some plans about this toy?
> 
> I have many, many plans.  My todo list runneth over.
> 
> Finishing netcat is left over from my 2009 todo list:
> 
> http://landley.net/toybox/todos/notes.txt
> 
>  netcat/nc: Implement remaining command line options.

Just noticed that in this http://landley.net/toybox/todo.txt:

> The following commands are done:
> ... nc, netcat ...

and worried about it's completeness with missing things like v4/v6
protocol support.

> 
> > Then, some other notes:
> > 
> > - busybox and openbsd netcats doesn't require to specify source
> > address and port for listen mode. Maybe rewrite netcat that it will
> > accept something like 'netcat -L 127.0.0.1 8033'?
> 
> See above.
> 
> > - Toybox netcat says that it executes program from -e option, but
> >   actually executes it via toys.optargs.
> 
> It executes the rest of the command line after -e.  If you give it -e
> "one two three" it's just like typing "one two three" on the command
> line and you'd better have a command with spaces in its name in your
> $PATH.

Okay. When you see the diff, you may notice that I had to fight with
this when trying to implement 'nc -L 127.0.0.1 8033'. Just don't know
how better to apply this here. Then I dropped that, remaining task was
to implement at least v6 support.

> 
> > - New network toys should be ready for ipv6 by default.
> 
> Note the date:
> 
> changeset:   189:22d22427dec6
> user:        Rob Landley <rob at landley.net>
> date:        Mon Dec 03 18:53:00 2007 -0600
> files:       toys/Config.in toys/netcat.c toys/toylist.h
> description:
> Add first pass at netcat.  Base applet, -f, and -w implemented.
> 
> "world ipv6 launch day" was earlier this month, and was once again
> resoundingly ignored:
> 
> http://www.fiercetelecom.com/story/world-ipv6-launch-results-what-effect-did-event-have-internet/2012-06-18
> 
> Global ipv4 traffic, 189.81 Tbps (terabits? terabytes?
> Terasomething.) ipv6 traffic: 24.07 giga-whatevers. So ipv4 is still
> about 10,000 times as much traffic as ipv6.
> 
> Yay the future and all that.  I'd like to support ipv6 on general
> principles. But unless you're in korea (the whole country sharing an
> old "class B" 16 bit IP address block last I checked), it's still
> "coming soon now" 15 years after I first heard about it when somebody
> did a presentation at a LUG meeting back in the 90's.

Yes, but ipv6 can be used not only with Internet. I use it, for
example, in some VPNs and play with it in QEMU-KVM.

> 
> Rob

(P.S. Diff can scary you, don't get it as a final implementation!)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: toybox-0.3.0-netcat-ipv6.diff
Type: application/octet-stream
Size: 7754 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20120621/8b1027dc/attachment-0004.obj>


More information about the Toybox mailing list