Re: how do I direct raw packages to a given socket?

Andreas Schuldei (schuldei@andrive.de)
Wed, 29 Sep 1999 15:37:52 +0200


Quoting Andi Kleen (ak@muc.de):
> no, this does not work. sock is a pointer. filedescriptor is a index.
ok, did not know that.
> if you want to multiplex it you would need to write a kernel
> protocol family that can supply multiple sockets.
I will try to do a userspace-daemon to check things out, first.
> If the problem is not very performance critical you can get around it
> with a small user space library that binds a packet socket to
> MCAT_PROTO and then does something like:
> /* only receive header */
> n = recv(packet_sk, buf, headerlen, MSG_PEEK);
> if (n <= headerlen) error();
> if (header is for me) {
> n = recv(packet_sk, buf, buflen, 0);
> Basically the MSG_PEEK avoids the full data copy if the packet
> is not for you. But it would still eat a lot of context switches,
> but for low speed networking (e.g. <= 64kbit/s) that should be no
> problem for modern CPUs.
I am on an embedded system and the processor is not mighty fast. But thanks
for the info. I will put your input to use.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/