• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Raw socket behavior in OS/X 10.5... "Invalid argument"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Raw socket behavior in OS/X 10.5... "Invalid argument"?


  • Subject: Re: Raw socket behavior in OS/X 10.5... "Invalid argument"?
  • From: Hostile Fork <email@hidden>
  • Date: Tue, 26 Aug 2008 02:14:34 -0700

Hi again all,

No one has chimed in yet about the raw socket problem I posted a couple of weeks ago.  So I did a little more digging, and asked the author of this post (which seemed similar, though it was on FreeBSD not Darwin) if he'd found the source of the similar problem he wrote about in 2006, possibly related:

http://lists.freebsd.org/pipermail/freebsd-net/2006-April/010342.html

He wrote back:

"I'm sorry but I never found a solution. I silently dropped the FreeBSDsupport :/ and up till today I never tried it again.  But I hope you will be more successful!"

I'm not sure what's up with raw sockets on BSD.  Found a couple of pointers to the idea that they had problems:

http://www.cs.ucsd.edu/~braghava/notes/freebsd-sockets.txt

But knowing that, I don't know how to fix these samples.  Does anyone have a contact who is savvy about these things to forward to, who might not read this list?  It would help libnet ( http://packetfactory.net/projects/libnet/ ) and thus help anyone trying to write cross-platform code that runs on OS/X.

Thanks again for any guidance.
---
http://hostilefork.com

On Aug 11, 2008, at 2:01 PM, Hostile Fork wrote:

Hello again list... :)

I just posted about my motivations for using the "libnet" layer, which I think is a generally useful thing:

http://packetfactory.net/projects/libnet/

On the Mac implementation of libnet, I'd tripped over a problem that I sent to the library's author (Mike Schiffman).  Mike got back to me about my question today, because he is brushing up the code for a new release of libnet... and said he found it happened to him too.

The problem has to do with getting "Invalid argument" errors when running the raw socket samples on OS/X 10.5.  It's pretty easy to build the library and see what I'm talking about.  The simplest case is probably ip_raw, which uses LIBNET_RAW4:

$ sudo sample/ip_raw
libnet 1.1 packet shaping: IP + payload[raw]
Using device (null)
Write error: libnet_write_raw_ipv4(): -1 bytes written (Invalid argument)

The same code worked fine on a Fedora Core linux box, FWIW.

In my DHCP server, I would have liked to use the raw socket layer so I wouldn't have to construct the link layer myself!  I worked around it because the get_addr example worked (and gave back real numbers, not xx):

$ sudo sample/get_addr
libnet 1.1 address getter
Interface:       en0
MAC address:       xx:xx:xx:xx:xx:xx
IP  address:       xxx.xxx.xx.x

So I was able to use that number to fill in the slots for the link layer (LIBNET_LINK).  But beyond the issue of it being extra work, I'm still a bit fuzzy on how that might affect the code if it were running on a different kind of network...

Can anyone confirm if the raw sockets used to work in an old OS/X and then stopped working?  Does anyone know why that "Invalid argument" is happening?

(Note: You will probably notice that the documentation on the libnet website is out of date with the current release.  If you look inside the archive for the current release, it contains current sample code and READMEs which are better.  I'm encouraging Mike to switch to a wiki or CMS for documentation...)

Thank you!  This is a good library and I hope we can figure out what's wrong before the updated release...
---
http://hostilefork.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Raw socket behavior in OS/X 10.5... "Invalid argument"?
      • From: Quinn <email@hidden>
References: 
 >Raw socket behavior in OS/X 10.5... "Invalid argument"? (From: Hostile Fork <email@hidden>)

  • Prev by Date: Adding Network Interfaces + System Config APIs
  • Next by Date: Re: How to change the system proxy configuration ?
  • Previous by thread: Raw socket behavior in OS/X 10.5... "Invalid argument"?
  • Next by thread: Re: Raw socket behavior in OS/X 10.5... "Invalid argument"?
  • Index(es):
    • Date
    • Thread