Skip to contentSkip to conversation

QUEUE handling, growing the packet.

DISCUSSION Scott MacKay 1 participant 1 message May 10, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,
In a userspace app, given packets by QUEUE, I want
to grow the data packet. The key problem I see is that the ipq_read() buffer is both the payload and the ipq_packet_msg structure (I think along with some potential alignment), making a simple malloc for the data space hard. Given that you use ipq_get_packet() to extract the packet (plus payload offset) from the buffer, can I just malloc() a larger data space and re ipq_get_packet()? Given:

len = ipq_read(s, buffer, 4096, 0);
m = ipq_get_packet(buffer);
old_len=m->data_len;

If I wanted to have the packet be 'new_len' bytes instead of 'old_len' would the following work (yes, minus memory checks and such):

new_buffer_len = len - old_len + new_len;
newBuffer=(char *)malloc(new_buffer_len);
memcpy(newBuffer,buffer,len);
m = ipq_get_packet(newBuffer);

My goal would to be able to use 'm' as if there is no change, but know that I have the additional space to alter payload contents. Thanks for any hints!

__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover