I'm experimenting with low-level I/O on interfaces on a small Linux
inside
the Linksys WRT54G wireless router. Doing this sort of thing:
dev1_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
sprintf(get_index.ifr_name, "eth0");
result = ioctl(dev1_socket, SIOCGIFINDEX, &get_index);
bind_arg.sll_family = AF_PACKET;
bind_arg.sll_ifindex = get_index.ifr_ifindex;
bind_arg.sll_protocol = htons(protocol);
result = bind(dev1_socket, (struct sockaddr *) &bind_arg,
sizeof(bind_arg));
On that box, the behavior of interfaces seems to be this:
If no process has a socket open on an interface, packets sent to
the interface fall on the floor.
If a process has a socket open on an interface, but does not read from
the interface for whatever reason, 16 incoming messages are queued, and
any subsequent messages fall on the floor.
So, it looks like the kernel maintains a circular buffer of length 16
to
hold incoming messages. If that buffer is full, any arriving messages
are ignored.
Here's my question: How do I ask the kernel how many messages are in
the
queue for a given interface? I am doing things like setting up eth0,
eth0:1,
eth0:2 etc., and using bind to have incoming messages of different
protocols
go to different interfaces.
I'd like to be able to use an ioctl, or some file in /proc, or
whatever,
and ask the kernel, "OK - how many packets are in the incoming queue
for device
eth0:2?" The number would be 0 .. 16 in the case of this box.
Thanks a million for any help or suggestions,
Greg
|