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

(usagi-users 02053) ICMP_ECHO raw socket



Hello,

 i wrote a simple program to use raw sockets and catch all
icmp packets.

// -- code snipped

       buf = (char*) malloc(sizeof(struct ip)+sizeof(struct icmp));

        sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

        for (;;) {
                n = recv(sockfd, buf, sizeof(buf),0);
                ip = (struct ip *) buf;
                ip_len = ip->ip_hl << 2; // ip header length

                icmp = (struct icmp *) (buf + ip_len);

                printf("n= %d\n",n);
                if (icmp->icmp_type == ICMP_ECHO) {
                        printf("ping request arrived\n");
                }
        }


It seems that the kernel donot pass ICMP_ECHO to raw socket
if i use ICMP_ECHOREPLY, it will work,

As far as i know, linux did not have such a restriction ?
is it because of USAGI (i am using snap 6'th jan).

Any help in this regard is appreciated.

-- basit