Hi,

Yes it's a typo, sorry... the end of the code is:
memcpy(encaped_pkt->data(), &my_header, sizeof(my_custom_header_t));
output(0).push(encaped_pkt);

Alexandre

________________________________________
From: Beyers Cronje [[email protected]]
Sent: Thursday, December 09, 2010 4:10 PM
To: Becholey Alexandre
Cc: [email protected]
Subject: Re: [Click] ToDevice(ath0) send: Message too long

Hi,

Unless you made a typo in your mail, one thing you're doing wrong is still 
accessing pointer p after calling p->uniqueify(), which is invalid. The proper 
way to use uniqueify() is as follows:

WritablePacket *q = p->uniqueify();
if (!q)
    return 0;
// p must not be used here.

Beyers

On Thu, Dec 9, 2010 at 3:32 PM, Becholey Alexandre 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

I'm trying to create a click element that add a custom header between the mac 
header and the ip header. My element has 1 input (ethernet frames) and 1 output 
(frames with the custom header).
Here is the script:
RatedSource
   -> UDPIPEncap(my_ip, 254, dst_ip, 254)
   -> EtherEncap(...) // I do this just to create some random ethernet frames
   -> Print(1)
   -> MyElement
   -> Print(2)
   -> EtherEncap(0x0800, my_mac, dst_mac)
   -> Print(3)
   -> Queue(2000)
   -> ToDevice(ath0)

Here is what my element does in his push function:
struct my_custom_header my_header;
my_header.n = 1; //an unsigned int
my_header.addr = some_addr; //a struct in_addr
WriteablePacket * encaped_pkt = p->uniqueify();
encaped_pkt->pull(sizeof(click_ether));
encaped_pkt = encaped_pkt->push(sizeof(my_custom_header_t));
memcpy(p->data(), &my_header, sizeof(my_custom_header_t));
output(0).push(p);

With the Prints I can see that my header is correctly written in the packet:
1:    106 | ffffffff ffff0002 6fffff04 08004500 005c0113 0000fa11
2:    100 | 01000000 0a0a0a07 4500005c 01130000 fa11985b 0a0a0a04
3:    114 | ffffffff ffff0002 6fffff04 08000100 00000a0a 0a074500
But then I get the "ToDevice(ath0) send: Message too long"

I'm using click (userlevel) on an asus router running OpenWRT (8.09) with an 
atheros wifi card (madwifi driver).
When I remove MyElement and the Following EtherEncap in the script, there is no 
problem (I can sniff the sent frames from another router with tcpdump for 
example).

Any idee why? It's the first time I encounter this problem. I can without any 
problem create some packets (Packet::make(...)) and send them.

Alexandre Becholey
_______________________________________________
click mailing list
[email protected]<mailto:[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