#define VERSION VER2(0,10)
#include "ipstack.h"
#include "link.h"
-#include <tpl_drv_common.h>
-#include <tpl_drv_network.h>
+#include <api_drv_common.h>
+#include <api_drv_network.h>
// === CONSTANTS ===
//! Default timeout value, 30 seconds
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data);
// === GLOBALS ===
+tVFS_NodeType gIP_InterfaceNodeType = {
+ .ReadDir = IPStack_Iface_ReadDir,
+ .FindDir = IPStack_Iface_FindDir,
+ .IOCtl = IPStack_Iface_IOCtl
+};
//! Loopback (127.0.0.0/8, ::1) Pseudo-Interface
tInterface gIP_LoopInterface = {
.Node = {
.Size = -1,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
- .ReadDir = IPStack_Iface_ReadDir,
- .FindDir = IPStack_Iface_FindDir,
- .IOCtl = IPStack_Iface_IOCtl
+ .Type = &gIP_InterfaceNodeType
},
.Adapter = NULL,
.Type = 0
return &gIP_LoopInterface.Node;
}
- #if 0
- i = 0; num = 0;
- while('0' <= Name[i] && Name[i] <= '9')
- {
- num *= 10;
- num += Name[i] - '0';
- i ++;
- }
- if(Name[i] != '\0') {
- LEAVE('n');
- return NULL;
- }
-
- for( iface = gIP_Interfaces; iface; iface = iface->Next )
- {
- if( (int)iface->Node.ImplInt == num )
- {
- LEAVE('p', &iface->Node);
- return &iface->Node;
- }
- }
- #else
for( iface = gIP_Interfaces; iface; iface = iface->Next )
{
if( strcmp(iface->Name, Name) == 0 )
return &iface->Node;
}
}
- #endif
LEAVE('p', NULL);
return NULL;
{
char name[4] = "";
tInterface *iface = IPStack_AddInterface(Data, name);
+ if(iface == NULL) LEAVE_RET('i', -1);
tmp = iface->Node.ImplInt;
}
LEAVE_RET('i', tmp);
card = IPStack_GetAdapter(Device);
if( !card ) {
+ Log_Debug("IPStack", "Unable to open card '%s'", Device);
LEAVE('n');
return NULL; // ERR_YOURBAD
}
iface->Node.Size = -1;
iface->Node.NumACLs = 1;
iface->Node.ACLs = &gVFS_ACL_EveryoneRX;
- iface->Node.ReadDir = IPStack_Iface_ReadDir;
- iface->Node.FindDir = IPStack_Iface_FindDir;
- iface->Node.IOCtl = IPStack_Iface_IOCtl;
- iface->Node.MkNod = NULL;
- iface->Node.Link = NULL;
- iface->Node.Relink = NULL;
- iface->Node.Close = NULL;
+ iface->Node.Type = &gIP_InterfaceNodeType;
// Set Defaults
iface->TimeoutDelay = DEFAULT_TIMEOUT;
// Delay setting ImplInt until after the adapter is opened
// Keeps things simple
iface->Node.ImplInt = giIP_NextIfaceId++;
- sprintf(iface->Name, "%i", iface->Node.ImplInt);
+ sprintf(iface->Name, "%i", (int)iface->Node.ImplInt);
// Append to list
SHORTLOCK( &glIP_Interfaces );