diff options
| author | Michael Brown | 2013-08-27 17:08:15 +0200 |
|---|---|---|
| committer | Michael Brown | 2013-08-27 17:39:43 +0200 |
| commit | 22a0c4475c91c745f0e5cc1171939359921d09f9 (patch) | |
| tree | d5f09c98c2d49a399f504267c18a2dc8dfbb7042 /src/include/ipxe | |
| parent | [linux] Give tap devices a name and bus type (diff) | |
| download | ipxe-22a0c4475c91c745f0e5cc1171939359921d09f9.tar.gz ipxe-22a0c4475c91c745f0e5cc1171939359921d09f9.tar.xz ipxe-22a0c4475c91c745f0e5cc1171939359921d09f9.zip | |
[ipv4] Generalise fragment reassembly mechanism
Generalise the concept of fragment reassembly to allow for code
sharing between IPv4 and IPv6 protocols.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
| -rw-r--r-- | src/include/ipxe/fragment.h | 68 | ||||
| -rw-r--r-- | src/include/ipxe/ip.h | 12 |
2 files changed, 68 insertions, 12 deletions
diff --git a/src/include/ipxe/fragment.h b/src/include/ipxe/fragment.h new file mode 100644 index 000000000..6b47439d5 --- /dev/null +++ b/src/include/ipxe/fragment.h @@ -0,0 +1,68 @@ +#ifndef _IPXE_FRAGMENT_H +#define _IPXE_FRAGMENT_H + +/** @file + * + * Fragment reassembly + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include <stdint.h> +#include <ipxe/list.h> +#include <ipxe/iobuf.h> +#include <ipxe/retry.h> + +/** Fragment reassembly timeout */ +#define FRAGMENT_TIMEOUT ( TICKS_PER_SEC / 2 ) + +/** A fragment reassembly buffer */ +struct fragment { + /* List of fragment reassembly buffers */ + struct list_head list; + /** Reassembled packet */ + struct io_buffer *iobuf; + /** Length of non-fragmentable portion of reassembled packet */ + size_t hdrlen; + /** Reassembly timer */ + struct retry_timer timer; +}; + +/** A fragment reassembler */ +struct fragment_reassembler { + /** List of fragment reassembly buffers */ + struct list_head list; + /** + * Check if fragment matches fragment reassembly buffer + * + * @v fragment Fragment reassembly buffer + * @v iobuf I/O buffer + * @v hdrlen Length of non-fragmentable potion of I/O buffer + * @ret is_fragment Fragment matches this reassembly buffer + */ + int ( * is_fragment ) ( struct fragment *fragment, + struct io_buffer *iobuf, size_t hdrlen ); + /** + * Get fragment offset + * + * @v iobuf I/O buffer + * @v hdrlen Length of non-fragmentable potion of I/O buffer + * @ret offset Offset + */ + size_t ( * fragment_offset ) ( struct io_buffer *iobuf, size_t hdrlen ); + /** + * Check if more fragments exist + * + * @v iobuf I/O buffer + * @v hdrlen Length of non-fragmentable potion of I/O buffer + * @ret more_frags More fragments exist + */ + int ( * more_fragments ) ( struct io_buffer *iobuf, size_t hdrlen ); +}; + +extern struct io_buffer * +fragment_reassemble ( struct fragment_reassembler *fragments, + struct io_buffer *iobuf, size_t *hdrlen ); + +#endif /* _IPXE_FRAGMENT_H */ diff --git a/src/include/ipxe/ip.h b/src/include/ipxe/ip.h index ca508e274..3234b7b0e 100644 --- a/src/include/ipxe/ip.h +++ b/src/include/ipxe/ip.h @@ -70,18 +70,6 @@ struct ipv4_miniroute { struct in_addr gateway; }; -/* IPv4 fragment reassembly buffer */ -struct ipv4_fragment { - /* List of fragment reassembly buffers */ - struct list_head list; - /** Reassembled packet */ - struct io_buffer *iobuf; - /** Current offset */ - size_t offset; - /** Reassembly timer */ - struct retry_timer timer; -}; - extern struct list_head ipv4_miniroutes; extern struct net_protocol ipv4_protocol __net_protocol; |
