31 NET_LIST_FOR_EACH (ListEntry, List) {
32 SockToken = NET_LIST_USER_STRUCT (
72 if ((Sock->ConnectionToken !=
NULL) && (Sock->ConnectionToken->Event == Event)) {
76 if ((Sock->CloseToken !=
NULL) && (Sock->CloseToken->Event == Event)) {
105 if (
NULL == SockToken) {
108 "SockBufferIOToken: No Memory to allocate SockToken\n")
114 SockToken->
Sock = Sock;
143 ASSERT ((Sock !=
NULL) && (Sock->ProtoHandler !=
NULL));
145 if (Sock->InDestroy) {
149 Sock->InDestroy =
TRUE;
151 if (Sock->IpVersion == IP_VERSION_4) {
152 IpProtocolGuid = &gEfiIp4ProtocolGuid;
153 TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
155 IpProtocolGuid = &gEfiIp6ProtocolGuid;
156 TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
160 Tcb = ProtoData->TcpPcb;
162 ASSERT (Tcb !=
NULL);
170 ProtoData->TcpService->IpIo->Image,
174 if (Sock->DestroyCallback !=
NULL) {
175 Sock->DestroyCallback (Sock, Sock->Context);
181 Status =
gBS->OpenProtocol (
187 EFI_OPEN_PROTOCOL_GET_PROTOCOL
190 if (EFI_ERROR (Status)) {
193 "SockDestroyChild: Open protocol installed on socket failed with %r\n",
201 gBS->UninstallMultipleProtocolInterfaces (
209 if (EFI_ERROR (Status)) {
212 "SockDestroyChild: Get the lock to access socket failed with %r\n",
216 return EFI_ACCESS_DENIED;
224 if (EFI_ERROR (Status)) {
227 "SockDestroyChild: Protocol detach socket failed with %r\n",
231 Sock->InDestroy =
FALSE;
241 if (EFI_ERROR (Status)) {
276 "SockCreateChild: No resource to create a new socket\n")
283 if (EFI_ERROR (Status)) {
286 "SockCreateChild: Get the lock to access socket failed with %r\n",
298 if (EFI_ERROR (Status)) {
301 "SockCreateChild: Protocol failed to attach a socket with %r\n",
315 if (Sock->IpVersion == IP_VERSION_4) {
316 TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
318 TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
327 EFI_OPEN_PROTOCOL_GET_PROTOCOL
332 gBS->UninstallMultipleProtocolInterfaces (
362 if (EFI_ERROR (Status)) {
365 "SockConfigure: Get the access for socket failed with %r",
369 return EFI_ACCESS_DENIED;
373 Status = EFI_ACCESS_DENIED;
415 if (EFI_ERROR (Status)) {
418 "SockConnect: Get the access for socket failed with %r",
422 return EFI_ACCESS_DENIED;
426 Status = EFI_NO_MAPPING;
431 Status = EFI_NOT_STARTED;
436 Status = EFI_ACCESS_DENIED;
443 Status = EFI_ACCESS_DENIED;
490 if (EFI_ERROR (Status)) {
493 "SockAccept: Get the access for socket failed with %r",
497 return EFI_ACCESS_DENIED;
501 Status = EFI_NO_MAPPING;
506 Status = EFI_NOT_STARTED;
511 Status = EFI_ACCESS_DENIED;
518 Status = EFI_ACCESS_DENIED;
527 NET_LIST_FOR_EACH (ListEntry, &Sock->ConnectionList) {
528 Socket = NET_LIST_USER_STRUCT (ListEntry,
SOCKET, ConnectionList);
531 ListenToken->NewChildHandle = Socket->
SockHandle;
542 "SockAccept: Accept a socket, now conncount is %d",
555 Status = EFI_OUT_OF_RESOURCES;
599 if (EFI_ERROR (Status)) {
602 "SockSend: Get the access for socket failed with %r",
606 return EFI_ACCESS_DENIED;
610 Status = EFI_NO_MAPPING;
618 Status = EFI_NOT_STARTED;
623 Status = EFI_ACCESS_DENIED;
630 Event = SndToken->Token.
Event;
633 Status = EFI_ACCESS_DENIED;
637 DataLen = TxData->DataLength;
652 if (
NULL == SockToken) {
653 Status = EFI_OUT_OF_RESOURCES;
658 &Sock->ProcessingSndTokenList,
663 if (
NULL == SockToken) {
664 DEBUG ((DEBUG_ERROR,
"SockSend: Failed to buffer IO token into socket processing SndToken List\n"));
666 Status = EFI_OUT_OF_RESOURCES;
672 if (EFI_ERROR (Status)) {
673 DEBUG ((DEBUG_ERROR,
"SockSend: Failed to process Snd Data\n"));
718 if (EFI_ERROR (Status)) {
721 "SockRcv: Get the access for socket failed with %r",
725 return EFI_ACCESS_DENIED;
729 Status = EFI_NO_MAPPING;
734 Status = EFI_NOT_STARTED;
739 Status = EFI_ACCESS_DENIED;
748 Event = RcvToken->Token.
Event;
750 Status = EFI_ACCESS_DENIED;
760 if (EFI_ABORTED != Sock->SockError) {
762 Sock->SockError = EFI_ABORTED;
775 if (RcvdBytes != 0) {
781 Status = EFI_OUT_OF_RESOURCES;
809 if (EFI_ERROR (Status)) {
812 "SockFlush: Get the access for socket failed with %r",
816 return EFI_ACCESS_DENIED;
820 Status = EFI_ACCESS_DENIED;
825 if (EFI_ERROR (Status)) {
828 "SockFlush: Protocol failed handling SOCK_FLUSH with %r",
878 if (EFI_ERROR (Status)) {
881 "SockClose: Get the access for socket failed with %r",
885 return EFI_ACCESS_DENIED;
889 Status = EFI_NO_MAPPING;
894 Status = EFI_NOT_STARTED;
899 Status = EFI_ACCESS_DENIED;
906 Status = EFI_ACCESS_DENIED;
910 Sock->CloseToken = Token;
949 if (EFI_ERROR (Status)) {
952 "SockCancel: Get the access for socket failed with %r",
956 return EFI_ACCESS_DENIED;
960 Status = EFI_NOT_STARTED;
968 if (Sock->ConnectionToken !=
NULL) {
970 Sock->ConnectionToken =
NULL;
983 if ((Token !=
NULL) && !EFI_ERROR (Status)) {
991 if ((Token !=
NULL) && !EFI_ERROR (Status)) {
999 if ((Token !=
NULL) && !EFI_ERROR (Status)) {
1030 return Sock->ProtoHandler (Sock,
SOCK_MODE, Mode);
1057 if (EFI_ERROR (Status)) {
1060 "SockRoute: Get the access for socket failed with %r",
1064 return EFI_ACCESS_DENIED;
1068 Status = EFI_NO_MAPPING;
1073 Status = EFI_NOT_STARTED;
1077 Status = Sock->ProtoHandler (Sock,
SOCK_ROUTE, RouteInfo);
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
#define SOCK_CONNECT
Need to connect to a peer.
#define SOCK_IS_DISCONNECTING(Sock)
#define SOCK_IS_CONFIGURED_ACTIVE(Sock)
#define GET_RCV_DATASIZE(Sock)
#define SOCK_CONSUMED
Application has retrieved data from socket.
#define SOCK_IS_CONNECTING(Sock)
#define SOCK_IS_CONFIGURED(Sock)
#define SOCK_ATTACH
Attach current socket to a new PCB.
#define SOCK_IS_NO_MORE_DATA(Sock)
UINT32 SockGetFreeSpace(IN SOCKET *Sock, IN UINT32 Which)
#define SOCK_CONFIGURE
Configure attached PCB.
@ SockStream
This socket providing stream service.
#define SOCK_IS_UNCONFIGURED(Sock)
#define SOCK_CLOSE
Need to close the protocol process.
#define SOCK_IS_LISTENING(Sock)
#define SOCK_IS_CLOSED(Sock)
#define SOCK_MODE
Need to get the mode data of the protocol.
VOID SockSetState(IN OUT SOCKET *Sock, IN UINT8 State)
#define SOCK_ABORT
Need to reset the protocol process.
#define SOCK_ROUTE
Need to add a route information.
#define SOCK_IS_NO_MAPPING(Sock)
#define SOCK_IS_CONNECTED(Sock)
#define SOCK_DETACH
Detach current socket from the PCB.
#define SOCK_FLUSH
Flush attached PCB.
#define SOCK_ERROR(Sock, Error)
EFI_STATUS SockProcessTcpSndData(IN SOCKET *Sock, IN VOID *TcpTxData)
VOID SockDestroy(IN OUT SOCKET *Sock)
SOCKET * SockCreate(IN SOCK_INIT_DATA *SockInitData)
VOID SockConnFlush(IN OUT SOCKET *Sock)
UINT32 SockProcessRcvToken(IN OUT SOCKET *Sock, IN OUT SOCK_IO_TOKEN *RcvToken)
EFI_STATUS SockCancelToken(IN SOCK_COMPLETION_TOKEN *Token, IN OUT LIST_ENTRY *SpecifiedTokenList)
#define SIGNAL_TOKEN(Token, TokenStatus)
EFI_STATUS SockFlush(IN OUT SOCKET *Sock)
BOOLEAN SockTokenExisted(IN SOCKET *Sock, IN EFI_EVENT Event)
SOCKET * SockCreateChild(IN SOCK_INIT_DATA *SockInitData)
EFI_STATUS SockClose(IN OUT SOCKET *Sock, IN VOID *Token, IN BOOLEAN OnAbort)
EFI_STATUS SockConnect(IN SOCKET *Sock, IN VOID *Token)
EFI_STATUS SockRcv(IN SOCKET *Sock, IN VOID *Token)
SOCK_TOKEN * SockBufferToken(IN SOCKET *Sock, IN LIST_ENTRY *List, IN VOID *Token, IN UINT32 DataLen)
EFI_STATUS SockRoute(IN SOCKET *Sock, IN VOID *RouteInfo)
EFI_STATUS SockDestroyChild(IN OUT SOCKET *Sock)
EFI_STATUS SockSend(IN SOCKET *Sock, IN VOID *Token)
BOOLEAN SockTokenExistedInList(IN LIST_ENTRY *List, IN EFI_EVENT Event)
EFI_STATUS SockAccept(IN SOCKET *Sock, IN VOID *Token)
EFI_STATUS SockGetMode(IN SOCKET *Sock, IN OUT VOID *Mode)
EFI_STATUS SockCancel(IN OUT SOCKET *Sock, IN VOID *Token)
EFI_STATUS SockConfigure(IN SOCKET *Sock, IN VOID *ConfigData)
VOID EFIAPI Exit(IN EFI_STATUS Status)
#define EFI_CONNECTION_FIN
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
EFI_STATUS EFIAPI EfiAcquireLockOrFail(IN EFI_LOCK *Lock)
EFI_EVENT Event
The event to be issued.
LIST_ENTRY TokenList
The entry to add in the token list.
SOCK_COMPLETION_TOKEN * Token
The application's token.
UINT32 RemainDataLen
Unprocessed data length.
IP_IO_IP_INFO * IpInfo
Pointer reference to Ip used to send pkt.
SOCKET * Parent
listening parent that accept the connection
EFI_LOCK Lock
The lock of socket.
EFI_HANDLE SockHandle
The virtual handle of the socket.
SOCK_DESTROY_CALLBACK DestroyCallback
Callback before destroyed.
SOCK_PROTO_HANDLER ProtoHandler
The request handler of protocol.
EFI_HANDLE DriverBinding
Socket's driver binding protocol.
UINT32 ConnCnt
the current count of connections to it
VOID * Context
The context of the callback.