• 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
Using ctl_enqueuembuf
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using ctl_enqueuembuf


  • Subject: Using ctl_enqueuembuf
  • From: "Carl Smith" <email@hidden>
  • Date: Tue, 19 Apr 2005 11:17:35 -0400
  • Thread-topic: Using ctl_enqueuembuf

Title: Message
I am using the function ctl_enqueuembuf to pass data up to my userland process from my NKE. My problem lies in that I am passing a structure that has some pointers to buffers within this structure and these buffers are always showing empty/zeros when I receive them on the userland side. I am using the example from TCPlogger, in how TCPlogger is passing a structure up to it's user land, but for some reason for me it is not working.
 
I get all the correct values for ints/booleans and etc. that are in my structure but the _MALLOCed buffers, from the NKE are empty. I suspect it has to do something with the way I filling out the mbuf because like I said I can receive the struct on the userland side, the pointers seem good to the buffers with in the structure but these buffers are just empty, zeroed out.
 
Maybe if someone can take a look at the code below they have some suggestions or see something I do not.
 
The code from the kernel side is:
 
struct Test_Struct
{
    int n1;
    int n2;
    char* buf1;
}
 
struct Test_Struct *test;
 
test = _MALLOC(sizeof(struct Test_Struct), M_TEMP, M_WIATOK|M_ZERO);
 
if((test->buf1 = _MALLOC(50, M_TEMP, M_WAITOK|M_ZERO)) != 0)
{
    bcopy("Here comes the test data", test->buf1, 20);
    test->n1 = 66;
    test->n2 = 678;
}
 
// now send the struct to user land
struct mbuf *m;
 
size_t len = sizeof(Test_Struct);
 
if(len > MCLBYTES)
    return EMSGSIZE;
 
if ((m = m_gethdr(M_NOWAIT, MT_DATA)) == NULL)
    return ENOBUFS;
 
m->m_flags |= M_EOR;
 
if(len >MLEN)
{
 
    MCLGET(m, M_NOWAIT);
    if(!(m->m_flags & M_EXT))
    {
        m_freem(m);
        return(ENOBUFS);
    }
}
 
bcopy(test, mtod(m, void*), len);
m->m_pkthdr.len = m->m_len=len;
 
ctl_enqueuembuf(ctlref, m, flags);
// ctlref is a pointer to previously registered controller, that is hooked to this NKE
 
Below is a sample of the code in userland that receives the data from ctl_enqueuembuf:
struct Test_Struct teststruct;
int nBytesRc;
 
nBytesRc = recv(nfd, &teststruct, sizeof(teststruct), 0);
 
if(nBytesRc > 0)
{
    // do what every with teststruct.buf1; and other members of the received struct.
 
    This is where I can look at the teststruct and buf1 is always empty.
}
 
 
Thanks for looking at my email
 
Carl
 _______________________________________________
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

  • Follow-Ups:
    • Re: Using ctl_enqueuembuf
      • From: Justin Walker <email@hidden>
    • Re: Using ctl_enqueuembuf
      • From: Stephane Sudre <email@hidden>
  • Prev by Date: Re: Determine if user can admin
  • Next by Date: Re: Using ctl_enqueuembuf
  • Previous by thread: Re: Determine if user can admin
  • Next by thread: Re: Using ctl_enqueuembuf
  • Index(es):
    • Date
    • Thread