X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Modules%2FIPStack%2Fmain.c;h=fe4bf0f685da552348884d1dce9011f7c40c006c;hb=f0b06cece87e5f73678413cbbc1e3100ddf6e247;hp=da7441c4fa94d11f6bff3051bf6907faacda1cda;hpb=7c2a4b6359a81dac11d89eda748d1cc0640f6d33;p=tpg%2Facess2.git diff --git a/Modules/IPStack/main.c b/Modules/IPStack/main.c index da7441c4..fe4bf0f6 100644 --- a/Modules/IPStack/main.c +++ b/Modules/IPStack/main.c @@ -28,12 +28,12 @@ extern int IPv6_Initialise(); int IPStack_Install(char **Arguments); int IPStack_IOCtlRoot(tVFS_Node *Node, int ID, void *Data); char *IPStack_Root_ReadDir(tVFS_Node *Node, int Pos); -tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, char *Name); +tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name); int IPStack_Root_IOCtl(tVFS_Node *Node, int ID, void *Data); int IPStack_AddInterface(char *Device); tAdapter *IPStack_GetAdapter(char *Path); char *IPStack_Iface_ReadDir(tVFS_Node *Node, int Pos); -tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, char *Name); +tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, const char *Name); int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data); // === GLOBALS === @@ -50,11 +50,11 @@ tDevFS_Driver gIP_DriverInfo = { .IOCtl = IPStack_Root_IOCtl } }; -tSpinlock glIP_Interfaces = 0; +tShortSpinlock glIP_Interfaces; tInterface *gIP_Interfaces = NULL; tInterface *gIP_Interfaces_Last = NULL; int giIP_NextIfaceId = 1; -tSpinlock glIP_Adapters = 0; +tMutex glIP_Adapters; tAdapter *gIP_Adapters = NULL; tSocketFile *gIP_FileTemplates; @@ -154,7 +154,7 @@ char *IPStack_Root_ReadDir(tVFS_Node *Node, int Pos) /** * \brief Get the node of an interface */ -tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, char *Name) +tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name) { int i, num; tInterface *iface; @@ -175,7 +175,7 @@ tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, char *Name) for( iface = gIP_Interfaces; iface; iface = iface->Next ) { - if( iface->Node.ImplInt == num ) + if( (int)iface->Node.ImplInt == num ) { LEAVE('p', &iface->Node); return &iface->Node; @@ -247,7 +247,7 @@ char *IPStack_Iface_ReadDir(tVFS_Node *Node, int Pos) /** * \brief Gets a named node from an interface directory */ -tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, char *Name) +tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, const char *Name) { tSocketFile *file = gIP_FileTemplates; @@ -561,7 +561,7 @@ int IPStack_AddInterface(char *Device) iface->Node.ImplInt = giIP_NextIfaceId++; // Append to list - LOCK( &glIP_Interfaces ); + SHORTLOCK( &glIP_Interfaces ); if( gIP_Interfaces ) { gIP_Interfaces_Last->Next = iface; gIP_Interfaces_Last = iface; @@ -570,7 +570,7 @@ int IPStack_AddInterface(char *Device) gIP_Interfaces = iface; gIP_Interfaces_Last = iface; } - RELEASE( &glIP_Interfaces ); + SHORTREL( &glIP_Interfaces ); gIP_DriverInfo.RootNode.Size ++; @@ -590,14 +590,14 @@ tAdapter *IPStack_GetAdapter(char *Path) ENTER("sPath", Path); - LOCK( &glIP_Adapters ); + Mutex_Acquire( &glIP_Adapters ); // Check if this adapter is already open for( dev = gIP_Adapters; dev; dev = dev->Next ) { if( strcmp(dev->Device, Path) == 0 ) { dev->NRef ++; - RELEASE( &glIP_Adapters ); + Mutex_Release( &glIP_Adapters ); LEAVE('p', dev); return dev; } @@ -606,7 +606,7 @@ tAdapter *IPStack_GetAdapter(char *Path) // Ok, so let's open it dev = malloc( sizeof(tAdapter) + strlen(Path) + 1 ); if(!dev) { - RELEASE( &glIP_Adapters ); + Mutex_Release( &glIP_Adapters ); LEAVE('n'); return NULL; } @@ -620,7 +620,7 @@ tAdapter *IPStack_GetAdapter(char *Path) dev->DeviceFD = VFS_Open( dev->Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE ); if( dev->DeviceFD == -1 ) { free( dev ); - RELEASE( &glIP_Adapters ); + Mutex_Release( &glIP_Adapters ); LEAVE('n'); return NULL; } @@ -632,7 +632,7 @@ tAdapter *IPStack_GetAdapter(char *Path) Warning("IPStack_GetAdapter: '%s' is not a network interface", dev->Device); VFS_Close( dev->DeviceFD ); free( dev ); - RELEASE( &glIP_Adapters ); + Mutex_Release( &glIP_Adapters ); LEAVE('n'); return NULL; } @@ -644,7 +644,7 @@ tAdapter *IPStack_GetAdapter(char *Path) dev->Next = gIP_Adapters; gIP_Adapters = dev; - RELEASE( &glIP_Adapters ); + Mutex_Release( &glIP_Adapters ); // Start watcher Link_WatchDevice( dev );