1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

receiving packet as such

Discussion in 'C' started by transfernly, Mar 2, 2010.

  1. transfernly

    transfernly New Member

    Joined:
    Dec 15, 2009
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    hello all....
    is there any possibility to get the entire packet
    as such when data is sent
    (since its sent in the form of packets)
    including the details like source ip,port etc...atleast from IP header....
    cos i want to receive
    the packet and send the same packet as such
    to another server...and if so if anyone has a sample snippet please share with me...
    my code says it cant bind...
    its getting bind errors

    any help is really appreciated

    thank you
     
  2. sganesh

    sganesh New Member

    Joined:
    Feb 19, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    you can try the raw socket in c.
    In C socket function SOCK_RAW macro is available.
    see man 2 socket.
     
  3. transfernly

    transfernly New Member

    Joined:
    Dec 15, 2009
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0

    i did see that......and i also read a document which says this
    "
    Limitations on Raw Sockets

    On Windows 7, Windows Server 2008 R2, Windows Vista,

    and Windows XP with Service Pack 2 (SP2), the ability to

    send traffic over raw sockets has been restricted in several ways:

    * TCP data cannot be sent over raw sockets.

    * UDP datagrams with an invalid source address

    cannot be sent over raw sockets. The IP source address for

    any outgoing UDP datagram must exist on a network interface or

    the datagram is dropped. This change was made to limit the ability

    of malicious code to create distributed denial-of-service attacks and

    limits the ability to send spoofed packets

    (TCP/IP packets with a forged source IP address).

    * A call to the bind function with a raw socket is not allowed.

    These above restrictions do not apply to Windows Server 2008 ,

    Windows Server 2003, or to versions of the operating

    system earlier than Windows XP with SP2. "

    so incase if any one has any of the sample code... do help me...

    Thank you
     
  4. sganesh

    sganesh New Member

    Joined:
    Feb 19, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Do you want sample code in raw socket or You want some other solution to solve your problem?

    Actually, I worked in raw sockets I too know the demerits in it.

    And we can get the header details in the getsockopt() function.
     
  5. transfernly

    transfernly New Member

    Joined:
    Dec 15, 2009
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    if u can provide me with a sample code i will be very much happy.....code which receives a packet as such...cos later i will have to parse it for future uses.....
    thank you
     

Share This Page