#include <Protocol/ComponentName.h>
#include <Protocol/DriverConfiguration.h>
#include <Protocol/DriverDiagnostics.h>
+#include <Protocol/Dpc.h>
#define EFI_NET_LITTLE_ENDIAN
//
// Convert the EFI_IP4_ADDRESS to plain UINT32 IP4 address.
//
-#define EFI_IP4(EfiIpAddr) (*(IP4_ADDR *) ((EfiIpAddr).Addr))
-#define EFI_NTOHL(EfiIp) (NTOHL (EFI_IP4 ((EfiIp))))
-#define EFI_IP_EQUAL(Ip1, Ip2) (EFI_IP4 (Ip1) == EFI_IP4 (Ip2))
+#define EFI_IP4(EfiIpAddr) (*(IP4_ADDR *) ((EfiIpAddr).Addr))
+#define EFI_NTOHL(EfiIp) (NTOHL (EFI_IP4 ((EfiIp))))
+#define EFI_IP4_EQUAL(Ip1, Ip2) (NetCompareMem ((Ip1), (Ip2), sizeof (EFI_IPv4_ADDRESS)) == 0)
INTN
NetGetMaskLength (
extern IP4_ADDR mIp4AllMasks [IP4_MASK_NUM];
-//@MT:#include EFI_PROTOCOL_CONSUMER (LoadedImage)
-//@MT:#include EFI_PROTOCOL_CONSUMER (ServiceBinding)
-//@MT:#include EFI_PROTOCOL_CONSUMER (SimpleNetwork)
+
+extern EFI_IPv4_ADDRESS mZeroIp4Addr;
+
+#define NET_IS_DIGIT(Ch) (('0' <= (Ch)) && ((Ch) <= '9'))
+#define NET_ROUNDUP(size, unit) (((size) + (unit) - 1) & (~((unit) - 1)))
//
// Wrap functions to ease the impact of EFI library changes.
// to the standard EFI enviornment. It will NOT consider multiprocessor.
//
#define NET_TPL_LOCK TPL_CALLBACK
-#define NET_TPL_RECYCLE_LOCK (NET_TPL_LOCK + 1)
-#define NET_TPL_EVENT TPL_CALLBACK
-#define NET_TPL_RECYCLE (NET_TPL_LOCK + 1)
-#define NET_TPL_SLOW_TIMER (TPL_CALLBACK - 1)
-#define NET_TPL_FAST_TIMER NET_TPL_RECYCLE
-#define NET_TPL_TIMER TPL_CALLBACK
+#define NET_TPL_EVENT TPL_NOTIFY
+#define NET_TPL_RECYCLE TPL_NOTIFY
+#define NET_TPL_TIMER NET_TPL_LOCK
#define NET_LOCK EFI_LOCK
#define NET_LOCK_INIT(x) EfiInitializeLock (x, NET_TPL_LOCK)
-#define NET_RECYCLE_LOCK_INIT(x) EfiInitializeLock (x, NET_TPL_RECYCLE_LOCK)
+#define NET_RECYCLE_LOCK_INIT(x) EfiInitializeLock (x, NET_TPL_RECYCLE)
#define NET_TRYLOCK(x) EfiAcquireLockOrFail (x)
#define NET_UNLOCK(x) EfiReleaseLock (x)
#define TICKS_PER_MS 10000U
#define TICKS_PER_SECOND 10000000U
-#define NET_MIN(a, b) ((a) < (b) ? (a) : (b))
-#define NET_MAX(a, b) ((a) > (b) ? (a) : (b))
-#define NET_RANDOM(Seed) (((Seed) * 1103515245L + 12345) % 4294967295L)
+#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL)
UINT32
NetLibGetMacString (
IN EFI_HANDLE SnpHandle,
IN EFI_HANDLE ImageHandle,
- IN OUT CONST CHAR16 **MacString
+ IN OUT CHAR16 **MacString
+ );
+
+VOID
+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_HANDLE
IN EFI_GUID *ProtocolGuid
);
-typedef
EFI_STATUS
-(EFIAPI *NET_LIB_DRIVER_UNLOAD) (
- IN EFI_HANDLE ImageHandle
+NetLibQueueDpc (
+ IN EFI_TPL DpcTpl,
+ IN EFI_DPC_PROCEDURE DpcProcedure,
+ IN VOID *DpcContext OPTIONAL
);
EFI_STATUS
-EFIAPI
-NetLibDefaultUnload (
- IN EFI_HANDLE ImageHandle
+NetLibDispatchDpc (
+ VOID
);
EFI_STATUS
-NetLibInstallAllDriverProtocolsWithUnload (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
- IN EFI_HANDLE DriverBindingHandle,
- IN EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics, OPTIONAL
- IN NET_LIB_DRIVER_UNLOAD CustomizedUnload
+EFIAPI
+NetLibDefaultUnload (
+ IN EFI_HANDLE ImageHandle
);
-EFI_STATUS
-NetLibInstallAllDriverProtocols (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable,
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
- IN EFI_HANDLE DriverBindingHandle,
- IN EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL
- );
-\r
enum {
//
//Various signatures
IN UINT16 Len
);
-//\r
-// The debug level definition. This value is also used as the\r
-// syslog's servity level. Don't change it.\r
-//\r
-enum {\r
- NETDEBUG_LEVEL_TRACE = 5,\r
- NETDEBUG_LEVEL_WARNING = 4,\r
- NETDEBUG_LEVEL_ERROR = 3,\r
-};\r
-\r
-#ifdef EFI_NETWORK_STACK_DEBUG\r
-\r
-//\r
-// The debug output expects the ASCII format string, Use %a to print ASCII\r
-// string, and %s to print UNICODE string. PrintArg must be enclosed in ().\r
-// For example: NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name));\r
-//\r
-#define NET_DEBUG_TRACE(Module, PrintArg) \\r
- NetDebugOutput ( \\r
- NETDEBUG_LEVEL_TRACE, \\r
- Module, \\r
- __FILE__, \\r
- __LINE__, \\r
- NetDebugASPrint PrintArg \\r
- )\r
-\r
-#define NET_DEBUG_WARNING(Module, PrintArg) \\r
- NetDebugOutput ( \\r
- NETDEBUG_LEVEL_WARNING, \\r
- Module, \\r
- __FILE__, \\r
- __LINE__, \\r
- NetDebugASPrint PrintArg \\r
- )\r
-\r
-#define NET_DEBUG_ERROR(Module, PrintArg) \\r
- NetDebugOutput ( \\r
- NETDEBUG_LEVEL_ERROR, \\r
- Module, \\r
- __FILE__, \\r
- __LINE__, \\r
- NetDebugASPrint PrintArg \\r
- )\r
-\r
-#else\r
-#define NET_DEBUG_TRACE(Module, PrintString)\r
-#define NET_DEBUG_WARNING(Module, PrintString)\r
-#define NET_DEBUG_ERROR(Module, PrintString)\r
-#endif\r
-\r
-UINT8 *\r
-NetDebugASPrint (\r
- UINT8 *Format,\r
- ...\r
- );\r
-\r
-EFI_STATUS\r
-NetDebugOutput (\r
- UINT32 Level,\r
- UINT8 *Module,\r
- UINT8 *File,\r
- UINT32 Line,\r
- UINT8 *Message\r
- );\r
-\r
-//\r
-// Network debug message is sent out as syslog.\r
-//\r
-enum {\r
- NET_SYSLOG_FACILITY = 16, // Syslog local facility local use\r
- NET_SYSLOG_PACKET_LEN = 512,\r
- NET_DEBUG_MSG_LEN = 470, // 512 - (ether+ip+udp head length)\r
- NET_SYSLOG_TX_TIMEOUT = 500 *1000 *10, // 500ms\r
+//
+// The debug level definition. This value is also used as the
+// syslog's servity level. Don't change it.
+//
+enum {
+ NETDEBUG_LEVEL_TRACE = 5,
+ NETDEBUG_LEVEL_WARNING = 4,
+ NETDEBUG_LEVEL_ERROR = 3,
+};
+
+#ifdef EFI_NETWORK_STACK_DEBUG
+
+//
+// The debug output expects the ASCII format string, Use %a to print ASCII
+// string, and %s to print UNICODE string. PrintArg must be enclosed in ().
+// For example: NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name));
+//
+#define NET_DEBUG_TRACE(Module, PrintArg) \
+ NetDebugOutput ( \
+ NETDEBUG_LEVEL_TRACE, \
+ Module, \
+ __FILE__, \
+ __LINE__, \
+ NetDebugASPrint PrintArg \
+ )
+
+#define NET_DEBUG_WARNING(Module, PrintArg) \
+ NetDebugOutput ( \
+ NETDEBUG_LEVEL_WARNING, \
+ Module, \
+ __FILE__, \
+ __LINE__, \
+ NetDebugASPrint PrintArg \
+ )
+
+#define NET_DEBUG_ERROR(Module, PrintArg) \
+ NetDebugOutput ( \
+ NETDEBUG_LEVEL_ERROR, \
+ Module, \
+ __FILE__, \
+ __LINE__, \
+ NetDebugASPrint PrintArg \
+ )
+
+#else
+#define NET_DEBUG_TRACE(Module, PrintString)
+#define NET_DEBUG_WARNING(Module, PrintString)
+#define NET_DEBUG_ERROR(Module, PrintString)
+#endif
+
+UINT8 *
+NetDebugASPrint (
+ UINT8 *Format,
+ ...
+ );
+
+EFI_STATUS
+NetDebugOutput (
+ UINT32 Level,
+ UINT8 *Module,
+ UINT8 *File,
+ UINT32 Line,
+ UINT8 *Message
+ );
+
+//
+// Network debug message is sent out as syslog.
+//
+enum {
+ NET_SYSLOG_FACILITY = 16, // Syslog local facility local use
+ NET_SYSLOG_PACKET_LEN = 512,
+ NET_DEBUG_MSG_LEN = 470, // 512 - (ether+ip+udp head length)
+ NET_SYSLOG_TX_TIMEOUT = 500 *1000 *10, // 500ms
};
#endif