Hi,
man 7 packet states
sll_protocol is the standard ethernet protocol type in network order
as defined in the linux/if_ether.h include file. It defaults to the
socket's protocol.
But then later on says
For bind only sll_protocol and sll_ifindex are used.
I'm unsure as to which is the expected behavour. stracing the sample
program below shows that it does not pick up the protocol from the
socket. (bind() also needs the sll_family filled in else it will fail
with an invalid argument).
I don't have a heap of experience with this; should bind pick up the
protocol from the socket or should the manpage be clarified?
-i
ianw@xxxxxxxxxxxxxxxxxx
http://www.gelato.unsw.edu.au
--- sample program ---
strace shows
socket(PF_PACKET, SOCK_RAW, 2144) = 3
bind(3, {sa_family=AF_PACKET, proto=0000, if0, ...
^^^^
#include <sys/socket.h>
#include <netpacket/packet.h>
#include <net/ethernet.h>
int main(void)
{
struct sockaddr_ll sa;
int s = socket(AF_PACKET, SOCK_RAW, htons(0x6008));
bzero(&sa, sizeof(struct sockaddr_ll));
sa.sll_family = AF_PACKET;
sa.sll_ifindex = 0;
bind(s, (struct sockaddr *)&sa, sizeof(struct sockaddr_ll));
close(s);
return 0;
}
pgpq6yQB6k3pE.pgp
Description: PGP signature
|