[Click] Fwd: Ether Type and Spliting of Packet ( sorry for last incompelte mail)
Beyers Cronje
bcronje at gmail.com
Tue Aug 14 15:46:09 EDT 2007
Hi Khan,
click_ip * ip_p;
> click_tcp * tcph;
> ip_p = p->ip_header()
>
> if(ip_p == IP_PROTO_TCP) {
> tcph= p->tcp_header()
> assert(tcph)
> }
> and it gives me an assert error!! dont know y as the prototype matches teh
> TCP but still there is no pointer to TCP HEADER
In your example above ip_p is a pointer to the IP Header and NOT the ip
protocol field of the IP header. You need to do something like:
click_ip *iph = p->ip_header(); // IP Header
uint8_t ip_p = iph->ip_p; // Protocol field
if (ip_p == IP_PROTO_TCP)
Again, are you using MarkIPHeader or CheckIPHeader before your element??
ALSO, are you sure your element is receiving IP packets? ARP etc packets
will cause problems in your element. Make sure you are using a Classifier
element to filter out all non-IP packets, something like the following
config:
FromDevice(eth0) -> Classifier(12/0800) -> MarkIPHeader(14) -> YourElement;
2.
>
> another question i have is that to change the eth type of a packet is it
> supose to look something like this :
> click_ether * eth_h = (click_ether *) p_in->data();
> uint_16 new_eth_type = 0x0555;
> eth_h = (ntohs) new_eth_type;
>
> ??
click_ether *eth_h = (click_ether *)p->data(); // Get a pointer to the
ethernet header
uint16_t ether_type = 0x1111;
eth_h->ether_type = htons(ether_type); // Host to network and NOT network
to host
Assuming p above is a writable packet and p->data() does indeed point to the
ethernet header, in other words you have not used something like Strip to
move the data pointer up.
and last question i have is
> if i have this TCP packet , how do i make two packets out of it,
Create a new packet using Packet::Make and copy the data across, or clone
the packet and uniquefy the cloned packet.
to make a data packet out of it is easy, i can just set teh tcph->flags = 0;
> and this woudl mean that all teh ACK fields are no longer in use
>
> but to make the pure ACK packet with no data part is difficult.
> i tired to find the length of the packet header using
> ip_header_len = p->ip_hl << 2;
> tcp_header_len = tcph->th_off << 2;
> ip_p->ip_len = ip_header_len +
> tcp_header_len;
>
> data_len = ip_len - DATA_LEN ? how do i find
> this data length?
>
> and what other changes do i have to make inorder for the packets to be
> accpeted by the network.
> i woudl ofcourse use the IPSETCHKSUM and TCPSETCHKSUM in this order after
> teh output of this element.
I suggest you reread the TCP/IP rfc as it explains it all in detail.
Regards
Beyers Cronje
More information about the click
mailing list