git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Networking - Working on DHCP client (and related changes)
[tpg/acess2.git]
/
Modules
/
IPStack
/
interface.c
diff --git
a/Modules/IPStack/interface.c
b/Modules/IPStack/interface.c
index
74f0cf8
..
b0b63b9
100644
(file)
--- a/
Modules/IPStack/interface.c
+++ b/
Modules/IPStack/interface.c
@@
-6,8
+6,8
@@
#define VERSION VER2(0,10)
#include "ipstack.h"
#include "link.h"
#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
// === CONSTANTS ===
//! Default timeout value, 30 seconds
@@
-32,6
+32,11
@@
tVFS_Node *IPStack_Iface_FindDir(tVFS_Node *Node, const char *Name);
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data);
// === GLOBALS ===
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 = {
//! Loopback (127.0.0.0/8, ::1) Pseudo-Interface
tInterface gIP_LoopInterface = {
.Node = {
@@
-40,9
+45,7
@@
tInterface gIP_LoopInterface = {
.Size = -1,
.NumACLs = 1,
.ACLs = &gVFS_ACL_EveryoneRX,
.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
},
.Adapter = NULL,
.Type = 0
@@
-75,10
+78,12
@@
char *IPStack_Root_ReadDir(tVFS_Node *Node, int Pos)
// Routing Subdir
if( Pos == 0 ) {
// Routing Subdir
if( Pos == 0 ) {
+ LEAVE('s', "routes");
return strdup("routes");
}
// Pseudo Interfaces
if( Pos == 1 ) {
return strdup("routes");
}
// Pseudo Interfaces
if( Pos == 1 ) {
+ LEAVE('s', "lo");
return strdup("lo");
}
Pos -= 2;
return strdup("lo");
}
Pos -= 2;
@@
-136,11
+141,13
@@
tVFS_Node *IPStack_Root_FindDir(tVFS_Node *Node, const char *Name)
// Routing subdir
if( strcmp(Name, "routes") == 0 ) {
// Routing subdir
if( strcmp(Name, "routes") == 0 ) {
+ LEAVE('p', &gIP_RouteNode);
return &gIP_RouteNode;
}
// Loopback
if( strcmp(Name, "lo") == 0 ) {
return &gIP_RouteNode;
}
// Loopback
if( strcmp(Name, "lo") == 0 ) {
+ LEAVE('p', &gIP_LoopInterface.Node);
return &gIP_LoopInterface.Node;
}
return &gIP_LoopInterface.Node;
}
@@
-178,6
+185,7
@@
int IPStack_Root_IOCtl(tVFS_Node *Node, int ID, void *Data)
case 4:
if( Threads_GetUID() != 0 ) LEAVE_RET('i', -1);
if( !CheckString( Data ) ) LEAVE_RET('i', -1);
case 4:
if( Threads_GetUID() != 0 ) LEAVE_RET('i', -1);
if( !CheckString( Data ) ) LEAVE_RET('i', -1);
+ LOG("New interface for '%s'", Data);
{
char name[4] = "";
tInterface *iface = IPStack_AddInterface(Data, name);
{
char name[4] = "";
tInterface *iface = IPStack_AddInterface(Data, name);
@@
-234,13
+242,7
@@
tInterface *IPStack_AddInterface(const char *Device, const char *Name)
iface->Node.Size = -1;
iface->Node.NumACLs = 1;
iface->Node.ACLs = &gVFS_ACL_EveryoneRX;
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;
// Set Defaults
iface->TimeoutDelay = DEFAULT_TIMEOUT;
@@
-251,7
+253,7
@@
tInterface *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++;
// 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 );
// Append to list
SHORTLOCK( &glIP_Interfaces );
@@
-367,6
+369,7
@@
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data)
// Set type
iface->Type = *(int*)Data;
// Set type
iface->Type = *(int*)Data;
+ LOG("Interface type set to %i", iface->Type);
size = IPStack_GetAddressSize(iface->Type);
// Check it's actually valid
if( iface->Type != 0 && size == 0 ) {
size = IPStack_GetAddressSize(iface->Type);
// Check it's actually valid
if( iface->Type != 0 && size == 0 ) {
@@
-402,9
+405,9
@@
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data)
size = IPStack_GetAddressSize(iface->Type);
if( !CheckMem( Data, size ) ) LEAVE_RET('i', -1);
// TODO: Protect against trashing
size = IPStack_GetAddressSize(iface->Type);
if( !CheckMem( Data, size ) ) LEAVE_RET('i', -1);
// TODO: Protect against trashing
+ LOG("Interface address set to '%s'", IPStack_PrintAddress(iface->Type, Data));
memcpy( iface->Address, Data, size );
memcpy( iface->Address, Data, size );
- LEAVE('i', 1);
- return 1;
+ LEAVE_RET('i', 1);
/*
* getset_subnet
/*
* getset_subnet
@@
-422,12
+425,11
@@
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data)
// Is the mask sane?
if( *(int*)Data < 0 || *(int*)Data > IPStack_GetAddressSize(iface->Type)*8-1 )
LEAVE_RET('i', -1);
// Is the mask sane?
if( *(int*)Data < 0 || *(int*)Data > IPStack_GetAddressSize(iface->Type)*8-1 )
LEAVE_RET('i', -1);
-
+ LOG("Set subnet bits to %i", *(int*)Data);
// Ok, set it
iface->SubnetBits = *(int*)Data;
}
// Ok, set it
iface->SubnetBits = *(int*)Data;
}
- LEAVE('i', iface->SubnetBits);
- return iface->SubnetBits;
+ LEAVE_RET('i', iface->SubnetBits);
/*
* get_device
/*
* get_device
@@
-441,7
+443,7
@@
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data)
if( !CheckMem( Data, iface->Adapter->DeviceLen+1 ) )
LEAVE_RET('i', -1);
strcpy( Data, iface->Adapter->Device );
if( !CheckMem( Data, iface->Adapter->DeviceLen+1 ) )
LEAVE_RET('i', -1);
strcpy( Data, iface->Adapter->Device );
-
return iface->Adapter->DeviceLen
;
+
LEAVE_RET('i', iface->Adapter->DeviceLen)
;
/*
* ping
/*
* ping
@@
-456,8
+458,7
@@
int IPStack_Iface_IOCtl(tVFS_Node *Node, int ID, void *Data)
case 4:
if( !CheckMem( Data, sizeof(tIPv4) ) ) LEAVE_RET('i', -1);
tmp = IPv4_Ping(iface, *(tIPv4*)Data);
case 4:
if( !CheckMem( Data, sizeof(tIPv4) ) ) LEAVE_RET('i', -1);
tmp = IPv4_Ping(iface, *(tIPv4*)Data);
- LEAVE('i', tmp);
- return tmp;
+ LEAVE_RET('i', tmp);
case 6:
LEAVE_RET('i', 1);
case 6:
LEAVE_RET('i', 1);
UCC
git Repository :: git.ucc.asn.au