[Click] No network header/Segmentation fault

Tushar Soni omega_marines at yahoo.com
Fri Jul 4 11:06:54 EDT 2008


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!é



      



More information about the click mailing list