Re: Building IP header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HI Mike,

Thanks for the response. It worked for me. I just tried with some other options.

1. First i changed the protocol field to IPPROTO_ICMP so that i tought of sending
ICMP echo packets.

2. Then i built a ICMP packet, which is encapsulated in the IP header which is
also given my me. Here i gave a IP address which is not a IP address of any of my
interfaces ( I gave 1.2.3.4 ).

3. Now i bind the socket to a interface ( some IP address of the interface in my
box ).

4. I sent the packet using sendto ( Remember this is a ICMP echo packet).

5. In my same box i opened a RAW socket with IPPROTO_ICMP as protocol. Here i
tried to see the ICMP packet sent by me with source IP 1.2.3.4. I got the packet.
It worked.

BUT, i want to know that when i give the protocol ( IP hdr ) field to some value
between 132-255 ( unassigned ) it is taken as zero. Here comes the problem. I
want to sent a message with some protocol field which is unassigned. I used
htons(140) but the field is filled with value zero. What i have to do to make it
work with my protocol number. Any pointers??

Also will your tool support this( Unassigned protocol - both sending and
reception ), yet to check out. Project Purple is nice.

TIA,
Ramesh

Mike Ricketts wrote:

> On Sun, 23 Dec 2001, S Ramesh wrote:
>
> > I want to build a packet with a source IP address and dest ip address (
> > usual case ) given by me and the protocol field in the IP hdr is a
> > unassigned protocol number ( i used 140 ).  I built the IP header by
> > opening a RAW socket and by setting the IP_HDRINCL option. The source IP
> > address i gave is not the IP address in any of the interfaces of my
> > machine. ( I gave 1.2.3.4 ). I bind the raw socket to a local interface
> > ( my ip address is 192.168.100.242 ) and sent the packet using sendto.
> >
> I think I know what is happening, but my understanding of this is a little
> flakey - maybe somebody else can confirm it...
> Because you are sending to a local interface, the kernel sends the packet
> over the loopback interface rather than sending out and in again, so your
> recvfrom is missing it.  I think that if you specify MSG_DONTROUTE when
> sending the packet, it will behave as you expect and you should see the
> packet.
>
> <shameless plug>
> You could be using SendIP
> (http://www.earth.li/projectpurple/progs/sendip.html) to send the packet,
> without needing to write any code.
> sendip -p ipv4 -is <source addr> -id <dest addr> -d data dest_ip
> </shameless plug>
>
> --
> Mike Ricketts <mike@earth.li>                      http://www.earth.li/~mike/
>
> Beware of self-styled experts: an ex is a has-been, and a spurt is a
> drip under pressure.

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux