site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Thread-index: AcVFX5QdXb/F6+b4S5+WP8/3kbPyXgAe6S2w Thread-topic: Using ctl_enqueuembuf Thanks Justin, things make a little more sense. I think I was confusing myself looking at the TCPlogger example, and I guess I was assuming mbufs where doing something 'magical' on my structure. So say I want to use a sendto or write, I used 'ctl_register()' in my kernel to register my Kernel Controller, is there some way to obtain the socket fd that sendto() or write() require using the kern_ctl_ref return by the call to ctl_register()? Thanks Carl -----Original Message----- From: darwin-kernel-bounces+csmith=fortresstech.com@lists.apple.com [mailto:darwin-kernel-bounces+csmith=fortresstech.com@lists.apple.com] On Behalf Of Justin Walker Sent: Wednesday, April 20, 2005 12:15 AM To: darwin-kernel Dev Subject: Re: Using ctl_enqueuembuf On Apr 19, 2005, at 11:26, Carl Smith wrote:
Ok thinking....
Always a good sign :-}
I am coping the sizeof the structure. Now only because I was looking at the TCPlogger example, which passed a rather large structure 'struct TCPLogEntry', in which it had sub structures and in turn had buffers with log data, that I thought the mbuf code took care of the structure and everything in it.
Keep in mind that mbufs are kernel structures that describe data buffers. There's no magic in them, and the semantics that you apply to their content is a complete mystery to the support routines that deal with the mbufs. In particular, if you have a buffer pointer pointing off into the great beyond, ctl_enqueuembuf won't be aware of it.
But the total data, would be the sizeof the struct plus the sizeof buf1.
That's what you want to transfer to user mode, but to the kernel code looking at the mbuf, the total data is the size of the structure.
I guess I am not clear on how to get buf1 up to userland using ctl_enqueuembuf.
Do I need to make two calls to ctl_enqueuembuf, with the struct then the buf1? Of is there a way to get both buffers into my mbuf?
buf1 points to a malloc'd structure, so you can't treat that as an mbuf. Also, don't forget to free that buffer when you are done with it. See below.
Then if I have to make two calls to ctl_enqueuembuf, in the kernel side, I am not certain how 'catch' it in user land?
I would take an alternate approach. For a start, review the man page for recv(), and the Wright/Stevens book for background. There may be something in there that strikes a chord with you. In short, you will have to turn all your data containers into mbufs if you want to use mbuf-handling routines to deal with them. Regards, Justin -- Justin C. Walker, Curmudgeon-at-Large /~\ The ASCII \ / Ribbon Campaign X Help Cure HTML Email / \ _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/csmith%40fortresste ch.com This email sent to csmith@fortresstech.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com