SpiderScript! (with a sample script)
[tpg/acess2.git] / Modules / IPStack / ipstack.h
index 8b846ab..4395394 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef _IPSTACK_H_
 #define _IPSTACK_H_
 
-#include <common.h>
+#include <acess.h>
 #include <vfs.h>
 
 typedef union uIPv4    tIPv4;
@@ -13,32 +13,35 @@ typedef union uIPv6 tIPv6;
 typedef struct sMacAddr        tMacAddr;
 typedef struct sAdapter        tAdapter;
 typedef struct sInterface      tInterface;
+typedef struct sSocketFile     tSocketFile;
 
 typedef void   (*tIPCallback)(tInterface *Interface, void *Address, int Length, void *Buffer);
 
 union uIPv4 {
        Uint32  L;
        Uint8   B[4];
-};
+} __attribute__((packed));
 
 union uIPv6 {
+       Uint16  W[8];
        Uint32  L[4];
        Uint8   B[16];
-};
+} __attribute__((packed));
 
 struct sMacAddr {
        Uint8   B[6];
-};
+} __attribute__((packed));
 
 struct sInterface {
        struct sInterface       *Next;
        tVFS_Node       Node;
        tAdapter        *Adapter;
-        int    Type;   // 4 for IPv4 and 6 for IPv6
+        int    TimeoutDelay;   // Time in miliseconds before a packet times out
+        int    Type;   // 0 for disabled, 4 for IPv4 and 6 for IPv6
        union {
                struct  {
                        tIPv6   Address;
-                        int    SubnetBits;
+                        int    SubnetBits;     //Should this be outside the union?
                }       IP6;
                
                struct {
@@ -54,12 +57,24 @@ struct sInterface {
  */
 struct sAdapter {
        struct sAdapter *Next;
-       char    *Device;
+       
         int    DeviceFD;
+        int    NRef;
        
        tMacAddr        MacAddr;
+        int    DeviceLen;
+       char    Device[];
+};
+
+/**
+ * \brief Describes a socket file definition
+ */
+struct sSocketFile
+{
+       struct sSocketFile      *Next;
+       const char      *Name;
        
-       tInterface      *Interfaces;
+       tVFS_Node       *(*Init)(tInterface *Interface);
 };
 
 static const tMacAddr cMAC_BROADCAST = {{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
@@ -68,16 +83,18 @@ static const tMacAddr cMAC_BROADCAST = {{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
 #define IP4_SET(t,v)   (t).L = (v).L;
 #define IP6_SET(t,v)   memcpy(&(t),&(v),sizeof(tIPv6))
 
-#define MAC_EQU(a,b)   memcmp(&(a),&(b),sizeof(tMacAddr))
+#define MAC_EQU(a,b)   (memcmp(&(a),&(b),sizeof(tMacAddr))==0)
 #define IP4_EQU(a,b)   ((a).L==(b).L)
-#define IP6_EQU(a,b)   memcmp(&(a),&(b),sizeof(tIPv6))
+#define IP6_EQU(a,b)   (memcmp(&(a),&(b),sizeof(tIPv6))==0)
 
 // === FUNCTIONS ===
 #define htonb(v)       (v)
-#define htons(in)      BigEndian16(in)
-#define htonl(in)      BigEndian32(in)
+#define htons(v)       BigEndian16(v)
+#define htonl(v)       BigEndian32(v)
 #define ntonb(v)       (v)
-#define ntohs(in)      BigEndian16(in)
-#define ntohl(in)      BigEndian16(in)
+#define ntohs(v)       BigEndian16(v)
+#define ntohl(v)       BigEndian32(v)
+
+extern int     IPStack_AddFile(tSocketFile *File);
 
 #endif

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