Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bsd sockets in a kext



Chrish,

Thanks a lot for your last example, I had to modify it a little bit to make
it work, but it work very well :-).

The difference is that your code was calling mach_port_deallocate() with
only one argument while the headers requires 2:

mach_port_deallocate ( masterPort );

This is the working line:

mach_port_deallocate ( mach_task_self(), masterPort );

I've seen other examples in the archives with only one argument, so I guess
there used to be a declaration with only one argument.

I think I'll make my source code available when I'll have a clean code in a
complete driver. I hope this will be a good inspiration for future driver
developers.


>> Thank you for the tip. This seems to be the way to go but I still have
>> a lot
>> of trouble and I'm confused by the comments in the headers.
>
> Which comments? What headers? Please be specific so that everyone has a
> reference...

Sure. I know how time-consuming it is to write a documentation for
developers.

With the last example I have a much better understanding on what I'm
supposed to do.

As far as I was understanding it the kext have to register itself for
sending messages, but I could not see where it declare anything saying
'thisisme'. 'registerService(0);' is not very explicit.

So I suppose that my C++ object (actually the code of my kext) containing
the start() function must have a really unique name which will be used by
the user level daemon to identify it with IOServiceAddMatchingNotification()

In IOKitLib.h

MessageClients()

IOServiceAddInterestNotification(). Make sure to call
registerService()

The comments explain that the function register to get notifications. After
that we have a bunch of descriptions of the parameters. I did not figured
out what refcon was for. (seems NULL is a good value for it).

/*! @function IOServiceAddInterestNotification
@abstract Register for notification of state changes in an IOService.
@discussion IOService objects deliver notifications of their state
changes to their clients via the IOService::message API, and to other
interested parties including callers of this function. Message type s are
defined IOKit/IOMessage.h.
@param notifyPort A IONotificationPortRef object that controls how
messages will be sent when the notification is fired. See
IONotificationPortCreate.
@param interestType A notification type from IOKitKeys.h
<br> kIOGeneralInterest General state changes delivered via the
IOService::message API.
<br> kIOBusyInterest Delivered when the IOService changes its busy state
to or from zero. The message argument contains the new busy state causing
the notification.
@param callback A callback function called when the notification fires,
with messageType and messageArgument for the state change.
@param refCon A reference constant for the callbacks use.
@param notification An object handle is returned on success, and should
be released by the caller when the notification is to be destroyed.
@result A kern_return_t error code. */

kern_return_t
IOServiceAddInterestNotification(
IONotificationPortRef notifyPort,
io_service_t service,
const io_name_t interestType,
IOServiceInterestCallback callback,
void * refCon,
io_object_t * notification );


--
Stephane ODUL
email@hidden
http://www.soft.odul.net/
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Bsd sockets in a kext (From: Chris Sarcone <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.