Raw socket question?

Raw socket question?

Post by Nguyen Tuan Hun » Tue, 31 Aug 1999 04:00:00



Hi,
    I have one question about RAW socket in Suse Linux 2.2.11. In
following my C program code I want reading TCP message with RAW socket
(I now it is not correct)

/*-------  serv.c ---------*/
int main(void)
{
    int sockfd, n, servlen;
    char buf]1028];
    struct sockaddr_in serv;

    if((sockfd=socket(AF_INET, RAW_SOCK, IPPROTO_TCP))<0) {
        perror("Open socket error\n");
        return -1;
    }

    while(1) {
        if((n=recvfrom(sockfd, buf, 1028, 0, (struct sockaddr *) &serv,
servlen))<0) {
            perror("recvfrom error\n");
            return -2;
        }
    }

    if(sockfd) close(sockfd);
    return 0;

Quote:}

/*------- end ------------*/

Now, the my question is, if IP layer (in /net/ipv4/ip_input.c file
ip_local_deliver() function) receive packet from Ethernet, and check all

RAW socket before deliver packet to highter layer. If the function check

RAW socket, return value is not NULL, but I don't read anything with
socket, and with TCP socket I can read it.
How do "ip_local_deliver" function work? How do I know read TCP message
with RAW socket?
    I did it with FreeBSD OS, but in Linux it is difficult, because I
have not any books (not TCP/IP Illustrataed by R. Stevens).

Thank very much.
    Hung

 
 
 

1. Help: RAW socket question...

Hi,

I'm learning Unix network programming and have a project to do using RAW
sockets.  I have to do this as part of a simulation.  I construct my own
IP and UDP headers correctly on some data structure.  Then I open a RAW
socket and sendto a broadcast address.  This works on an SGI running Irix
fine, but when I bring the code over to Linux, nothing gets sent.
I'm assuming that this may have something to do with the Big/Little Endian
Bitfields.  Also, if I try to send from Irix to Linux, the data comes out
half right.  For example, my structure is a 256 char buffer and an integer.
The char buffer prints out fine but the integer is all screwed up.

Thanks to anyone who can help.

Tuan

--

8?)

2. PPP config issues

3. More raw socket questions

4. MOD_Rewrite question

5. Raw Socket Questions - not in FAQs

6. parity vs. non-parity memory ???

7. raw socket question

8. tcsh warning

9. Linux raw socket question

10. raw socket question

11. Raw sockets Question

12. Linux raw socket question

13. raw IP and raw ICMP socket???