home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl502b.zip / ext / DPI / snmp_lDPI.h < prev    next >
C/C++ Source or Header  |  1995-09-26  |  13KB  |  236 lines

  1. /*
  2. \begin{verbatim}
  3. */
  4.  
  5. #ifndef snmp_lDPIH
  6. #define snmp_lDPIH
  7.  
  8. /*********************************************************************/
  9. /*                                                                   */
  10. /* SNMP-DPI API - SNMP Distributed Protocol Interface                */
  11. /*                Application Programming Interface                  */
  12. /*                                                                   */
  13. /* Sep 07, 1995 - Version 0.14i                                      */
  14. /*                                                                   */
  15. /* Copyright    - (C) International Business Machines Corp. 1994     */
  16. /*                                                                   */
  17. /*   Permission to use, copy, modify, and distribute this software   */
  18. /*   and its documentation for any lawful purpose and without fee is */
  19. /*   hereby granted, provided that this notice be retained unaltered,*/
  20. /*   and that the names of IBM and all other contributors shall not  */
  21. /*   be used in advertising or publicity pertaining to distribution  */
  22. /*   of the software without specific written prior permission.      */
  23. /*   No contributor makes any representations about the suitability  */
  24. /*   of this software for any purpose.  It is provided "as is"       */
  25. /*   without express or implied warranty.                            */
  26. /*                                                                   */
  27. /*   IBM AND ALL OTHER CONTRIBUTORS DISCLAIM ALL WARRANTIES WITH     */
  28. /*   REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF    */
  29. /*   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE,    */
  30. /*   AND NON-INFRINGEMENT.                                           */
  31. /*                                                                   */
  32. /*   IN NO EVENT SHALL IBM OR ANY OTHER CONTRIBUTOR BE LIABLE FOR    */
  33. /*   ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN      */
  34. /*   CONTRACT, TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN   */
  35. /*   CONNECTION WITH, THE USE OR PERFORMANCE OF THIS SOFTWARE.       */
  36. /*                                                                   */
  37. /* snmp_lDPI.h  - Include file for SNMP DPI sub-agent support.       */
  38. /*              - This one is normally not exposed to DPI sub-agent  */
  39. /*                programmers. It defines things for internal calls  */
  40. /*                between the DPI library functions that reside in   */
  41. /*                different source files                             */
  42. /*              - It may also be tailored for platform dependent     */
  43. /*                things, because the target end-user (DPI sub-agent */
  44. /*                programmer) in principle only uses the interface   */
  45. /*                as defined in snmp_dpi.h                           */
  46. /*-------------------------------------------------------------------*/
  47.  
  48. /* Change activitity:
  49.  *
  50.  * $Log: snmp_lDPI.h,v $
  51.  * Revision 3.1  1995/09/07  20:36:53  snmpdev
  52.  * add invalid prototype define
  53.  *
  54.  * Revision 3.0  1995/04/05  21:30:00  snmpdev
  55.  * new level for snmpv2 development
  56.  *
  57.  * Revision 2.9  1995/04/05  21:29:17  snmpdev
  58.  * rfc1440 freeze
  59.  *
  60.  * Revision 2.0  1994/10/29  01:19:29  pederson
  61.  * Revision 2.0
  62.  *
  63.  *
  64.  */
  65.  
  66. #include "snmp_dpi.h"
  67.  
  68. /*********************************************************************/
  69. /* This macro defines how we do tracing for DPI internal debugging   */
  70. /* It uses an external variable dpi_debug, that is normally defined  */
  71. /* in the source file snmp_mDPI.c. That variable can be set to on or */
  72. /* off by the DPI programmer with a DPIdebug(..) call.               */
  73. /* The definition is:   DPI_DEBUG(minimum_level,code_to_execute)     */
  74. /* So if the debug_level in dpi_debug is GE than minimum_level, then */
  75. /* the code_to_executed is executed.                                 */
  76. /*********************************************************************/
  77. #ifndef DPI_DEBUG                         /* if no DPI_DEBUG wanted  */
  78. #define DPI_DEBUG(a,b) ;                  /* ignore DPI_DEBUG stuff  */
  79. #else                                     /* if DPI_DEBUG wanted     */
  80. #undef DPI_DEBUG                          /* undefine and then       */
  81. #define DPI_DEBUG_CODE                    /* for conditional code    */
  82. #define DPI_DEBUG(a,b)                    /* use this instead       */\
  83.         if (dpi_debug>=(a)) (b)           /* to generate debug code */
  84. extern  int dpi_debug;                    /* holds debug level       */
  85. #endif /* def DPI_DEBUG */
  86.  
  87. /*********************************************************************/
  88. /* We do not use plain text in our DPI interface routines but we use */
  89. /* the following defined strings. Currently the code also does not   */
  90. /* use any printf statements, but instead uses the DPI_DM (display   */
  91. /* Message) macro. So this allows us to do different things in the   */
  92. /* future. For instance call a dynamically loadable NLS module to    */
  93. /* print NLS specific messages. DPI_M_xxx definitions would then     */
  94. /* probably change to message numbers, but the code does not need    */
  95. /* to change.                                                        */
  96. /*********************************************************************/
  97. #define DPI_DM printf              /* Display Message this way       */
  98. /*#define DPI_DM printf("DPI_M %s(%d): ",__FILE__,__LINE__);printf   */
  99. #define DPI_M_NONE            "** NONE **" /* used as text string    */
  100. #define DPI_M_DEBUG_ON        "ON"         /* used as text string    */
  101. #define DPI_M_DEBUG_OFF       "OFF"        /* used as text string    */
  102. #define DPI_M_YES             "Yes"        /* used as text string    */
  103. #define DPI_M_NO              "No"         /* used as text string    */
  104. #define DPI_M_CSET_ASCII      "ASCII"      /* used as text string    */
  105. #define DPI_M_CSET_NATIVE     "Native"     /* used as text string    */
  106. #define DPI_M_DEBUG_ONOFF          "DPI Debug turned %s (level %d)\n"
  107. #define DPI_M_NO_DEBUG_CODE        "DPI Debug code not available\n"
  108. #define DPI_M_OUT_OF_MEMORY        "Out of memory\n"
  109. #define DPI_M_DPI_BUFFER_OVERFLOW  "DPI buffer overflow\n"
  110. #define DPI_M_PDU_BUFFER_OVERFLOW  "PDU buffer overflow\n"
  111. #define DPI_M_DPI_ENCODING_ERROR   "DPI encoding error\n"
  112. #define DPI_M_DPI_DECODING_ERROR   "DPI decoding error\n"
  113. #define DPI_M_INVALID_DPI_TYPE     "Invalid DPI packet type\n"
  114. #define DPI_M_INVALID_SNMP_TYPE    "%s: Invalid value type %d\n"
  115. #define DPI_M_INVALID_DPI_LEVEL    "%s: Unsupported DPI level\n"
  116. #define DPI_M_INVALID_DPI_VERSION  "Invalid/Unsupported DPI version\n"
  117. #define DPI_M_INVALID_DPI_RELEASE  "Invalid/Unsupported DPI release\n"
  118. #define DPI_M_INVALID_DPI_PORT     "Invalid/Unsupported DPI port\n"
  119. #define DPI_M_INVALID_DPI_T_PROTO  "Invalid/Unsupported transport %s\n"
  120. #define DPI_M_INVALID_SNMP_VERSION "Invalid/Unsupported SNMP version\n"
  121. #define DPI_M_INVALID_INT_LENGTH   "%s: invalid integer length %hu\n"
  122. #define DPI_M_INVALID_I64_LENGTH   "%s: invalid 64-bit length %hu\n"
  123. #define DPI_M_INVALID_NSAP_LENGTH  "%s: invalid NSAP length %hu\n"
  124. #define DPI_M_INVALID_NULL_LENGTH  "%s: invalid NULL length %hu\n"
  125. #define DPI_M_INVALID_OID          "%s: invalid objectID: %s\n"
  126. #define DPI_M_INVALID_GROUPID      "%s: invalid groupID: %s\n"
  127. #define DPI_M_INVALID_INSTANCE     "%s: invalid instanceID: %s\n"
  128. #define DPI_M_INVALID_TIMEOUT      "%s: invalid timeout: %lu\n"
  129. #define DPI_M_INVALID_MAXVB        "%s: invalid maxVarbinds: %lu\n"
  130. #define DPI_M_INVALID_PWLEN        "%s: invalid password_len: %lu\n"
  131. #define DPI_M_INVALID_VAL_LENGTH   "%s: Value length is invalid\n"
  132. #define DPI_M_INVALID_TRAP_GEN     "%s: Invalid generic type %ld\n"
  133. #define DPI_M_INVALID_TRAP_SPEC    "%s: Invalid specific type %ld\n"
  134. #define DPI_M_COMMUNITY_TOO_LONG   "Community name too long\n"
  135. #define DPI_M_SADESC_TOO_LONG      "%s: description too long\n"
  136. #define DPI_M_ZERO_LENGTH          "Length is zero\n"
  137. #define DPI_M_NULL_PTR             "%s: NULL ptr (zero)passed\n"
  138. #define DPI_M_MISSING_VALUE        "Missing value\n"
  139. #define DPI_M_MISSING_SA_OID       "Missing subagent Identifier\n"
  140. #define DPI_M_MISSING_SA_DESCR     "Missing subagent Description\n"
  141. #define DPI_M_MISSING_PRIORITY     "Missing priority\n"
  142. #define DPI_M_MISSING_VIEW_SELECT  "Missing view selection\n"
  143. #define DPI_M_MISSING_BULK_SELECT  "Missing bulk selection\n"
  144. #define DPI_M_MISSING_COMMUNITY    "Missing community name\n"
  145. #define DPI_M_MISSING_REASON_CODE  "Missing reason code\n"
  146. #define DPI_M_MISSING_SUBTREE      "Missing subtree(s)\n"
  147. #define DPI_M_MISSING_GROUP_ID     "%s: Missing groupID\n"
  148. #define DPI_M_MISSING_TRAILING_DOT "Missing trailing dot\n"
  149. #define DPI_M_MISSING_CSET         "Missing selected character set\n"
  150. #define DPI_M_MISSING_OID          "%s: Missing objectID\n"
  151. #define DPI_M_NO_IPADDR_FOR_HOST   "No IP address for host %s\n"
  152. #define DPI_M_ALL_CONNECTIONS_USED "All %d connections in use\n"
  153. #define DPI_M_CLOSING_FD           "Closing connection on fd %d\n"
  154. #define DPI_M_INVALID_HANDLE       "Invalid handle %d\n"
  155. #define DPI_M_INVALID_ERROR_CODE   "%s: Invalid error code: %ld\n"
  156. #define DPI_M_INVALID_ERROR_INDEX  "%s: Invalid error index: %ld\n"
  157. #define DPI_M_OUT_PACKET           "Outgoing DPI packet"
  158. #define DPI_M_IN_PACKET            "Incoming DPI packet"
  159. #define DPI_M_NOT_ALL_BYTES_SENT   "Only %d of %lu bytes sent\n"
  160. #define DPI_M_EOF_RECEIVED         "EOF received on DPI %s fd %d\n"
  161. #define DPI_M_CONNECTION_SETUP     "%s connection setup for fd %d\n"
  162. #define DPI_M_DUMP_OF_BYTES        "Dump of %d byte %s:\n  "
  163. #define DPI_M_INCOMPLETE_IN_PACKET \
  164.             "Incomplete incoming DPI packet on %s fd %d\n"
  165. #define DPI_M_TIMEOUT_ON_FD \
  166.             "Timeout after %d seconds on fd %d\n"
  167. #define DPI_M_CODE_OUT_OF_SYNC \
  168.             "Code out of sync, source file %s, line %d\n"
  169. #define DPI_M_RECEIVED_PACKET_ON_FD \
  170.             "Received %lu byte DPI packet on %s fd %d\n"
  171. #define DPI_M_SENT_PACKET_ON_UDP_FD \
  172.             "Sent %lu byte DPI packet on fd %d to %s port %u\n"
  173. #define DPI_M_SENT_PACKET_ON_TCP_FD \
  174.             "Sent %lu byte DPI packet on fd %d\n"
  175. #define DPI_M_PACKET_DROP \
  176.             "Drop %lu byte DPI packet, too large for %d byte buffer\n"
  177. #define DPI_M_VERSION1 \
  178.             "%s: Major=%d, Version=%d, Release=%d, Id=%u, Type=%s\n"
  179. #define DPI_M_VERSION2 \
  180.             "%*s  Community=%.*s\n"
  181. #define DPI_M_OPEN_PART_1 "%s: subagent Identification=%s\n"
  182. #define DPI_M_OPEN_PART_2 "%*s  Description=%s\n"
  183. #define DPI_M_OPEN_PART_3 "%*s  Selected Character Set is %d (%s)\n"
  184. #define DPI_M_OPEN_PART_4 \
  185.             "%*s  timeout=%lu, max_varBinds=%lu, password=%.*s\n"
  186. #define DPI_M_CLOSE    "%s: close reason_code=%ld (%s)\n"
  187. #define DPI_M_REGISTER1 "%s: subtree=%s, priority=%ld, timeout=%u\n"
  188. #define DPI_M_REGISTER2 "%*s  view_selection=%s\n"
  189. #define DPI_M_REGISTER3 "%*s  bulk_selection=%s\n"
  190. #define DPI_M_REGISTER4 "%*s  community=%.*s\n"
  191. #define DPI_M_UNREGISTER          "%s: subtree=%s reason_code=%d\n"
  192. #define DPI_M_OBJECT_PART_1       "%s: subtree=%s, instance=%s\n"
  193. #define DPI_M_OBJECT_PART_2       "%*s  object=%s\n"
  194. #define DPI_M_VALUE_PART_1 \
  195.             "%*s  value_type=%s ['%2.2x'H], value_len=%d\n"
  196. #define DPI_M_VALUE_PART_2         "%*s  value="
  197. #define DPI_M_VALUE_INTEGER32      "%ld [0x%8.8x]\n"
  198. #define DPI_M_VALUE_IPADDRESS      "%d.%d.%d.%d\n"
  199. #define DPI_M_VALUE_U_INTEGER32    "%lu [0x%8.8x]\n"
  200. #define DPI_M_VALUE_COUNTER64      "%lu.%lu [0x%8.8x%8.8x]\n"
  201. #define DPI_M_VALUE_OID            "%.*s\n"
  202. #define DPI_M_VALUE_NULL           "** NULL **\n"
  203. #define DPI_M_VALUE_DISPLAY_STRING "%.*s\n"
  204. #define DPI_M_VALUE_OCTETS_PART_1  "'"
  205. #define DPI_M_VALUE_OCTETS_PART_2  "%2.2x"
  206. #define DPI_M_VALUE_OCTETS_PART_3  "\n%*s"
  207. #define DPI_M_VALUE_OCTETS_PART_4  "'H\n"
  208. #define DPI_M_RESPONSE "%s: ret_code=%d [0x%x] (%s), ret_index=%lu\n"
  209. #define DPI_M_TRAP \
  210.        "%s: generic=%ld [0x%x], specific=%ld [0x%x], enterprise=%s\n"
  211.  
  212. /*********************************************************************/
  213. /* These 2 fucntions are defined here and not in snmp_dpi.h, because */
  214. /* they are meant to be used by system specific code only and NOT by */
  215. /* the normal sub-agent programmer (he/she just calls lookup_host and*/
  216. /* qDPIport (or query_DPI_port) to obtain the IP address and the DPI */
  217. /* port from the agent. Following 2 functions are system independent */
  218. /* and are proved as part of snmp_mkDPI.c code.                      */
  219. /*********************************************************************/
  220. extern long int       extract_DPI_port(  /* extract DPI port from    */
  221.   char                  *packet_p,       /* this SNMP response PDU   */
  222.   int                    packet_len);    /* that has this length     */
  223.  
  224. extern unsigned char *mkDPIqport_packet( /* Make a GET for DPIport   */
  225.   int                    snmp_version,   /* SNMP version (1=SNMPv1)  */
  226.   int                    tcp_udp_port,   /* 0=TCP or 1=UDP port      */
  227.   char                  *community_p,    /* ptr to community name    */
  228.   int                    community_len,  /* length of community name */
  229.   int                   *pdu_len);       /* receives length of result*/
  230.  
  231. #endif /* snmp_lDPIH */
  232.  
  233. /*
  234. \end{verbatim}
  235. */
  236.