ReactOS 0.4.16-dev-87-g3dfbe52
ifenum.h
Go to the documentation of this file.
1/* ifenum.h
2 * Copyright (C) 2003 Juan Lang
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * This module implements functions shared by DLLs that need to enumerate
19 * network interfaces and addresses. It's meant to hide some problematic
20 * defines like socket(), as well as provide only one file
21 * that needs to be ported to implement these functions on different platforms,
22 * since the Windows API provides multiple ways to get at this info.
23 *
24 * Like Windows, it uses a numeric index to identify an interface uniquely.
25 * As implemented, an interface represents a UNIX network interface, virtual
26 * or real, and thus can have 0 or 1 IP addresses associated with it. (This
27 * only supports IPv4.)
28 * The indexes returned are not guaranteed to be contiguous, so don't call
29 * getNumInterfaces() and assume the values [0,getNumInterfaces() - 1] will be
30 * valid indexes; use getInterfaceIndexTable() instead. Non-loopback
31 * interfaces have lower index values than loopback interfaces, in order to
32 * make the indexes somewhat reusable as Netbios LANA numbers. See ifenum.c
33 * for more detail on this.
34 *
35 * See also the companion file, ipstats.h, for functions related to getting
36 * statistics.
37 */
38#ifndef WINE_IFENUM_H_
39#define WINE_IFENUM_H_
40
41//#include <stdarg.h>
42
43//#include "windef.h"
44//#include "winbase.h"
45//#include "iprtrmib.h"
46
47#define MAX_INTERFACE_PHYSADDR 8
48#define MAX_INTERFACE_DESCRIPTION 256
49
50/* Call before using the functions in this module */
51void interfaceMapInit(void);
52/* Call to free resources allocated in interfaceMapInit() */
53void interfaceMapFree(void);
54
57
58/* A table of interface indexes, see get*InterfaceTable(). Ignore numAllocated,
59 * it's used during the creation of the table.
60 */
61typedef struct _InterfaceIndexTable {
66
67/* Returns a table with all known interface indexes, or NULL if one could not
68 * be allocated. free() the returned table.
69 */
71
72/* Like getInterfaceIndexTable, but filters out loopback interfaces. */
74
75/* ByName/ByIndex versions of various getter functions. */
76
77/* can be used as quick check to see if you've got a valid index, returns NULL
78 * if not. The buffer returned may have been allocated. It should be returned
79 * by calling consumeInterfaceNmae.
80 */
82
83/* consume the interface name provided by getInterfaceName. */
84
85void consumeInterfaceName( const char *ifname );
86
87/* Fills index with the index of name, if found. Returns
88 * ERROR_INVALID_PARAMETER if name or index is NULL, ERROR_INVALID_DATA if name
89 * is not found, and NO_ERROR on success.
90 */
92
93/* This bunch returns IP addresses, and INADDR_ANY or INADDR_NONE if not found,
94 * appropriately depending on the f/n.
95 */
102
103/* Gets a few physical charactersistics of a device: MAC addr len, MAC addr,
104 * and type as one of the MIB_IF_TYPEs.
105 * len's in-out: on in, needs to say how many bytes are available in addr,
106 * which to be safe should be MAX_INTERFACE_PHYSADDR. On out, it's how many
107 * bytes were set, or how many were required if addr isn't big enough.
108 * Returns ERROR_INVALID_PARAMETER if name, len, addr, or type is NULL.
109 * Returns ERROR_INVALID_DATA if name/index isn't valid.
110 * Returns ERROR_INSUFFICIENT_BUFFER if addr isn't large enough for the
111 * physical address; *len will contain the required size.
112 * May return other errors, e.g. ERROR_OUTOFMEMORY or ERROR_NO_MORE_FILES,
113 * if internal errors occur.
114 * Returns NO_ERROR on success.
115 */
117 PDWORD type);
119 PDWORD type);
120
121/* Get the operational status as a (MIB_)IF_OPER_STATUS type.
122 */
125
126DWORD getInterfaceMtuByName(const char *name, PDWORD mtu);
128
129/* Fills in the MIB_IFROW by name/index. Doesn't fill in interface statistics,
130 * see ipstats.h for that.
131 * Returns ERROR_INVALID_PARAMETER if name or entry is NULL, ERROR_INVALID_DATA
132 * if name/index isn't valid, and NO_ERROR otherwise.
133 */
136
137/* Converts the network-order bytes in addr to a printable string. Returns
138 * string.
139 */
140char *toIPAddressString(unsigned int addr, char string[16]);
141
142/* add and delete IP addresses */
144 PULONG NteContext, PULONG NteInstance );
145NTSTATUS deleteIpAddress( ULONG NteContext );
146
147/* Inserts a route into the route table. */
149
150BOOL isLoopback( HANDLE tcpFile, TDIEntityID *loop_maybe );
151
152#endif /* ndef WINE_IFENUM_H_ */
LONG NTSTATUS
Definition: precomp.h:26
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int Mask
Definition: fpcontrol.c:82
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
void interfaceMapFree(void)
DWORD getInterfaceStatusByName(const char *name, PDWORD status)
DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr, PDWORD type)
DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry)
DWORD getInterfaceMtuByName(const char *name, PDWORD mtu)
DWORD getNumNonLoopbackInterfaces(void)
struct _InterfaceIndexTable InterfaceIndexTable
DWORD getNumInterfaces(void)
DWORD getInterfaceBCastAddrByName(const char *name)
DWORD getInterfaceStatusByIndex(DWORD index, PDWORD status)
DWORD getInterfaceMaskByIndex(DWORD index)
InterfaceIndexTable * getNonLoopbackInterfaceIndexTable(void)
DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry)
DWORD getInterfaceMtuByIndex(DWORD index, PDWORD mtu)
const char * getInterfaceNameByIndex(DWORD index)
DWORD getInterfaceBCastAddrByIndex(DWORD index)
DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr, PDWORD type)
DWORD getInterfaceMaskByName(const char *name)
DWORD getInterfaceIPAddrByName(const char *name)
DWORD getInterfaceIndexByName(const char *name, PDWORD index)
DWORD createIpForwardEntryOS(PMIB_IPFORWARDROW pRoute)
void interfaceMapInit(void)
InterfaceIndexTable * getInterfaceIndexTable(void)
char * toIPAddressString(unsigned int addr, char string[16])
NTSTATUS addIPAddress(IPAddr Address, IPMask Mask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
DWORD getInterfaceIPAddrByIndex(DWORD index)
NTSTATUS deleteIpAddress(ULONG NteContext)
void consumeInterfaceName(const char *ifname)
BOOL isLoopback(HANDLE tcpFile, TDIEntityID *loop_maybe)
ULONG IPMask
Definition: ipexport.h:28
uint32_t entry
Definition: isohybrid.c:63
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
ULONG IPAddr
Definition: pfhook.h:35
static WCHAR Address[46]
Definition: ping.c:68
DWORD numAllocated
Definition: ifenum.h:63
DWORD indexes[1]
Definition: ifenum.h:64
Definition: name.c:39
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59