Networking - Reworked route table management
[tpg/acess2.git] / Modules / IPStack / main.c
index 5aa6715..d5d1ebc 100644 (file)
@@ -30,6 +30,11 @@ extern tRoute        *IPStack_AddRoute(const char *Interface, void *Network, int Subnet
 
 // === GLOBALS ===
 MODULE_DEFINE(0, VERSION, IPStack, IPStack_Install, NULL, NULL);
+tVFS_NodeType  gIP_RootNodeType = {
+       .ReadDir = IPStack_Root_ReadDir,
+       .FindDir = IPStack_Root_FindDir,
+       .IOCtl = IPStack_Root_IOCtl
+};
 tDevFS_Driver  gIP_DriverInfo = {
        NULL, "ip",
        {
@@ -37,9 +42,7 @@ tDevFS_Driver gIP_DriverInfo = {
        .NumACLs = 1,
        .ACLs = &gVFS_ACL_EveryoneRX,
        .Flags = VFS_FFLAG_DIRECTORY,
-       .ReadDir = IPStack_Root_ReadDir,
-       .FindDir = IPStack_Root_FindDir,
-       .IOCtl = IPStack_Root_IOCtl
+       .Type = &gIP_RootNodeType
        }
 };
 
@@ -122,6 +125,10 @@ int IPStack_Install(char **Arguments)
                                        
                                        // Route for addrData/iBits, no next hop, default metric
                                        IPStack_AddRoute(iface->Name, iface->Address, iBits, NULL, 0);
+
+                                       Log_Notice("IPStack", "Boot interface %s/%i on %s",
+                                               IPStack_PrintAddress(iType, addrData), iBits,
+                                               dev);
                                }
                                
                                continue;
@@ -225,7 +232,7 @@ int IPStack_CompareAddress(int AddressType, const void *Address1, const void *Ad
        const Uint8     *addr1 = Address1, *addr2 = Address2;
        
        // Sanity check size
-       if( CheckBits < 0 )     CheckBits = 0;
+       if( CheckBits < 0 )     CheckBits = size*8;
        if( CheckBits > size*8 )        CheckBits = size*8;
        
        if( CheckBits == 0 )    return 1;       // /0 matches anything
@@ -259,8 +266,8 @@ const char *IPStack_PrintAddress(int AddressType, const void *Address)
                static char     ret[8*4+7+1];
                const Uint16    *addr = Address;
                sprintf(ret, "%x:%x:%x:%x:%x:%x:%x:%x",
-                       addr[0], addr[1], addr[2], addr[3],
-                       addr[4], addr[5], addr[6], addr[7]
+                       ntohs(addr[0]), ntohs(addr[1]), ntohs(addr[2]), ntohs(addr[3]),
+                       ntohs(addr[4]), ntohs(addr[5]), ntohs(addr[6]), ntohs(addr[7])
                        );
                return ret;
                }

UCC git Repository :: git.ucc.asn.au