Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. rtipxmib.h
  5. Abstract:
  6. Common include file for all IPX MIB instrumentations support by router
  7. Author:
  8. Vadim Eydelman (vadime) 30-May-1996
  9. Revision History:
  10. --*/
  11. #ifndef _SNMP_RTIPXMIB_
  12. #define _SNMP_RTIPXMIB_
  13. // Macros for converting MIB fields from SNMP master agent format
  14. // to router structures
  15. #define GetAsnInteger(srcBuf,defVal)\
  16. (((srcBuf)->asnType) \
  17. ? (srcBuf)->asnValue.number \
  18. : defVal)
  19. #define SetAsnInteger(dstBuf,val) \
  20. if ((dstBuf)->asnType) { \
  21. ASSERT((dstBuf)->asnType==ASN_INTEGER); \
  22. (dstBuf)->asnValue.number = (AsnInteger)(val); \
  23. }
  24. #define ForceAsnInteger(dstBuf,val) { \
  25. (dstBuf)->asnType = ASN_INTEGER; \
  26. (dstBuf)->asnValue.number = (AsnInteger)(val); \
  27. }
  28. #define GetAsnCounter(srcBuf,defVal)\
  29. (((srcBuf)->asnType) \
  30. ? (srcBuf)->asnValue.counter\
  31. : defVal)
  32. #define SetAsnCounter(dstBuf,val) \
  33. if ((dstBuf)->asnType) { \
  34. ASSERT((dstBuf)->asnType==ASN_RFC1155_COUNTER); \
  35. (dstBuf)->asnValue.counter = (AsnCounter)(val); \
  36. }
  37. #define ForceAsnCounter(dstBuf,val) { \
  38. (dstBuf)->asnType = ASN_RFC1155_COUNTER; \
  39. (dstBuf)->asnValue.counter = (AsnCounter)(val); \
  40. }
  41. #define GetAsnServType(srcBuf,defVal) \
  42. (USHORT)(((srcBuf)->asnType) \
  43. ? ((((srcBuf)->asnValue.string.length>0) \
  44. ? (srcBuf)->asnValue.string.stream[1] \
  45. : 0) \
  46. + (((srcBuf)->asnValue.string.length>1) \
  47. ? (((srcBuf)->asnValue.string.stream[0])<<8)\
  48. : 0)) \
  49. : defVal)
  50. #define SetAsnServType(dstBuf,buffer,val) \
  51. if ((dstBuf)->asnType) { \
  52. ASSERT((dstBuf)->asnType==ASN_OCTETSTRING); \
  53. (dstBuf)->asnValue.string.length = 2; \
  54. (buffer)[1] = (BYTE)(val&0xFF); \
  55. (buffer)[0] = (BYTE)((val>>8)&0xFF); \
  56. (dstBuf)->asnValue.string.stream = (BYTE *)buffer; \
  57. (dstBuf)->asnValue.string.dynamic = FALSE; \
  58. }
  59. #define ForceAsnServType(dstBuf,buffer,val) { \
  60. (dstBuf)->asnType = ASN_OCTETSTRING; \
  61. (dstBuf)->asnValue.string.length = 2; \
  62. (buffer)[1] = (BYTE)(val&0xFF); \
  63. (buffer)[0] = (BYTE)((val>>8)&0xFF); \
  64. (dstBuf)->asnValue.string.stream = (BYTE *)buffer; \
  65. (dstBuf)->asnValue.string.dynamic = FALSE; \
  66. }
  67. #define GetAsnMediaType(srcBuf,defVal) \
  68. (USHORT)(((srcBuf)->asnType) \
  69. ? ((((srcBuf)->asnValue.string.length>0) \
  70. ? (srcBuf)->asnValue.string.stream[0] \
  71. : 0) \
  72. + (((srcBuf)->asnValue.string.length>1) \
  73. ? (((srcBuf)->asnValue.string.stream[1])<<8)\
  74. : 0)) \
  75. : defVal)
  76. #define SetAsnMediaType(dstBuf,buffer,val) \
  77. if ((dstBuf)->asnType) { \
  78. ASSERT((dstBuf)->asnType==ASN_OCTETSTRING); \
  79. (dstBuf)->asnValue.string.length = 2; \
  80. (buffer)[0] = (BYTE)(val&0xFF); \
  81. (buffer)[1] = (BYTE)((val>>8)&0xFF); \
  82. (dstBuf)->asnValue.string.stream = (BYTE *)buffer; \
  83. (dstBuf)->asnValue.string.dynamic = FALSE; \
  84. }
  85. #define ForceAsnMediaType(dstBuf,buffer,val) { \
  86. (dstBuf)->asnType = ASN_OCTETSTRING; \
  87. (dstBuf)->asnValue.string.length = 2; \
  88. (buffer)[0] = (BYTE)(val&0xFF); \
  89. (buffer)[1] = (BYTE)((val>>8)&0xFF); \
  90. (dstBuf)->asnValue.string.stream = (BYTE *)buffer; \
  91. (dstBuf)->asnValue.string.dynamic = FALSE; \
  92. }
  93. #define GetAsnOctetString(dst,srcBuf,maxlen,defVal) \
  94. (((srcBuf)->asnType) \
  95. ? (memset (&(dst)[(srcBuf)->asnValue.string.length],\
  96. 0, maxlen-(srcBuf)->asnValue.string.length),\
  97. memcpy (dst,(srcBuf)->asnValue.string.stream, \
  98. (srcBuf)->asnValue.string.length)) \
  99. : (defVal ? memcpy (dst, defVal, maxlen) : NULL))
  100. #define SetAsnOctetString(dstBuf,buffer,src,len) \
  101. if ((dstBuf)->asnType) { \
  102. ASSERT((dstBuf)->asnType==ASN_OCTETSTRING); \
  103. (dstBuf)->asnValue.string.length = len; \
  104. (dstBuf)->asnValue.string.stream = (BYTE *)memcpy (buffer,src,len); \
  105. (dstBuf)->asnValue.string.dynamic = FALSE; \
  106. }
  107. #define ForceAsnOctetString(dstBuf,buffer,src,len) { \
  108. (dstBuf)->asnType = ASN_OCTETSTRING; \
  109. (dstBuf)->asnValue.string.length = len; \
  110. (dstBuf)->asnValue.string.stream = (BYTE *)memcpy (buffer,src,len); \
  111. (dstBuf)->asnValue.string.dynamic = FALSE; \
  112. }
  113. #define GetAsnDispString(dst,srcBuf,defVal) \
  114. (((srcBuf)->asnType) \
  115. ? ((dst)[(srcBuf)->asnValue.string.length] = 0, \
  116. strncpy (dst,(srcBuf)->asnValue.string.stream, \
  117. (srcBuf)->asnValue.string.length)) \
  118. : (defVal ? strcpy (dst,defVal) : ((dst)[0] = 0, NULL)))
  119. #define SetAsnDispString(dstBuf,buffer,src,len) \
  120. if ((dstBuf)->asnType) { \
  121. ASSERT((dstBuf)->asnType==ASN_RFC1213_DISPSTRING); \
  122. (dstBuf)->asnValue.string.length = strlen(src); \
  123. if ((dstBuf)->asnValue.string.length>len) \
  124. (dstBuf)->asnValue.string.length = len; \
  125. (dstBuf)->asnValue.string.stream = (BYTE *)strncpy (buffer,src, \
  126. (dstBuf)->asnValue.string.length); \
  127. (dstBuf)->asnValue.string.dynamic = FALSE; \
  128. }
  129. #define ForceAsnDispString(dstBuf,buffer,src,len) { \
  130. (dstBuf)->asnType = ASN_RFC1213_DISPSTRING; \
  131. (dstBuf)->asnValue.string.length = strlen(src); \
  132. if ((dstBuf)->asnValue.string.length>len) \
  133. (dstBuf)->asnValue.string.length = len; \
  134. (dstBuf)->asnValue.string.stream = (BYTE *)strncpy (buffer,src, \
  135. (dstBuf)->asnValue.string.length); \
  136. (dstBuf)->asnValue.string.dynamic = FALSE; \
  137. }
  138. #define FreeAsnString(buf) { \
  139. if ((buf)->asnValue.string.dynamic) \
  140. SNMP_free ((buf)->asnValue.string.stream); \
  141. }
  142. // Constants shared by several MIB instrumetnations
  143. #define ZERO_INTERFACE_INDEX 0
  144. #define INVALID_INTERFACE_INDEX 0xFFFFFFFF
  145. extern UCHAR ZERO_NET_NUM[4];
  146. #define INVALID_NET_NUM ZERO_NET_NUM
  147. #define ZERO_SERVER_TYPE 0x0000
  148. #define INVALID_SERVER_TYPE 0xFFFF
  149. extern UCHAR ZERO_SERVER_NAME[1];
  150. #define INVALID_SERVER_NAME ZERO_SERVER_NAME
  151. #define MIPX_EXIST_STATE_NOACTION 0
  152. #define MIPX_EXIST_STATE_DELETED 1
  153. #define MIPX_EXIST_STATE_CREATED 2
  154. #define NIPX_INVALID_SYS_INSTANCE 0xFFFFFFFF
  155. #define NIPX_DEFAULT_SYS_INSTANCE 0
  156. #define NIPX_STATE_NOACTION 0
  157. #define NIPX_STATE_OFF 1
  158. #define NIPX_STATE_ON 2
  159. #define NIPX_CIRCTYPE_OTHER 1
  160. #define NIPX_CIRCTYPE_BCAST 2
  161. #define NIPX_CIRCTYPE_PTTOPT 3
  162. #define NIPX_CIRCTYPE_WANRIP 4
  163. #define NIPX_CIRCTYPE_UNNUMBEREDRIP 5
  164. #define NIPX_CIRCTYPE_DYNAMIC 6
  165. #define NIPX_CIRCTYPE_WANWS 7
  166. #define NIPX_STATIC_STATUS_UNKNOWN 1
  167. #define NIPX_STATIC_STATUS_CURRENT 2
  168. #define NIPX_STATIC_STATUS_CHANGED 3
  169. #define NIPX_STATIC_STATUS_READ 4
  170. #define NIPX_STATIC_STATUS_READING 5
  171. #define NIPX_STATIC_STATUS_WRITE 6
  172. #define NIPX_STATIC_STATUS_WRITING 7
  173. extern MIB_SERVER_HANDLE g_MibServerHandle;
  174. DWORD
  175. ConnectToRouter (
  176. VOID
  177. );
  178. BOOL EnsureRouterConnection();
  179. #endif