ipf_inject_input returns ENOTSUP
ipf_inject_input returns ENOTSUP
- Subject: ipf_inject_input returns ENOTSUP
- From: Allan Hoeltje <email@hidden>
- Date: Mon, 19 Sep 2005 18:18:41 -0700
Can anyone here tell me how far off the code below is? My kext swallows IP
packets and sends them to a user app. The user app modifies the contents of
the RTP data contained in the IP packet and returns the whole IP packet back
to the kext via the kern_ctl_reg ctl_setopt function which in turn calls
this injectIPPacket code.
The ipf_inject_input returns ENOTSUP which, according to the Darwin source
code in kpi_ipfilter.c, means that the IP packet does not have a vaild IP
version number.
I suspect that I am not setting the first mbuf correctly to indicate that it
is a M_PKTHDR.
What is the proper way to create an mbuf from (void *) data? I've searched
the available source code and documentation and have found no complete
solutions.
Also, if I give ipf_inject_input or ipf_inject_output the address of my IP
filter I get a panic. It is my understanding that if I do not want this
packet to be seen in my filter again I should set a tag and pass the filter
in the inject call. Is that correct? Do I need to set a tag and/or pass
the filter to inject?
Thanks!
-Allan
// set in kext start funct by call to ipf_addv4
static ipfilter_t gIPv4Filter;
void
injectIPPacket( void * packet, size_t packetSize, int direction )
{
errno_t err = 0;
mbuf_t mbuf = NULL;
err = mbuf_allocpacket( MBUF_WAITOK, packetSize, 0, &mbuf );
if (err == 0)
{
err = mbuf_copyback( mbuf, 0, packetSize, packet, MBUF_WAITOK );
}
if (mbuf != NULL)
{
// Tag the packet to show that we've seen it.
err = SetTag( mbuf, ((direction == kKEXT_CTL_IncomingRTP)
? INBOUND_DONE : OUTBOUND_DONE) );
if (err == 0)
{
if (direction == kKEXT_CTL_IncomingRTP)
{
// why does specifying my filter call back cause a panic?
// err = ipf_inject_input( mbuf, gIPv4Filter );
err = ipf_inject_input( mbuf, 0 );
}
else
{
// why does specifying my filter call back cause a panic?
// err = ipf_inject_output( mbuf, gIPv4Filter, 0 );
err = ipf_inject_output( mbuf, 0, 0 );
}
if (err != 0)
{
printf( "injectRtpPacket: %s returned %d\n",
((direction == kKEXT_CTL_IncomingRTP)
? "incoming" : "outgoing"), err );
mbuf_freem( mbuf );
}
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden