19typedef UINT32 IP4_ADDR;
20typedef UINT32 TCP_SEQNO;
21typedef UINT16 TCP_PORTNO;
23#define NET_ETHER_ADDR_LEN 6
24#define NET_IFTYPE_ETHERNET 0x01
26#define NET_VLAN_TAG_LEN 4
27#define ETHER_TYPE_VLAN 0x8100
29#define EFI_IP_PROTO_UDP 0x11
30#define EFI_IP_PROTO_TCP 0x06
31#define EFI_IP_PROTO_ICMP 0x01
32#define IP4_PROTO_IGMP 0x02
34#define DNS_MAX_NAME_SIZE 255
35#define DNS_MAX_MESSAGE_SIZE 512
40#define IP4_ADDR_CLASSA 1
41#define IP4_ADDR_CLASSB 2
42#define IP4_ADDR_CLASSC 3
43#define IP4_ADDR_CLASSD 4
44#define IP4_ADDR_CLASSE 5
46#define IP4_MASK_NUM 33
47#define IP6_PREFIX_NUM 129
49#define IP4_MASK_MAX 32
50#define IP6_PREFIX_MAX 128
52#define IP6_HOP_BY_HOP 0
53#define IP6_DESTINATION 60
55#define IP6_FRAGMENT 44
58#define IP6_NO_NEXT_HEADER 59
63#define IP6_PREFIX_LENGTH 64
70#define DNS_TYPE_CNAME 5
72#define DNS_TYPE_WKS 11
73#define DNS_TYPE_PTR 12
74#define DNS_TYPE_HINFO 13
75#define DNS_TYPE_MINFO 14
77#define DNS_TYPE_TXT 16
78#define DNS_TYPE_AAAA 28
79#define DNS_TYPE_SRV_RR 33
80#define DNS_TYPE_AXFR 252
81#define DNS_TYPE_MAILB 253
82#define DNS_TYPE_ANY 255
87#define DNS_CLASS_INET 1
90#define DNS_CLASS_ANY 255
95#define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U
103 UINT8 DstMac[NET_ETHER_ADDR_LEN];
104 UINT8 SrcMac[NET_ETHER_ADDR_LEN];
120#define VLAN_TCI_CFI_CANONICAL_MAC 0
121#define VLAN_TCI_CFI_NON_CANONICAL_MAC 1
210#define NET_MAC_EQUAL(pMac1, pMac2, Len) \
211 (CompareMem ((pMac1), (pMac2), Len) == 0)
213#define NET_MAC_IS_MULTICAST(Mac, BMac, Len) \
214 (((*((UINT8 *) Mac) & 0x01) == 0x01) && (!NET_MAC_EQUAL (Mac, BMac, Len)))
216#define NTOHL(x) SwapBytes32 (x)
218#define HTONL(x) NTOHL(x)
220#define NTOHS(x) SwapBytes16 (x)
222#define HTONS(x) NTOHS(x)
223#define NTOHLL(x) SwapBytes64 (x)
224#define HTONLL(x) NTOHLL(x)
225#define NTOHLLL(x) Ip6Swap128 (x)
226#define HTONLLL(x) NTOHLLL(x)
231#define IP4_IS_MULTICAST(Ip) (((Ip) & 0xF0000000) == 0xE0000000)
232#define IP4_IS_UNSPECIFIED(Ip) ((Ip) == 0)
233#define IP4_IS_LOCAL_BROADCAST(Ip) ((Ip) == 0xFFFFFFFF)
234#define IP4_NET_EQUAL(Ip1, Ip2, NetMask) (((Ip1) & (NetMask)) == ((Ip2) & (NetMask)))
235#define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) != (IP4_MASK_MAX + 1))
237#define IP6_IS_MULTICAST(Ip6) (((Ip6)->Addr[0]) == 0xFF)
242#define EFI_IP4(EfiIpAddr) (*(IP4_ADDR *) ((EfiIpAddr).Addr))
243#define EFI_NTOHL(EfiIp) (NTOHL (EFI_IP4 ((EfiIp))))
244#define EFI_IP4_EQUAL(Ip1, Ip2) (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv4_ADDRESS)) == 0)
246#define EFI_IP6_EQUAL(Ip1, Ip2) (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv6_ADDRESS)) == 0)
248#define IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS)))
249#define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS)))
250#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)))
256#define NETDEBUG_LEVEL_TRACE 5
257#define NETDEBUG_LEVEL_WARNING 4
258#define NETDEBUG_LEVEL_ERROR 3
263#define NET_SYSLOG_FACILITY 16
264#define NET_SYSLOG_PACKET_LEN 512
265#define NET_SYSLOG_TX_TIMEOUT (500 * 1000 * 10)
266#define NET_DEBUG_MSG_LEN 470
273#define NET_DEBUG_TRACE(Module, PrintArg) \
275 NETDEBUG_LEVEL_TRACE, \
279 NetDebugASPrint PrintArg \
282#define NET_DEBUG_WARNING(Module, PrintArg) \
284 NETDEBUG_LEVEL_WARNING, \
288 NetDebugASPrint PrintArg \
291#define NET_DEBUG_ERROR(Module, PrintArg) \
293 NETDEBUG_LEVEL_ERROR, \
297 NetDebugASPrint PrintArg \
530extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM];
534#define NET_IS_DIGIT(Ch) (('0' <= (Ch)) && ((Ch) <= '9'))
535#define NET_IS_HEX(Ch) ((('0' <= (Ch)) && ((Ch) <= '9')) || (('A' <= (Ch)) && ((Ch) <= 'F')) || (('a' <= (Ch)) && ((Ch) <= 'f')))
536#define NET_ROUNDUP(size, unit) (((size) + (unit) - 1) & (~((unit) - 1)))
537#define NET_IS_LOWER_CASE_CHAR(Ch) (('a' <= (Ch)) && ((Ch) <= 'z'))
538#define NET_IS_UPPER_CASE_CHAR(Ch) (('A' <= (Ch)) && ((Ch) <= 'Z'))
540#define TICKS_PER_MS 10000U
541#define TICKS_PER_SECOND 10000000U
618#define NET_LIST_USER_STRUCT(Entry, Type, Field) \
619 BASE_CR(Entry, Type, Field)
621#define NET_LIST_USER_STRUCT_S(Entry, Type, Field, Sig) \
622 CR(Entry, Type, Field, Sig)
627#define NET_LIST_FOR_EACH(Entry, ListHead) \
628 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
636#define NET_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
637 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink; \
638 Entry != (ListHead); \
639 Entry = NextEntry, NextEntry = Entry->ForwardLink \
645#define NET_LIST_HEAD(ListHead, Type, Field) \
646 NET_LIST_USER_STRUCT((ListHead)->ForwardLink, Type, Field)
648#define NET_LIST_TAIL(ListHead, Type, Field) \
649 NET_LIST_USER_STRUCT((ListHead)->BackLink, Type, Field)
781 IN VOID *Context OPTIONAL,
821#define NET_MAP_INCREAMENT 64
918 IN VOID *Value OPTIONAL
944 IN VOID *Value OPTIONAL
993 OUT VOID **Value OPTIONAL
1017 OUT VOID **Value OPTIONAL
1041 OUT VOID **Value OPTIONAL
1046(EFIAPI *NET_MAP_CALLBACK)(
1075 IN NET_MAP_CALLBACK CallBack,
1076 IN VOID *Arg OPTIONAL
1253 OUT CHAR16 **MacString
1290 OUT BOOLEAN *MediaPresent
1350 IN IP4_ADDR LocalIp,
1351 IN UINT16 LocalPort,
1352 IN IP4_ADDR RemoteIp,
1353 IN UINT16 RemotePort,
1355 IN BOOLEAN UseDefaultAddress
1385 IN UINT16 LocalPort,
1387 IN UINT16 RemotePort,
1523 OUT UINT8 *PrefixLength
1551#define NET_BUF_SIGNATURE SIGNATURE_32 ('n', 'b', 'u', 'f')
1552#define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c')
1553#define NET_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u')
1555#define NET_PROTO_DATA 64
1556#define NET_BUF_HEAD 1
1557#define NET_BUF_TAIL 0
1558#define NET_VECTOR_OWN_FIRST 0x01
1560#define NET_CHECK_SIGNATURE(PData, SIGNATURE) \
1561 ASSERT (((PData) != NULL) && ((PData)->Signature == (SIGNATURE)))
1571typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE)(VOID *Arg);
1581 NET_VECTOR_EXT_FREE Free;
1625 UINT8 ProtoData[NET_PROTO_DATA];
1664 UINT32 Reserved : 24;
1665 UINT32 NextHeader : 8;
1679#define NET_GET_REF(PData) ((PData)->RefCnt++)
1680#define NET_PUT_REF(PData) ((PData)->RefCnt--)
1681#define NETBUF_FROM_PROTODATA(Info) BASE_CR((Info), NET_BUF, ProtoData)
1683#define NET_BUF_SHARED(Buf) \
1684 (((Buf)->RefCnt > 1) || ((Buf)->Vector->RefCnt > 1))
1686#define NET_VECTOR_SIZE(BlockNum) \
1687 (sizeof (NET_VECTOR) + ((BlockNum) - 1) * sizeof (NET_BLOCK))
1689#define NET_BUF_SIZE(BlockOpNum) \
1690 (sizeof (NET_BUF) + ((BlockOpNum) - 1) * sizeof (NET_BLOCK_OP))
1692#define NET_HEADSPACE(BlockOp) \
1693 ((UINTN)((BlockOp)->Head) - (UINTN)((BlockOp)->BlockHead))
1695#define NET_TAILSPACE(BlockOp) \
1696 ((UINTN)((BlockOp)->BlockTail) - (UINTN)((BlockOp)->Tail))
1754 OUT UINT32 *Index OPTIONAL
1935 IN UINT32 HeadSpace,
1937 IN NET_VECTOR_EXT_FREE ExtFree,
1938 IN VOID *Arg OPTIONAL
1959 IN OUT UINT32 *ExtNum
1983 IN UINT32 HeadSpace,
1984 IN UINT32 HeaderLen,
1985 IN NET_VECTOR_EXT_FREE ExtFree,
1986 IN VOID *Arg OPTIONAL
2156 IN UINT16 Checksum1,
2214 IN UINT8 NextHeader,
2271 IN CHAR16 *DomainName
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
VOID EFIAPI NetbufQueInit(IN OUT NET_BUF_QUEUE *NbufQue)
VOID *EFIAPI NetMapRemoveTail(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
VOID EFIAPI NetbufReserve(IN OUT NET_BUF *Nbuf, IN UINT32 Len)
LIST_ENTRY *EFIAPI NetListRemoveHead(IN OUT LIST_ENTRY *Head)
UINT16 EFIAPI NetIp6PseudoHeadChecksum(IN EFI_IPv6_ADDRESS *Src, IN EFI_IPv6_ADDRESS *Dst, IN UINT8 NextHeader, IN UINT32 Len)
LIST_ENTRY *EFIAPI NetListRemoveTail(IN OUT LIST_ENTRY *Head)
NET_BUF *EFIAPI NetbufClone(IN NET_BUF *Nbuf)
UINT32 EFIAPI NetbufTrim(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
UINT16 EFIAPI NetbufChecksum(IN NET_BUF *Nbuf)
EFI_STATUS EFIAPI NetLibGetMacAddress(IN EFI_HANDLE ServiceHandle, OUT EFI_MAC_ADDRESS *MacAddress, OUT UINTN *AddressSize)
EFI_STATUS EFIAPI NetbufBuildExt(IN NET_BUF *Nbuf, IN OUT NET_FRAGMENT *ExtFragment, IN OUT UINT32 *ExtNum)
UINT32 EFIAPI NetbufQueTrim(IN OUT NET_BUF_QUEUE *NbufQue, IN UINT32 Len)
EFI_STATUS EFIAPI NetLibGetMacString(IN EFI_HANDLE ServiceHandle, IN EFI_HANDLE ImageHandle OPTIONAL, OUT CHAR16 **MacString)
UINT16 EFIAPI NetblockChecksum(IN UINT8 *Bulk, IN UINT32 Len)
UINT32 EFIAPI NetbufQueCopy(IN NET_BUF_QUEUE *NbufQue, IN UINT32 Offset, IN UINT32 Len, OUT UINT8 *Dest)
BOOLEAN EFIAPI NetIp4IsUnicast(IN IP4_ADDR Ip, IN IP4_ADDR NetMask)
BOOLEAN EFIAPI NetIp6IsValidUnicast(IN EFI_IPv6_ADDRESS *Ip6)
VOID EFIAPI NetMapClean(IN OUT NET_MAP *Map)
VOID EFIAPI NetbufQueFlush(IN OUT NET_BUF_QUEUE *NbufQue)
EFI_HANDLE EFIAPI NetLibGetVlanHandle(IN EFI_HANDLE ControllerHandle, IN UINT16 VlanId)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
VOID EFIAPI NetLibCreateIPv6DPathNode(IN OUT IPv6_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN EFI_IPv6_ADDRESS *LocalIp, IN UINT16 LocalPort, IN EFI_IPv6_ADDRESS *RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol)
EFI_STATUS EFIAPI NetLibAsciiStrToIp4(IN CONST CHAR8 *String, OUT EFI_IPv4_ADDRESS *Ip4Address)
CHAR8 *EFIAPI NetLibCreateDnsQName(IN CHAR16 *DomainName)
BOOLEAN EFIAPI NetIp6IsNetEqual(EFI_IPv6_ADDRESS *Ip1, EFI_IPv6_ADDRESS *Ip2, UINT8 PrefixLength)
NET_MAP_ITEM *EFIAPI NetMapFindKey(IN NET_MAP *Map, IN VOID *Key)
EFI_STATUS EFIAPI NetMapInsertHead(IN OUT NET_MAP *Map, IN VOID *Key, IN VOID *Value OPTIONAL)
BOOLEAN EFIAPI NetIp6IsLinkLocalAddr(IN EFI_IPv6_ADDRESS *Ip6)
EFI_IPv6_ADDRESS *EFIAPI Ip6Swap128(EFI_IPv6_ADDRESS *Ip6)
UINT16 EFIAPI NetAddChecksum(IN UINT16 Checksum1, IN UINT16 Checksum2)
NET_BUF_QUEUE *EFIAPI NetbufQueAlloc(VOID)
VOID EFIAPI NetListInsertAfter(IN OUT LIST_ENTRY *PrevEntry, IN OUT LIST_ENTRY *NewEntry)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
NET_BUF *EFIAPI NetbufAlloc(IN UINT32 Len)
VOID EFIAPI NetMapInit(IN OUT NET_MAP *Map)
NET_BUF *EFIAPI NetbufGetFragment(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT32 HeadSpace)
NET_BUF *EFIAPI NetbufFromExt(IN NET_FRAGMENT *ExtFragment, IN UINT32 ExtNum, IN UINT32 HeadSpace, IN UINT32 HeadLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
EFI_STATUS EFIAPI NetLibDetectMedia(IN EFI_HANDLE ServiceHandle, OUT BOOLEAN *MediaPresent)
UINT32 EFIAPI NetGetUint32(IN UINT8 *Buf)
CHAR8 *EFIAPI NetDebugASPrint(IN CHAR8 *Format,...)
VOID EFIAPI NetLibCreateIPv4DPathNode(IN OUT IPv4_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN IP4_ADDR LocalIp, IN UINT16 LocalPort, IN IP4_ADDR RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol, IN BOOLEAN UseDefaultAddress)
EFI_STATUS EFIAPI NetLibDefaultUnload(IN EFI_HANDLE ImageHandle)
NET_BUF *EFIAPI NetbufFromBufList(IN LIST_ENTRY *BufList, IN UINT32 HeadSpace, IN UINT32 HeaderLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
BOOLEAN EFIAPI NetIsInHandleBuffer(IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
VOID EFIAPI NetPutUint32(IN OUT UINT8 *Buf, IN UINT32 Data)
EFI_STATUS EFIAPI NetLibDetectMediaWaitTimeout(IN EFI_HANDLE ServiceHandle, IN UINT64 Timeout, OUT EFI_STATUS *MediaState)
EFI_STATUS EFIAPI NetLibGetSystemGuid(OUT EFI_GUID *SystemGuid)
EFI_STATUS EFIAPI NetLibStrToIp4(IN CONST CHAR16 *String, OUT EFI_IPv4_ADDRESS *Ip4Address)
VOID NetIpSecNetbufFree(NET_BUF *Nbuf)
INTN EFIAPI NetGetIpClass(IN IP4_ADDR Addr)
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
EFI_HANDLE EFIAPI NetLibGetSnpHandle(IN EFI_HANDLE ServiceHandle, OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL)
NET_BUF *EFIAPI NetbufDuplicate(IN NET_BUF *Nbuf, IN OUT NET_BUF *Duplicate OPTIONAL, IN UINT32 HeadSpace)
EFI_STATUS EFIAPI NetLibStrToIp6andPrefix(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address, OUT UINT8 *PrefixLength)
VOID EFIAPI NetbufFreeList(IN OUT LIST_ENTRY *Head)
BOOLEAN EFIAPI NetMapIsEmpty(IN NET_MAP *Map)
EFI_STATUS EFIAPI NetLibAsciiStrToIp6(IN CONST CHAR8 *String, OUT EFI_IPv6_ADDRESS *Ip6Address)
INTN EFIAPI NetGetMaskLength(IN IP4_ADDR NetMask)
VOID EFIAPI NetbufQueFree(IN NET_BUF_QUEUE *NbufQue)
EFI_STATUS EFIAPI NetLibStrToIp6(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address)
EFI_STATUS EFIAPI PseudoRandomU32(OUT UINT32 *Output)
UINT16 EFIAPI NetPseudoHeadChecksum(IN IP4_ADDR Src, IN IP4_ADDR Dst, IN UINT8 Proto, IN UINT16 Len)
UINT8 *EFIAPI NetbufGetByte(IN NET_BUF *Nbuf, IN UINT32 Offset, OUT UINT32 *Index OPTIONAL)
EFI_STATUS EFIAPI NetLibIp6ToStr(IN EFI_IPv6_ADDRESS *Ip6Address, OUT CHAR16 *String, IN UINTN StringSize)
VOID *EFIAPI NetMapRemoveItem(IN OUT NET_MAP *Map, IN OUT NET_MAP_ITEM *Item, OUT VOID **Value OPTIONAL)
VOID *EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
EFI_HANDLE EFIAPI NetLibGetNicHandle(IN EFI_HANDLE Controller, IN EFI_GUID *ProtocolGuid)
EFI_STATUS EFIAPI NetMapInsertTail(IN OUT NET_MAP *Map, IN VOID *Key, IN VOID *Value OPTIONAL)
EFI_STATUS EFIAPI NetDestroyLinkList(IN LIST_ENTRY *List, IN NET_DESTROY_LINK_LIST_CALLBACK CallBack, IN VOID *Context OPTIONAL, OUT UINTN *ListLength OPTIONAL)
VOID EFIAPI NetbufQueAppend(IN OUT NET_BUF_QUEUE *NbufQue, IN OUT NET_BUF *Nbuf)
EFI_STATUS(EFIAPI * NET_DESTROY_LINK_LIST_CALLBACK)(IN LIST_ENTRY *Entry, IN VOID *Context OPTIONAL)
EFI_STATUS EFIAPI NetMapIterate(IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, IN VOID *Arg OPTIONAL)
VOID EFIAPI NetListInsertBefore(IN OUT LIST_ENTRY *PostEntry, IN OUT LIST_ENTRY *NewEntry)
EFI_STATUS EFIAPI PseudoRandom(OUT VOID *Output, IN UINTN OutputLength)
UINT16 EFIAPI NetLibGetVlanId(IN EFI_HANDLE ServiceHandle)
NET_BUF *EFIAPI NetbufQueRemove(IN OUT NET_BUF_QUEUE *NbufQue)
EFI_STATUS EFIAPI NetDebugOutput(IN UINT32 Level, IN UINT8 *Module, IN UINT8 *File, IN UINT32 Line, IN UINT8 *Message)
UINTN EFIAPI NetMapGetCount(IN NET_MAP *Map)