[Click] No network header/Segmentation fault
Tushar Soni
omega_marines at yahoo.com
Mon Jul 7 04:33:01 EDT 2008
Hi,
Thanks for your reply. I tried both MarkIPHeader and CheckIPHeader, but when I use them it gives me segmentation fault. I think the reinterpret_cast<const click_ip *>(p->data()) is not working for this particular decoded packet.
But I did try something. In my code after I decode I added the following lines:
p->push(sizeof(struct click_ether));
p->set_mac_header(p->data(), 14); //This sets the mac header as well as the network header
click_ip *iph = p->ip_header(); //Now this works and returns the ip header
p->set_network_header(20); //This essentially sets the transport header
click_udp *udph = p->udp_header(); //This also works now
After doing this when I push the packet, then the IPPrint() element (after stripping 14 bytes that i added) is able to print and there are no segmentation faults. So far so good. I send this packet to the tun. But somehow the packet is being dropped or not processed and it never reaches the application layer. I am thinking the initial reason why this packet does not have any network or transport header maybe causing the kernel to drop it. I checked the checksums of both ip and udp header and they seem to be correct. Would you have any ideas why this is happening???
Thanks a lot for your help.
Best Regards,
Tushar
Tºüçhé §übt!é
----- Original Message ----
From: Beyers Cronje <bcronje at gmail.com>
To: Tushar Soni <omega_marines at yahoo.com>
Cc: click at pdos.csail.mit.edu
Sent: Friday, July 4, 2008 5:27:59 PM
Subject: Re: [Click] No network header/Segmentation fault
Hi,
You have to use either MarkIPHeader of CheckIPHeader elements to set the IP header annotations.
Beyers
On Fri, Jul 4, 2008 at 5:06 PM, Tushar Soni <omega_marines at yahoo.com> wrote:
Hi everyone,
I have a scenario where coding some packets at the access point and decoding the packets at receiver side using click. Now when i decode the packet and use Print() element, the packet structure and ip header looks ok. But when i use IPPrint it gives me segmentation fault. When i try to get the ip header(Packet::ip_header()) or the udp header(Packet::udp_header()) it returns null (so this is the reason why IPPrint does not work). The commented code should explain better about what i am doing and the problems i am facing. I would be glad if someone could help me figure out what i am doing wrong. Thanks.
Tushar
For coding i combine a certain number of packets, from ip header onwards(ip header included). So when i decode i should have a packet from ipheader onwards.
void
Decoder::check_uncoded(Packet *p) //p is the coded packet
{
FoundPacketsList found_pkts_list;// this is typedef of type : Vector<Packet *>
WritablePacket *wp = p->uniqueify();
xor_header *xor_h_cod = (xor_header *)wp->data();//i have created my own header
int entries_cod = xor_h_cod->get_entries();
int coded_hlen = xor_header::get_header_length(entries_cod);
for( int i = 0; i < entries_cod; i++)
{
//_ddhq is a type if queue and here i am basically checking if the ipid of the unocoded packet
//is present in the coded header that i created
int location = _ddhq.is_present(xor_h_cod->get_entry_ipid(i));
if( location >= 0 )
{
//if the id is in the coded header i add it to a list
found_pkts_list.push_back(_ddhq.packet(location));
}
}
if(found_pkts_list.size() > 0)
{
bool decodable = false;
//this is the condition for decodability
if( entries_cod - found_pkts_list.size() == 1)
{
decodable = true;
}
//remove my header
wp->pull(coded_hlen);
FoundPacketsList::iterator x = found_pkts_list.begin();
//here i combine the packets in the list with the coded packet to decode it
while( x < found_pkts_list.end())
{
Packet *p_i = (*x);
unsigned char *xored_data = (unsigned char *)wp->data();
unsigned char *data = (unsigned char *)(p_i->ip_header());
int len = p_i->length();
for (int i = 0; i < len; i++) {
xored_data[i] ^= data[i];
}
x++;
}
if(decodable)
{
//wp = wp->uniqueify();
click_chatter("WOOHOO Packet Decoded");
click_chatter("Length: %u", wp->length());
click_ip *iph = wp->ip_header();
//PROBLEM IS HERE ip_header() returns nothing
if(!iph)
click_chatter("Shitty packet"); // this is always called because the iph is never created
else
{
click_udp *udph = wp->udp_header();
if(!udph)
click_chatter("UDP header not found");
}
//here i push the packet to the higher layers
//i use a tun element for this and when i run it gives: no network header as the error
output(1).push(wp);
}
}
else
{
click_chatter("None of the packets found in uncoded queue.");
_codedq.push(0,p);
}
}
Tºüçhé §übt!é
_______________________________________________
click mailing list
click at amsterdam.lcs.mit.edu
https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list