]>
Commit | Line | Data |
---|---|---|
772db4bb | 1 | /** @file |
2 | ||
3 | Copyright (c) 2005 - 2006, Intel Corporation | |
4 | All rights reserved. This program and the accompanying materials | |
5 | are licensed and made available under the terms and conditions of the BSD License | |
6 | which accompanies this distribution. The full text of the license may be found at | |
7 | http://opensource.org/licenses/bsd-license.php | |
8 | ||
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
11 | ||
12 | ||
13 | Module Name: | |
14 | ||
15 | Ip4If.h | |
16 | ||
17 | Abstract: | |
18 | ||
19 | Definition for IP4 pesudo interface structure. | |
20 | ||
21 | ||
22 | **/ | |
23 | ||
24 | #ifndef __EFI_IP4_IF_H__ | |
25 | #define __EFI_IP4_IF_H__ | |
26 | ||
27 | enum { | |
28 | IP4_FRAME_RX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'), | |
29 | IP4_FRAME_TX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'), | |
30 | IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'), | |
31 | IP4_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'I', 'F'), | |
32 | }; | |
33 | ||
34 | // | |
35 | // This prototype is used by both receive and transmission. | |
36 | // When receiving Netbuf is allocated by IP4_INTERFACE, and | |
37 | // released by IP4. Flag shows whether the frame is received | |
38 | // as link broadcast/multicast... | |
39 | // | |
40 | // When transmitting, the Netbuf is from IP4, and provided | |
41 | // to the callback as a reference. Flag isn't used. | |
42 | // | |
43 | // IpInstance can be NULL which means that it is the IP4 driver | |
44 | // itself sending the packets. IP4 driver may send packets that | |
45 | // don't belong to any instance, such as ICMP errors, ICMP echo | |
46 | // responses, or IGMP packets. IpInstance is used as a tag in | |
47 | // this module. | |
48 | // | |
49 | typedef | |
50 | VOID | |
51 | (*IP4_FRAME_CALLBACK) ( | |
52 | IP4_PROTOCOL *IpInstance, OPTIONAL | |
53 | NET_BUF *Packet, | |
54 | EFI_STATUS IoStatus, | |
55 | UINT32 LinkFlag, | |
56 | VOID *Context | |
57 | ); | |
58 | ||
59 | // | |
60 | // Each receive request is wrapped in an IP4_LINK_RX_TOKEN. | |
61 | // Upon completion, the Callback will be called. Only one | |
62 | // receive request is send to MNP. IpInstance is always NULL. | |
63 | // Reference MNP's spec for information. | |
64 | // | |
65 | typedef struct { | |
66 | UINT32 Signature; | |
67 | IP4_INTERFACE *Interface; | |
68 | ||
69 | IP4_PROTOCOL *IpInstance; | |
70 | IP4_FRAME_CALLBACK CallBack; | |
71 | VOID *Context; | |
72 | ||
73 | EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken; | |
74 | } IP4_LINK_RX_TOKEN; | |
75 | ||
76 | // | |
77 | // Each transmit request is wrapped in an IP4_LINK_TX_TOKEN. | |
78 | // Upon completion, the Callback will be called. | |
79 | // | |
80 | typedef struct { | |
81 | UINT32 Signature; | |
82 | NET_LIST_ENTRY Link; | |
83 | ||
84 | IP4_INTERFACE *Interface; | |
85 | ||
86 | IP4_PROTOCOL *IpInstance; | |
87 | IP4_FRAME_CALLBACK CallBack; | |
88 | NET_BUF *Packet; | |
89 | VOID *Context; | |
90 | ||
91 | EFI_MAC_ADDRESS DstMac; | |
92 | EFI_MAC_ADDRESS SrcMac; | |
93 | ||
94 | EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken; | |
95 | EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData; | |
96 | } IP4_LINK_TX_TOKEN; | |
97 | ||
98 | // | |
99 | // Only one ARP request is requested for all the frames in | |
100 | // a time. It is started for the first frames to the Ip. Any | |
101 | // subsequent transmission frame will be linked to Frames, and | |
102 | // be sent all at once the ARP requests succeed. | |
103 | // | |
104 | typedef struct { | |
105 | UINT32 Signature; | |
106 | NET_LIST_ENTRY Link; | |
107 | ||
108 | NET_LIST_ENTRY Frames; | |
109 | IP4_INTERFACE *Interface; | |
110 | ||
111 | // | |
112 | // ARP requesting staffs | |
113 | // | |
114 | EFI_EVENT OnResolved; | |
115 | IP4_ADDR Ip; | |
116 | EFI_MAC_ADDRESS Mac; | |
117 | } IP4_ARP_QUE; | |
118 | ||
119 | // | |
120 | // Callback to select which frame to cancel. Caller can cancel a | |
121 | // single frame, or all the frame from an IP instance. | |
122 | // | |
123 | typedef | |
124 | BOOLEAN | |
125 | (*IP4_FRAME_TO_CANCEL) ( | |
126 | IP4_LINK_TX_TOKEN *Frame, | |
127 | VOID *Context | |
128 | ); | |
129 | ||
130 | // | |
131 | // Each IP4 instance has its own station address. All the instances | |
132 | // with the same station address share a single interface structure. | |
133 | // Each interface has its own ARP child, and shares one MNP child. | |
134 | // Notice the special cases that DHCP can configure the interface | |
135 | // with 0.0.0.0/0.0.0.0. | |
136 | // | |
137 | typedef struct _IP4_INTERFACE { | |
138 | UINT32 Signature; | |
139 | NET_LIST_ENTRY Link; | |
140 | INTN RefCnt; | |
141 | ||
142 | // | |
143 | // IP address and subnet mask of the interface. It also contains | |
144 | // the subnet/net broadcast address for quick access. The fileds | |
145 | // are invalid if (Configured == FALSE) | |
146 | // | |
147 | IP4_ADDR Ip; | |
148 | IP4_ADDR SubnetMask; | |
149 | IP4_ADDR SubnetBrdcast; | |
150 | IP4_ADDR NetBrdcast; | |
151 | BOOLEAN Configured; | |
152 | ||
153 | // | |
154 | // Handle used to create/destory ARP child. All the IP children | |
155 | // share one MNP which is owned by IP service binding. | |
156 | // | |
157 | EFI_HANDLE Controller; | |
158 | EFI_HANDLE Image; | |
159 | ||
160 | EFI_MANAGED_NETWORK_PROTOCOL *Mnp; | |
161 | EFI_ARP_PROTOCOL *Arp; | |
162 | EFI_HANDLE ArpHandle; | |
163 | ||
164 | // | |
165 | // Queues to keep the frames sent and waiting ARP request. | |
166 | // | |
167 | NET_LIST_ENTRY ArpQues; | |
168 | NET_LIST_ENTRY SentFrames; | |
169 | IP4_LINK_RX_TOKEN *RecvRequest; | |
170 | ||
171 | // | |
172 | // The interface's MAC and broadcast MAC address. | |
173 | // | |
174 | EFI_MAC_ADDRESS Mac; | |
175 | EFI_MAC_ADDRESS BroadcastMac; | |
176 | UINT32 HwaddrLen; | |
177 | ||
178 | // | |
179 | // All the IP instances that have the same IP/SubnetMask are linked | |
180 | // together through IpInstances. If any of the instance enables | |
181 | // promiscuous receive, PromiscRecv is true. | |
182 | // | |
183 | NET_LIST_ENTRY IpInstances; | |
184 | BOOLEAN PromiscRecv; | |
185 | } IP4_INTERFACE; | |
186 | ||
187 | IP4_INTERFACE * | |
188 | Ip4CreateInterface ( | |
189 | IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp, | |
190 | IN EFI_HANDLE Controller, | |
191 | IN EFI_HANDLE ImageHandle | |
192 | ); | |
193 | ||
194 | EFI_STATUS | |
195 | Ip4SetAddress ( | |
196 | IN IP4_INTERFACE *Interface, | |
197 | IN IP4_ADDR IpAddr, | |
198 | IN IP4_ADDR SubnetMask | |
199 | ); | |
200 | ||
201 | EFI_STATUS | |
202 | Ip4FreeInterface ( | |
203 | IN IP4_INTERFACE *Interface, | |
204 | IN IP4_PROTOCOL *IpInstance OPTIONAL | |
205 | ); | |
206 | ||
207 | EFI_STATUS | |
208 | Ip4SendFrame ( | |
209 | IN IP4_INTERFACE *Interface, | |
210 | IN IP4_PROTOCOL *IpInstance, OPTIONAL | |
211 | IN NET_BUF *Packet, | |
212 | IN IP4_ADDR NextHop, | |
213 | IN IP4_FRAME_CALLBACK CallBack, | |
214 | IN VOID *Context | |
215 | ); | |
216 | ||
217 | VOID | |
218 | Ip4CancelFrames ( | |
219 | IN IP4_INTERFACE *Interface, | |
220 | IN EFI_STATUS IoStatus, | |
221 | IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL | |
222 | IN VOID *Context | |
223 | ); | |
224 | ||
225 | VOID | |
226 | Ip4CancelReceive ( | |
227 | IN IP4_INTERFACE *Interface | |
228 | ); | |
229 | ||
230 | EFI_STATUS | |
231 | Ip4ReceiveFrame ( | |
232 | IN IP4_INTERFACE *Interface, | |
233 | IN IP4_PROTOCOL *IpInstance, OPTIONAL | |
234 | IN IP4_FRAME_CALLBACK CallBack, | |
235 | IN VOID *Context | |
236 | ); | |
237 | ||
238 | #endif |