TianoCore EDK2 master
Loading...
Searching...
No Matches
SockInterface.c
Go to the documentation of this file.
1
10#include "SockImpl.h"
11
22BOOLEAN
24 IN LIST_ENTRY *List,
25 IN EFI_EVENT Event
26 )
27{
28 LIST_ENTRY *ListEntry;
29 SOCK_TOKEN *SockToken;
30
31 NET_LIST_FOR_EACH (ListEntry, List) {
32 SockToken = NET_LIST_USER_STRUCT (
33 ListEntry,
35 TokenList
36 );
37
38 if (Event == SockToken->Token->Event) {
39 return TRUE;
40 }
41 }
42
43 return FALSE;
44}
45
57BOOLEAN
59 IN SOCKET *Sock,
60 IN EFI_EVENT Event
61 )
62{
63 if (SockTokenExistedInList (&Sock->SndTokenList, Event) ||
64 SockTokenExistedInList (&Sock->ProcessingSndTokenList, Event) ||
65 SockTokenExistedInList (&Sock->RcvTokenList, Event) ||
66 SockTokenExistedInList (&Sock->ListenTokenList, Event)
67 )
68 {
69 return TRUE;
70 }
71
72 if ((Sock->ConnectionToken != NULL) && (Sock->ConnectionToken->Event == Event)) {
73 return TRUE;
74 }
75
76 if ((Sock->CloseToken != NULL) && (Sock->CloseToken->Event == Event)) {
77 return TRUE;
78 }
79
80 return FALSE;
81}
82
96 IN SOCKET *Sock,
97 IN LIST_ENTRY *List,
98 IN VOID *Token,
99 IN UINT32 DataLen
100 )
101{
102 SOCK_TOKEN *SockToken;
103
104 SockToken = AllocateZeroPool (sizeof (SOCK_TOKEN));
105 if (NULL == SockToken) {
106 DEBUG (
107 (DEBUG_ERROR,
108 "SockBufferIOToken: No Memory to allocate SockToken\n")
109 );
110
111 return NULL;
112 }
113
114 SockToken->Sock = Sock;
115 SockToken->Token = (SOCK_COMPLETION_TOKEN *)Token;
116 SockToken->RemainDataLen = DataLen;
117 InsertTailList (List, &SockToken->TokenList);
118
119 return SockToken;
120}
121
133 IN OUT SOCKET *Sock
134 )
135{
136 EFI_STATUS Status;
137 TCP_PROTO_DATA *ProtoData;
138 TCP_CB *Tcb;
139 EFI_GUID *IpProtocolGuid;
140 EFI_GUID *TcpProtocolGuid;
141 VOID *SockProtocol;
142
143 ASSERT ((Sock != NULL) && (Sock->ProtoHandler != NULL));
144
145 if (Sock->InDestroy) {
146 return EFI_SUCCESS;
147 }
148
149 Sock->InDestroy = TRUE;
150
151 if (Sock->IpVersion == IP_VERSION_4) {
152 IpProtocolGuid = &gEfiIp4ProtocolGuid;
153 TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
154 } else {
155 IpProtocolGuid = &gEfiIp6ProtocolGuid;
156 TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
157 }
158
159 ProtoData = (TCP_PROTO_DATA *)Sock->ProtoReserved;
160 Tcb = ProtoData->TcpPcb;
161
162 ASSERT (Tcb != NULL);
163
164 //
165 // Close the IP protocol.
166 //
167 gBS->CloseProtocol (
168 Tcb->IpInfo->ChildHandle,
169 IpProtocolGuid,
170 ProtoData->TcpService->IpIo->Image,
171 Sock->SockHandle
172 );
173
174 if (Sock->DestroyCallback != NULL) {
175 Sock->DestroyCallback (Sock, Sock->Context);
176 }
177
178 //
179 // Retrieve the protocol installed on this sock
180 //
181 Status = gBS->OpenProtocol (
182 Sock->SockHandle,
183 TcpProtocolGuid,
184 &SockProtocol,
185 Sock->DriverBinding,
186 Sock->SockHandle,
187 EFI_OPEN_PROTOCOL_GET_PROTOCOL
188 );
189
190 if (EFI_ERROR (Status)) {
191 DEBUG (
192 (DEBUG_ERROR,
193 "SockDestroyChild: Open protocol installed on socket failed with %r\n",
194 Status)
195 );
196 }
197
198 //
199 // Uninstall the protocol installed on this sock
200 //
201 gBS->UninstallMultipleProtocolInterfaces (
202 Sock->SockHandle,
203 TcpProtocolGuid,
204 SockProtocol,
205 NULL
206 );
207
208 Status = EfiAcquireLockOrFail (&(Sock->Lock));
209 if (EFI_ERROR (Status)) {
210 DEBUG (
211 (DEBUG_ERROR,
212 "SockDestroyChild: Get the lock to access socket failed with %r\n",
213 Status)
214 );
215
216 return EFI_ACCESS_DENIED;
217 }
218
219 //
220 // force protocol layer to detach the PCB
221 //
222 Status = Sock->ProtoHandler (Sock, SOCK_DETACH, NULL);
223
224 if (EFI_ERROR (Status)) {
225 DEBUG (
226 (DEBUG_ERROR,
227 "SockDestroyChild: Protocol detach socket failed with %r\n",
228 Status)
229 );
230
231 Sock->InDestroy = FALSE;
232 } else if (SOCK_IS_CONFIGURED (Sock)) {
233 SockConnFlush (Sock);
234 SockSetState (Sock, SO_CLOSED);
235
236 Sock->ConfigureState = SO_UNCONFIGURED;
237 }
238
239 EfiReleaseLock (&(Sock->Lock));
240
241 if (EFI_ERROR (Status)) {
242 return Status;
243 }
244
245 SockDestroy (Sock);
246 return EFI_SUCCESS;
247}
248
259SOCKET *
261 IN SOCK_INIT_DATA *SockInitData
262 )
263{
264 SOCKET *Sock;
265 EFI_STATUS Status;
266 VOID *SockProtocol;
267 EFI_GUID *TcpProtocolGuid;
268
269 //
270 // create a new socket
271 //
272 Sock = SockCreate (SockInitData);
273 if (NULL == Sock) {
274 DEBUG (
275 (DEBUG_ERROR,
276 "SockCreateChild: No resource to create a new socket\n")
277 );
278
279 return NULL;
280 }
281
282 Status = EfiAcquireLockOrFail (&(Sock->Lock));
283 if (EFI_ERROR (Status)) {
284 DEBUG (
285 (DEBUG_ERROR,
286 "SockCreateChild: Get the lock to access socket failed with %r\n",
287 Status)
288 );
289 goto ERROR;
290 }
291
292 //
293 // inform the protocol layer to attach the socket
294 // with a new protocol control block
295 //
296 Status = Sock->ProtoHandler (Sock, SOCK_ATTACH, NULL);
297 EfiReleaseLock (&(Sock->Lock));
298 if (EFI_ERROR (Status)) {
299 DEBUG (
300 (DEBUG_ERROR,
301 "SockCreateChild: Protocol failed to attach a socket with %r\n",
302 Status)
303 );
304 goto ERROR;
305 }
306
307 return Sock;
308
309ERROR:
310
311 if (Sock->DestroyCallback != NULL) {
312 Sock->DestroyCallback (Sock, Sock->Context);
313 }
314
315 if (Sock->IpVersion == IP_VERSION_4) {
316 TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
317 } else {
318 TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
319 }
320
321 gBS->OpenProtocol (
322 Sock->SockHandle,
323 TcpProtocolGuid,
324 &SockProtocol,
325 Sock->DriverBinding,
326 Sock->SockHandle,
327 EFI_OPEN_PROTOCOL_GET_PROTOCOL
328 );
329 //
330 // Uninstall the protocol installed on this sock
331 //
332 gBS->UninstallMultipleProtocolInterfaces (
333 Sock->SockHandle,
334 TcpProtocolGuid,
335 SockProtocol,
336 NULL
337 );
338 SockDestroy (Sock);
339 return NULL;
340}
341
355 IN SOCKET *Sock,
356 IN VOID *ConfigData
357 )
358{
359 EFI_STATUS Status;
360
361 Status = EfiAcquireLockOrFail (&(Sock->Lock));
362 if (EFI_ERROR (Status)) {
363 DEBUG (
364 (DEBUG_ERROR,
365 "SockConfigure: Get the access for socket failed with %r",
366 Status)
367 );
368
369 return EFI_ACCESS_DENIED;
370 }
371
372 if (SOCK_IS_CONFIGURED (Sock)) {
373 Status = EFI_ACCESS_DENIED;
374 goto OnExit;
375 }
376
377 ASSERT (Sock->State == SO_CLOSED);
378
379 Status = Sock->ProtoHandler (Sock, SOCK_CONFIGURE, ConfigData);
380
381OnExit:
382 EfiReleaseLock (&(Sock->Lock));
383
384 return Status;
385}
386
407 IN SOCKET *Sock,
408 IN VOID *Token
409 )
410{
411 EFI_STATUS Status;
412 EFI_EVENT Event;
413
414 Status = EfiAcquireLockOrFail (&(Sock->Lock));
415 if (EFI_ERROR (Status)) {
416 DEBUG (
417 (DEBUG_ERROR,
418 "SockConnect: Get the access for socket failed with %r",
419 Status)
420 );
421
422 return EFI_ACCESS_DENIED;
423 }
424
425 if (SOCK_IS_NO_MAPPING (Sock)) {
426 Status = EFI_NO_MAPPING;
427 goto OnExit;
428 }
429
430 if (SOCK_IS_UNCONFIGURED (Sock)) {
431 Status = EFI_NOT_STARTED;
432 goto OnExit;
433 }
434
435 if (!SOCK_IS_CLOSED (Sock) || !SOCK_IS_CONFIGURED_ACTIVE (Sock)) {
436 Status = EFI_ACCESS_DENIED;
437 goto OnExit;
438 }
439
440 Event = ((SOCK_COMPLETION_TOKEN *)Token)->Event;
441
442 if (SockTokenExisted (Sock, Event)) {
443 Status = EFI_ACCESS_DENIED;
444 goto OnExit;
445 }
446
447 Sock->ConnectionToken = (SOCK_COMPLETION_TOKEN *)Token;
448 SockSetState (Sock, SO_CONNECTING);
449 Status = Sock->ProtoHandler (Sock, SOCK_CONNECT, NULL);
450
451OnExit:
452 EfiReleaseLock (&(Sock->Lock));
453 return Status;
454}
455
477 IN SOCKET *Sock,
478 IN VOID *Token
479 )
480{
481 EFI_TCP4_LISTEN_TOKEN *ListenToken;
482 LIST_ENTRY *ListEntry;
483 EFI_STATUS Status;
484 SOCKET *Socket;
485 EFI_EVENT Event;
486
487 ASSERT (SockStream == Sock->Type);
488
489 Status = EfiAcquireLockOrFail (&(Sock->Lock));
490 if (EFI_ERROR (Status)) {
491 DEBUG (
492 (DEBUG_ERROR,
493 "SockAccept: Get the access for socket failed with %r",
494 Status)
495 );
496
497 return EFI_ACCESS_DENIED;
498 }
499
500 if (SOCK_IS_NO_MAPPING (Sock)) {
501 Status = EFI_NO_MAPPING;
502 goto Exit;
503 }
504
505 if (SOCK_IS_UNCONFIGURED (Sock)) {
506 Status = EFI_NOT_STARTED;
507 goto Exit;
508 }
509
510 if (!SOCK_IS_LISTENING (Sock)) {
511 Status = EFI_ACCESS_DENIED;
512 goto Exit;
513 }
514
515 Event = ((SOCK_COMPLETION_TOKEN *)Token)->Event;
516
517 if (SockTokenExisted (Sock, Event)) {
518 Status = EFI_ACCESS_DENIED;
519 goto Exit;
520 }
521
522 ListenToken = (EFI_TCP4_LISTEN_TOKEN *)Token;
523
524 //
525 // Check if a connection has already in this Sock->ConnectionList
526 //
527 NET_LIST_FOR_EACH (ListEntry, &Sock->ConnectionList) {
528 Socket = NET_LIST_USER_STRUCT (ListEntry, SOCKET, ConnectionList);
529
530 if (SOCK_IS_CONNECTED (Socket)) {
531 ListenToken->NewChildHandle = Socket->SockHandle;
532 SIGNAL_TOKEN (&(ListenToken->CompletionToken), EFI_SUCCESS);
533
534 RemoveEntryList (ListEntry);
535
536 ASSERT (Socket->Parent != NULL);
537
538 Socket->Parent->ConnCnt--;
539
540 DEBUG (
541 (DEBUG_NET,
542 "SockAccept: Accept a socket, now conncount is %d",
543 Socket->Parent->ConnCnt)
544 );
545 Socket->Parent = NULL;
546
547 goto Exit;
548 }
549 }
550
551 //
552 // Buffer this token for latter incoming connection request
553 //
554 if (NULL == SockBufferToken (Sock, &(Sock->ListenTokenList), Token, 0)) {
555 Status = EFI_OUT_OF_RESOURCES;
556 }
557
558Exit:
559 EfiReleaseLock (&(Sock->Lock));
560
561 return Status;
562}
563
584 IN SOCKET *Sock,
585 IN VOID *Token
586 )
587{
588 SOCK_IO_TOKEN *SndToken;
589 EFI_EVENT Event;
590 UINT32 FreeSpace;
592 EFI_STATUS Status;
593 SOCK_TOKEN *SockToken;
594 UINT32 DataLen;
595
596 ASSERT (SockStream == Sock->Type);
597
598 Status = EfiAcquireLockOrFail (&(Sock->Lock));
599 if (EFI_ERROR (Status)) {
600 DEBUG (
601 (DEBUG_ERROR,
602 "SockSend: Get the access for socket failed with %r",
603 Status)
604 );
605
606 return EFI_ACCESS_DENIED;
607 }
608
609 if (SOCK_IS_NO_MAPPING (Sock)) {
610 Status = EFI_NO_MAPPING;
611 goto Exit;
612 }
613
614 SndToken = (SOCK_IO_TOKEN *)Token;
615 TxData = (EFI_TCP4_TRANSMIT_DATA *)SndToken->Packet.TxData;
616
617 if (SOCK_IS_UNCONFIGURED (Sock)) {
618 Status = EFI_NOT_STARTED;
619 goto Exit;
620 }
621
622 if (!(SOCK_IS_CONNECTING (Sock) || SOCK_IS_CONNECTED (Sock))) {
623 Status = EFI_ACCESS_DENIED;
624 goto Exit;
625 }
626
627 //
628 // check if a token is already in the token buffer
629 //
630 Event = SndToken->Token.Event;
631
632 if (SockTokenExisted (Sock, Event)) {
633 Status = EFI_ACCESS_DENIED;
634 goto Exit;
635 }
636
637 DataLen = TxData->DataLength;
638
639 //
640 // process this sending token now or buffer it only?
641 //
642 FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF);
643
644 if ((FreeSpace < Sock->SndBuffer.LowWater) || !SOCK_IS_CONNECTED (Sock)) {
645 SockToken = SockBufferToken (
646 Sock,
647 &Sock->SndTokenList,
648 SndToken,
649 DataLen
650 );
651
652 if (NULL == SockToken) {
653 Status = EFI_OUT_OF_RESOURCES;
654 }
655 } else {
656 SockToken = SockBufferToken (
657 Sock,
658 &Sock->ProcessingSndTokenList,
659 SndToken,
660 DataLen
661 );
662
663 if (NULL == SockToken) {
664 DEBUG ((DEBUG_ERROR, "SockSend: Failed to buffer IO token into socket processing SndToken List\n"));
665
666 Status = EFI_OUT_OF_RESOURCES;
667 goto Exit;
668 }
669
670 Status = SockProcessTcpSndData (Sock, TxData);
671
672 if (EFI_ERROR (Status)) {
673 DEBUG ((DEBUG_ERROR, "SockSend: Failed to process Snd Data\n"));
674
675 RemoveEntryList (&(SockToken->TokenList));
676 FreePool (SockToken);
677 }
678 }
679
680Exit:
681 EfiReleaseLock (&(Sock->Lock));
682 return Status;
683}
684
706 IN SOCKET *Sock,
707 IN VOID *Token
708 )
709{
710 SOCK_IO_TOKEN *RcvToken;
711 UINT32 RcvdBytes;
712 EFI_STATUS Status;
713 EFI_EVENT Event;
714
715 ASSERT (SockStream == Sock->Type);
716
717 Status = EfiAcquireLockOrFail (&(Sock->Lock));
718 if (EFI_ERROR (Status)) {
719 DEBUG (
720 (DEBUG_ERROR,
721 "SockRcv: Get the access for socket failed with %r",
722 Status)
723 );
724
725 return EFI_ACCESS_DENIED;
726 }
727
728 if (SOCK_IS_NO_MAPPING (Sock)) {
729 Status = EFI_NO_MAPPING;
730 goto Exit;
731 }
732
733 if (SOCK_IS_UNCONFIGURED (Sock)) {
734 Status = EFI_NOT_STARTED;
735 goto Exit;
736 }
737
738 if (!(SOCK_IS_CONNECTED (Sock) || SOCK_IS_CONNECTING (Sock))) {
739 Status = EFI_ACCESS_DENIED;
740 goto Exit;
741 }
742
743 RcvToken = (SOCK_IO_TOKEN *)Token;
744
745 //
746 // check if a token is already in the token buffer of this socket
747 //
748 Event = RcvToken->Token.Event;
749 if (SockTokenExisted (Sock, Event)) {
750 Status = EFI_ACCESS_DENIED;
751 goto Exit;
752 }
753
754 RcvToken = (SOCK_IO_TOKEN *)Token;
755 RcvdBytes = GET_RCV_DATASIZE (Sock);
756
757 //
758 // check whether an error has happened before
759 //
760 if (EFI_ABORTED != Sock->SockError) {
761 SIGNAL_TOKEN (&(RcvToken->Token), Sock->SockError);
762 Sock->SockError = EFI_ABORTED;
763 goto Exit;
764 }
765
766 //
767 // check whether can not receive and there is no any
768 // data buffered in Sock->RcvBuffer
769 //
770 if (SOCK_IS_NO_MORE_DATA (Sock) && (0 == RcvdBytes)) {
771 Status = EFI_CONNECTION_FIN;
772 goto Exit;
773 }
774
775 if (RcvdBytes != 0) {
776 SockProcessRcvToken (Sock, RcvToken);
777
778 Status = Sock->ProtoHandler (Sock, SOCK_CONSUMED, NULL);
779 } else {
780 if (NULL == SockBufferToken (Sock, &Sock->RcvTokenList, RcvToken, 0)) {
781 Status = EFI_OUT_OF_RESOURCES;
782 }
783 }
784
785Exit:
786 EfiReleaseLock (&(Sock->Lock));
787 return Status;
788}
789
801 IN OUT SOCKET *Sock
802 )
803{
804 EFI_STATUS Status;
805
806 ASSERT (SockStream == Sock->Type);
807
808 Status = EfiAcquireLockOrFail (&(Sock->Lock));
809 if (EFI_ERROR (Status)) {
810 DEBUG (
811 (DEBUG_ERROR,
812 "SockFlush: Get the access for socket failed with %r",
813 Status)
814 );
815
816 return EFI_ACCESS_DENIED;
817 }
818
819 if (!SOCK_IS_CONFIGURED (Sock)) {
820 Status = EFI_ACCESS_DENIED;
821 goto Exit;
822 }
823
824 Status = Sock->ProtoHandler (Sock, SOCK_FLUSH, NULL);
825 if (EFI_ERROR (Status)) {
826 DEBUG (
827 (DEBUG_ERROR,
828 "SockFlush: Protocol failed handling SOCK_FLUSH with %r",
829 Status)
830 );
831
832 goto Exit;
833 }
834
835 SOCK_ERROR (Sock, EFI_ABORTED);
836 SockConnFlush (Sock);
837 SockSetState (Sock, SO_CLOSED);
838
839 Sock->ConfigureState = SO_UNCONFIGURED;
840
841Exit:
842 EfiReleaseLock (&(Sock->Lock));
843 return Status;
844}
845
867 IN OUT SOCKET *Sock,
868 IN VOID *Token,
869 IN BOOLEAN OnAbort
870 )
871{
872 EFI_STATUS Status;
873 EFI_EVENT Event;
874
875 ASSERT (SockStream == Sock->Type);
876
877 Status = EfiAcquireLockOrFail (&(Sock->Lock));
878 if (EFI_ERROR (Status)) {
879 DEBUG (
880 (DEBUG_ERROR,
881 "SockClose: Get the access for socket failed with %r",
882 Status)
883 );
884
885 return EFI_ACCESS_DENIED;
886 }
887
888 if (SOCK_IS_NO_MAPPING (Sock)) {
889 Status = EFI_NO_MAPPING;
890 goto Exit;
891 }
892
893 if (SOCK_IS_UNCONFIGURED (Sock)) {
894 Status = EFI_NOT_STARTED;
895 goto Exit;
896 }
897
898 if (SOCK_IS_DISCONNECTING (Sock)) {
899 Status = EFI_ACCESS_DENIED;
900 goto Exit;
901 }
902
903 Event = ((SOCK_COMPLETION_TOKEN *)Token)->Event;
904
905 if (SockTokenExisted (Sock, Event)) {
906 Status = EFI_ACCESS_DENIED;
907 goto Exit;
908 }
909
910 Sock->CloseToken = Token;
911 SockSetState (Sock, SO_DISCONNECTING);
912
913 if (OnAbort) {
914 Status = Sock->ProtoHandler (Sock, SOCK_ABORT, NULL);
915 } else {
916 Status = Sock->ProtoHandler (Sock, SOCK_CLOSE, NULL);
917 }
918
919Exit:
920 EfiReleaseLock (&(Sock->Lock));
921 return Status;
922}
923
938 IN OUT SOCKET *Sock,
939 IN VOID *Token
940 )
941{
942 EFI_STATUS Status;
943
944 Status = EFI_SUCCESS;
945
946 ASSERT (SockStream == Sock->Type);
947
948 Status = EfiAcquireLockOrFail (&(Sock->Lock));
949 if (EFI_ERROR (Status)) {
950 DEBUG (
951 (DEBUG_ERROR,
952 "SockCancel: Get the access for socket failed with %r",
953 Status)
954 );
955
956 return EFI_ACCESS_DENIED;
957 }
958
959 if (SOCK_IS_UNCONFIGURED (Sock)) {
960 Status = EFI_NOT_STARTED;
961 goto Exit;
962 }
963
964 //
965 // 1. Check ConnectionToken.
966 //
967 if ((Token == NULL) || ((SOCK_COMPLETION_TOKEN *)Token == Sock->ConnectionToken)) {
968 if (Sock->ConnectionToken != NULL) {
969 SIGNAL_TOKEN (Sock->ConnectionToken, EFI_ABORTED);
970 Sock->ConnectionToken = NULL;
971 }
972
973 if (Token != NULL) {
974 Status = EFI_SUCCESS;
975 goto Exit;
976 }
977 }
978
979 //
980 // 2. Check ListenTokenList.
981 //
982 Status = SockCancelToken (Token, &Sock->ListenTokenList);
983 if ((Token != NULL) && !EFI_ERROR (Status)) {
984 goto Exit;
985 }
986
987 //
988 // 3. Check RcvTokenList.
989 //
990 Status = SockCancelToken (Token, &Sock->RcvTokenList);
991 if ((Token != NULL) && !EFI_ERROR (Status)) {
992 goto Exit;
993 }
994
995 //
996 // 4. Check SndTokenList.
997 //
998 Status = SockCancelToken (Token, &Sock->SndTokenList);
999 if ((Token != NULL) && !EFI_ERROR (Status)) {
1000 goto Exit;
1001 }
1002
1003 //
1004 // 5. Check ProcessingSndTokenList.
1005 //
1006 Status = SockCancelToken (Token, &Sock->ProcessingSndTokenList);
1007
1008Exit:
1009 EfiReleaseLock (&(Sock->Lock));
1010 return Status;
1011}
1012
1026 IN SOCKET *Sock,
1027 IN OUT VOID *Mode
1028 )
1029{
1030 return Sock->ProtoHandler (Sock, SOCK_MODE, Mode);
1031}
1032
1050 IN SOCKET *Sock,
1051 IN VOID *RouteInfo
1052 )
1053{
1054 EFI_STATUS Status;
1055
1056 Status = EfiAcquireLockOrFail (&(Sock->Lock));
1057 if (EFI_ERROR (Status)) {
1058 DEBUG (
1059 (DEBUG_ERROR,
1060 "SockRoute: Get the access for socket failed with %r",
1061 Status)
1062 );
1063
1064 return EFI_ACCESS_DENIED;
1065 }
1066
1067 if (SOCK_IS_NO_MAPPING (Sock)) {
1068 Status = EFI_NO_MAPPING;
1069 goto Exit;
1070 }
1071
1072 if (SOCK_IS_UNCONFIGURED (Sock)) {
1073 Status = EFI_NOT_STARTED;
1074 goto Exit;
1075 }
1076
1077 Status = Sock->ProtoHandler (Sock, SOCK_ROUTE, RouteInfo);
1078
1079Exit:
1080 EfiReleaseLock (&(Sock->Lock));
1081 return Status;
1082}
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define SOCK_CONNECT
Need to connect to a peer.
Definition: Socket.h:89
#define SOCK_IS_DISCONNECTING(Sock)
Definition: Socket.h:215
#define SOCK_IS_CONFIGURED_ACTIVE(Sock)
Definition: Socket.h:138
#define GET_RCV_DATASIZE(Sock)
Definition: Socket.h:255
#define SOCK_CONSUMED
Application has retrieved data from socket.
Definition: Socket.h:88
#define SOCK_IS_CONNECTING(Sock)
Definition: Socket.h:193
#define SOCK_IS_CONFIGURED(Sock)
Definition: Socket.h:125
#define SOCK_ATTACH
Attach current socket to a new PCB.
Definition: Socket.h:81
#define SOCK_IS_NO_MORE_DATA(Sock)
Definition: Socket.h:226
UINT32 SockGetFreeSpace(IN SOCKET *Sock, IN UINT32 Which)
Definition: SockImpl.c:1156
#define SOCK_CONFIGURE
Configure attached PCB.
Definition: Socket.h:83
@ SockStream
This socket providing stream service.
Definition: Socket.h:350
#define SOCK_IS_UNCONFIGURED(Sock)
Definition: Socket.h:114
#define SOCK_CLOSE
Need to close the protocol process.
Definition: Socket.h:90
#define SOCK_IS_LISTENING(Sock)
Definition: Socket.h:182
#define SOCK_IS_CLOSED(Sock)
Definition: Socket.h:171
#define SOCK_MODE
Need to get the mode data of the protocol.
Definition: Socket.h:94
VOID SockSetState(IN OUT SOCKET *Sock, IN UINT8 State)
Definition: SockImpl.c:920
#define SO_CLOSED
Definition: Socket.h:64
#define SOCK_ABORT
Need to reset the protocol process.
Definition: Socket.h:91
#define SOCK_ROUTE
Need to add a route information.
Definition: Socket.h:93
#define SO_UNCONFIGURED
Definition: Socket.h:73
#define SOCK_IS_NO_MAPPING(Sock)
Definition: Socket.h:160
#define SOCK_IS_CONNECTED(Sock)
Definition: Socket.h:204
#define SOCK_DETACH
Detach current socket from the PCB.
Definition: Socket.h:82
#define SOCK_FLUSH
Flush attached PCB.
Definition: Socket.h:84
#define SOCK_ERROR(Sock, Error)
Definition: Socket.h:312
EFI_STATUS SockProcessTcpSndData(IN SOCKET *Sock, IN VOID *TcpTxData)
Definition: SockImpl.c:349
VOID SockDestroy(IN OUT SOCKET *Sock)
Definition: SockImpl.c:809
SOCKET * SockCreate(IN SOCK_INIT_DATA *SockInitData)
Definition: SockImpl.c:633
VOID SockConnFlush(IN OUT SOCKET *Sock)
Definition: SockImpl.c:857
UINT32 SockProcessRcvToken(IN OUT SOCKET *Sock, IN OUT SOCK_IO_TOKEN *RcvToken)
Definition: SockImpl.c:304
EFI_STATUS SockCancelToken(IN SOCK_COMPLETION_TOKEN *Token, IN OUT LIST_ENTRY *SpecifiedTokenList)
Definition: SockImpl.c:573
#define SIGNAL_TOKEN(Token, TokenStatus)
Definition: SockImpl.h:23
EFI_STATUS SockFlush(IN OUT SOCKET *Sock)
BOOLEAN SockTokenExisted(IN SOCKET *Sock, IN EFI_EVENT Event)
Definition: SockInterface.c:58
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)
Definition: SockInterface.c:95
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)
Definition: SockInterface.c:23
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
Definition: UefiBaseType.h:175
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
VOID EFIAPI EfiReleaseLock(IN EFI_LOCK *Lock)
Definition: UefiLib.c:499
EFI_STATUS EFIAPI EfiAcquireLockOrFail(IN EFI_LOCK *Lock)
Definition: UefiLib.c:463
EFI_EVENT Event
The event to be issued.
Definition: Socket.h:328
LIST_ENTRY TokenList
The entry to add in the token list.
Definition: Socket.h:512
SOCKET * Sock
Definition: Socket.h:515
SOCK_COMPLETION_TOKEN * Token
The application's token.
Definition: Socket.h:513
UINT32 RemainDataLen
Unprocessed data length.
Definition: Socket.h:514
IP_IO_IP_INFO * IpInfo
Pointer reference to Ip used to send pkt.
Definition: TcpProto.h:336
SOCKET * Parent
listening parent that accept the connection
Definition: Socket.h:481
EFI_LOCK Lock
The lock of socket.
Definition: Socket.h:470
EFI_HANDLE SockHandle
The virtual handle of the socket.
Definition: Socket.h:461
SOCK_DESTROY_CALLBACK DestroyCallback
Callback before destroyed.
Definition: Socket.h:504
SOCK_PROTO_HANDLER ProtoHandler
The request handler of protocol.
Definition: Socket.h:496
EFI_HANDLE DriverBinding
Socket's driver binding protocol.
Definition: Socket.h:462
UINT32 ConnCnt
the current count of connections to it
Definition: Socket.h:480
VOID * Context
The context of the callback.
Definition: Socket.h:505
Definition: Base.h:213