ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ifenum.h
Go to the documentation of this file.
00001 /* ifenum.h
00002  * Copyright (C) 2003 Juan Lang
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  *
00018  * This module implements functions shared by DLLs that need to enumerate
00019  * network interfaces and addresses.  It's meant to hide some problematic
00020  * defines like socket(), as well as provide only one file
00021  * that needs to be ported to implement these functions on different platforms,
00022  * since the Windows API provides multiple ways to get at this info.
00023  *
00024  * Like Windows, it uses a numeric index to identify an interface uniquely.
00025  * As implemented, an interface represents a UNIX network interface, virtual
00026  * or real, and thus can have 0 or 1 IP addresses associated with it.  (This
00027  * only supports IPv4.)
00028  * The indexes returned are not guaranteed to be contiguous, so don't call
00029  * getNumInterfaces() and assume the values [0,getNumInterfaces() - 1] will be
00030  * valid indexes; use getInterfaceIndexTable() instead.  Non-loopback
00031  * interfaces have lower index values than loopback interfaces, in order to
00032  * make the indexes somewhat reusable as Netbios LANA numbers.  See ifenum.c
00033  * for more detail on this.
00034  *
00035  * See also the companion file, ipstats.h, for functions related to getting
00036  * statistics.
00037  */
00038 #ifndef WINE_IFENUM_H_
00039 #define WINE_IFENUM_H_
00040 
00041 #include <stdarg.h>
00042 
00043 #include "windef.h"
00044 #include "winbase.h"
00045 #include "iprtrmib.h"
00046 
00047 #define MAX_INTERFACE_PHYSADDR    8
00048 #define MAX_INTERFACE_DESCRIPTION 256
00049 
00050 /* Call before using the functions in this module */
00051 void interfaceMapInit(void);
00052 /* Call to free resources allocated in interfaceMapInit() */
00053 void interfaceMapFree(void);
00054 
00055 DWORD getNumInterfaces(void);
00056 DWORD getNumNonLoopbackInterfaces(void);
00057 
00058 /* A table of interface indexes, see get*InterfaceTable().  Ignore numAllocated,
00059  * it's used during the creation of the table.
00060  */
00061 typedef struct _InterfaceIndexTable {
00062   DWORD numIndexes;
00063   DWORD numAllocated;
00064   DWORD indexes[1];
00065 } InterfaceIndexTable;
00066 
00067 /* Returns a table with all known interface indexes, or NULL if one could not
00068  * be allocated.  free() the returned table.
00069  */
00070 InterfaceIndexTable *getInterfaceIndexTable(void);
00071 
00072 /* Like getInterfaceIndexTable, but filters out loopback interfaces. */
00073 InterfaceIndexTable *getNonLoopbackInterfaceIndexTable(void);
00074 
00075 /* ByName/ByIndex versions of various getter functions. */
00076 
00077 /* can be used as quick check to see if you've got a valid index, returns NULL
00078  * if not.  The buffer returned may have been allocated.  It should be returned
00079  * by calling consumeInterfaceNmae.
00080  */
00081 const char *getInterfaceNameByIndex(DWORD index);
00082 
00083 /* consume the interface name provided by getInterfaceName. */
00084 
00085 void consumeInterfaceName( const char *ifname );
00086 
00087 /* Fills index with the index of name, if found.  Returns
00088  * ERROR_INVALID_PARAMETER if name or index is NULL, ERROR_INVALID_DATA if name
00089  * is not found, and NO_ERROR on success.
00090  */
00091 DWORD getInterfaceIndexByName(const char *name, PDWORD index);
00092 
00093 /* This bunch returns IP addresses, and INADDR_ANY or INADDR_NONE if not found,
00094  * appropriately depending on the f/n.
00095  */
00096 DWORD getInterfaceIPAddrByName(const char *name);
00097 DWORD getInterfaceIPAddrByIndex(DWORD index);
00098 DWORD getInterfaceMaskByName(const char *name);
00099 DWORD getInterfaceMaskByIndex(DWORD index);
00100 DWORD getInterfaceBCastAddrByName(const char *name);
00101 DWORD getInterfaceBCastAddrByIndex(DWORD index);
00102 
00103 /* Gets a few physical charactersistics of a device:  MAC addr len, MAC addr,
00104  * and type as one of the MIB_IF_TYPEs.
00105  * len's in-out: on in, needs to say how many bytes are available in addr,
00106  * which to be safe should be MAX_INTERFACE_PHYSADDR.  On out, it's how many
00107  * bytes were set, or how many were required if addr isn't big enough.
00108  * Returns ERROR_INVALID_PARAMETER if name, len, addr, or type is NULL.
00109  * Returns ERROR_INVALID_DATA if name/index isn't valid.
00110  * Returns ERROR_INSUFFICIENT_BUFFER if addr isn't large enough for the
00111  * physical address; *len will contain the required size.
00112  * May return other errors, e.g. ERROR_OUTOFMEMORY or ERROR_NO_MORE_FILES,
00113  * if internal errors occur.
00114  * Returns NO_ERROR on success.
00115  */
00116 DWORD getInterfacePhysicalByName(const char *name, PDWORD len, PBYTE addr,
00117  PDWORD type);
00118 DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr,
00119  PDWORD type);
00120 
00121 /* Get the operational status as a (MIB_)IF_OPER_STATUS type.
00122  */
00123 DWORD getInterfaceStatusByName(const char *name, PDWORD status);
00124 DWORD getInterfaceStatusByIndex(DWORD index, PDWORD status);
00125 
00126 DWORD getInterfaceMtuByName(const char *name, PDWORD mtu);
00127 DWORD getInterfaceMtuByIndex(DWORD index, PDWORD mtu);
00128 
00129 /* Fills in the MIB_IFROW by name/index.  Doesn't fill in interface statistics,
00130  * see ipstats.h for that.
00131  * Returns ERROR_INVALID_PARAMETER if name or entry is NULL, ERROR_INVALID_DATA
00132  * if name/index isn't valid, and NO_ERROR otherwise.
00133  */
00134 DWORD getInterfaceEntryByName(const char *name, PMIB_IFROW entry);
00135 DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry);
00136 
00137 /* Converts the network-order bytes in addr to a printable string.  Returns
00138  * string.
00139  */
00140 char *toIPAddressString(unsigned int addr, char string[16]);
00141 
00142 /* add and delete IP addresses */
00143 NTSTATUS addIPAddress( IPAddr Address, IPMask Mask, DWORD IfIndex,
00144                        PULONG NteContext, PULONG NteInstance );
00145 NTSTATUS deleteIpAddress( ULONG NteContext );
00146 
00147 /* Inserts a route into the route table. */
00148 DWORD createIpForwardEntryOS(PMIB_IPFORWARDROW pRoute);
00149 
00150 BOOL isLoopback( HANDLE tcpFile, TDIEntityID *loop_maybe );
00151 
00152 #endif /* ndef WINE_IFENUM_H_ */

Generated on Sat May 26 2012 04:22:42 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.