11 typedef union uIPv4 tIPv4;
12 typedef union uIPv6 tIPv6;
13 typedef struct sMacAddr tMacAddr;
14 typedef struct sAdapter tAdapter;
15 typedef struct sInterface tInterface;
16 typedef struct sSocketFile tSocketFile;
18 typedef void (*tIPCallback)(tInterface *Interface, void *Address, int Length, void *Buffer);
20 enum eInterfaceTypes {
22 AF_INET4 = 4, // tIPv4
29 } __attribute__((packed));
35 } __attribute__((packed));
39 } __attribute__((packed));
42 * \brief Route definition structure
44 typedef struct sRoute {
47 tVFS_Node Node; //!< Node for route manipulation
49 tInterface *Interface; //!< Interface for this route
50 int AddressType; //!< 0: Invalid, 4: IPv4, 6: IPv4
51 void *Network; //!< Network - Pointer to tIPv4/tIPv6/... at end of structure
52 int SubnetBits; //!< Number of bits in \a Network that are valid
53 void *NextHop; //!< Next Hop address - Pointer to tIPv4/tIPv6/... at end of structure
54 int Metric; //!< Route priority
58 struct sInterface *Next; //!< Next interface in list
60 tVFS_Node Node; //!< Node to use the interface
62 tAdapter *Adapter; //!< Adapter the interface is associated with
63 int TimeoutDelay; //!< Time in miliseconds before a packet times out
64 int Type; //!< Interface type, see ::eInterfaceTypes
66 void *Address; //!< IP address (stored after the Name)
67 int SubnetBits; //!< Number of bits that denote the address network
69 tRoute Route; //!< Interface route
75 * \brief Represents a network adapter
78 struct sAdapter *Next;
80 int DeviceFD; //!< File descriptor of the device
81 int NRef; //!< Number of times it's been referenced
83 tMacAddr MacAddr; //!< Physical address of the adapter
84 int DeviceLen; //!< Device name length
85 char Device[]; //!< Device name
89 * \brief Describes a socket file definition
93 struct sSocketFile *Next;
96 tVFS_Node *(*Init)(tInterface *Interface);
99 static const tMacAddr cMAC_BROADCAST = {{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
101 #define MAC_SET(t,v) memcpy(&(t),&(v),sizeof(tMacAddr))
102 #define IP4_SET(t,v) (t).L = (v).L;
103 #define IP6_SET(t,v) memcpy(&(t),&(v),sizeof(tIPv6))
105 #define MAC_EQU(a,b) (memcmp(&(a),&(b),sizeof(tMacAddr))==0)
106 #define IP4_EQU(a,b) ((a).L==(b).L)
107 #define IP6_EQU(a,b) (memcmp(&(a),&(b),sizeof(tIPv6))==0)
111 #define htons(v) BigEndian16(v)
112 #define htonl(v) BigEndian32(v)
114 #define ntohs(v) BigEndian16(v)
115 #define ntohl(v) BigEndian32(v)
117 extern int IPStack_AddFile(tSocketFile *File);
118 extern int IPStack_GetAddressSize(int AddressType);
119 extern int IPStack_CompareAddress(int AddressType, void *Address1, void *Address2, int CheckBits);
120 extern const char *IPStack_PrintAddress(int AddressType, void *Address);
122 extern tRoute *IPStack_FindRoute(int AddressType, tInterface *Interface, void *Address);