1 | /** @file
|
---|
2 | Prototypes definitions of IKE service.
|
---|
3 |
|
---|
4 | Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
|
---|
5 |
|
---|
6 | This program and the accompanying materials
|
---|
7 | are licensed and made available under the terms and conditions of the BSD License
|
---|
8 | which accompanies this distribution. The full text of the license may be found at
|
---|
9 | http://opensource.org/licenses/bsd-license.php.
|
---|
10 |
|
---|
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
13 |
|
---|
14 | **/
|
---|
15 |
|
---|
16 | #ifndef _IKE_SERVICE_H_
|
---|
17 | #define _IKE_SERVICE_H_
|
---|
18 |
|
---|
19 | #include "Ike.h"
|
---|
20 | #include "IpSecImpl.h"
|
---|
21 | #include "IkeCommon.h"
|
---|
22 |
|
---|
23 | #define IPSEC_CRYPTO_LIB_MEMORY 128 * 1024
|
---|
24 |
|
---|
25 | /**
|
---|
26 | This is prototype definition of general interface to intialize a IKE negotiation.
|
---|
27 |
|
---|
28 | @param[in] UdpService Point to Udp Servcie used for the IKE packet sending.
|
---|
29 | @param[in] SpdEntry Point to SPD entry related to this IKE negotiation.
|
---|
30 | @param[in] PadEntry Point to PAD entry related to this IKE negotiation.
|
---|
31 | @param[in] RemoteIp Point to IP Address which the remote peer to negnotiate.
|
---|
32 |
|
---|
33 | @retval EFI_SUCCESS The operation is successful.
|
---|
34 | @return Otherwise The operation is failed.
|
---|
35 |
|
---|
36 | **/
|
---|
37 | typedef
|
---|
38 | EFI_STATUS
|
---|
39 | (*IKE_NEGOTIATE_SA) (
|
---|
40 | IN IKE_UDP_SERVICE * UdpService,
|
---|
41 | IN IPSEC_SPD_ENTRY * SpdEntry,
|
---|
42 | IN IPSEC_PAD_ENTRY * PadEntry,
|
---|
43 | IN EFI_IP_ADDRESS * RemoteIp
|
---|
44 | );
|
---|
45 |
|
---|
46 | /**
|
---|
47 | This is prototype definition fo general interface to start a IKE negotiation at Quick Mode.
|
---|
48 |
|
---|
49 | This function will be called when the related IKE SA is existed and start to
|
---|
50 | create a Child SA.
|
---|
51 |
|
---|
52 | @param[in] IkeSaSession Point to IKE SA Session related to this Negotiation.
|
---|
53 | @param[in] SpdEntry Point to SPD entry related to this Negotiation.
|
---|
54 | @param[in] Context Point to data passed from the caller.
|
---|
55 |
|
---|
56 | @retval EFI_SUCCESS The operation is successful.
|
---|
57 | @retval Otherwise The operation is failed.
|
---|
58 |
|
---|
59 | **/
|
---|
60 | typedef
|
---|
61 | EFI_STATUS
|
---|
62 | (*IKE_NEGOTIATE_CHILD_SA) (
|
---|
63 | IN UINT8 *IkeSaSession,
|
---|
64 | IN IPSEC_SPD_ENTRY *SpdEntry,
|
---|
65 | IN UINT8 *Context
|
---|
66 | );
|
---|
67 |
|
---|
68 | /**
|
---|
69 | This is prototype definition of the general interface when initialize a Inforamtion
|
---|
70 | Exchange.
|
---|
71 |
|
---|
72 | @param[in] IkeSaSession Point to IKE SA Session related to.
|
---|
73 | @param[in] Context Point to data passed from caller.
|
---|
74 |
|
---|
75 | **/
|
---|
76 | typedef
|
---|
77 | EFI_STATUS
|
---|
78 | (*IKE_NEGOTIATE_INFO) (
|
---|
79 | IN UINT8 *IkeSaSession,
|
---|
80 | IN UINT8 *Context
|
---|
81 | );
|
---|
82 |
|
---|
83 | /**
|
---|
84 | This is prototype definition of the general interface when recived a IKE Pakcet
|
---|
85 | for the IKE SA establishing.
|
---|
86 |
|
---|
87 | @param[in] UdpService Point to UDP service used to send IKE Packet.
|
---|
88 | @param[in] IkePacket Point to received IKE packet.
|
---|
89 |
|
---|
90 | **/
|
---|
91 | typedef
|
---|
92 | VOID
|
---|
93 | (*IKE_HANDLE_SA) (
|
---|
94 | IN IKE_UDP_SERVICE *UdpService,
|
---|
95 | IN IKE_PACKET *IkePacket
|
---|
96 | );
|
---|
97 |
|
---|
98 | /**
|
---|
99 | This is prototyp definition of the general interface when recived a IKE Packet
|
---|
100 | xfor the Child SA establishing.
|
---|
101 |
|
---|
102 | @param[in] UdpService Point to UDP service used to send IKE packet.
|
---|
103 | @param[in] IkePacket Point to received IKE packet.
|
---|
104 |
|
---|
105 | **/
|
---|
106 | typedef
|
---|
107 | VOID
|
---|
108 | (*IKE_HANDLE_CHILD_SA) (
|
---|
109 | IN IKE_UDP_SERVICE *UdpService,
|
---|
110 | IN IKE_PACKET *IkePacket
|
---|
111 | );
|
---|
112 |
|
---|
113 | /**
|
---|
114 | This is prototype definition of the general interface when received a IKE
|
---|
115 | information Packet.
|
---|
116 |
|
---|
117 | @param[in] UdpService Point to UDP service used to send IKE packet.
|
---|
118 | @param[in] IkePacket Point to received IKE packet.
|
---|
119 |
|
---|
120 | **/
|
---|
121 | typedef
|
---|
122 | VOID
|
---|
123 | (*IKE_HANDLE_INFO) (
|
---|
124 | IN IKE_UDP_SERVICE *UdpService,
|
---|
125 | IN IKE_PACKET *IkePacket
|
---|
126 | );
|
---|
127 |
|
---|
128 | typedef struct _IKE_EXCHANGE_INTERFACE {
|
---|
129 | UINT8 IkeVer;
|
---|
130 | IKE_NEGOTIATE_SA NegotiateSa;
|
---|
131 | IKE_NEGOTIATE_CHILD_SA NegotiateChildSa;
|
---|
132 | IKE_NEGOTIATE_INFO NegotiateInfo;
|
---|
133 | IKE_HANDLE_SA HandleSa;
|
---|
134 | IKE_HANDLE_CHILD_SA HandleChildSa;
|
---|
135 | IKE_HANDLE_INFO HandleInfo;
|
---|
136 | } IKE_EXCHANGE_INTERFACE;
|
---|
137 |
|
---|
138 | /**
|
---|
139 | Open and configure a UDPIO of Udp4 for IKE packet receiving.
|
---|
140 |
|
---|
141 | This function is called at the IPsecDriverBinding start. IPsec create a UDP4 and
|
---|
142 | a UDP4 IO for each NIC handle.
|
---|
143 |
|
---|
144 | @param[in] Private Point to IPSEC_PRIVATE_DATA
|
---|
145 | @param[in] Controller Handler for NIC card.
|
---|
146 | @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
147 |
|
---|
148 | @retval EFI_SUCCESS The Operation is successful.
|
---|
149 | @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
|
---|
150 |
|
---|
151 | **/
|
---|
152 | EFI_STATUS
|
---|
153 | IkeOpenInputUdp4 (
|
---|
154 | IN IPSEC_PRIVATE_DATA *Private,
|
---|
155 | IN EFI_HANDLE Controller,
|
---|
156 | IN EFI_HANDLE ImageHandle
|
---|
157 | );
|
---|
158 |
|
---|
159 | /**
|
---|
160 | Open and configure a UDPIO of Udp6 for IKE packet receiving.
|
---|
161 |
|
---|
162 | This function is called at the IPsecDriverBinding start. IPsec create a UDP6 and UDP6
|
---|
163 | IO for each NIC handle.
|
---|
164 |
|
---|
165 | @param[in] Private Point to IPSEC_PRIVATE_DATA
|
---|
166 | @param[in] Controller Handler for NIC card.
|
---|
167 | @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
168 |
|
---|
169 | @retval EFI_SUCCESS The Operation is successful.
|
---|
170 | @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
|
---|
171 |
|
---|
172 | **/
|
---|
173 | EFI_STATUS
|
---|
174 | IkeOpenInputUdp6 (
|
---|
175 | IN IPSEC_PRIVATE_DATA *Private,
|
---|
176 | IN EFI_HANDLE Controller,
|
---|
177 | IN EFI_HANDLE ImageHandle
|
---|
178 | );
|
---|
179 |
|
---|
180 | /**
|
---|
181 | The general interface of starting IPsec Key Exchange.
|
---|
182 |
|
---|
183 | This function is called when start a IKE negotiation to get a Key.
|
---|
184 |
|
---|
185 | @param[in] UdpService Point to IKE_UDP_SERVICE which will be used for
|
---|
186 | IKE packet sending.
|
---|
187 | @param[in] SpdEntry Point to the SPD entry related to the IKE negotiation.
|
---|
188 | @param[in] RemoteIp Point to EFI_IP_ADDRESS related to the IKE negotiation.
|
---|
189 |
|
---|
190 | @retval EFI_SUCCESS The Operation is successful.
|
---|
191 | @retval EFI_ACCESS_DENIED No related PAD entry was found.
|
---|
192 |
|
---|
193 | **/
|
---|
194 | EFI_STATUS
|
---|
195 | IkeNegotiate (
|
---|
196 | IN IKE_UDP_SERVICE *UdpService,
|
---|
197 | IN IPSEC_SPD_ENTRY *SpdEntry,
|
---|
198 | IN EFI_IP_ADDRESS *RemoteIp
|
---|
199 | );
|
---|
200 |
|
---|
201 | /**
|
---|
202 | The general interface when receive a IKE packet.
|
---|
203 |
|
---|
204 | This function is called when UDP IO receives a IKE packet.
|
---|
205 |
|
---|
206 | @param[in] Packet Point to received IKE packet.
|
---|
207 | @param[in] EndPoint Point to UDP_END_POINT which contains the information of
|
---|
208 | Remote IP and Port.
|
---|
209 | @param[in] IoStatus The Status of Recieve Token.
|
---|
210 | @param[in] Context Point to data passed from the caller.
|
---|
211 |
|
---|
212 | **/
|
---|
213 | VOID
|
---|
214 | EFIAPI
|
---|
215 | IkeDispatch (
|
---|
216 | IN NET_BUF *Packet,
|
---|
217 | IN UDP_END_POINT *EndPoint,
|
---|
218 | IN EFI_STATUS IoStatus,
|
---|
219 | IN VOID *Context
|
---|
220 | );
|
---|
221 |
|
---|
222 | /**
|
---|
223 | Check if the NIC handle is binded to a Udp service.
|
---|
224 |
|
---|
225 | @param[in] Private Pointer of IPSEC_PRIVATE_DATA
|
---|
226 | @param[in] Handle The Handle of the NIC card
|
---|
227 | @param[in] IpVersion The version of the IP stack.
|
---|
228 |
|
---|
229 | @return a pointer of IKE_UDP_SERVICE.
|
---|
230 |
|
---|
231 | **/
|
---|
232 | IKE_UDP_SERVICE *
|
---|
233 | IkeLookupUdp (
|
---|
234 | IN IPSEC_PRIVATE_DATA *Private,
|
---|
235 | IN EFI_HANDLE Handle,
|
---|
236 | IN UINT8 IpVersion
|
---|
237 | );
|
---|
238 |
|
---|
239 |
|
---|
240 | /**
|
---|
241 | Delete all established IKE SAs and related Child SAs.
|
---|
242 |
|
---|
243 | This function is the subfunction of the IpSecCleanupAllSa(). It first calls
|
---|
244 | IkeDeleteChildSa() to delete all Child SAs then send out the related
|
---|
245 | Information packet.
|
---|
246 |
|
---|
247 | @param[in] Private Pointer of the IPSEC_PRIVATE_DATA.
|
---|
248 | @param[in] IsDisableIpsec Indicate whether needs to disable IPsec.
|
---|
249 |
|
---|
250 | **/
|
---|
251 | VOID
|
---|
252 | IkeDeleteAllSas (
|
---|
253 | IN IPSEC_PRIVATE_DATA *Private,
|
---|
254 | IN BOOLEAN IsDisableIpsec
|
---|
255 | );
|
---|
256 |
|
---|
257 |
|
---|
258 | extern IKE_EXCHANGE_INTERFACE mIkev1Exchange;
|
---|
259 | extern IKE_EXCHANGE_INTERFACE mIkev2Exchange;
|
---|
260 |
|
---|
261 | #endif
|
---|