For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2006 > Re: sending a packet using raw socket









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: sending a packet using raw socket
mangesh sawant

2006-03-24, 10:00 pm

First thanks for letting me know that structure can be sent over
network .

reason for using following sequence
| 2 - strcpy(data , "");
| 3- strcat(data , "data u want to send");

if structure u want to send has n members then u have to use 'strcat' n
times .

Barry Margolin

2006-03-24, 10:00 pm

In article <1143249617.678691.134040@z34g2000cwc.googlegroups.com>,
"mangesh sawant" <mangesh@interinfosystems.com> wrote:

> First thanks for letting me know that structure can be sent over
> network .
>
> reason for using following sequence
> | 2 - strcpy(data , "");
> | 3- strcat(data , "data u want to send");
>
> if structure u want to send has n members then u have to use 'strcat' n
> times .


strcat() is only for strings, not structure members.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Rainer Temme

2006-03-27, 4:00 am

manu wrote:

> now i am trying to write various structures and convert it to strings
> for sendto..


No, you don't do this!
You convert your "program-internal" data to exactly that
data-representation that is required by the standard of
the protocol that you're implementing.

If you develop your own protocol, write the required
standard first.

> My question is..
> for handling ICMP packets, the structure is defined in ip_icmp.h, but
> for OSPF no header file is defined.


You certainly should get a copy of RFC-2328
(see http://www.faqs.org/rfcs/rfc2328.html )
and read it and try to undersdtand it. (This RFC describes OSPF)

Rainer
Barry Margolin

2006-03-27, 8:00 am

In article <1143428013.144932.8460@u72g2000cwu.googlegroups.com>,
"manu" <manoharyes@gmail.com> wrote:

> thank u guys...
> thank u soo much for the info.
>
> Now i am confirmed tat I can build my own structure and hand it to IP
> layer using raw sockets.
> now i am trying to write various structures and convert it to strings
> for sendto..
>
> My question is..
> for handling ICMP packets, the structure is defined in ip_icmp.h, but
> for OSPF no header file is defined.


Naturally, since Unix doesn't have any built-in OSPF support. Why would
it need a header file for something it doesn't use?

> so we need to define our own structure and fill in the header..
> so , are we allowed to build any structure with any members on it?
> how does the IP layer know if the structure is valid?
> is there any specific headers(OSPF) which has to be mandatorily
> filled?


You need to fill in all the headers that IP and OSPF require.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com