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
11 * Copyright 2000 James Hatheway
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef WSCONTROL_H_INCLUDED
29 #define WSCONTROL_H_INCLUDED
31 typedef unsigned char uchar
; /* This doesn't seem to be in any standard headers */
33 #define WSCTL_SUCCESS 0
34 #define PROCFS_NETDEV_FILE "/proc/net/dev" /* Points to the file in the /proc fs
35 that lists the network devices.
36 Do we need an #ifdef LINUX for this? */
37 #define PROCFS_ROUTE_FILE "/proc/net/route" /* Points to the file in the /proc fs
38 that contains the routing table */
39 #define WSCNTL_COUNT_INTERFACES 1
40 #define WSCNTL_COUNT_ROUTES 2
42 /* struct contains a routing table entry */
43 typedef struct wscntl_routeentry
45 unsigned long wre_intf
;
46 unsigned long wre_dest
;
48 unsigned long wre_mask
;
49 unsigned long wre_metric
;
52 /* WsControl Helper Functions */
53 int WSCNTL_GetEntryCount(const int); /* Obtains the number of network interfaces/routes */
54 int WSCNTL_GetInterfaceName(int, char *); /* Obtains the name of an interface */
55 int WSCNTL_GetTransRecvStat(int intNumber
, unsigned long *transBytes
,
56 unsigned long *recvBytes
); /* Obtains bytes recv'd/trans by interface */
57 int WSCNTL_GetRouteTable(int numRoutes
, wscntl_routeentry
*routeTable
); /* get the routing for the interface intf */
60 * TCP/IP action codes.
62 #define WSCNTL_TCPIP_QUERY_INFO 0x00000000
63 #define WSCNTL_TCPIP_SET_INFO 0x00000001
64 #define WSCNTL_TCPIP_ICMP_ECHO 0x00000002
65 #define WSCNTL_TCPIP_TEST 0x00000003
68 /* Structure of an entity ID */
69 typedef struct TDIEntityID
71 unsigned long tei_entity
;
72 unsigned long tei_instance
;
75 /* Structure of an object ID */
76 typedef struct TDIObjectID
78 TDIEntityID toi_entity
;
79 unsigned long toi_class
;
80 unsigned long toi_type
;
84 typedef struct IPSNMPInfo
86 unsigned long ipsi_forwarding
;
87 unsigned long ipsi_defaultttl
;
88 unsigned long ipsi_inreceives
;
89 unsigned long ipsi_inhdrerrors
;
90 unsigned long ipsi_inaddrerrors
;
91 unsigned long ipsi_forwdatagrams
;
92 unsigned long ipsi_inunknownprotos
;
93 unsigned long ipsi_indiscards
;
94 unsigned long ipsi_indelivers
;
95 unsigned long ipsi_outrequests
;
96 unsigned long ipsi_routingdiscards
;
97 unsigned long ipsi_outdiscards
;
98 unsigned long ipsi_outnoroutes
;
99 unsigned long ipsi_reasmtimeout
;
100 unsigned long ipsi_reasmreqds
;
101 unsigned long ipsi_reasmoks
;
102 unsigned long ipsi_reasmfails
;
103 unsigned long ipsi_fragoks
;
104 unsigned long ipsi_fragfails
;
105 unsigned long ipsi_fragcreates
;
106 unsigned long ipsi_numif
;
107 unsigned long ipsi_numaddr
;
108 unsigned long ipsi_numroutes
;
111 typedef struct IPAddrEntry
113 unsigned long iae_addr
;
114 unsigned long iae_index
;
115 unsigned long iae_mask
;
116 unsigned long iae_bcastaddr
;
117 unsigned long iae_reasmsize
;
128 #define MAX_PHYSADDR_SIZE 8
129 #define MAX_IFDESCR_LEN 256
130 typedef struct IFEntry
132 unsigned long if_index
;
133 unsigned long if_type
;
134 unsigned long if_mtu
;
135 unsigned long if_speed
;
136 unsigned long if_physaddrlen
;
137 uchar if_physaddr
[MAX_PHYSADDR_SIZE
];
138 unsigned long if_adminstatus
;
139 unsigned long if_operstatus
;
140 unsigned long if_lastchange
;
141 unsigned long if_inoctets
;
142 unsigned long if_inucastpkts
;
143 unsigned long if_innucastpkts
;
144 unsigned long if_indiscards
;
145 unsigned long if_inerrors
;
146 unsigned long if_inunknownprotos
;
147 unsigned long if_outoctets
;
148 unsigned long if_outucastpkts
;
149 unsigned long if_outnucastpkts
;
150 unsigned long if_outdiscards
;
151 unsigned long if_outerrors
;
152 unsigned long if_outqlen
;
153 unsigned long if_descrlen
;
158 /* FIXME: real name and definition of this struct that contains
159 * an IP route table entry is unknown */
160 typedef struct IPRouteEntry
{
161 unsigned long ire_addr
;
162 unsigned long ire_index
; //matches if_index in IFEntry and iae_index in IPAddrEntry
163 unsigned long ire_metric
;
164 unsigned long ire_option4
;
165 unsigned long ire_option5
;
166 unsigned long ire_option6
;
167 unsigned long ire_gw
;
168 unsigned long ire_option8
;
169 unsigned long ire_option9
;
170 unsigned long ire_option10
;
171 unsigned long ire_mask
;
172 unsigned long ire_option12
;
176 /* Not sure what EXACTLY most of this stuff does.
177 WsControl was implemented mainly by observing
178 its behaviour in Win98 ************************/
179 #define INFO_CLASS_GENERIC 0x100
180 #define INFO_CLASS_PROTOCOL 0x200
181 #define INFO_TYPE_PROVIDER 0x100
182 #define ENTITY_LIST_ID 0
183 #define CL_NL_ENTITY 0x301
184 #define IF_ENTITY 0x200
185 #define ENTITY_TYPE_ID 1
186 #define IP_MIB_ADDRTABLE_ENTRY_ID 0x102
187 #define IP_MIB_ROUTETABLE_ENTRY_ID 0x101 /* FIXME: not real name */
188 /************************************************/
190 /* Valid values to get back from entity type ID query */
191 #define CO_TL_NBF 0x400 /* Entity implements NBF prot. */
192 #define CO_TL_SPX 0x402 /* Entity implements SPX prot. */
193 #define CO_TL_TCP 0x404 /* Entity implements TCP prot. */
194 #define CO_TL_SPP 0x406 /* Entity implements SPP prot. */
195 #define CL_TL_NBF 0x401 /* CL NBF protocol */
196 #define CL_TL_UDP 0x403 /* Entity implements UDP */
197 #define ER_ICMP 0x380 /* The ICMP protocol */
198 #define CL_NL_IPX 0x301 /* Entity implements IPX */
199 #define CL_NL_IP 0x303 /* Entity implements IP */
200 #define AT_ARP 0x280 /* Entity implements ARP */
201 #define AT_NULL 0x282 /* Entity does no address */
202 #define IF_GENERIC 0x200 /* Generic interface */
203 #define IF_MIB 0x202 /* Supports MIB-2 interface */
206 #endif /* WSCONTROL_H_INCLUDED */