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