iPXE
fragment.h
Go to the documentation of this file.
1 #ifndef _IPXE_FRAGMENT_H
2 #define _IPXE_FRAGMENT_H
3 
4 /** @file
5  *
6  * Fragment reassembly
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/list.h>
14 #include <ipxe/iobuf.h>
15 #include <ipxe/retry.h>
16 
17 /** Fragment reassembly timeout */
18 #define FRAGMENT_TIMEOUT ( TICKS_PER_SEC / 2 )
19 
20 /** A fragment reassembly buffer */
21 struct fragment {
22  /* List of fragment reassembly buffers */
23  struct list_head list;
24  /** Reassembled packet */
25  struct io_buffer *iobuf;
26  /** Length of non-fragmentable portion of reassembled packet */
27  size_t hdrlen;
28  /** Reassembly timer */
30  /** Fragment reassembler */
32 };
33 
34 /** A fragment reassembler */
36  /** List of fragment reassembly buffers */
37  struct list_head list;
38  /**
39  * Check if fragment matches fragment reassembly buffer
40  *
41  * @v fragment Fragment reassembly buffer
42  * @v iobuf I/O buffer
43  * @v hdrlen Length of non-fragmentable potion of I/O buffer
44  * @ret is_fragment Fragment matches this reassembly buffer
45  */
46  int ( * is_fragment ) ( struct fragment *fragment,
47  struct io_buffer *iobuf, size_t hdrlen );
48  /**
49  * Get fragment offset
50  *
51  * @v iobuf I/O buffer
52  * @v hdrlen Length of non-fragmentable potion of I/O buffer
53  * @ret offset Offset
54  */
55  size_t ( * fragment_offset ) ( struct io_buffer *iobuf, size_t hdrlen );
56  /**
57  * Check if more fragments exist
58  *
59  * @v iobuf I/O buffer
60  * @v hdrlen Length of non-fragmentable potion of I/O buffer
61  * @ret more_frags More fragments exist
62  */
63  int ( * more_fragments ) ( struct io_buffer *iobuf, size_t hdrlen );
64  /** Associated IP statistics */
66 };
67 
68 extern struct io_buffer *
69 fragment_reassemble ( struct fragment_reassembler *fragments,
70  struct io_buffer *iobuf, size_t *hdrlen );
71 
72 #endif /* _IPXE_FRAGMENT_H */
struct list_head list
Definition: fragment.h:23
struct ip_statistics * stats
Associated IP statistics.
Definition: fragment.h:65
__SIZE_TYPE__ size_t
Definition: stdint.h:6
I/O buffers.
A fragment reassembly buffer.
Definition: fragment.h:21
Retry timers.
A retry timer.
Definition: retry.h:21
A fragment reassembler.
Definition: fragment.h:35
A doubly-linked list entry (or list head)
Definition: list.h:18
A timer.
Definition: timer.h:28
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct io_buffer * iobuf
Reassembled packet.
Definition: fragment.h:25
size_t(* fragment_offset)(struct io_buffer *iobuf, size_t hdrlen)
Get fragment offset.
Definition: fragment.h:55
IP system statistics.
Definition: ipstat.h:44
Linked lists.
struct fragment_reassembler * fragments
Fragment reassembler.
Definition: fragment.h:31
int(* is_fragment)(struct fragment *fragment, struct io_buffer *iobuf, size_t hdrlen)
Check if fragment matches fragment reassembly buffer.
Definition: fragment.h:46
int(* more_fragments)(struct io_buffer *iobuf, size_t hdrlen)
Check if more fragments exist.
Definition: fragment.h:63
struct list_head list
List of fragment reassembly buffers.
Definition: fragment.h:37
A persistent I/O buffer.
Definition: iobuf.h:32
struct io_buffer * fragment_reassemble(struct fragment_reassembler *fragments, struct io_buffer *iobuf, size_t *hdrlen)
Reassemble packet.
Definition: fragment.c:88
size_t hdrlen
Length of non-fragmentable portion of reassembled packet.
Definition: fragment.h:27