Adding several modules to the Tree, plus some files that escaped earlier
[tpg/acess2.git] / Modules / IPStack / main.c
1 /*
2  * Acess2 IP Stack
3  * - Address Resolution Protocol
4  */
5 #include "ipstack.h"
6 #include <modules.h>
7 #include <fs_devfs.h>
8
9 // === IMPORTS ===
10  int    ARP_Initialise();
11
12 // === PROTOTYPES ===
13  int    IPStack_Install(char **Arguments);
14 char    *IPStack_ReadDir(tVFS_Node *Node, int Pos);
15 tVFS_Node       *IPStack_FindDir(tVFS_Node *Node, char *Name);
16
17 // === GLOBALS ===
18 MODULE_DEFINE(0, 0x000A, IPStack, IPStack_Install, NULL);
19 tDevFS_Driver   gIP_DriverInfo = {
20         NULL, "ip",
21         {
22         .NumACLs = 1,
23         .ACLs = &gVFS_ACL_EveryoneRX,
24         .Flags = VFS_FFLAG_DIRECTORY,
25         .ReadDir = IPStack_ReadDir,
26         .FindDir = IPStack_FindDir
27         }
28 };
29  int    giIP_NumInterfaces;
30 tInterface      *gIP_Interfaces = NULL;
31
32 // === CODE ===
33 /**
34  * \fn int IPStack_Install(char **Arguments)
35  * \brief Intialise the relevant parts of the stack and register with DevFS
36  */
37 int IPStack_Install(char **Arguments)
38 {
39          int    i = 0;
40         
41         // Install Handlers
42         ARP_Initialise();
43         
44         // Parse module arguments
45         for( i = 0; Arguments[i]; i++ )
46         {
47                 //if(strcmp(Arguments[i], "Device") == '=') {
48                 //      
49                 //}
50         }
51         
52         return 1;
53 }
54
55 /**
56  * \brief Read from the IP Stack's Device Directory
57  */
58 char *IPStack_ReadDir(tVFS_Node *Node, int Pos)
59 {
60         tInterface      *iface;
61         char    name[5] = "ip0\0\0";
62         
63         // Create the name
64         if(Pos < 10)
65                 name[2] = '0' + Pos;
66         else {
67                 name[2] = '0' + Pos/10;
68                 name[3] = '0' + Pos%10;
69         }
70         
71         // Traverse the list
72         for( iface = gIP_Interfaces; iface && Pos--; iface = iface->Next ) ;
73         
74         // Did we run off the end?
75         if(!iface)      return NULL;
76         
77         // Return the pre-generated name
78         return strdup(name);
79 }
80
81 /**
82  * \brief Get the node of an interface
83  */
84 tVFS_Node *IPStack_FindDir(tVFS_Node *Node, char *Name)
85 {
86         return NULL;
87 }

UCC git Repository :: git.ucc.asn.au