// - <HexStreamAddress> is a condensed hexadecimal stream (in big endian)
// (E.g. 0A000201 for 10.0.2.1 IPv4)
// - <Bits> is the number of subnet bits (E.g. 24 for an IPv4 Class C)
+ // Example: /Devices/ne2k/0,4,0A00020A,24
+
+ // I could also define routes using <Interface>,<HexStreamNetwork>,<Bits>,<HexStreamGateway>
+ // Example: 1,00000000,0,0A000201
}
}
- gIP_LoopInterface.Adapter = IPStack_GetAdapter("/Devices/fifo/anon");
+ // Initialise loopback interface
+ gIP_LoopInterface.Adapter = IPStack_GetAdapter("LOOPBACK");
DevFS_AddDevice( &gIP_DriverInfo );
if( CheckBits < 0 ) CheckBits = 0;
if( CheckBits > size*8 ) CheckBits = size*8;
+ if( CheckBits == 0 ) return 1; // /0 matches anythin
+
// Check first bits/8 bytes
if( memcmp(Address1, Address2, CheckBits/8) != 0 ) return 0;
return 0;
}
+
+const char *IPStack_PrintAddress(int AddressType, void *Address)
+{
+ switch( AddressType )
+ {
+ case 4: {
+ static char ret[4*3+3+1];
+ Uint8 *addr = Address;
+ sprintf(ret, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]);
+ return ret;
+ }
+
+ case 6: {
+ static char ret[8*4+7+1];
+ 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]
+ );
+ return ret;
+ }
+
+ default:
+ return "";
+ }
+}