Source code of Windows XP (NT5)
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.

247 lines
10 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. routing\ip\mcastmib\defs.h
  5. Abstract:
  6. IP Multicast MIB defines
  7. Revision history:
  8. Dave Thaler 4/17/98 Created
  9. --*/
  10. #ifndef __DEFS_H__
  11. #define __DEFS_H__
  12. //
  13. // Define this when snmpsfx.dll supports 3-phase sets
  14. //
  15. #undef THREE_PHASE
  16. //
  17. // Define this if the router keeps track of the number of hops to the
  18. // closest member (e.g. MOSPF can calculate this) to set a TTL per oif entry.
  19. //
  20. #undef CLOSEST_MEMBER_HOPS
  21. #define PRINT_IPADDR(x) \
  22. ((x)&0x000000ff),(((x)&0x0000ff00)>>8),(((x)&0x00ff0000)>>16),(((x)&0xff000)>>24)
  23. #define IP_ADDRESS_LEN 4
  24. //------------------------------------------------------------------------------
  25. // Memory allocation/deallocation macros
  26. //------------------------------------------------------------------------------
  27. #define MULTICAST_MIB_ALLOC( x ) HeapAlloc( GetProcessHeap(), 0, (x) )
  28. #define MULTICAST_MIB_FREE( x ) HeapFree( GetProcessHeap(), 0, (x) )
  29. //------------------------------------------------------------------------------
  30. // Macro to simplify use of DIM MIB functions
  31. //------------------------------------------------------------------------------
  32. #define CONNECT_TO_ROUTER(res) \
  33. (res) = ( g_hMIBServer ) ? NO_ERROR : ConnectToRouter()
  34. #define MIB_GET(type, w, x, y, z, res) \
  35. { \
  36. CONNECT_TO_ROUTER(res); \
  37. \
  38. if ( (res) == NO_ERROR ) \
  39. { \
  40. (res) = MprAdminMIBEntry ## type( \
  41. g_hMIBServer, \
  42. PID_IP, \
  43. IPRTRMGR_PID, \
  44. (LPVOID) (w), \
  45. (x), \
  46. (LPVOID *) (y), \
  47. (z) \
  48. ); \
  49. } \
  50. }
  51. #define MIB_SET(type, x, y, res) \
  52. { \
  53. CONNECT_TO_ROUTER(res); \
  54. \
  55. if ( (res) == NO_ERROR ) \
  56. { \
  57. (res) = MprAdminMIBEntry ## type( \
  58. g_hMIBServer, \
  59. PID_IP, \
  60. IPRTRMGR_PID, \
  61. (LPVOID) (x), \
  62. (y) \
  63. ); \
  64. } \
  65. }
  66. #define MULTICAST_MIB_GET(w, x, y, z, res) \
  67. MIB_GET(Get, w, x, y, z, res)
  68. #define MULTICAST_MIB_GETFIRST(w, x, y, z, res) \
  69. MIB_GET(GetFirst, w, x, y, z, res)
  70. #define MULTICAST_MIB_GETNEXT(w, x, y, z, res) \
  71. MIB_GET(GetNext, w, x, y, z, res)
  72. #define MULTICAST_MIB_VALIDATE(x, y, res) \
  73. MIB_SET(Validate, x, y, res)
  74. #define MULTICAST_MIB_COMMIT(x, y, res) \
  75. MIB_SET(Set, x, y, res)
  76. #define MULTICAST_MIB_CLEANUP(x, y, res) \
  77. MIB_SET(Cleanup, x, y, res)
  78. //------------------------------------------------------------------------------
  79. // Macros to convert between Asn and Win32 data types
  80. //------------------------------------------------------------------------------
  81. #define SetAsnInteger(dstBuf,val){ \
  82. if ((dstBuf)->asnType) \
  83. { \
  84. ASSERT((dstBuf)->asnType==ASN_INTEGER); \
  85. (dstBuf)->asnValue.number = (AsnInteger)(val); \
  86. } \
  87. }
  88. #define ForceSetAsnInteger(dstBuf,val){ \
  89. (dstBuf)->asnType = ASN_INTEGER; \
  90. (dstBuf)->asnValue.number = (AsnInteger)(val); \
  91. }
  92. #define SetAsnCounter(dstBuf,val){ \
  93. if ((dstBuf)->asnType) \
  94. { \
  95. ASSERT((dstBuf)->asnType==ASN_RFC1155_COUNTER); \
  96. (dstBuf)->asnValue.counter = (AsnCounter)(val); \
  97. } \
  98. }
  99. #define SetAsnTimeTicks(dstBuf,val){ \
  100. if ((dstBuf)->asnType) \
  101. { \
  102. ASSERT((dstBuf)->asnType==ASN_RFC1155_TIMETICKS); \
  103. (dstBuf)->asnValue.ticks = (AsnTimeticks)(val); \
  104. } \
  105. }
  106. #define SetAsnOctetString(dstBuf,buffer,src,len){ \
  107. if ((dstBuf)->asnType) \
  108. { \
  109. ASSERT((dstBuf)->asnType==ASN_OCTETSTRING); \
  110. (dstBuf)->asnValue.string.length = len; \
  111. (dstBuf)->asnValue.string.stream = (BYTE*)memcpy(buffer,src,len);\
  112. (dstBuf)->asnValue.string.dynamic = FALSE; \
  113. } \
  114. }
  115. #define SetAsnIPAddress(dstBuf,buffer,val){ \
  116. if ((dstBuf)->asnType) \
  117. { \
  118. ASSERT((dstBuf)->asnType==ASN_RFC1155_IPADDRESS); \
  119. (dstBuf)->asnValue.address.length = IP_ADDRESS_LEN; \
  120. if(!(dstBuf)->asnValue.address.stream) \
  121. { \
  122. (dstBuf)->asnValue.address.stream = (PBYTE)buffer; \
  123. (dstBuf)->asnValue.address.dynamic = FALSE; \
  124. } \
  125. (*(DWORD*)((dstBuf)->asnValue.address.stream)) = val; \
  126. } \
  127. }
  128. #define ForceSetAsnIPAddress(dstBuf,buffer,val){ \
  129. (dstBuf)->asnType = ASN_RFC1155_IPADDRESS; \
  130. (dstBuf)->asnValue.address.length = IP_ADDRESS_LEN; \
  131. if(!((dstBuf)->asnValue.address.stream)) \
  132. { \
  133. (dstBuf)->asnValue.address.stream = (PBYTE)buffer; \
  134. (dstBuf)->asnValue.address.dynamic = FALSE; \
  135. } \
  136. (*(DWORD*)((dstBuf)->asnValue.address.stream)) = val; \
  137. }
  138. #define GetAsnInteger(srcBuf,defVal) \
  139. (((srcBuf)->asnType)? ((srcBuf)->asnValue.number):(defVal))
  140. #define GetAsnCounter(srcBuf,defVal) \
  141. (((srcBuf)->asnType)? ((srcBuf)->asnValue.counter):(defVal))
  142. #define GetAsnTimeTicks(srcBuf, defval) \
  143. ( ( (srcBuf)-> asnType ) ? (srcBuf)-> asnValue.ticks : (defval) )
  144. #define GetAsnIPAddress(srcBuf,defVal) \
  145. (DWORD)(((srcBuf)->asnType && (srcBuf)->asnValue.string.length)? \
  146. (*(DWORD*)((srcBuf)->asnValue.address.stream)) : (defVal))
  147. #define GetAsnOctetString(dst,srcBuf) \
  148. (((srcBuf)->asnType) \
  149. ? (memcpy(dst,(srcBuf)->asnValue.string.stream,\
  150. (srcBuf)->asnValue.string.length)) \
  151. : NULL)
  152. #define IsAsnTypeNull(asnObj) (!((asnObj)->asnType))
  153. #define IsAsnIPAddressTypeNull(asnObj) (!((asnObj)->asnType && (asnObj)->asnValue.address.length))
  154. //
  155. // Timeouts for the caches in millisecs
  156. //
  157. #define IPMULTI_IF_CACHE_TIMEOUT (1 * 1000)
  158. //------------------------------------------------------------------------------
  159. // Debug tracing macros
  160. //------------------------------------------------------------------------------
  161. #ifdef MIB_DEBUG
  162. #define TRACE0(Z) TracePrintf(g_dwTraceId,Z)
  163. #define TRACE1(Y,Z) TracePrintf(g_dwTraceId,Y,Z)
  164. #define TRACE2(X,Y,Z) TracePrintf(g_dwTraceId,X,Y,Z)
  165. #define TRACE3(W,X,Y,Z) TracePrintf(g_dwTraceId,W,X,Y,Z)
  166. #define TRACE4(V,W,X,Y,Z) TracePrintf(g_dwTraceId,V,W,X,Y,Z)
  167. #define TRACE5(U,V,W,X,Y,Z) TracePrintf(g_dwTraceId,U,W,X,Y,Z)
  168. #define TRACEW0(Z) TracePrintfW(g_dwTraceId,Z)
  169. #define TraceEnter(X) TracePrintf(g_dwTraceId,"Entering " X)
  170. #define TraceLeave(X) TracePrintf(g_dwTraceId,"Leaving " X "\n")
  171. #define TraceError(X) \
  172. TracePrintf( g_dwTraceId, "MprAdminMIB API returned : %d", (X) );
  173. #define TraceError1(x) \
  174. { \
  175. LPWSTR __lpwszErr = NULL; \
  176. \
  177. TRACE1( "MprAdminMIB API returned : %d", (x) ); \
  178. MprAdminGetErrorString( (x), &__lpwszErr ); \
  179. \
  180. if ( __lpwszErr ) \
  181. { \
  182. TRACEW0( __lpwszErr ); \
  183. LocalFree( __lpwszErr ); \
  184. } \
  185. }
  186. #else
  187. #define TRACE0(Z)
  188. #define TRACE1(Y,Z)
  189. #define TRACE2(X,Y,Z)
  190. #define TRACE3(W,X,Y,Z)
  191. #define TRACE4(V,W,X,Y,Z)
  192. #define TRACE5(U,V,W,X,Y,Z)
  193. #define TRACEW0(Z)
  194. #define TraceEnter(X)
  195. #define TraceLeave(X)
  196. #define TraceError(x)
  197. #endif
  198. #endif