Hi, thanks to everyone for providing me with different ideas. First I am trying to use m_copydata() method because I think it will be easy for me to copy data back and forth (using m_copydataback() ).
But right now I am having problem using m_copydata() function. I want to copy data in all mbufs (only payload but no tcp/ip header) except the first Mbuf in chain. If payload is small enough to fit within 1st mbuf then I don't need that either. I am getting kernel panic ( please see below). I can see custom message "Starting m_copydata()" in log file. So I assume the problem is due to incorrect parameter in m_copydata(). here is the sample of code I am trying to use: /********************************/ caddr_t my_data_copy = NULL; /* check if m_len < m_pkthdr.len */ if ( m->m_len < m->m_pkthdr.len ) { /* copy data if there are more than 1 Mbufs in Chain */ log (LOG_DEBUG,"Starting m_copydata() \n"); m_copydata( m, m->m_len , m->m_pkthdr.len - m->m_len , my_data_copy); log (LOG_DEBUG,"%d Byte of Data copied\n", m->m_pkthdr.len - m->m_len); } else { /* skip if there is only 1 MBUF */ //log (LOG_DEBUG,"There must Only 1 MBUF in chain\n"); } /********************************/ Kernel Panic: Feb 12 11:36:09 bsd1 /kernel: Fatal trap 12: page fault while in kernel mode Feb 12 11:36:09 bsd1 /kernel: fault virtual address = 0x0 Feb 12 11:36:09 bsd1 /kernel: fault code = supervisor write, page not present Feb 12 11:36:09 bsd1 /kernel: instruction pointer = 0x8:0xc024efc2 Feb 12 11:36:09 bsd1 /kernel: stack pointer = 0x10:0xd15e8d08 Feb 12 11:36:09 bsd1 /kernel: frame pointer = 0x10:0xd15e8d2c Feb 12 11:36:09 bsd1 /kernel: code segment = base 0x0, limit 0xfffff, type 0x1b Feb 12 11:36:09 bsd1 /kernel: = DPL 0, pres 1, def32 1, gran 1 Feb 12 11:36:09 bsd1 /kernel: processor eflags = interrupt enabled, resume, IOPL = 0 Feb 12 11:36:09 bsd1 /kernel: current process = 154 (ping) Feb 12 11:36:09 bsd1 /kernel: interrupt mask = Feb 12 11:36:09 bsd1 /kernel: I am using "ping -s 1200 host" to send larger packets so that system creates at least 2 mbufs. ------------ On Feb 7, 2008 3:26 PM, Sam Leffler <[EMAIL PROTECTED]> wrote: > > Biks N wrote: > > Hi, > > > > I am new to FreeBSD kernel programming. > > > > Currently I am trying to work on mbuf data manupulation. > > > > >From my understanding: data (payload) is stored into one or more mufs > > which are chained together through m_next pointer. > > > > Now, I need to retrive all data in mbuf chain ( mbufs linked by > > m_next). I am working ip_output() in netinet/ip_output.c > > > > Does there exist inbuilt function/macro to retrive all the data in mbuf > > chain? > > > > man 9 mbuf; look for m_copydata. > > Sam > > _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"