]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
2 | \r | |
3e8c18da | 3 | Copyright (c) 2005 - 2006, Intel Corporation.<BR>\r |
83cbd279 | 4 | All rights reserved. This program and the accompanying materials\r |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
83cbd279 | 12 | **/\r |
13 | \r | |
14 | #ifndef __EFI_IP4_INPUT_H__\r | |
15 | #define __EFI_IP4_INPUT_H__\r | |
16 | \r | |
96e1079f | 17 | typedef enum {\r |
83cbd279 | 18 | IP4_MIN_HEADLEN = 20,\r |
19 | IP4_MAX_HEADLEN = 60,\r | |
20 | \r | |
21 | IP4_ASSEMLE_HASH_SIZE = 31,\r | |
22 | IP4_FRAGMENT_LIFE = 120,\r | |
23 | IP4_MAX_PACKET_SIZE = 65535\r | |
96e1079f | 24 | } IP4_INPUT_ENUM_TYPES;\r |
25 | \r | |
26 | ///\r | |
27 | /// Per packet information for input process. LinkFlag specifies whether\r | |
28 | /// the packet is received as Link layer unicast, multicast or broadcast.\r | |
29 | /// The CastType is the IP layer cast type, such as IP multicast or unicast.\r | |
30 | /// Start, End and Length are staffs used to assemble the packets. Start\r | |
31 | /// is the sequence number of the first byte of data in the packet. Length\r | |
32 | /// is the number of bytes of data. End = Start + Length, that is, the\r | |
33 | /// sequence number of last byte + 1. Each assembled packet has a count down\r | |
34 | /// life. If it isn't consumed before Life reaches zero, the packet is released.\r | |
35 | ///\r | |
83cbd279 | 36 | typedef struct {\r |
37 | UINTN LinkFlag;\r | |
38 | INTN CastType;\r | |
39 | INTN Start;\r | |
40 | INTN End;\r | |
41 | INTN Length;\r | |
42 | UINT32 Life;\r | |
43 | EFI_STATUS Status;\r | |
44 | } IP4_CLIP_INFO;\r | |
45 | \r | |
96e1079f | 46 | ///\r |
47 | /// Structure used to assemble IP packets.\r | |
48 | ///\r | |
83cbd279 | 49 | typedef struct {\r |
e48e37fc | 50 | LIST_ENTRY Link;\r |
83cbd279 | 51 | \r |
52 | //\r | |
53 | // Identity of one IP4 packet. Each fragment of a packet has\r | |
54 | // the same (Dst, Src, Id, Protocol).\r | |
55 | //\r | |
56 | IP4_ADDR Dst;\r | |
57 | IP4_ADDR Src;\r | |
58 | UINT16 Id;\r | |
59 | UINT8 Protocol;\r | |
60 | \r | |
61 | INTN TotalLen;\r | |
62 | INTN CurLen;\r | |
e48e37fc | 63 | LIST_ENTRY Fragments; // List of all the fragments of this packet\r |
83cbd279 | 64 | \r |
65 | IP4_HEAD *Head; // IP head of the first fragment\r | |
66 | IP4_CLIP_INFO *Info; // Per packet info of the first fragment\r | |
67 | INTN Life; // Count down life for the packet.\r | |
68 | } IP4_ASSEMBLE_ENTRY;\r | |
69 | \r | |
96e1079f | 70 | ///\r |
71 | /// Each Ip service instance has an assemble table to reassemble\r | |
72 | /// the packets before delivery to its children. It is organized\r | |
73 | /// as hash table.\r | |
74 | ///\r | |
83cbd279 | 75 | typedef struct {\r |
e48e37fc | 76 | LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];\r |
83cbd279 | 77 | } IP4_ASSEMBLE_TABLE;\r |
78 | \r | |
79 | #define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))\r | |
80 | \r | |
81 | #define IP4_ASSEMBLE_HASH(Dst, Src, Id, Proto) \\r | |
82 | (((Dst) + (Src) + ((Id) << 16) + (Proto)) % IP4_ASSEMLE_HASH_SIZE)\r | |
83 | \r | |
84 | #define IP4_RXDATA_WRAP_SIZE(NumFrag) \\r | |
85 | (sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))\r | |
86 | \r | |
2ff29212 | 87 | /**\r |
88 | Initialize an already allocated assemble table. This is generally\r | |
89 | the assemble table embedded in the IP4 service instance.\r | |
90 | \r | |
3e8c18da | 91 | @param[in, out] Table The assemble table to initialize.\r |
2ff29212 | 92 | \r |
93 | **/\r | |
83cbd279 | 94 | VOID\r |
95 | Ip4InitAssembleTable (\r | |
2ff29212 | 96 | IN OUT IP4_ASSEMBLE_TABLE *Table\r |
83cbd279 | 97 | );\r |
98 | \r | |
2ff29212 | 99 | /**\r |
100 | Clean up the assemble table: remove all the fragments\r | |
101 | and assemble entries.\r | |
102 | \r | |
3e8c18da | 103 | @param[in] Table The assemble table to clean up\r |
2ff29212 | 104 | \r |
105 | **/\r | |
83cbd279 | 106 | VOID\r |
107 | Ip4CleanAssembleTable (\r | |
108 | IN IP4_ASSEMBLE_TABLE *Table\r | |
109 | );\r | |
110 | \r | |
2ff29212 | 111 | /**\r |
112 | The IP4 input routine. It is called by the IP4_INTERFACE when a\r | |
113 | IP4 fragment is received from MNP.\r | |
114 | \r | |
3e8c18da | 115 | @param[in] Ip4Instance The IP4 child that request the receive, most like\r |
2ff29212 | 116 | it is NULL.\r |
3e8c18da | 117 | @param[in] Packet The IP4 packet received.\r |
118 | @param[in] IoStatus The return status of receive request.\r | |
119 | @param[in] Flag The link layer flag for the packet received, such\r | |
2ff29212 | 120 | as multicast.\r |
3e8c18da | 121 | @param[in] Context The IP4 service instance that own the MNP.\r |
2ff29212 | 122 | \r |
123 | **/\r | |
83cbd279 | 124 | VOID\r |
125 | Ip4AccpetFrame (\r | |
126 | IN IP4_PROTOCOL *Ip4Instance,\r | |
127 | IN NET_BUF *Packet,\r | |
128 | IN EFI_STATUS IoStatus,\r | |
129 | IN UINT32 Flag,\r | |
130 | IN VOID *Context\r | |
131 | );\r | |
132 | \r | |
2ff29212 | 133 | /**\r |
134 | Demultiple the packet. the packet delivery is processed in two\r | |
135 | passes. The first pass will enque a shared copy of the packet\r | |
136 | to each IP4 child that accepts the packet. The second pass will\r | |
137 | deliver a non-shared copy of the packet to each IP4 child that\r | |
138 | has pending receive requests. Data is copied if more than one\r | |
139 | child wants to consume the packet because each IP child needs\r | |
140 | its own copy of the packet to make changes.\r | |
141 | \r | |
3e8c18da | 142 | @param[in] IpSb The IP4 service instance that received the packet\r |
143 | @param[in] Head The header of the received packet\r | |
144 | @param[in] Packet The data of the received packet\r | |
2ff29212 | 145 | \r |
146 | @retval EFI_NOT_FOUND No IP child accepts the packet\r | |
147 | @retval EFI_SUCCESS The packet is enqueued or delivered to some IP\r | |
148 | children.\r | |
149 | \r | |
150 | **/\r | |
83cbd279 | 151 | EFI_STATUS\r |
152 | Ip4Demultiplex (\r | |
2ff29212 | 153 | IN IP4_SERVICE *IpSb,\r |
83cbd279 | 154 | IN IP4_HEAD *Head,\r |
155 | IN NET_BUF *Packet\r | |
156 | );\r | |
157 | \r | |
2ff29212 | 158 | /**\r |
159 | Enqueue a received packet to all the IP children that share\r | |
160 | the same interface.\r | |
161 | \r | |
3e8c18da | 162 | @param[in] IpSb The IP4 service instance that receive the packet\r |
163 | @param[in] Head The header of the received packet\r | |
164 | @param[in] Packet The data of the received packet\r | |
165 | @param[in] IpIf The interface to enqueue the packet to\r | |
2ff29212 | 166 | \r |
167 | @return The number of the IP4 children that accepts the packet\r | |
168 | \r | |
169 | **/\r | |
83cbd279 | 170 | INTN\r |
171 | Ip4InterfaceEnquePacket (\r | |
2ff29212 | 172 | IN IP4_SERVICE *IpSb,\r |
83cbd279 | 173 | IN IP4_HEAD *Head,\r |
174 | IN NET_BUF *Packet,\r | |
2ff29212 | 175 | IN IP4_INTERFACE *IpIf\r |
83cbd279 | 176 | );\r |
177 | \r | |
2ff29212 | 178 | /**\r |
179 | Deliver the received packets to upper layer if there are both received\r | |
180 | requests and enqueued packets. If the enqueued packet is shared, it will\r | |
181 | duplicate it to a non-shared packet, release the shared packet, then\r | |
182 | deliver the non-shared packet up.\r | |
183 | \r | |
3e8c18da | 184 | @param[in] IpInstance The IP child to deliver the packet up.\r |
2ff29212 | 185 | \r |
186 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the\r | |
187 | packets.\r | |
188 | @retval EFI_SUCCESS All the enqueued packets that can be delivered\r | |
189 | are delivered up.\r | |
190 | \r | |
191 | **/\r | |
83cbd279 | 192 | EFI_STATUS\r |
193 | Ip4InstanceDeliverPacket (\r | |
2ff29212 | 194 | IN IP4_PROTOCOL *IpInstance\r |
83cbd279 | 195 | );\r |
196 | \r | |
2ff29212 | 197 | /**\r |
198 | Timeout the fragment and enqueued packets.\r | |
199 | \r | |
3e8c18da | 200 | @param[in] IpSb The IP4 service instance to timeout\r |
2ff29212 | 201 | \r |
202 | **/\r | |
83cbd279 | 203 | VOID\r |
204 | Ip4PacketTimerTicking (\r | |
205 | IN IP4_SERVICE *IpSb\r | |
206 | );\r | |
207 | \r | |
208 | #endif\r |