Re: ICMP_ECHO request/ raw socket

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

 



On Mon, 6 Jan 2003 05:29:04 -0600 (CST)
Abdul Basit <basit@basit.cc> wrote:

> 
> 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);

You get only incomming packets that way, use:

sockfd = socket(PF_PACKET, SOCK_RAW, ETH_P_IP);

and use socket filter or filter it youyself.

Marian
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux