3 * This header file includes #defines, structure and type definitions,
4 * and function declarations that support the implementation of the
5 * (undocumented) Winsock 1 call WsControl.
7 * The functionality of WsControl was created by observing its behaviour
8 * in Windows 98, so there are likely to be bugs with the assumptions
12 #ifndef WSCONTROL_H_INCLUDED
13 #define WSCONTROL_H_INCLUDED
15 typedef unsigned char uchar; /* This doesn't seem to be in any standard headers */
17 #define WSCTL_SUCCESS 0
18 #define PROCFS_NETDEV_FILE "/proc/net/dev" /* Points to the file in the /proc fs
19 that lists the network devices.
20 Do we need an #ifdef LINUX for this? */
21 #define PROCFS_ROUTE_FILE "/proc/net/route" /* Points to the file in the /proc fs
22 that contains the routing table */
23 #define WSCNTL_COUNT_INTERFACES 1
24 #define WSCNTL_COUNT_ROUTES 2
26 /* struct contains a routing table entry */
27 typedef struct wscntl_routeentry
29 unsigned long wre_intf;
30 unsigned long wre_dest;
32 unsigned long wre_mask;
33 unsigned long wre_metric;
36 /* WsControl Helper Functions */
37 int WSCNTL_GetEntryCount(const int); /* Obtains the number of network interfaces/routes */
38 int WSCNTL_GetInterfaceName(int, char *); /* Obtains the name of an interface */
39 int WSCNTL_GetTransRecvStat(int intNumber, unsigned long *transBytes,
40 unsigned long *recvBytes); /* Obtains bytes recv'd/trans by interface */
41 int WSCNTL_GetRouteTable(int numRoutes, wscntl_routeentry *routeTable); /* get the routing for the interface intf */
44 * TCP/IP action codes.
46 #define WSCNTL_TCPIP_QUERY_INFO 0x00000000
47 #define WSCNTL_TCPIP_SET_INFO 0x00000001
48 #define WSCNTL_TCPIP_ICMP_ECHO 0x00000002
49 #define WSCNTL_TCPIP_TEST 0x00000003
52 /* Structure of an entity ID */
53 typedef struct TDIEntityID
55 unsigned long tei_entity;
56 unsigned long tei_instance;
59 /* Structure of an object ID */
60 typedef struct TDIObjectID
62 TDIEntityID toi_entity;
63 unsigned long toi_class;
64 unsigned long toi_type;
68 typedef struct IPSNMPInfo
70 unsigned long ipsi_forwarding;
71 unsigned long ipsi_defaultttl;
72 unsigned long ipsi_inreceives;
73 unsigned long ipsi_inhdrerrors;
74 unsigned long ipsi_inaddrerrors;
75 unsigned long ipsi_forwdatagrams;
76 unsigned long ipsi_inunknownprotos;
77 unsigned long ipsi_indiscards;
78 unsigned long ipsi_indelivers;
79 unsigned long ipsi_outrequests;
80 unsigned long ipsi_routingdiscards;
81 unsigned long ipsi_outdiscards;
82 unsigned long ipsi_outnoroutes;
83 unsigned long ipsi_reasmtimeout;
84 unsigned long ipsi_reasmreqds;
85 unsigned long ipsi_reasmoks;
86 unsigned long ipsi_reasmfails;
87 unsigned long ipsi_fragoks;
88 unsigned long ipsi_fragfails;
89 unsigned long ipsi_fragcreates;
90 unsigned long ipsi_numif;
91 unsigned long ipsi_numaddr;
92 unsigned long ipsi_numroutes;
95 typedef struct IPAddrEntry
97 unsigned long iae_addr;
98 unsigned long iae_index;
99 unsigned long iae_mask;
100 unsigned long iae_bcastaddr;
101 unsigned long iae_reasmsize;
107 #define MAX_PHYSADDR_SIZE 8
108 #define MAX_IFDESCR_LEN 256
109 typedef struct IFEntry
111 unsigned long if_index;
112 unsigned long if_type;
113 unsigned long if_mtu;
114 unsigned long if_speed;
115 unsigned long if_physaddrlen;
116 uchar if_physaddr[MAX_PHYSADDR_SIZE];
117 unsigned long if_adminstatus;
118 unsigned long if_operstatus;
119 unsigned long if_lastchange;
120 unsigned long if_inoctets;
121 unsigned long if_inucastpkts;
122 unsigned long if_innucastpkts;
123 unsigned long if_indiscards;
124 unsigned long if_inerrors;
125 unsigned long if_inunknownprotos;
126 unsigned long if_outoctets;
127 unsigned long if_outucastpkts;
128 unsigned long if_outnucastpkts;
129 unsigned long if_outdiscards;
130 unsigned long if_outerrors;
131 unsigned long if_outqlen;
132 unsigned long if_descrlen;
137 /* FIXME: real name and definition of this struct that contains
138 * an IP route table entry is unknown */
139 typedef struct IPRouteEntry {
140 unsigned long ire_addr;
141 unsigned long ire_index; //matches if_index in IFEntry and iae_index in IPAddrEntry
142 unsigned long ire_metric;
143 unsigned long ire_option4;
144 unsigned long ire_option5;
145 unsigned long ire_option6;
146 unsigned long ire_gw;
147 unsigned long ire_option8;
148 unsigned long ire_option9;
149 unsigned long ire_option10;
150 unsigned long ire_mask;
151 unsigned long ire_option12;
155 /* Not sure what EXACTLY most of this stuff does.
156 WsControl was implemented mainly by observing
157 its behaviour in Win98 ************************/
158 #define INFO_CLASS_GENERIC 0x100
159 #define INFO_CLASS_PROTOCOL 0x200
160 #define INFO_TYPE_PROVIDER 0x100
161 #define ENTITY_LIST_ID 0
162 #define CL_NL_ENTITY 0x301
163 #define IF_ENTITY 0x200
164 #define ENTITY_TYPE_ID 1
165 #define IP_MIB_ADDRTABLE_ENTRY_ID 0x102
166 #define IP_MIB_ROUTETABLE_ENTRY_ID 0x101 /* FIXME: not real name */
167 /************************************************/
169 /* Valid values to get back from entity type ID query */
170 #define CO_TL_NBF 0x400 /* Entity implements NBF prot. */
171 #define CO_TL_SPX 0x402 /* Entity implements SPX prot. */
172 #define CO_TL_TCP 0x404 /* Entity implements TCP prot. */
173 #define CO_TL_SPP 0x406 /* Entity implements SPP prot. */
174 #define CL_TL_NBF 0x401 /* CL NBF protocol */
175 #define CL_TL_UDP 0x403 /* Entity implements UDP */
176 #define ER_ICMP 0x380 /* The ICMP protocol */
177 #define CL_NL_IPX 0x301 /* Entity implements IPX */
178 #define CL_NL_IP 0x303 /* Entity implements IP */
179 #define AT_ARP 0x280 /* Entity implements ARP */
180 #define AT_NULL 0x282 /* Entity does no address */
181 #define IF_GENERIC 0x200 /* Generic interface */
182 #define IF_MIB 0x202 /* Supports MIB-2 interface */
185 #endif /* WSCONTROL_H_INCLUDED */