I am writing a NKE following some of the
example/text given in the 'About Network
Kernel Extensions' document, along with
following some code from an example I found
here on this forum along with some code
from the tcplog example.
My problem is that on the call
'ctl_register' I am getting a return value of (22)
from the ctl_register call and according to
the documentation ctl_register should
return a 0 on success. And in turn from my
client app when I try to 'connect' to
this NKE of mine it is failing, with an
errno of 1.
So I am assuming something is wrong with my
ctl_register call. I load my kext using
'sudo kextload -v mynke.kext'. I am
originally signed in as 'admin'. Not sure if
this means anything.
Below is a portion of the code, from my
NKE, that I am using to try and register
my NKE.
Does the ctl_id have anything to do with
it? I did register it but do I have to do
anything special with/to the kernel? I am
also using the same ID in my client side.
"kern_return_t ClientKern103_start (kmod_info_t
* ki, void * d)
{
int
nReturn = 0;
struct
kern_ctl_reg AFctl_reg;
bzero(&AFctl_reg,
sizeof(AFctl_reg));
AFctl_reg.ctl_id
= AFMAC_KERN_ID;
AFctl_reg.ctl_unit = 0;
AFctl_reg.ctl_flags = CTL_FLAG_PRIVILEGED;
AFctl_reg.ctl_sendsize = 0;
AFctl_reg.ctl_recvsize = 0;
//
Dispatch functions
//
==================
AFctl_reg.ctl_connect
= AFKernConnect;
AFctl_reg.ctl_disconnect
= AFKernDisconnect;
AFctl_reg.ctl_write = AFClientKernXWrite;
AFctl_reg.ctl_set = NULL;
AFctl_reg.ctl_get = AFKernGet;
static
kern_ctl_ref ctlref = 0; /* Reference of the kernel controller */
nReturn
= ctl_register(&AFctl_reg, 0, &ctlref);
if(nReturn
!= 0)
{
if(nReturn
== EINVAL)
printf("Kernel
Register failed");
else
printf("Kernel
Register failed with the error (%d)\n", nReturn);
}
return KERN_SUCCESS;
}
"
I am not looking to anything fancy, yet, I
am just trying to get the communication
going between my NKE and my client.
Any help/suggestions/example code would
greatly be appreciated.
Thank You