X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FIPStack%2Fmain.c;h=6b75b7708a5700a90a42713f73985b954dd2099f;hb=95a530ccd8a001ca1488d7265268cf8bee2b650e;hp=37caba8c81b3cc60e2253b7701b3ec522d288e84;hpb=845ed09f3edef0c836200df6afbd6bfbc7b3fef6;p=tpg%2Facess2.git diff --git a/Modules/IPStack/main.c b/Modules/IPStack/main.c index 37caba8c..6b75b770 100644 --- a/Modules/IPStack/main.c +++ b/Modules/IPStack/main.c @@ -21,6 +21,8 @@ extern void UDP_Initialise(); extern void TCP_Initialise(); extern int IPv4_Initialise(); extern int IPv4_Ping(tInterface *Iface, tIPv4 Addr); +extern int IPv6_Initialise(); +//extern int IPv6_Ping(tInterface *Iface, tIPv6 Addr); // === PROTOTYPES === int IPStack_Install(char **Arguments); @@ -65,9 +67,12 @@ int IPStack_Install(char **Arguments) { int i = 0; - // Install Handlers + // Layer 2 - Data Link Layer ARP_Initialise(); + // Layer 3 - Network Layer IPv4_Initialise(); + IPv6_Initialise(); + // Layer 4 - Transport Layer TCP_Initialise(); UDP_Initialise(); @@ -84,7 +89,7 @@ int IPStack_Install(char **Arguments) DevFS_AddDevice( &gIP_DriverInfo ); - return 1; + return MODULE_ERR_OK; } /** @@ -92,6 +97,7 @@ int IPStack_Install(char **Arguments) */ int IPStack_AddFile(tSocketFile *File) { + Log_Log("IPStack", "Added file '%s'", File->Name); File->Next = gIP_FileTemplates; gIP_FileTemplates = File; return 0; @@ -224,7 +230,9 @@ int IPStack_Root_IOCtl(tVFS_Node *Node, int ID, void *Data) char *IPStack_Iface_ReadDir(tVFS_Node *Node, int Pos) { tSocketFile *file = gIP_FileTemplates; - while(Pos-- && file) file = file->Next; + while(Pos-- && file) { + file = file->Next; + } if(!file) return NULL; @@ -258,6 +266,7 @@ static const char *casIOCtls_Iface[] = { "get_address", "set_address", "getset_subnet", "get_gateway", "set_gateway", + "get_device", "ping", NULL }; @@ -455,11 +464,23 @@ int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data) } break; + /* + * get_device + * - Gets the name of the attached device + */ + case 10: + if( Data == NULL ) + LEAVE_RET('i', iface->Adapter->DeviceLen); + if( !CheckMem( Data, iface->Adapter->DeviceLen+1 ) ) + LEAVE_RET('i', -1); + strcpy( Data, iface->Adapter->Device ); + return iface->Adapter->DeviceLen; + /* * ping * - Send an ICMP Echo */ - case 10: + case 11: switch(iface->Type) { case 0: @@ -490,9 +511,12 @@ int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data) int IPStack_AddInterface(char *Device) { tInterface *iface; + tAdapter *card; ENTER("sDevice", Device); + card = IPStack_GetAdapter(Device); + iface = malloc(sizeof(tInterface)); if(!iface) { LEAVE('i', -2); @@ -504,9 +528,8 @@ int IPStack_AddInterface(char *Device) // Create Node iface->Node.ImplPtr = iface; - iface->Node.ImplInt = giIP_NextIfaceId++; iface->Node.Flags = VFS_FFLAG_DIRECTORY; - iface->Node.Size = 0; + iface->Node.Size = -1; iface->Node.NumACLs = 1; iface->Node.ACLs = &gVFS_ACL_EveryoneRX; iface->Node.ReadDir = IPStack_Iface_ReadDir; @@ -524,6 +547,10 @@ int IPStack_AddInterface(char *Device) return -1; // Return ERR_YOUFAIL } + // Delay setting ImplInt until after the adapter is opened + // Keeps things simple + iface->Node.ImplInt = giIP_NextIfaceId++; + // Append to list LOCK( &glIP_Interfaces ); if( gIP_Interfaces ) { @@ -578,6 +605,7 @@ tAdapter *IPStack_GetAdapter(char *Path) // Fill Structure strcpy( dev->Device, Path ); dev->NRef = 1; + dev->DeviceLen = strlen(Path); // Open Device dev->DeviceFD = VFS_Open( dev->Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE );