2003-05-13 05:32:20 +02:00
|
|
|
/* ifenum.h
|
2006-01-25 13:14:12 +01:00
|
|
|
* Copyright (C) 2003,2006 Juan Lang
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2006-01-20 16:16:56 +01:00
|
|
|
* This module implements network interface and address enumeration. It's
|
|
|
|
* meant to hide some problematic defines like socket(), and make iphlpapi
|
|
|
|
* more portable.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* Like Windows, it uses a numeric index to identify an interface uniquely.
|
|
|
|
* As implemented, an interface represents a UNIX network interface, virtual
|
|
|
|
* or real, and thus can have 0 or 1 IP addresses associated with it. (This
|
|
|
|
* only supports IPv4.)
|
|
|
|
* The indexes returned are not guaranteed to be contiguous, so don't call
|
|
|
|
* getNumInterfaces() and assume the values [0,getNumInterfaces() - 1] will be
|
2004-02-09 21:54:28 +01:00
|
|
|
* valid indexes; use getInterfaceIndexTable() instead.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* See also the companion file, ipstats.h, for functions related to getting
|
|
|
|
* statistics.
|
|
|
|
*/
|
|
|
|
#ifndef WINE_IFENUM_H_
|
|
|
|
#define WINE_IFENUM_H_
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2003-05-13 05:32:20 +02:00
|
|
|
#include "iprtrmib.h"
|
2010-03-12 03:36:46 +01:00
|
|
|
#define USE_WS_PREFIX
|
|
|
|
#include "winsock2.h"
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
#define MAX_INTERFACE_PHYSADDR 8
|
|
|
|
#define MAX_INTERFACE_DESCRIPTION 256
|
|
|
|
|
2011-05-13 17:18:56 +02:00
|
|
|
DWORD getNumInterfaces(void) DECLSPEC_HIDDEN;
|
|
|
|
DWORD getNumNonLoopbackInterfaces(void) DECLSPEC_HIDDEN;
|
|
|
|
BOOL isIfIndexLoopback(ULONG idx) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2006-01-27 19:19:32 +01:00
|
|
|
/* A table of interface indexes, see get*InterfaceTable(). */
|
2003-05-13 05:32:20 +02:00
|
|
|
typedef struct _InterfaceIndexTable {
|
|
|
|
DWORD numIndexes;
|
|
|
|
DWORD indexes[1];
|
|
|
|
} InterfaceIndexTable;
|
|
|
|
|
|
|
|
/* Returns a table with all known interface indexes, or NULL if one could not
|
2004-12-13 14:21:39 +01:00
|
|
|
* be allocated. HeapFree() the returned table.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
InterfaceIndexTable *getInterfaceIndexTable(void) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
/* Like getInterfaceIndexTable, but filters out loopback interfaces. */
|
2011-05-13 17:18:56 +02:00
|
|
|
InterfaceIndexTable *getNonLoopbackInterfaceIndexTable(void) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
/* ByName/ByIndex versions of various getter functions. */
|
|
|
|
|
|
|
|
/* can be used as quick check to see if you've got a valid index, returns NULL
|
2006-01-27 19:19:32 +01:00
|
|
|
* if not. Overwrites your buffer, which should be at least of size
|
|
|
|
* MAX_ADAPTER_NAME.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
char *getInterfaceNameByIndex(DWORD index, char *name) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
/* Fills index with the index of name, if found. Returns
|
|
|
|
* ERROR_INVALID_PARAMETER if name or index is NULL, ERROR_INVALID_DATA if name
|
|
|
|
* is not found, and NO_ERROR on success.
|
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
DWORD getInterfaceIndexByName(const char *name, PDWORD index) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2008-04-03 19:10:30 +02:00
|
|
|
/* Gets a few physical characteristics of a device: MAC addr len, MAC addr,
|
2003-05-13 05:32:20 +02:00
|
|
|
* and type as one of the MIB_IF_TYPEs.
|
|
|
|
* len's in-out: on in, needs to say how many bytes are available in addr,
|
|
|
|
* which to be safe should be MAX_INTERFACE_PHYSADDR. On out, it's how many
|
|
|
|
* bytes were set, or how many were required if addr isn't big enough.
|
|
|
|
* Returns ERROR_INVALID_PARAMETER if name, len, addr, or type is NULL.
|
|
|
|
* Returns ERROR_INVALID_DATA if name/index isn't valid.
|
|
|
|
* Returns ERROR_INSUFFICIENT_BUFFER if addr isn't large enough for the
|
|
|
|
* physical address; *len will contain the required size.
|
|
|
|
* May return other errors, e.g. ERROR_OUTOFMEMORY or ERROR_NO_MORE_FILES,
|
|
|
|
* if internal errors occur.
|
|
|
|
* Returns NO_ERROR on success.
|
|
|
|
*/
|
|
|
|
DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr,
|
2011-05-13 17:18:56 +02:00
|
|
|
PDWORD type) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2009-01-08 21:15:00 +01:00
|
|
|
/* Fills in the MIB_IFROW by name. Doesn't fill in interface statistics,
|
2003-05-13 05:32:20 +02:00
|
|
|
* see ipstats.h for that.
|
2009-01-08 21:15:00 +01:00
|
|
|
* Returns ERROR_INVALID_PARAMETER if name is NULL, ERROR_INVALID_DATA
|
|
|
|
* if name isn't valid, and NO_ERROR otherwise.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2011-05-13 17:18:56 +02:00
|
|
|
DWORD getNumIPAddresses(void) DECLSPEC_HIDDEN;
|
2006-01-25 13:14:12 +01:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
/* Gets the configured IP addresses for the system, and sets *ppIpAddrTable to
|
|
|
|
* a table of them allocated from heap, or NULL if out of memory. Returns
|
|
|
|
* NO_ERROR on success, something else on failure. Note there may be more than
|
|
|
|
* one IP address may exist per interface.
|
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
DWORD getIPAddrTable(PMIB_IPADDRTABLE *ppIpAddrTable, HANDLE heap, DWORD flags) DECLSPEC_HIDDEN;
|
2006-01-24 12:18:50 +01:00
|
|
|
|
2010-03-12 03:36:46 +01:00
|
|
|
/* Returns the IPv6 addresses for a particular interface index.
|
|
|
|
* Returns NO_ERROR on success, something else on failure.
|
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
ULONG v6addressesFromIndex(DWORD index, SOCKET_ADDRESS **addrs, ULONG *num_addrs) DECLSPEC_HIDDEN;
|
2010-03-12 03:36:46 +01:00
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
/* Converts the network-order bytes in addr to a printable string. Returns
|
|
|
|
* string.
|
|
|
|
*/
|
2011-05-13 17:18:56 +02:00
|
|
|
char *toIPAddressString(unsigned int addr, char string[16]) DECLSPEC_HIDDEN;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2011-05-13 17:18:56 +02:00
|
|
|
DWORD getInterfaceMtuByName(const char *name, PDWORD mtu) DECLSPEC_HIDDEN;
|
|
|
|
DWORD getInterfaceStatusByName(const char *name, PDWORD status) DECLSPEC_HIDDEN;
|
2009-04-29 11:41:02 +02:00
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
#endif /* ndef WINE_IFENUM_H_ */
|