From: John Hodge Date: Sun, 7 Nov 2010 03:57:30 +0000 (+0800) Subject: More cleanup in IPStack (making routes usable) X-Git-Tag: rel0.07~66 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8025b7daeb599847864cc3d8e3c2a41e63e3789d;hp=8c721d1069e9c0c769b847e9903d83b99d1acdfe;p=tpg%2Facess2.git More cleanup in IPStack (making routes usable) - libnet got a main :) --- diff --git a/Modules/IPStack/interface.c b/Modules/IPStack/interface.c index 4958d7fc..9b11e5f3 100644 --- a/Modules/IPStack/interface.c +++ b/Modules/IPStack/interface.c @@ -122,7 +122,9 @@ char *IPStack_Root_ReadDir(tVFS_Node *Node, int Pos) */ tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name) { + #if 0 int i, num; + #endif tInterface *iface; ENTER("pNode sName", Node, Name); @@ -137,6 +139,7 @@ tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name) return &gIP_LoopInterface.Node; } + #if 0 i = 0; num = 0; while('0' <= Name[i] && Name[i] <= '9') { @@ -157,6 +160,17 @@ tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name) return &iface->Node; } } + #else + for( iface = gIP_Interfaces; iface; iface = iface->Next ) + { + if( strcmp(iface->Name, Name) == 0 ) + { + LEAVE('p', &iface->Node); + return &iface->Node; + } + } + #endif + LEAVE('p', NULL); return NULL; } @@ -221,7 +235,7 @@ int IPStack_AddInterface(const char *Device, const char *Name) card = IPStack_GetAdapter(Device); - iface = malloc(sizeof(tInterface) + strlen(Name)); + iface = malloc(sizeof(tInterface) + sprintf(NULL, "%i", giIP_NextIfaceId) + 1); if(!iface) { LEAVE('i', -2); return -2; // Return ERR_MYBAD @@ -258,6 +272,7 @@ int IPStack_AddInterface(const char *Device, const char *Name) // Delay setting ImplInt until after the adapter is opened // Keeps things simple iface->Node.ImplInt = giIP_NextIfaceId++; + sprintf(iface->Name, "%i", iface->Node.ImplInt); // Append to list SHORTLOCK( &glIP_Interfaces ); diff --git a/Modules/IPStack/ipstack.h b/Modules/IPStack/ipstack.h index 974ec9c6..885e048d 100644 --- a/Modules/IPStack/ipstack.h +++ b/Modules/IPStack/ipstack.h @@ -58,6 +58,8 @@ struct sInterface { int SubnetBits; } IP4; }; + + char Name[]; }; /** diff --git a/Modules/IPStack/routing.c b/Modules/IPStack/routing.c index 33b756cb..643de1ee 100644 --- a/Modules/IPStack/routing.c +++ b/Modules/IPStack/routing.c @@ -244,12 +244,13 @@ tRoute *IPStack_FindRoute(int AddressType, void *Address) */ static const char *casIOCtls_Route[] = { DRV_IOCTLNAMES, - "get_network", // Get network - (void *Data) - "set_network", // Set network - (void *Data) - "get_nexthop", // Get next hop - (void *Data) - "set_nexthop", // Set next hop - (void *Data) - "getset_subnetbits", // Get/Set subnet bits - (int *Bits) - "getset_metric", // Get/Set metric - (int *Metric) + "get_network", // Get network - (void *Data), returns boolean success + "set_network", // Set network - (void *Data), returns boolean success + "get_nexthop", // Get next hop - (void *Data), returns boolean success + "set_nexthop", // Set next hop - (void *Data), returns boolean success + "getset_subnetbits", // Get/Set subnet bits - (int *Bits), returns current value + "getset_metric", // Get/Set metric - (int *Metric), returns current value + "get_interface", // Get interface name - (char *Name), returns name length, NULL OK NULL }; @@ -325,6 +326,15 @@ int IPStack_Route_IOCtl(tVFS_Node *Node, int ID, void *Data) } return rt->Metric; + // Get interface name + case 10: + if( Data ) { + if( !CheckMem(Data, strlen(rt->Interface->Name) + 1) ) + return -1; + strcpy(Data, rt->Interface->Name); + } + return strlen(rt->Interface->Name); + default: return 0; } diff --git a/Usermode/Libraries/libnet.so_src/Makefile b/Usermode/Libraries/libnet.so_src/Makefile index f92e7bc4..fa775eff 100644 --- a/Usermode/Libraries/libnet.so_src/Makefile +++ b/Usermode/Libraries/libnet.so_src/Makefile @@ -6,7 +6,7 @@ CPPFLAGS += CFLAGS += -Wall LDFLAGS += -lc -soname libnet.so -OBJ = address.o +OBJ = main.o address.o BIN = ../libnet.so include ../Makefile.tpl diff --git a/Usermode/Libraries/libnet.so_src/main.c b/Usermode/Libraries/libnet.so_src/main.c new file mode 100644 index 00000000..526e296d --- /dev/null +++ b/Usermode/Libraries/libnet.so_src/main.c @@ -0,0 +1,14 @@ +/* + * Acess2 Networking Toolkit + * By John Hodge (thePowersGang) + * + * main.c + * - Library main (and misc functions) + */ +#include + +// === CODE === +int SoMain(void) +{ + return 0; +}