Translating IPv6/IPv4 packets

Juan Luis Baptiste juancho at linuxmail.org
Sun Mar 17 01:55:56 EST 2002


Hi,

We are figuring out how to translate fragmented packets with the Click translation elements, we want to hear comments about it.

Translating from IPv4 to IPv6:

1.IPv6 Header:

* payload length: Total length minus the internet header length length (multiply by 4) from the ipv4 header, plus 8 for fragment header.
* Next Header: 44 (fragment header).

2. Fragment header:

* Next Header: value of protocol field from ipv4 headerIf it is 1 (ICMPv4), then substitute it with 58 (ICMPv6) Reserved: 0 (all zero bits)
* Fragment offset: value of fragment Offset from ipv4 header Offset.
* M flag: value of more fragment Offset from ipv4 Header.
* Identification: The low-order 16 bits are copied from the value of identification field in the ipv4 header. The higher order bits set to zero.

Translation from IPv6 to IPv4:

* Total Length: value of payload from ipv6 header, minus 8 for the fragment header, plus the size of the ipv4 header.
* Identification: copy from the low-order 16 bits in the identification field in the fragment header.
* Flags: the more fragments flags is copied from the fragment header and the don't fragment flag is set to false.
* Fragment Offset: copy value of fragment Offset field in the fragment header Offset.

We think that it is necessary to create a new data type "click_fragment", so we can represent IPv6 fragment header. THe format of a fragment header is the following:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Next Header|Reserved|Fragment Offset|Res|M |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

A possible implementation of that header in click could be the following:
 /*********************************************************
#ifndef CLICK_FRAGMENT_H
#define CLICK_FRAGMENT_H

typedef unsigned int fragment_seq;

struct click_fragment {
uint8_t ip6_nxt; /* next header */
uint8_t reserv; /* reserved */
unsigned short f_offset:13; /* Fragment offset */
#if CLICK_BYTE_ORDER == CLICK_LITTLE_ENDIAN
uint8_t m : 1; /* m flag */
uint8_t res : 2; /* res */
#endif
#if CLICK_BYTE_ORDER == CLICK_BIG_ENDIAN
uint8_t res : 2; /* res */
uint8_t m : 1; /* m flag */
#endif
fragment_seq id; /* identification */
};

#endif
/**************************************************************

Any comments?

Juan Luis


-- 

Get your free email from www.linuxmail.org 


Powered by Outblaze



More information about the click mailing list