Hey,

Well I have not forgotten to Strip or the offset.

Here is my click configuration:

tun::KernelTun(1.0.0.1/8);
decoder::Decoder(); //This is the element i created inside which is the code 
that i sent in my previous mails
FromDevice(ath0, SNIFFER false)->pre_cl::Classifier(12/0977, -); //0x0977 is 
the ethernet type for my coded packet.
pre_cl[0]->Strip(14)->[1]decoder[1]->MarkIPHeader(0)->IPPrint(decoded)->tun;
pre_cl[1]->Strip(14)->CheckIPHeader()->MarkIPHeader(0)->IPClassifier(dst udp 
port 1234)->[0]decoder[0]->tun; 

Tushar


Tºüçhé §übt!é



----- Original Message ----
From: Beyers Cronje <[EMAIL PROTECTED]>
To: Tushar Soni <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Sent: Monday, July 7, 2008 11:45:52 AM
Subject: Re: [Click] No network header/Segmentation fault


PS you would need to use Unstrip(14) before forwarding to tun if you use the 
config below.
 
Alternatively you can leave out Strip/Unstrip and just specify the offset of 
the IP Header directly in MarkIPHeader i.e. MarkIPHeader(14)


On Mon, Jul 7, 2008 at 11:43 AM, Beyers Cronje <[EMAIL PROTECTED]> wrote:

Hi,
 
I think you forgot to use Strip or specified the offset to MarkIPHeader in your 
configuration. Also remember to use Classifier to only push proper IP packets 
to MarkIPHeader, i.e. to get rid of ARP packets etc.
Your config should start with something like this:
 
FromDevice(eth0) -> Classifier(12/0800) -> Strip(14) -> MarkIPHeader -> .......
 Beyers

 
On Mon, Jul 7, 2008 at 10:33 AM, Tushar Soni <[EMAIL PROTECTED]> wrote:

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 <[EMAIL PROTECTED]>
To: Tushar Soni <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click


      
_______________________________________________
click mailing list
[email protected]
https://amsterdam.lcs.mit.edu/mailman/listinfo/click

Reply via email to