Interface Filter NKE Packet Handling
Greetings, I'm working on a port of a body of networking code as an Interface filter NKE. As it runs on several platforms it already has the concept of abstracting things like network packets and the actions one can do with them. But I'm having problems figuring out how to best map some of these abstractions to Darwin. The first is handling network packets themselves. The operations are things like allocating, copying, freeing, prefixing and postfixing data, etc. One specific issue is which mbuf allocator to use. If found functions like these * MGET(struct mbuf *m, int how, int type) * allocates an mbuf and initializes it to contain internal data. * * MGETHDR(struct mbuf *m, int how, int type) * allocates an mbuf and initializes it to contain a packet header * and internal data. If I'm reading this right the header in question is a struct pkthdr. That struct has many members but it's not clear to me if this it represents the ethernet media's header or is something else? And either way what's the right way to set its contents? And more general that just that, does anyone know of Darwin-accurate documentation for these mbuf functions? The names are intriguing but what does m_prepend, m_prepend_2, or m_pulldown, actually do, for example? The NKE.pdf file lists their names but says no more. The second area involves actions I can perform with packets. Here I'm looking at functions like dlil_inject_if_input() to send packets up the network stack and dlil_inject_if_output() to send packets out the wire. The input function takes a frame header as well as an mbuf. Does that mean its mbufs should be allocated by MGET to avoid putting another header in it? Does the output function assume the reverse (ie that the mbuf has come from MGETHDR)? If so, again, how is it to be filled in (things like MAC addresses and ether-types)? And lastly, when I hook in as an an interface filter and my filter_if_input() gets called with a received frame, does it include the media header? Any advise on where to look for this kind of information or what sample code or projects might help would be appreciate. Thanks! Mike _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Michael Cashwell