home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / iprtrmib.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  16KB  |  453 lines

  1. /*++
  2.  
  3. Copyright (c) 1995 -1997  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     iprtrmib.h
  8.  
  9. Abstract:
  10.     This file contains:
  11.         o Definitions of the MIB_XX structures passed to and from the IP Router Manager
  12.             to query and set MIB variables handled by the IP Router Manager
  13.         o The #defines for the MIB variables IDs  handled by the IP Router Manager
  14.             and made accessible by the MprAdminMIBXXX APIs
  15.         o The Routing PID of the IP Router Manager (as mentioned in ipinfoid.h)
  16.  
  17. --*/
  18.  
  19. #ifndef __ROUTING_IPRTRMIB_H__
  20. #define __ROUTING_IPRTRMIB_H__
  21.  
  22. //////////////////////////////////////////////////////////////////////////////
  23. //                                                                          //
  24. // Included to get the value of MAX_INTERFACE_NAME_LEN                      //
  25. //                                                                          //
  26. //////////////////////////////////////////////////////////////////////////////
  27.  
  28. #include <mprapi.h>
  29.  
  30. //////////////////////////////////////////////////////////////////////////////
  31. //                                                                          //
  32. // Included to get the necessary constants                                  //
  33. //                                                                          //
  34. //////////////////////////////////////////////////////////////////////////////
  35.  
  36. #include <ipifcons.h>
  37.  
  38. //////////////////////////////////////////////////////////////////////////////
  39. //                                                                          //
  40. // This is the Id for IP Router Manager.  The Router Manager handles        //
  41. // MIB-II, Forwarding MIB and some enterprise specific information.         //
  42. // Calls made with any other ID are passed on to the corresponding protocol //
  43. // For example, and MprAdminMIBXXX call with a protocol ID of PID_IP and    //
  44. // a routing Id of 0xD will be sent to the IP Router Manager and then       //
  45. // forwarded to OSPF                                                        //
  46. // This lives in the same number space as the protocol Ids of RIP, OSPF     //
  47. // etc, so any change made to it should be done keeping this in mind        //
  48. //                                                                          //
  49. //////////////////////////////////////////////////////////////////////////////
  50.  
  51.  
  52. #define IPRTRMGR_PID 10000
  53.  
  54. #define ANY_SIZE 1
  55.  
  56.  
  57. //////////////////////////////////////////////////////////////////////////////
  58. //                                                                          //
  59. // The following #defines are the Ids of the MIB variables made accessible  //
  60. // to the user via MprAdminMIBXXX Apis.  It will be noticed that these are  //
  61. // not the same as RFC 1213, since the MprAdminMIBXXX APIs work on rows and //
  62. // groups instead of scalar variables                                       //
  63. //                                                                          //
  64. //////////////////////////////////////////////////////////////////////////////
  65.  
  66.  
  67. #define IF_NUMBER         0
  68. #define IF_TABLE          IF_NUMBER         + 1
  69. #define IF_ROW            IF_TABLE          + 1
  70. #define IP_STATS          IF_ROW            + 1
  71. #define IP_ADDRTABLE      IP_STATS          + 1
  72. #define IP_ADDRROW        IP_ADDRTABLE      + 1
  73. #define IP_FORWARDNUMBER  IP_ADDRROW        + 1
  74. #define IP_FORWARDTABLE   IP_FORWARDNUMBER  + 1 
  75. #define IP_FORWARDROW     IP_FORWARDTABLE   + 1
  76. #define IP_NETTABLE       IP_FORWARDROW     + 1
  77. #define IP_NETROW         IP_NETTABLE       + 1
  78. #define ICMP_STATS        IP_NETROW         + 1
  79. #define TCP_STATS         ICMP_STATS        + 1
  80. #define TCP_TABLE         TCP_STATS         + 1
  81. #define TCP_ROW           TCP_TABLE         + 1
  82. #define UDP_STATS         TCP_ROW           + 1
  83. #define UDP_TABLE         UDP_STATS         + 1
  84. #define UDP_ROW           UDP_TABLE         + 1
  85. #define IF_FILTERTABLE    UDP_ROW           + 1
  86. #define IF_FILTERTIMES    IF_FILTERTABLE    + 1
  87.  
  88.  
  89. #define NUMBER_OF_EXPORTED_VARIABLES    IF_FILTERTIMES    + 1
  90.  
  91. //////////////////////////////////////////////////////////////////////////////
  92. //                                                                          //
  93. // MIB_OPAQUE_QUERY is the structure filled in by the user to identify a    //
  94. // MIB variable                                                             //
  95. //                                                                          //
  96. //  dwVarId     ID of MIB Variable (One of the Ids #defined above)          //
  97. //  dwVarIndex  Variable sized array containing the indices needed to       //
  98. //              identify a variable. NOTE: Unlike SNMP we dont require that //
  99. //              a scalar variable be indexed by 0                           //
  100. //                                                                          //
  101. //////////////////////////////////////////////////////////////////////////////
  102.  
  103. typedef struct _MIB_OPAQUE_QUERY
  104. {
  105.     DWORD  dwVarId;
  106.     DWORD  rgdwVarIndex[ANY_SIZE];
  107. }MIB_OPAQUE_QUERY, *PMIB_OPAQUE_QUERY;
  108.  
  109. //////////////////////////////////////////////////////////////////////////////
  110. //                                                                          //
  111. // The following are the structures which are filled in and returned to the //
  112. // user when a query is made, OR  are filled in BY THE USER when a set is   //
  113. // done                                                                     //
  114. //                                                                          //
  115. //////////////////////////////////////////////////////////////////////////////
  116.  
  117. typedef struct _MIB_IFNUMBER
  118. {
  119.     DWORD    dwValue;
  120. } MIB_IFNUMBER, *PMIB_IFNUMBER;
  121.  
  122.  
  123. #define MAXLEN_IFDESCR 256
  124. #define MAXLEN_PHYSADDR 8
  125.  
  126. typedef struct _MIB_IFROW
  127. {
  128.     WCHAR   wszName[MAX_INTERFACE_NAME_LEN];
  129.     DWORD    dwIndex;
  130.     DWORD    dwType;
  131.     DWORD    dwMtu;
  132.     DWORD    dwSpeed;
  133.     DWORD    dwPhysAddrLen;
  134.     BYTE    bPhysAddr[MAXLEN_PHYSADDR];
  135.     DWORD    dwAdminStatus;
  136.     DWORD    dwOperStatus;
  137.     DWORD    dwLastChange;
  138.     DWORD    dwInOctets;
  139.     DWORD    dwInUcastPkts;
  140.     DWORD    dwInNUcastPkts;
  141.     DWORD    dwInDiscards;
  142.     DWORD    dwInErrors;
  143.     DWORD    dwInUnknownProtos;
  144.     DWORD    dwOutOctets;
  145.     DWORD    dwOutUcastPkts;
  146.     DWORD    dwOutNUcastPkts;
  147.     DWORD    dwOutDiscards;
  148.     DWORD    dwOutErrors;
  149.     DWORD    dwOutQLen;
  150.     DWORD    dwDescrLen;
  151.     BYTE    bDescr[MAXLEN_IFDESCR];
  152. } MIB_IFROW,*PMIB_IFROW;
  153.  
  154. typedef struct _MIB_IFTABLE
  155. {
  156.     DWORD     dwNumEntries;
  157.     MIB_IFROW table[ANY_SIZE];
  158. } MIB_IFTABLE, *PMIB_IFTABLE;
  159.  
  160. #define SIZEOF_IFTABLE(X) (FIELD_OFFSET(MIB_IFTABLE,table[0]) + ((X) * sizeof(MIB_IFROW)) + ALIGN_SIZE)
  161.  
  162. typedef struct _MIBICMPSTATS 
  163. {
  164.     DWORD        dwMsgs;
  165.     DWORD        dwErrors;
  166.     DWORD        dwDestUnreachs;
  167.     DWORD        dwTimeExcds;
  168.     DWORD        dwParmProbs;
  169.     DWORD        dwSrcQuenchs;
  170.     DWORD        dwRedirects;
  171.     DWORD        dwEchos;
  172.     DWORD        dwEchoReps;
  173.     DWORD        dwTimestamps;
  174.     DWORD        dwTimestampReps;
  175.     DWORD        dwAddrMasks;
  176.     DWORD        dwAddrMaskReps;
  177. } MIBICMPSTATS;
  178.  
  179. typedef    struct _MIBICMPINFO
  180. {
  181.     MIBICMPSTATS    icmpInStats;
  182.     MIBICMPSTATS    icmpOutStats;
  183. } MIBICMPINFO;
  184.  
  185. typedef struct _MIB_ICMP
  186. {
  187.     MIBICMPINFO stats;
  188. } MIB_ICMP,*PMIB_ICMP;
  189.  
  190. typedef struct _MIB_UDPSTATS
  191. {
  192.     DWORD       dwInDatagrams;
  193.     DWORD       dwNoPorts;
  194.     DWORD       dwInErrors;
  195.     DWORD       dwOutDatagrams;
  196.     DWORD       dwNumAddrs;
  197. } MIB_UDPSTATS,*PMIB_UDPSTATS;
  198.  
  199. typedef struct _MIB_UDPROW
  200. {
  201.     DWORD       dwLocalAddr;
  202.     DWORD       dwLocalPort;
  203. } MIB_UDPROW, *PMIB_UDPROW;
  204.  
  205. typedef struct _MIB_UDPTABLE
  206. {
  207.     DWORD       dwNumEntries;
  208.     MIB_UDPROW  table[ANY_SIZE];
  209. } MIB_UDPTABLE, *PMIB_UDPTABLE;
  210.  
  211. #define SIZEOF_UDPTABLE(X) (FIELD_OFFSET(MIB_UDPTABLE, table[0]) + ((X) * sizeof(MIB_UDPROW)) + ALIGN_SIZE)
  212.  
  213. typedef struct _MIB_TCPSTATS
  214. {
  215.     DWORD       dwRtoAlgorithm;
  216.     DWORD       dwRtoMin;
  217.     DWORD       dwRtoMax;
  218.     DWORD       dwMaxConn;
  219.     DWORD       dwActiveOpens;
  220.     DWORD       dwPassiveOpens;
  221.     DWORD       dwAttemptFails;
  222.     DWORD       dwEstabResets;
  223.     DWORD       dwCurrEstab;
  224.     DWORD       dwInSegs;
  225.     DWORD       dwOutSegs;
  226.     DWORD       dwRetransSegs;
  227.     DWORD       dwInErrs;
  228.     DWORD       dwOutRsts;
  229.     DWORD       dwNumConns;
  230. } MIB_TCPSTATS, *PMIB_TCPSTATS;
  231.  
  232. #define MIB_TCP_RTO_OTHER       1
  233. #define MIB_TCP_RTO_CONSTANT    2
  234. #define MIB_TCP_RTO_RSRE        3
  235. #define MIB_TCP_RTO_VANJ        4
  236.  
  237. #define MIB_TCP_MAXCONN_DYNAMIC (DWORD)-1
  238.  
  239. typedef struct _MIB_TCPROW
  240. {
  241.     DWORD       dwState;
  242.     DWORD       dwLocalAddr;
  243.     DWORD       dwLocalPort;
  244.     DWORD       dwRemoteAddr;
  245.     DWORD       dwRemotePort;
  246. } MIB_TCPROW, *PMIB_TCPROW;
  247.  
  248. #define MIB_TCP_STATE_CLOSED            1                 
  249. #define MIB_TCP_STATE_LISTEN            2                 
  250. #define MIB_TCP_STATE_SYN_SENT          3                 
  251. #define MIB_TCP_STATE_SYN_RCVD          4                 
  252. #define MIB_TCP_STATE_ESTAB             5                 
  253. #define MIB_TCP_STATE_FIN_WAIT1         6                 
  254. #define MIB_TCP_STATE_FIN_WAIT2         7                 
  255. #define MIB_TCP_STATE_CLOSE_WAIT        8                 
  256. #define MIB_TCP_STATE_CLOSING           9                
  257. #define MIB_TCP_STATE_LAST_ACK         10                
  258. #define MIB_TCP_STATE_TIME_WAIT        11                
  259. #define MIB_TCP_STATE_DELETE_TCB       12                
  260.  
  261. typedef struct _MIB_TCPTABLE
  262. {
  263.     DWORD      dwNumEntries;
  264.     MIB_TCPROW table[ANY_SIZE];
  265. } MIB_TCPTABLE, *PMIB_TCPTABLE;
  266.  
  267. #define SIZEOF_TCPTABLE(X) (FIELD_OFFSET(MIB_TCPTABLE,table[0]) + ((X) * sizeof(MIB_TCPROW)) + ALIGN_SIZE)
  268.  
  269. #define MIB_USE_CURRENT_TTL         ((DWORD)-1)
  270. #define MIB_USE_CURRENT_FORWARDING  ((DWORD)-1)
  271.  
  272. typedef struct _MIB_IPSTATS
  273. {
  274.     DWORD        dwForwarding;
  275.     DWORD        dwDefaultTTL;
  276.     DWORD        dwInReceives;
  277.     DWORD        dwInHdrErrors;
  278.     DWORD        dwInAddrErrors;
  279.     DWORD        dwForwDatagrams;
  280.     DWORD        dwInUnknownProtos;
  281.     DWORD        dwInDiscards;
  282.     DWORD        dwInDelivers;
  283.     DWORD        dwOutRequests;
  284.     DWORD        dwRoutingDiscards;
  285.     DWORD        dwOutDiscards;
  286.     DWORD        dwOutNoRoutes;
  287.     DWORD        dwReasmTimeout;
  288.     DWORD        dwReasmReqds;
  289.     DWORD        dwReasmOks;
  290.     DWORD        dwReasmFails;
  291.     DWORD        dwFragOks;
  292.     DWORD        dwFragFails;
  293.     DWORD        dwFragCreates;
  294.     DWORD        dwNumIf;
  295.     DWORD        dwNumAddr;
  296.     DWORD        dwNumRoutes;
  297. } MIB_IPSTATS, *PMIB_IPSTATS;
  298.  
  299. #define    MIB_IP_FORWARDING               1
  300. #define    MIB_IP_NOT_FORWARDING           2
  301.  
  302.  
  303. typedef struct _MIB_IPADDRROW
  304. {
  305.     DWORD        dwAddr;
  306.     DWORD        dwIndex;
  307.     DWORD        dwMask;
  308.     DWORD        dwBCastAddr;
  309.     DWORD        dwReasmSize;
  310.     unsigned short    unused1;
  311.     unsigned short    unused2;
  312. } MIB_IPADDRROW, *PMIB_IPADDRROW;
  313.  
  314. typedef struct _MIB_IPADDRTABLE
  315. {
  316.     DWORD         dwNumEntries;
  317.     MIB_IPADDRROW table[ANY_SIZE];
  318. } MIB_IPADDRTABLE, *PMIB_IPADDRTABLE;
  319.  
  320.  
  321. #define SIZEOF_IPADDRTABLE(X) (FIELD_OFFSET(MIB_IPADDRTABLE,table[0]) + ((X) * sizeof(MIB_IPADDRROW)) + ALIGN_SIZE)
  322.  
  323.  
  324. typedef struct _MIB_IPFORWARDNUMBER
  325. {
  326.     DWORD      dwValue;
  327. }MIB_IPFORWARDNUMBER,*PMIB_IPFORWARDNUMBER;
  328.  
  329. typedef struct _MIB_IPFORWARDROW
  330. {
  331.     DWORD        dwForwardDest;
  332.     DWORD        dwForwardMask;
  333.     DWORD        dwForwardPolicy;
  334.     DWORD        dwForwardNextHop;
  335.     DWORD        dwForwardIfIndex;
  336.     DWORD        dwForwardType;
  337.     DWORD        dwForwardProto;
  338.     DWORD        dwForwardAge;
  339.     DWORD       dwForwardNextHopAS;
  340.     DWORD        dwForwardMetric1;
  341.     DWORD        dwForwardMetric2;
  342.     DWORD        dwForwardMetric3;
  343.     DWORD        dwForwardMetric4;
  344.     DWORD        dwForwardMetric5;
  345. }MIB_IPFORWARDROW, *PMIB_IPFORWARDROW;
  346.  
  347. #define    MIB_IPROUTE_TYPE_OTHER        1
  348. #define    MIB_IPROUTE_TYPE_INVALID    2
  349. #define    MIB_IPROUTE_TYPE_DIRECT        3
  350. #define    MIB_IPROUTE_TYPE_INDIRECT    4
  351.  
  352. #define    MIB_IPROUTE_METRIC_UNUSED    (DWORD)-1
  353.  
  354. #define MIB_IPPROTO_OTHER            1
  355. #define MIB_IPPROTO_LOCAL            2
  356. #define MIB_IPPROTO_NETMGMT            3
  357. #define MIB_IPPROTO_ICMP            4
  358. #define MIB_IPPROTO_EGP                5
  359. #define MIB_IPPROTO_GGP                6
  360. #define MIB_IPPROTO_HELLO            7
  361. #define MIB_IPPROTO_RIP                8
  362. #define MIB_IPPROTO_IS_IS            9
  363. #define MIB_IPPROTO_ES_IS            10
  364. #define MIB_IPPROTO_CISCO            11
  365. #define MIB_IPPROTO_BBN                12
  366. #define MIB_IPPROTO_OSPF            13
  367. #define MIB_IPPROTO_BGP                14
  368.  
  369. typedef struct _MIB_IPFORWARDTABLE
  370. {
  371.     DWORD               dwNumEntries;
  372.     MIB_IPFORWARDROW    table[ANY_SIZE];
  373. }MIB_IPFORWARDTABLE, *PMIB_IPFORWARDTABLE;
  374.  
  375.  
  376.  
  377.  
  378. #define SIZEOF_IPFORWARDTABLE(X) (FIELD_OFFSET(MIB_IPFORWARDTABLE,table[0]) + ((X) * sizeof(MIB_IPFORWARDROW)) + ALIGN_SIZE)
  379.  
  380.  
  381. typedef struct _MIB_IPNETROW
  382. {
  383.     DWORD        dwIndex;
  384.     DWORD        dwPhysAddrLen;
  385.     BYTE        bPhysAddr[MAXLEN_PHYSADDR];
  386.     DWORD        dwAddr;
  387.     DWORD        dwType;
  388. } MIB_IPNETROW, *PMIB_IPNETROW;
  389.  
  390. #define    MIB_IPNET_TYPE_OTHER        1
  391. #define    MIB_IPNET_TYPE_INVALID        2
  392. #define    MIB_IPNET_TYPE_DYNAMIC        3
  393. #define    MIB_IPNET_TYPE_STATIC        4
  394.  
  395. typedef struct _MIB_IPNETTABLE
  396. {
  397.     DWORD             dwNumEntries;
  398.     MIB_IPNETROW      table[ANY_SIZE];
  399. } MIB_IPNETTABLE, *PMIB_IPNETTABLE;
  400.  
  401. #define SIZEOF_IPNETTABLE(X) (FIELD_OFFSET(MIB_IPNETTABLE, table[0]) + ((X) * sizeof(MIB_IPNETROW)) + ALIGN_SIZE)
  402.  
  403. //////////////////////////////////////////////////////////////////////////////
  404. //                                                                          //
  405. // All the info passed to (SET/CREATE) and from (GET/GETNEXT/GETFIRST)      //
  406. // IP Router Manager is encapsulated in the following "discriminated"       //
  407. // union.  To pass, say MIB_IFROW, use the following code                   //
  408. //                                                                          //
  409. //  PMIB_OPAQUE_INFO    pInfo;                                              //
  410. //  PMIB_IFROW          pIfRow;                                             //
  411. //  DWORD rgdwBuff[(MAX_MIB_OFFSET + sizeof(MIB_IFROW))/sizeof(DWORD) + 1]; //
  412. //                                                                          //
  413. //  pInfo   = (PMIB_OPAQUE_INFO)rgdwBuffer;                                 //
  414. //  pIfRow  = (MIB_IFROW *)(pInfo->rgbyData);                               //
  415. //                                                                          //
  416. //  This can also be accomplished by using the following macro              //
  417. //                                                                          //
  418. //  DEFINE_MIB_BUFFER(pInfo,MIB_IFROW, pIfRow);                             //
  419. //                                                                          //
  420. //////////////////////////////////////////////////////////////////////////////
  421.  
  422.  
  423. typedef struct _MIB_OPAQUE_INFO
  424. {
  425.     DWORD  dwId;
  426.  
  427.     union
  428.     {
  429.         ULONGLONG   ullAlign;
  430.         BYTE        rgbyData[1];
  431.     };
  432.  
  433. }MIB_OPAQUE_INFO, *PMIB_OPAQUE_INFO;
  434.  
  435. #define MAX_MIB_OFFSET      8
  436.  
  437. #define MIB_INFO_SIZE(S)                \
  438.     (MAX_MIB_OFFSET + sizeof(S))
  439.  
  440. #define MIB_INFO_SIZE_IN_DWORDS(S)      \
  441.     ((MIB_INFO_SIZE(S))/sizeof(DWORD) + 1)
  442.  
  443. #define DEFINE_MIB_BUFFER(X,Y,Z)                                        \
  444.     DWORD        __rgdwBuff[MIB_INFO_SIZE_IN_DWORDS(Y)]; \
  445.     PMIB_OPAQUE_INFO    X = (PMIB_OPAQUE_INFO)__rgdwBuff;               \
  446.     Y *                 Z = (Y *)(X->rgbyData)
  447.  
  448.  
  449. #define CAST_MIB_INFO(X,Y,Z)    Z = (Y)(X->rgbyData)
  450.  
  451.  
  452. #endif //__ROUTING_IPRTRMIB_H__
  453.