Help with sendto() and IP_HDRINCL socket option

Help with sendto() and IP_HDRINCL socket option

Post by Andrew Chalup » Sat, 25 Jul 1998 04:00:00



Folks

OK, I'm trying to write a test app which will send custom TCP segments out
to the network.  I've created a raw socket and set the IP_HDRINCL option.
I then proceed to build the packet in a u_char buffer (I'm actually
reading the packet data from a file and simply copying this info
byte-by-byte into the buffer).  At this point, I spew some stuff onto the
screen to ensure that everything was copied into the buffer correctly.  
All my code seems to work fine until I call sendto() when I get an
"invalid argument" error (errno is 22).  After a number of frustrating
hours trying to figure this out, I'm at a loss.  

I checked out the web and found some code for a similar application
( http://www.7thsphere.com/hpvac/files/hacking/arnudp001.c ) which uses
sento() along with IP_HDRINCL.  I compile it fine, but when I run it I get
the same error (invalid argument).  I have no clue why this stuff isn't
working.  Needless to say, I'm getting close to the postal stage.

Any ideas?

Oh, I'm running FreeBSD 2.2.5 and using gcc...

Andrew
--
e-mail:  andcha at nortel dot ca

 
 
 

Help with sendto() and IP_HDRINCL socket option

Post by Soumen Biswa » Sun, 26 Jul 1998 04:00:00



> Folks

> OK, I'm trying to write a test app which will send custom TCP segments out
> to the network.  I've created a raw socket and set the IP_HDRINCL option.
> I then proceed to build the packet in a u_char buffer (I'm actually
> reading the packet data from a file and simply copying this info
> byte-by-byte into the buffer).  At this point, I spew some stuff onto the
> screen to ensure that everything was copied into the buffer correctly.
> All my code seems to work fine until I call sendto() when I get an
> "invalid argument" error (errno is 22).  After a number of frustrating
> hours trying to figure this out, I'm at a loss.

> I checked out the web and found some code for a similar application
> ( http://www.7thsphere.com/hpvac/files/hacking/arnudp001.c ) which uses
> sento() along with IP_HDRINCL.  I compile it fine, but when I run it I get
> the same error (invalid argument).  I have no clue why this stuff isn't
> working.  Needless to say, I'm getting close to the postal stage.

> Any ideas?

> Oh, I'm running FreeBSD 2.2.5 and using gcc...

> Andrew
> --
> e-mail:  andcha at nortel dot ca

in freebsd ,  raw sock  expects the following fields in
host  order

 ip->ip_len  & ip->ip_off

 Soumen

 
 
 

1. IP_HDRINCL Option for raw IP sockets

Hi,
        I have root access to a machine and thus have the ability to
create raw sockets. The OS is FreeBSD 2.2-CURRENT. I am trying to
reroute an IP packet from one machine to another based on some
criteria and I don't want to do kernel modification. I tried using the
IP_HDRINCL option for opening a raw socket, but it doesn't seem to do
that. I treied to isolate the error and when I tried "perror" the
error message says "no buffers available". I tried this many times and
still the same error appears. Any suggestions/ part of code to
implement this?

Thanks in advance,

Cheers,
Sudheer

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*     SUDHEER TUMULURU        *     Research Assistant              *
*     307 SW 16th Avenue      *     E331  CSE                       *
*     Apt. #307               *     Dept. of Computer & Information *
*     Gainesville             *              Sciences & Engineering *
*     FL 32601-8508, USA      *     UNIVERSITY OF FLORIDA           *
* Phone : (352) 335-8869      * Phone : (352) 392-5770              *
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

              GO FLORIDA GATORS! 1996 NATIONAL CHAMPIONS!

2. Porting Unix apps to NT

3. IP_HDRINCL and IP_PKTINFO on RAW sockets with sendmsg

4. Xfree with V2200 GFX???

5. Guru Q: recvfrom on IP_HDRINCL socket

6. Solaris 7 System Administration Certification

7. generic socket options with unixdomain sockets?

8. amtime1970

9. Socket and socket options

10. Unix domain socket: can't test for blocking before sendto

11. sockets - latency between sendto() - recvfrom()

12. Unix datagram sendto revfrom socket support ipc

13. Why sendto() on UDP socket can block forever