VirtualBox

Ignore:
Timestamp:
Mar 12, 2019 12:40:12 PM (6 years ago)
Author:
vboxsync
Message:

EFI: First step in UDK2018 merge. Does not build yet.

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Include/Library/NetLib.h

    r58466 r77662  
    33  It provides basic functions for the UEFI network stack.
    44
    5 Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
     5Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
    66This program and the accompanying materials
    77are licensed and made available under the terms and conditions of the BSD License
     
    3838#define  IP4_PROTO_IGMP        0x02
    3939#define  IP6_ICMP              58
     40#define  DNS_MAX_NAME_SIZE     255
     41#define  DNS_MAX_MESSAGE_SIZE  512
    4042
    4143//
    4244// The address classification
    4345//
    44 #define  IP4_ADDR_CLASSA       1
    45 #define  IP4_ADDR_CLASSB       2
    46 #define  IP4_ADDR_CLASSC       3
     46#define  IP4_ADDR_CLASSA       1     // Deprecated
     47#define  IP4_ADDR_CLASSB       2     // Deprecated
     48#define  IP4_ADDR_CLASSC       3     // Deprecated
    4749#define  IP4_ADDR_CLASSD       4
    4850#define  IP4_ADDR_CLASSE       5
     
    5052#define  IP4_MASK_NUM          33
    5153#define  IP6_PREFIX_NUM        129
     54
     55#define  IP4_MASK_MAX          32
     56#define  IP6_PREFIX_MAX        128
    5257
    5358#define  IP6_HOP_BY_HOP        0
     
    6368
    6469#define  IP6_PREFIX_LENGTH     64
     70
     71//
     72// DNS QTYPE values
     73//
     74#define  DNS_TYPE_A            1
     75#define  DNS_TYPE_NS           2
     76#define  DNS_TYPE_CNAME        5
     77#define  DNS_TYPE_SOA          6
     78#define  DNS_TYPE_WKS          11
     79#define  DNS_TYPE_PTR          12
     80#define  DNS_TYPE_HINFO        13
     81#define  DNS_TYPE_MINFO        14
     82#define  DNS_TYPE_MX           15
     83#define  DNS_TYPE_TXT          16
     84#define  DNS_TYPE_AAAA         28
     85#define  DNS_TYPE_SRV_RR       33
     86#define  DNS_TYPE_AXFR         252
     87#define  DNS_TYPE_MAILB        253
     88#define  DNS_TYPE_ANY          255
     89
     90//
     91// DNS QCLASS values
     92//
     93#define  DNS_CLASS_INET        1
     94#define  DNS_CLASS_CH          3
     95#define  DNS_CLASS_HS          4
     96#define  DNS_CLASS_ANY         255
     97
     98//
     99// Number of 100ns units time Interval for network media state detect
     100//
     101#define MEDIA_STATE_DETECT_TIME_INTERVAL  1000000U
     102
    65103
    66104#pragma pack(1)
     
    200238//
    201239#define IP4_IS_MULTICAST(Ip)              (((Ip) & 0xF0000000) == 0xE0000000)
     240#define IP4_IS_UNSPECIFIED(Ip)            ((Ip) == 0)
    202241#define IP4_IS_LOCAL_BROADCAST(Ip)        ((Ip) == 0xFFFFFFFF)
    203242#define IP4_NET_EQUAL(Ip1, Ip2, NetMask)  (((Ip1) & (NetMask)) == ((Ip2) & (NetMask)))
    204 #define IP4_IS_VALID_NETMASK(Ip)          (NetGetMaskLength (Ip) != IP4_MASK_NUM)
     243#define IP4_IS_VALID_NETMASK(Ip)          (NetGetMaskLength (Ip) != (IP4_MASK_MAX + 1))
    205244
    206245#define IP6_IS_MULTICAST(Ip6)             (((Ip6)->Addr[0]) == 0xFF)
     
    221260//
    222261// The debug level definition. This value is also used as the
    223 // syslog's servity level. Don't change it.
     262// syslog's severity level. Don't change it.
    224263//
    225264#define NETDEBUG_LEVEL_TRACE   5
     
    304343  Because it isn't open the SNP BY_DRIVER, apply caution when using it.
    305344
    306   @param Level    The servity level of the message.
    307   @param Module   The Moudle that generates the log.
     345  @param Level    The severity level of the message.
     346  @param Module   The Module that generates the log.
    308347  @param File     The file that contains the log.
    309348  @param Line     The exact line that contains the log.
     
    347386  Return the class of the IP address, such as class A, B, C.
    348387  Addr is in host byte order.
     388
     389  [ATTENTION]
     390  Classful addressing (IP class A/B/C) has been deprecated according to RFC4632.
     391  Caller of this function could only check the returned value against
     392  IP4_ADDR_CLASSD (multicast) or IP4_ADDR_CLASSE (reserved) now.
    349393
    350394  The address of class A  starts with 0.
     
    373417/**
    374418  Check whether the IP is a valid unicast address according to
    375   the netmask. If NetMask is zero, use the IP address's class to get the default mask.
    376 
    377   If Ip is 0, IP is not a valid unicast address.
    378   Class D address is used for multicasting and class E address is reserved for future. If Ip
    379   belongs to class D or class E, Ip is not a valid unicast address.
    380   If all bits of the host address of Ip are 0 or 1, Ip is not a valid unicast address.
     419  the netmask.
     420
     421  ASSERT if NetMask is zero.
     422
     423  If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address,
     424  except when the originator is one of the endpoints of a point-to-point link with a 31-bit
     425  mask (RFC3021).
    381426
    382427  @param[in]  Ip                    The IP to check against.
    383428  @param[in]  NetMask               The mask of the IP.
    384429
    385   @return TRUE if Ip is a valid unicast address on the network, otherwise FALSE.
     430  @return TRUE if IP is a valid unicast address on the network, otherwise FALSE.
    386431
    387432**/
     
    395440/**
    396441  Check whether the incoming IPv6 address is a valid unicast address.
     442
     443  ASSERT if Ip6 is NULL.
    397444
    398445  If the address is a multicast address has binary 0xFF at the start, it is not
     
    417464  Check whether the incoming Ipv6 address is the unspecified address or not.
    418465
     466  ASSERT if Ip6 is NULL.
     467
    419468  @param[in] Ip6   - Ip6 address, in network order.
    420469
     
    432481  Check whether the incoming Ipv6 address is a link-local address.
    433482
     483  ASSERT if Ip6 is NULL.
     484
    434485  @param[in] Ip6   - Ip6 address, in network order.
    435486
     
    446497/**
    447498  Check whether the Ipv6 address1 and address2 are on the connected network.
     499
     500  ASSERT if Ip1 or Ip2 is NULL.
     501  ASSERT if PrefixLength exceeds or equals to IP6_PREFIX_MAX.
    448502
    449503  @param[in] Ip1          - Ip6 address1, in network order.
     
    466520  Switches the endianess of an IPv6 address.
    467521
     522  ASSERT if Ip6 is NULL.
     523
    468524  This function swaps the bytes in a 128-bit IPv6 address to switch the value
    469525  from little endian to big endian or vice versa. The byte swapped value is
     
    487543
    488544#define NET_IS_DIGIT(Ch)            (('0' <= (Ch)) && ((Ch) <= '9'))
     545#define NET_IS_HEX(Ch)              ((('0' <= (Ch)) && ((Ch) <= '9')) || (('A' <= (Ch)) && ((Ch) <= 'F')) || (('a' <= (Ch)) && ((Ch) <= 'f')))
    489546#define NET_ROUNDUP(size, unit)     (((size) + (unit) - 1) & (~((unit) - 1)))
    490547#define NET_IS_LOWER_CASE_CHAR(Ch)  (('a' <= (Ch)) && ((Ch) <= 'z'))
     
    499556  Extract a UINT32 from a byte stream.
    500557
     558  ASSERT if Buf is NULL.
     559
    501560  This function copies a UINT32 from a byte stream, and then converts it from Network
    502561  byte order to host byte order. Use this function to avoid alignment error.
     
    515574/**
    516575  Puts a UINT32 into the byte stream in network byte order.
     576
     577  ASSERT if Buf is NULL.
    517578
    518579  Converts a UINT32 from host byte order to network byte order, then copies it to the
     
    531592
    532593/**
    533   Initialize a random seed using current time.
    534 
    535   Get current time first. Then initialize a random seed based on some basic
    536   mathematical operations on the hour, day, minute, second, nanosecond and year
    537   of the current time.
    538 
    539   @return The random seed, initialized with current time.
     594  Initialize a random seed using current time and monotonic count.
     595
     596  Get current time and monotonic count first. Then initialize a random seed
     597  based on some basic mathematics operation on the hour, day, minute, second,
     598  nanosecond and year of the current time and the monotonic count value.
     599
     600  @return The random seed initialized with current time.
    540601
    541602**/
     
    632693  Insert a new node entry after a designated node entry of a doubly linked list.
    633694
     695  ASSERT if PrevEntry or NewEntry is NULL.
     696
    634697  Inserts a new node entry designated by NewEntry after the node entry designated by PrevEntry
    635698  of the doubly linked list.
     
    648711/**
    649712  Insert a new node entry before a designated node entry of a doubly linked list.
     713
     714  ASSERT if PostEntry or NewEntry is NULL.
    650715
    651716  Inserts a new node entry designated by NewEntry before the node entry designated by PostEntry
     
    719784                                 if NumberOfChildren is 0.
    720785
    721   @retval TURE                   Found the input Handle in ChildHandleBuffer.
     786  @retval TRUE                   Found the input Handle in ChildHandleBuffer.
    722787  @retval FALSE                  Can't find the input Handle in ChildHandleBuffer.
    723788
     
    794859  If Map is NULL, then ASSERT().
    795860
    796 
    797861  @param[in]  Map                   The net map to test.
    798862
     
    808872/**
    809873  Return the number of the <Key, Value> pairs in the netmap.
     874
     875  If Map is NULL, then ASSERT().
    810876
    811877  @param[in]  Map                   The netmap to get the entry number.
     
    828894
    829895  If Map is NULL, then ASSERT().
     896  If Key is NULL, then ASSERT().
    830897
    831898  @param[in, out]  Map                   The netmap to insert into.
     
    853920
    854921  If Map is NULL, then ASSERT().
     922  If Key is NULL, then ASSERT().
    855923
    856924  @param[in, out]  Map                   The netmap to insert into.
     
    877945
    878946  If Map is NULL, then ASSERT().
     947  If Key is NULL, then ASSERT().
    879948
    880949  @param[in]  Map                   The netmap to search within.
     
    9771046  Iterate through the netmap and call CallBack for each item.
    9781047
    979   It will contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
     1048  It will continue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
    9801049  from the loop. It returns the CallBack's last return value. This function is
    9811050  delete safe for the current item.
     
    11221191  Get MAC address associated with the network service handle.
    11231192
     1193  If MacAddress is NULL, then ASSERT().
     1194  If AddressSize is NULL, then ASSERT().
     1195
    11241196  There should be MNP Service Binding Protocol installed on the input ServiceHandle.
    11251197  If SNP is installed on the ServiceHandle or its parent handle, MAC address will
     
    11461218  Convert MAC address of the NIC associated with specified Service Binding Handle
    11471219  to a unicode string. Callers are responsible for freeing the string storage.
     1220
     1221  If MacString is NULL, then ASSERT().
    11481222
    11491223  Locate simple network protocol associated with the Service Binding Handle and
     
    11751249/**
    11761250  Detect media status for specified network device.
     1251
     1252  If MediaPresent is NULL, then ASSERT().
    11771253
    11781254  The underlying UNDI driver may or may not support reporting media status from
     
    12091285
    12101286/**
     1287  Detect media state for a network device. This routine will wait for a period of time at
     1288  a specified checking interval when a certain network is under connecting until connection
     1289  process finishes or timeout. If Aip protocol is supported by low layer drivers, three kinds
     1290  of media states can be detected: EFI_SUCCESS, EFI_NOT_READY and EFI_NO_MEDIA, represents
     1291  connected state, connecting state and no media state respectively. When function detects
     1292  the current state is EFI_NOT_READY, it will loop to wait for next time's check until state
     1293  turns to be EFI_SUCCESS or EFI_NO_MEDIA. If Aip protocol is not supported, function will
     1294  call NetLibDetectMedia() and return state directly.
     1295
     1296  @param[in]   ServiceHandle    The handle where network service binding protocols are
     1297                                installed on.
     1298  @param[in]   Timeout          The maximum number of 100ns units to wait when network
     1299                                is connecting. Zero value means detect once and return
     1300                                immediately.
     1301  @param[out]  MediaState       The pointer to the detected media state.
     1302
     1303  @retval EFI_SUCCESS           Media detection success.
     1304  @retval EFI_INVALID_PARAMETER ServiceHandle is not a valid network device handle or
     1305                                MediaState pointer is NULL.
     1306  @retval EFI_DEVICE_ERROR      A device error occurred.
     1307  @retval EFI_TIMEOUT           Network is connecting but timeout.
     1308
     1309**/
     1310EFI_STATUS
     1311EFIAPI
     1312NetLibDetectMediaWaitTimeout (
     1313  IN  EFI_HANDLE            ServiceHandle,
     1314  IN  UINT64                Timeout,
     1315  OUT EFI_STATUS            *MediaState
     1316  );
     1317
     1318
     1319/**
    12111320  Create an IPv4 device path node.
     1321
     1322  If Node is NULL, then ASSERT().
    12121323
    12131324  The header type of IPv4 device path node is MESSAGING_DEVICE_PATH.
     
    12421353  Create an IPv6 device path node.
    12431354
     1355  If Node is NULL, then ASSERT().
     1356  If LocalIp is NULL, then ASSERT().
     1357  If RemoteIp is NULL, then ASSERT().
     1358
    12441359  The header type of IPv6 device path node is MESSAGING_DEVICE_PATH.
    12451360  The header subtype of IPv6 device path node is MSG_IPv6_DP.
     
    12721387  Find the UNDI/SNP handle from controller and protocol GUID.
    12731388
     1389  If ProtocolGuid is NULL, then ASSERT().
     1390
    12741391  For example, IP will open an MNP child to transmit/receive
    12751392  packets. When MNP is stopped, IP should also be stopped. IP
     
    12771394  service binding instance that is installed on the UNDI/SNP handle.
    12781395  The controller is then either an MNP or an ARP child handle. Note that
    1279   IP opens these handles using BY_DRIVER. Use that infomation to get the
     1396  IP opens these handles using BY_DRIVER. Use that information to get the
    12801397  UNDI/SNP handle.
    12811398
     
    13181435
    13191436  @retval EFI_SUCCESS            Converted to an IPv4 address successfully.
    1320   @retval EFI_INVALID_PARAMETER  The string is malformated, or Ip4Address is NULL.
     1437  @retval EFI_INVALID_PARAMETER  The string is malformatted, or Ip4Address is NULL.
    13211438
    13221439**/
     
    13301447/**
    13311448  Convert one Null-terminated ASCII string to EFI_IPv6_ADDRESS. The format of the
    1332   string is defined in RFC 4291 - Text Pepresentation of Addresses.
     1449  string is defined in RFC 4291 - Text Representation of Addresses.
    13331450
    13341451  @param[in]      String         The pointer to the Ascii string.
     
    13361453
    13371454  @retval EFI_SUCCESS            Converted to an IPv6 address successfully.
    1338   @retval EFI_INVALID_PARAMETER  The string is malformated, or Ip6Address is NULL.
     1455  @retval EFI_INVALID_PARAMETER  The string is malformatted, or Ip6Address is NULL.
    13391456
    13401457**/
     
    13531470
    13541471  @retval EFI_SUCCESS            Converted to an IPv4 address successfully.
    1355   @retval EFI_INVALID_PARAMETER  The string is mal-formated or Ip4Address is NULL.
    1356   @retval EFI_OUT_OF_RESOURCES   Failed to perform the operation due to lack of resources.
     1472  @retval EFI_INVALID_PARAMETER  The string is mal-formatted or Ip4Address is NULL.
    13571473
    13581474**/
     
    13661482/**
    13671483  Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS.  The format of
    1368   the string is defined in RFC 4291 - Text Pepresentation of Addresses.
     1484  the string is defined in RFC 4291 - Text Representation of Addresses.
    13691485
    13701486  @param[in]      String         The pointer to the Ascii string.
     
    13721488
    13731489  @retval EFI_SUCCESS            Converted to an IPv6 address successfully.
    1374   @retval EFI_INVALID_PARAMETER  The string is malformated or Ip6Address is NULL.
    1375   @retval EFI_OUT_OF_RESOURCES   Failed to perform the operation due to a lack of resources.
     1490  @retval EFI_INVALID_PARAMETER  The string is malformatted or Ip6Address is NULL.
    13761491
    13771492**/
     
    13851500/**
    13861501  Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS and prefix length.
    1387   The format of the string is defined in RFC 4291 - Text Pepresentation of Addresses
     1502  The format of the string is defined in RFC 4291 - Text Representation of Addresses
    13881503  Prefixes: ipv6-address/prefix-length.
    13891504
     
    13931508
    13941509  @retval EFI_SUCCESS            Converted to an  IPv6 address successfully.
    1395   @retval EFI_INVALID_PARAMETER  The string is malformated, or Ip6Address is NULL.
    1396   @retval EFI_OUT_OF_RESOURCES   Failed to perform the operation due to a lack of resources.
     1510  @retval EFI_INVALID_PARAMETER  The string is malformatted, or Ip6Address is NULL.
    13971511
    13981512**/
     
    14621576  INTN                RefCnt;  // Reference count to share NET_VECTOR.
    14631577  NET_VECTOR_EXT_FREE Free;    // external function to free NET_VECTOR
    1464   VOID                *Arg;    // opeque argument to Free
     1578  VOID                *Arg;    // opaque argument to Free
    14651579  UINT32              Flag;    // Flags, NET_VECTOR_OWN_FIRST
    1466   UINT32              Len;     // Total length of the assocated BLOCKs
     1580  UINT32              Len;     // Total length of the associated BLOCKs
    14671581
    14681582  UINT32              BlockNum;
     
    15731687
    15741688#define NET_HEADSPACE(BlockOp)  \
    1575   (UINTN)((BlockOp)->Head - (BlockOp)->BlockHead)
     1689  ((UINTN)((BlockOp)->Head) - (UINTN)((BlockOp)->BlockHead))
    15761690
    15771691#define NET_TAILSPACE(BlockOp)  \
    1578   (UINTN)((BlockOp)->BlockTail - (BlockOp)->Tail)
     1692  ((UINTN)((BlockOp)->BlockTail) - (UINTN)((BlockOp)->Tail))
    15791693
    15801694/**
     
    21182232  This function obtains the system guid from the smbios table.
    21192233
     2234  If SystemGuid is NULL, then ASSERT().
     2235
    21202236  @param[out]  SystemGuid     The pointer of the returned system guid.
    21212237
     
    21302246  );
    21312247
     2248/**
     2249  Create Dns QName according the queried domain name.
     2250
     2251  If DomainName is NULL, then ASSERT().
     2252
     2253  QName is a domain name represented as a sequence of labels,
     2254  where each label consists of a length octet followed by that
     2255  number of octets. The QName terminates with the zero
     2256  length octet for the null label of the root. Caller should
     2257  take responsibility to free the buffer in returned pointer.
     2258
     2259  @param  DomainName    The pointer to the queried domain name string.
     2260
     2261  @retval NULL          Failed to fill QName.
     2262  @return               QName filled successfully.
     2263
     2264**/
     2265CHAR8 *
     2266EFIAPI
     2267NetLibCreateDnsQName (
     2268  IN  CHAR16              *DomainName
     2269  );
     2270
    21322271#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette