iPXE
fragment.h
Go to the documentation of this file.
00001 #ifndef _IPXE_FRAGMENT_H
00002 #define _IPXE_FRAGMENT_H
00003 
00004 /** @file
00005  *
00006  * Fragment reassembly
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/list.h>
00014 #include <ipxe/iobuf.h>
00015 #include <ipxe/retry.h>
00016 
00017 /** Fragment reassembly timeout */
00018 #define FRAGMENT_TIMEOUT ( TICKS_PER_SEC / 2 )
00019 
00020 /** A fragment reassembly buffer */
00021 struct fragment {
00022         /* List of fragment reassembly buffers */
00023         struct list_head list;
00024         /** Reassembled packet */
00025         struct io_buffer *iobuf;
00026         /** Length of non-fragmentable portion of reassembled packet */
00027         size_t hdrlen;
00028         /** Reassembly timer */
00029         struct retry_timer timer;
00030         /** Fragment reassembler */
00031         struct fragment_reassembler *fragments;
00032 };
00033 
00034 /** A fragment reassembler */
00035 struct fragment_reassembler {
00036         /** List of fragment reassembly buffers */
00037         struct list_head list;
00038         /**
00039          * Check if fragment matches fragment reassembly buffer
00040          *
00041          * @v fragment          Fragment reassembly buffer
00042          * @v iobuf             I/O buffer
00043          * @v hdrlen            Length of non-fragmentable potion of I/O buffer
00044          * @ret is_fragment     Fragment matches this reassembly buffer
00045          */
00046         int ( * is_fragment ) ( struct fragment *fragment,
00047                                 struct io_buffer *iobuf, size_t hdrlen );
00048         /**
00049          * Get fragment offset
00050          *
00051          * @v iobuf             I/O buffer
00052          * @v hdrlen            Length of non-fragmentable potion of I/O buffer
00053          * @ret offset          Offset
00054          */
00055         size_t ( * fragment_offset ) ( struct io_buffer *iobuf, size_t hdrlen );
00056         /**
00057          * Check if more fragments exist
00058          *
00059          * @v iobuf             I/O buffer
00060          * @v hdrlen            Length of non-fragmentable potion of I/O buffer
00061          * @ret more_frags      More fragments exist
00062          */
00063         int ( * more_fragments ) ( struct io_buffer *iobuf, size_t hdrlen );
00064         /** Associated IP statistics */
00065         struct ip_statistics *stats;
00066 };
00067 
00068 extern struct io_buffer *
00069 fragment_reassemble ( struct fragment_reassembler *fragments,
00070                       struct io_buffer *iobuf, size_t *hdrlen );
00071 
00072 #endif /* _IPXE_FRAGMENT_H */