/* * Ip6Dxe - IPv6 Network Stack DXE Driver (Reconstructed Source Overview) * * Source: AmiNetworkPkg/UefiNetworkStack/Ipv6/Ip6Dxe/ * PE: Index 0152, Ip6Dxe.efi * MD5: 0288be1cadd121eaa69221de6b7f42f3 * SHA256: c559cc7b50c059a3214ad238f60dc15176cba015c6267094e38b9be2820537d0 * * Analysis notes: * - 315 functions, 308 strings, 8 segments (92KB .text) * - 8 source files: Ip6Driver.c, Ip6Impl.c, Ip6ConfigImpl.c, * Ip6ConfigNv.c, Ip6Common.c, Ip6Output.c, Ip6Nd.c, Ip6Mld.c * - No import table (all protocol binding through BS->LocateProtocol * and BS->OpenProtocol) * - Signatures: IP6S=0x53365049, IP6I=0x49365049, IP6P=0x50365049, * IFCI=0x49434649, IP6C=0x43365049, nbuf=0x6675626E * * ============================================================ * THIS IS A REFERENCE OVERVIEW FOR THE RECONSTRUCTED SOURCE * ============================================================ */ #include "Ip6Dxe.h" /* ================================================================== */ /* SECTION 1: Driver Entry Point & Driver Binding Protocol */ /* (Ip6Driver.c) */ /* ================================================================== */ /* * _ModuleEntryPoint (0x548) * Entry point called by UEFI core. * 1. Calls sub_5C4 to initialize globals (gST, gBS, gRT) and locate * HII protocols (HII_DATABASE, HII_STRING, HII_CONFIG_ROUTING), * EFI_DPC_PROTOCOL. * 2. Opens EFI_LOADED_IMAGE_PROTOCOL to get ImageHandle info. * 3. Reads NetworkStackVar UEFI variable to check if IPv6 is enabled. * 4. Calls InstallMultipleProtocolInterfaces to install: * - EFI_IP6_PROTOCOL (GUID 18A031AB-B443-4D1A-A5C0-0C09261E9F71 at 0x1BCF8) * with protocol interface table at off_1BD88 * - EFI_IP6_CONFIG_PROTOCOL (GUID 107A772C-D5E1-11D4-9A46-0090273FC14D at 0x1BD28) * with protocol interface table at off_1BE08 * - Additional protocols: EFI_MANAGED_NETWORK_SERVICE_BINDING etc. * 5. Returns EFI_SUCCESS on success. */ /* * sub_5C4 (0x5C4) - Driver Library Constructor * Initializes gImageHandle, gST, gBS, gRT. * Locates protocols: * - HII_STRING_PROTOCOL -> gHiiString (0x1C1B0) * - HII_DATABASE_PROTOCOL -> gHiiDatabase (0x1C1A8) * - HII_CONFIG_ROUTING_PROTOCOL (0x1C1B8) * - HII package list handle (0x1C1C0) * - HII_CONFIG_ACCESS_PROTOCOL (0x1C1C8) * - EFI_DPC_PROTOCOL (0x1C1E0) */ /* * sub_94C (0x94C) - DriverBinding Supported * EFI_DRIVER_BINDING_PROTOCOL.Supported(). * Checks if the controller supports the Managed Network Protocol. * Returns EFI_SUCCESS if MNP is available on the controller. */ /* * sub_1160 (0x1160) - DriverBinding Start * EFI_DRIVER_BINDING_PROTOCOL.Start(). * Opens MNP child handle on the controller. * Calls sub_C80 to allocate and initialize the IP6_SERVICE instance. * Installs IP6 protocol on the child. * Initializes default routes, timers, and configuration. * Seeds random state for IPv6. */ /* * sub_13F0 (0x13F0) - DriverBinding Stop * EFI_DRIVER_BINDING_PROTOCOL.Stop(). * Destroys all child instances, cleans up MNP connection, * frees the IP6_SERVICE instance. */ /* * sub_C80 (0xC80) - Ip6CreateService * Allocates and initializes the IP6_SERVICE struct (4192 bytes). * Signature 'IP6S' at +0. * Sets: * - NotifyFunction = sub_1694 (+0x08, timer tick handler) * - DestroyChild = sub_1818 (+0x10) * - Timer events for periodic processing * - ND parameters (reachable time, retrans timer, etc.) * - Neighbor cache (128 entries at +0x88) * - Route table, prefix list * Opens MNP, configures it, creates receive buffer ring. */ /* * sub_9C4 (0x9C4) - Ip6DestroyService * Inverse of sub_C80. Stops all timers, closes MNP, * destroys all child instances, frees all resources. * Sets state to destroyed. */ /* * sub_1694 (0x1694) - Ip6ServiceCreateChild * EFI_IP6_SERVICE_BINDING_PROTOCOL.CreateChild(). * Allocates a new IP6_INSTANCE (360 bytes), passes it to sub_3568 * for initialization, opens MNP for this child. */ /* * sub_1818 (0x1818) - Ip6ServiceDestroyChild * EFI_IP6_SERVICE_BINDING_PROTOCOL.DestroyChild(). * Cleans up and frees the child instance. */ /* ================================================================== */ /* SECTION 2: EFI_IP6_PROTOCOL Implementation */ /* (Ip6Impl.c) */ /* ================================================================== */ /* * Address range: ~0x324C - 0x4724 (Ip6Impl.c functions) * * sub_324C (0x324C) - Ip6GetModeData * EFI_IP6_PROTOCOL.GetModeData(). * Returns current IPv6 state including: * - IsStarted (bool) * - MaxPacketSize * - StationAddress (copied from instance) * - AddressList, GroupTable, RouteTable, NeighborCache * Allocates and fills these tables dynamically. * * sub_3950 (0x3950) - Ip6Configure * EFI_IP6_PROTOCOL.Configure(). * If ConfigData is NULL: resets instance (cleans up). * Otherwise validates the config (station address, prefix length), * applies it to the interface, and registers address info. * * sub_3AE4 (0x3AE4) - Ip6Groups * EFI_IP6_PROTOCOL.Groups(). * Join/leave multicast groups. Calls into MLD functions. * * sub_3BD0 (0x3BD0) - Ip6Routes * EFI_IP6_PROTOCOL.Routes(). * Add/remove route table entries. * * sub_3D20 (0x3D20) - Ip6Neighbors * EFI_IP6_PROTOCOL.Neighbors(). * Add/update/delete neighbor cache entries. * * sub_3F4C (0x3F4C) - Ip6Transmit * EFI_IP6_PROTOCOL.Transmit(). * Builds IPv6 header, processes extension headers, * fragments if needed, and sends via MNP. * * sub_439C (0x439C) - Ip6Receive * EFI_IP6_PROTOCOL.Receive(). * Registers a receive completion token. * * sub_44C4 (0x44C4) - Ip6Cancel * EFI_IP6_PROTOCOL.Cancel(). * Cancels pending transmit/receive tokens. * * sub_4684 (0x4684) - Ip6Poll * EFI_IP6_PROTOCOL.Poll(). * Polls MNP for incoming packets. * * sub_4724 (0x4724) - Ip6OpenState (internal) * Opens config state. */ /* ================================================================== */ /* SECTION 3: EFI_IP6_CONFIG_PROTOCOL Implementation */ /* (Ip6ConfigImpl.c) */ /* ================================================================== */ /* * Address range: ~0x7988 - 0x9D20 (Ip6ConfigImpl.c functions) * * sub_7988 (0x7988) - Ip6ConfigSetData * EFI_IP6_CONFIG_PROTOCOL.SetData(). * Processes configuration data items: * - Manual address, gateway, DNS, etc. * Updates the IP6_SERVICE configuration state. * * sub_7C24 (0x7C24) - Ip6ConfigStart * Opens MNP child for configuration, * registers DHCPv6 event notification or initiates * stateless address autoconfiguration (SLAAC) based on config. * * sub_8770 (0x8770) - Ip6ConfigGetData * EFI_IP6_CONFIG_PROTOCOL.GetData(). * Retrieves current configuration data items. * Walks neighbor cache, prefix list, address list, route table * to populate the requested data type. * * sub_8DD8 (0x8DD8) - Ip6ConfigRegisterNotify * EFI_IP6_CONFIG_PROTOCOL.RegisterNotify(). * * sub_9078 (0x9078) - Ip6ConfigUnregisterNotify * EFI_IP6_CONFIG_PROTOCOL.UnregisterNotify(). * * sub_92B8 (0x92B8) - Ip6ConfigFindDataItem (internal) * Finds a data item by data type index. * * sub_94B4 (0x94B4) - Ip6ConfigGetConfigData (internal) * Collects config data from neighbors, addresses, etc. * * sub_958C (0x958C) - Ip6ConfigSetConfigData (internal) * Applies configuration changes. * * sub_97AC (0x97AC) - Ip6ConfigGetInfo (internal) * Retrieves interface info. * * sub_9CA0 (0x9CA0) - Ip6ConfigInit (internal) * Initializes the config data items with default values. */ /* ================================================================== */ /* SECTION 4: HII Configuration (Ip6ConfigNv.c) */ /* (Ip6ConfigNv.c) */ /* ================================================================== */ /* * Address range: ~0xE7E0 - 0x10484 (Ip6ConfigNv.c functions) * * These functions implement the EFI_HII_CONFIG_ACCESS_PROTOCOL: * - ExtractConfig, RouteConfig, Callback * * sub_FCC0 (0xFCC0) - Ip6ConfigNvCallback (main HII callback) * EFI_HII_CONFIG_ACCESS_PROTOCOL.Callback(). * Processes user interactions with the IPv6 configuration form: * - Question ID 264: Save interface ID * - Question ID 257: Parse and validate Interface ID string * - Question ID 258: Validate Gateway addresses * - Question ID 259: Validate Gateway addresses * - Question ID 260: Validate DNS addresses * - Question ID 261: Save config * - Question ID 262: Commit config * - Question ID 263: Refresh/reset config * * sub_EF84 (0xEF84) - Ip6ConfigNvExtractConfig * EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig(). * Converts NV data to HII configuration format. * * sub_F814 (0xF814) - Ip6ConfigNvRouteConfig * EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig(). * Routes configuration data from HII back to NV storage. * * sub_FA8C (0xFA8C) - Ip6ConfigNvCommitConfig (internal) * Commits the current NV data to the actual IP6 config. * * sub_F540 (0xF540) - Ip6ConfigNvUpdateForm (internal) * Updates the HII form based on current config. * * sub_13AF0 (0x13AF0) - Ip6ConfigNvCreatePopUp (internal) * Creates a pop-up dialog for error/info messages. */ /* ================================================================== */ /* SECTION 5: Common Utility Functions (Ip6Common.c) */ /* (Ip6Common.c) */ /* ================================================================== */ /* * Address range: ~0x2C04 - 0x38A4 (Ip6Common.c functions) * ~0xD1A4 - 0xDA30 (Ip6Common.c functions) * * sub_2C04 (0x2C04) - Ip6CommonGetAddressInfoList (internal) * Gets the address info list from the service instance. * * sub_D1A4 (0xD1A4) - Ip6CommonCreateAddressInfo (internal) * Creates and registers a new address info entry. * * sub_D318 (0xD318) - Ip6CommonFindAddressInfo (internal) * Finds a specific address info entry by address. * * sub_D3C4 (0xD3C4) - Ip6CommonAddAddressInfo (internal) * Adds an address-info mapping. * * sub_D500 (0xD500) - Ip6CommonRemoveAddressInfo (internal) * Removes an address info entry. * * sub_D5E8 (0xD5E8) - Ip6CommonAddNeighbor (internal) * Adds a neighbor cache entry. * * sub_D7B0 (0xD7B0) - Ip6CommonFindNeighbor (internal) * Finds a neighbor cache entry. * * sub_34F8 (0x34F8) - Ip6CommonPrefixMatch (internal) * Checks if an address matches a prefix. * * sub_3568 (0x3568) - Ip6CommonInitInstance (internal) * Initializes an IP6 instance structure. * * sub_3648 (0x3648) - Ip6CommonConfigureInstance (internal) * Configures the instance with specified parameters. * * sub_37F4 (0x37F4) - Ip6CommonCleanupInstance (internal) * Cleans up and resets an instance. */ /* ================================================================== */ /* SECTION 6: IPv6 Output (Ip6Output.c) */ /* (Ip6Output.c) */ /* ================================================================== */ /* * Address range: ~0x1A28 - 0x2B54 (Ip6Output.c functions) * * sub_1FB8 (0x1FB8) - Ip6Output (main output function) * Builds an IPv6 output packet from an NET_BUF. * Wraps the data with IPv6 header, extension headers. * Fragments if packet exceeds link MTU. * Calls into route lookup (sub_DAC8, sub_E490) and transmits. * * sub_1B40 (0x1B40) - Ip6OutputFragment (internal) * Fragments an IPv6 packet into multiple fragments. * * sub_1D80 (0x1D80) - Ip6OutputIpHeader (internal) * Builds the IPv6 header in the output packet. * * sub_1E9C (0x1E9C) - Ip6OutputExtHeader (internal) * Processes extension headers (Hop-by-Hop, Routing, Fragment, etc.) * * sub_280C (0x280C) - sub_280C * Validates output parameters. * * sub_DAC8 (0xDAC8) - Ip6OutputRouteLookup (internal) * Route table lookup for next-hop determination. */ /* ================================================================== */ /* SECTION 7: Neighbor Discovery (Ip6Nd.c) */ /* (Ip6Nd.c) */ /* ================================================================== */ /* * Address range: ~0x47B0 - 0x6DE4 (Ip6Nd.c functions) * * Implements Neighbor Discovery Protocol (RFC 4861). * * sub_47B0 (0x47B0) - Ip6NdStart (internal) * Initializes ND module for an instance (reachable timer, etc.) * * sub_48F4 (0x48F4) - Ip6NdStop (internal) * Stops ND module for an instance. * * sub_4A20 (0x4A20) - Ip6NdBeginWork (internal) * Begins ND work - processes ND messages. * * sub_4B90 (0x4B90) - sub_4B90 - ND timer callback (internal) * * sub_4C78 (0x4C78) - sub_4C78 - ND retransmission handler (internal) * * sub_4F28 (0x4F28) - sub_4F28 * ND periodic processing (timer tick). * * sub_5040 (0x5040) - sub_5040 * ND event handler - route/address discovery notifications. * * sub_50FC (0x50FC) - sub_50FC * ND timeout handler for neighbor/prefix state management. * * sub_5260 (0x5260) - sub_5260 * ND sending solicitation. * * sub_5488 (0x5488) - sub_5488 * ND processing received advertisement. * * sub_5B10 (0x5B10) - sub_5B10 * ND processing router advertisement. * * sub_5DB8 (0x5DB8) - sub_5DB8 * ND building and sending neighbor solicitation. * * sub_6120 (0x6120) - sub_6120 * ND building neighbor advertisement response. * * sub_6438 (0x6438) - sub_6438 * ND processing redirect messages. * * sub_6A90 (0x6A90) - sub_6A90 * ND generating link-local address. */ /* ================================================================== */ /* SECTION 8: Multicast Listener Discovery (Ip6Mld.c) */ /* (Ip6Mld.c) */ /* ================================================================== */ /* * Address range: ~0xACAC - 0xBA98 (Ip6Mld.c functions) * * Implements MLDv2 (RFC 3810) / MLDv1 (RFC 2710). * * sub_ACAC (0xACAC) - sub_ACAC * MLD initialization for an interface. * * sub_AD6C (0xAD6C) - sub_AD6C * MLD group join operation. * * sub_AE0C (0xAE0C) - sub_AE0C * MLD group leave operation. * * sub_B01C (0xB01C) - sub_B01C * MLD query processing. * * sub_B2EC (0xB2EC) - sub_B2EC * MLD report processing. * * sub_B5B4 (0xB5B4) - sub_B5B4 * MLD building and sending reports. * * sub_BB0C (0xBB0C) - sub_BB0C (also Ip6Mld?) * Another MLD handler. */ /* ================================================================== */ /* SECTION 9: Timer and Event Handlers */ /* (distributed across source files) */ /* ================================================================== */ /* * sub_AB40 (0xAB40) - TimerTicking (Ip6Driver.c internal) * Periodic timer callback (every 500ms based on timer config). * Drives ND and MLD state machines. * Called from the timer event created in sub_C80. * * sub_6EC0 (0x6EC0) - sub_6EC0 * Receive buffer processing callback. * Called when MNP signals received data. * Dispatches to ND and MLD protocol handlers. * * sub_7EB0 (0x7EB0) - sub_7EB0 * DPC queuing routine (deferred procedure call). * Queues work for deferred execution. * * sub_8068 (0x8068) - sub_8068 * DPC handler - processes received IP6 packets. * Demultiplexes by NextHeader (TCP=6, UDP=17, ICMPv6=58, etc.) * * sub_977C (0x977C) - sub_977C * Config notification callback (wake-up from DHCPv6/etc.) * * sub_9774 (0x9774) - sub_9774 * MNP receive completion callback. */ /* ================================================================== */ /* SECTION 10: Library Support Functions */ /* ================================================================== */ /* * Address range: ~0x10504 - 0x105CC (Debug/assert) * These provide DEBUG/ASSERT support similar to UEFI DebugLib. * Many xrefs from assert expressions throughout the driver. * * sub_10504 (0x10504) - DebugPrint (variadic) * sub_1058C (0x1058C) - Assert * * Library functions linked from MdePkg and MdeModulePkg: * - NetBuffer.c (0x1A618) - NET_BUF management * - DxeNetLib.c (0x1A3C0) - Network library utilities * - HiiLib.c (0x1A128) - HII library * - DxeDpcLib.c (0x1A9C0) - DPC library * - UefiLib/DriverModel.c * - UefiBootServicesTableLib * - UefiRuntimeServicesTableLib */ /* ================================================================== */ /* FUNCTION-CALL RELATIONSHIPS (Call Graph Summary) */ /* ================================================================== */ /* */ /* Driver entry: */ /* _ModuleEntryPoint (0x548) */ /* -> sub_5C4 (init gST/gBS/gRT and HII/DPC protocols) */ /* -> InstallMultipleProtocolInterfaces (installs 3 protocols) */ /* -> sub_7D4 (read variable, register DriverBinding) */ /* */ /* Driver Binding Protocol: */ /* sub_94C -> ControllerSupported */ /* sub_1160 -> DriverStart */ /* -> sub_C80 -> Ip6CreateService (4192 bytes) */ /* -> sub_7EB0 -> MNP open + config */ /* -> sub_9CA0 -> Config init */ /* -> sub_A31C -> Timer create */ /* -> sub_B230 -> Route/address setup */ /* -> sub_15C4C -> Event registration */ /* sub_13F0 -> DriverStop */ /* -> sub_9C4 -> Ip6DestroyService */ /* */ /* IP6 Protocol (per-child): */ /* sub_324C -> Ip6GetModeData */ /* -> sub_2C04 -> GetAddressInfoList */ /* -> sub_47B0 -> Ip6NdStart */ /* -> sub_48F4 -> Ip6NdStop */ /* sub_3950 -> Ip6Configure */ /* -> sub_34F8 -> PrefixMatch */ /* -> sub_37F4 -> CleanupInstance */ /* -> sub_3648 -> ConfigureInstance */ /* -> sub_D1A4 -> CreateAddressInfo */ /* sub_3F4C -> Ip6Transmit */ /* -> sub_1B40 -> Ip6Output (packet building) */ /* sub_439C -> Ip6Receive */ /* sub_44C4 -> Ip6Cancel */ /* sub_4684 -> Ip6Poll */ /* */ /* IP6 Config Protocol: */ /* sub_7988 -> SetData */ /* -> sub_8770 -> GetData (also called from GetData) */ /* -> sub_958C -> SetConfigData */ /* sub_8DD8 -> RegisterNotify */ /* sub_9078 -> UnregisterNotify */ /* sub_9774 -> ConfigCallback (MNP recv callback) */ /* sub_977C -> ConfigNotification (event notify) */ /* */ /* Timer/Event loop (running in background): */ /* sub_AB40 -> Timer tick (500ms periodic) */ /* -> sub_1694 -> Check for new TCP child protocol */ /* -> sub_6EC0 -> Receive data processing */ /* sub_6EC0 -> ProcessRecvData */ /* -> sub_8068 -> DPC handler for demux */ /* */ /* Output path: */ /* sub_1FB8 -> Ip6Output (transmit packet) */ /* -> sub_1B40 -> Fragmentation */ /* -> sub_1D80 -> Build IPv6 header */ /* -> sub_1E9C -> Build extension headers */ /* -> sub_DAC8 -> Route lookup */ /* -> sub_E490 -> Next header handling */ /* -> MNP Transmit */ /* */ /* ================================================================== */