• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting mbuf length
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting mbuf length


  • Subject: Getting mbuf length
  • From: Mitchell Laurren-Ring <email@hidden>
  • Date: Sat, 15 Nov 2008 17:37:05 -0800

Hey all:

I've got a kext that implements hooks for IP send and receive (and installed with ipf_addv4). My send hook converts the mbuf_t to a flat buffer using mbuf_copydata. Recently I've run into a problem where websites with large cookies cause my code to only copy part of the buffer. I thought that I might need to handle fragmented packets, but the NKE Programming Guide states "IP filters only receive reassembled packets. It is not possible to filter on packet fragments." This was good news because it should keep my code simple but why am I not seeing the entire packet when I copy the mbuf? I read Working With Memory Buffers and it warns several times that one should be careful not to overflow memory buffers when using mbuf_copydata. What it doesn't say is how to derive the total size of a packet given an mbuf_t. My predecessor wrote the following code:

		while(pmbf)
		{
			DataSize += mbuf_len(pmbf);
			pmbf = mbuf_next(pmbf);
		}

If there is an mbuf chain, this code will handle that. It doesn't seem to handle the more complex case of multiple packets (as defined in NKEPG). That should be an easy bit of code to wrap around this loop but I don't think that's my problem either. When I call mbuf_flags on pmbf, it's always either 0x02 or 0x03. If there were a fragmented packet, I would expect one of the higher bits to be set (MBUF_FRAG, for example).

In summary, what is the best way to obtain the length of an mbuf received in a packet hook function?

-Mick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Getting mbuf length
      • From: Vincent Lubet <email@hidden>
  • Prev by Date: Re: SOAP request faultcode 65794 (stream error)
  • Next by Date: Re: Getting mbuf length
  • Previous by thread: Re: SSL and manual peer-name validation
  • Next by thread: Re: Getting mbuf length
  • Index(es):
    • Date
    • Thread