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