bug in Packet::take() ?

Juan Luis Baptiste juancho at linuxmail.org
Mon Oct 28 00:11:03 EST 2002


Hi,   
   
I'm having a little trouble using Packet::take() to shrink the size of a packet in my ftpportmapper6 element.   
When an IPv6 client connects to an FTP IPv4 server through th Address Translator in Click, and it sends a PORT command, it gets   
translated into an EPRT one that is smaller than the original, I have to shrink the packet to fit the new smaller command. For   
example, the client after connectig to the server sends this command:   
   
EPRT |2|3ffe:1ce1:2:0:200::2|49153|   
//len= 37 (counting \r\n at the end)   
   
This is the translated command before making the new packet:   
   
PORT 1,0,0,1,192,1   
//newlen= 18 (without \r\n at the end)   
   
Difference of sizes:   
len - newlen = 19   
   
1.0.0.1 is the mapped IPv4 address that represents 3ffe:1ce1:2:0:200::2 in theIPv4 network.   
After having the new translated command I proceed to make the new packet that is going to contain the new command:   
   
WritablePacket *wp;   
int newlen = strlen(buf);   
   
if (len < newlen){ //new command is bigger than the old one   
  wp = p->put(newlen - len);   
}   
else{//new command is smaller than the old one, here is the problem   
  wp = p->uniqueify();   
  wp->take(len - newlen); //the same as doing wp->take(19);   
}   
memmove(wp->data() + data_offset + newlen, wp->data() + data_offset + len,len - pos);   
memcpy(wp->data() + data_offset,buf,newlen);   
   
The resulting command in wp is: (printed with click_chatter or with an sniffer like ethereal)   
   
PORT 1,0,0,1,192,12:0:200::2|49153|   
                  ^^^^^^^^^^^^^^^^^   
          these are the 19 bytes I want to remove!   
   
Looking at these output I only can think that Packet::take() isn't removing any bytes from the end of the packet. Is this a bug in   
take() or I'm doing something wrong?   
   
Thanks!   
   
Juan Luis Baptiste M.   
P.D.: I'm doing the translation as in app/ftpportmapper.cc   
-- 

Powered by Outblaze




More information about the click mailing list