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;
/*------- end ------------*/Quote:}
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