Re: Using AF_PACKET network buffers remain occupied?

A.N.Kuznetsov (kuznet@ms2.inr.ac.ru)
Wed, 8 Apr 1998 13:33:25 +0400


In article <87g1jpu8yh.fsf@genoveva.nex.hr> you wrote:
: I'm having trouble using AF_PACKET interface. Can someone please tell me
: where I can find an example of using AF_PACKET interface?

Well, your program is very good example 8)
Another example is the newest tcpdump, but it does not make sending.

: sll.sll_ifindex = ifr.ifr_ifindex;
: sll.sll_family = AF_PACKET;
: sll.sll_protocol = AMTP_PROTO; /* this is right, isn't it? no htons.*/

Nope. The rule is simple: host byte order never used in networking.

However, it is correct in your case 8)
You bind to invalid protocol and save a bit of memory and cpu
avoiding receiving any packets.

: sll.sll_pkttype = PACKET_OTHERHOST;
: /* should I set anything else before binding? */

Nope. BTW sll_pkttype is redundant too. All the fields in sockaddr_ll
except for protocol and ifindex are used only to pass information
from kernel to user (when receiving).

Moreover, they are useful only for (AF_NETLINK,SOCK_DGRAM) socket,
when link layer header is parsed by kernel.

Alexey Kuznetsov

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu