2 Implement the connection to the EFI socket library
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 CONST EFI_GUID mEslRawServiceGuid
= {
19 0xc31bf4a5, 0x2c7, 0x49d2, { 0xa5, 0x58, 0xfe, 0x62, 0x6f, 0x7e, 0xd4, 0x77 }
22 CONST EFI_GUID mEslTcp4ServiceGuid
= {
23 0xffc659c2, 0x4ef2, 0x4532, { 0xb8, 0x75, 0xcd, 0x9a, 0xa4, 0x27, 0x4c, 0xde }
26 CONST EFI_GUID mEslUdp4ServiceGuid
= {
27 0x44e03a55, 0x8d97, 0x4511, { 0xbf, 0xef, 0xa, 0x8b, 0xc6, 0x2c, 0x25, 0xae }
32 Connect to the EFI socket library
34 @param [in] ppSocketProtocol Address to receive the socket protocol address
36 @retval 0 Successfully returned the socket protocol
37 @retval other Value for errno
40 EslServiceGetProtocol (
41 IN EFI_SOCKET_PROTOCOL
** ppSocketProtocol
44 EFI_HANDLE ChildHandle
;
57 // Locate the socket protocol
60 Status
= EslSocketAllocate ( &ChildHandle
,
63 if ( !EFI_ERROR ( Status
)) {
64 *ppSocketProtocol
= &pSocket
->SocketProtocol
;
74 // Return the operation status
76 DBG_EXIT_DEC ( RetVal
);
82 Connect to the network layer
84 @retval EFI_SUCCESS Successfully connected to the network layer
88 EslServiceNetworkConnect (
93 EFI_HANDLE
* pHandles
;
95 CONST DT_SOCKET_BINDING
* pSocketBinding
;
96 CONST DT_SOCKET_BINDING
* pEnd
;
102 // Initialize the socket layer
104 Status
= EFI_SUCCESS
;
105 EslServiceLoad ( gImageHandle
);
108 // Connect the network devices
110 pSocketBinding
= &cEslSocketBinding
[0];
111 pEnd
= &pSocketBinding
[ cEslSocketBindingEntries
];
112 while ( pEnd
> pSocketBinding
) {
114 // Attempt to locate the network adapters
118 Status
= gBS
->LocateHandleBuffer ( ByProtocol
,
119 pSocketBinding
->pNetworkBinding
,
123 if ( EFI_ERROR ( Status
)) {
126 if ( NULL
!= pHandles
) {
128 // Attempt to connect to this network adapter
130 for ( Index
= 0; HandleCount
> Index
; Index
++ ) {
131 Status
= EslServiceConnect ( gImageHandle
,
133 if ( EFI_ERROR ( Status
)) {
139 // Done with the handles
141 gBS
->FreePool ( pHandles
);
145 // Set the next network protocol
151 // Return the network connection status
153 DBG_EXIT_STATUS ( Status
);
159 Disconnect from the network layer
161 @retval EFI_SUCCESS Successfully disconnected from the network layer
165 EslServiceNetworkDisconnect (
170 EFI_HANDLE
* pHandles
;
172 CONST DT_SOCKET_BINDING
* pSocketBinding
;
173 CONST DT_SOCKET_BINDING
* pEnd
;
181 Status
= EFI_SUCCESS
;
184 // Disconnect the network devices
186 pSocketBinding
= &cEslSocketBinding
[0];
187 pEnd
= &pSocketBinding
[ cEslSocketBindingEntries
];
188 while ( pEnd
> pSocketBinding
) {
190 // Attempt to locate the network adapters
194 Status
= gBS
->LocateHandleBuffer ( ByProtocol
,
195 pSocketBinding
->pNetworkBinding
,
199 if ( EFI_ERROR ( Status
)) {
202 if ( NULL
!= pHandles
) {
204 // Attempt to disconnect from this network adapter
206 for ( Index
= 0; HandleCount
> Index
; Index
++ ) {
207 Status
= EslServiceDisconnect ( gImageHandle
,
209 if ( EFI_ERROR ( Status
)) {
215 // Done with the handles
217 gBS
->FreePool ( pHandles
);
221 // Set the next network protocol
227 // Finish the disconnect operation
229 if ( !EFI_ERROR ( Status
)) {
230 EslServiceUnload ( );
234 // Return the network connection status
236 DBG_EXIT_STATUS ( Status
);
241 PFN_ESL_xSTRUCTOR mpfnEslConstructor
= EslServiceNetworkConnect
;
242 PFN_ESL_xSTRUCTOR mpfnEslDestructor
= EslServiceNetworkDisconnect
;