smux.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SNMP support
  2. * Copyright (C) 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. */
  21. #ifndef _ZEBRA_SNMP_H
  22. #define _ZEBRA_SNMP_H
  23. #include <net-snmp/agent/net-snmp-agent-includes.h>
  24. #include <net-snmp/agent/snmp_vars.h>
  25. #include "thread.h"
  26. /* Structures here are mostly compatible with UCD SNMP 4.1.1 */
  27. #define MATCH_FAILED (-1)
  28. #define MATCH_SUCCEEDED 0
  29. /* SYNTAX TruthValue from SNMPv2-TC. */
  30. #define SNMP_TRUE 1
  31. #define SNMP_FALSE 2
  32. /* SYNTAX RowStatus from SNMPv2-TC. */
  33. #define SNMP_VALID 1
  34. #define SNMP_INVALID 2
  35. #define IN_ADDR_SIZE sizeof(struct in_addr)
  36. #undef REGISTER_MIB
  37. #define REGISTER_MIB(descr, var, vartype, theoid) \
  38. smux_register_mib(descr, (struct variable *)var, sizeof(struct vartype), \
  39. sizeof(var)/sizeof(struct vartype), \
  40. theoid, sizeof(theoid)/sizeof(oid))
  41. struct trap_object
  42. {
  43. int namelen; /* Negative if the object is not indexed */
  44. oid name[MAX_OID_LEN];
  45. };
  46. /* Declare SMUX return value. */
  47. #define SNMP_LOCAL_VARIABLES \
  48. static long snmp_int_val __attribute__ ((unused)); \
  49. static struct in_addr snmp_in_addr_val __attribute__ ((unused));
  50. #define SNMP_INTEGER(V) \
  51. ( \
  52. *var_len = sizeof (snmp_int_val), \
  53. snmp_int_val = V, \
  54. (u_char *) &snmp_int_val \
  55. )
  56. #define SNMP_IPADDRESS(V) \
  57. ( \
  58. *var_len = sizeof (struct in_addr), \
  59. snmp_in_addr_val = V, \
  60. (u_char *) &snmp_in_addr_val \
  61. )
  62. extern void smux_init (struct thread_master *tm);
  63. extern void smux_register_mib(const char *, struct variable *,
  64. size_t, int, oid [], size_t);
  65. extern int smux_header_generic (struct variable *, oid [], size_t *,
  66. int, size_t *, WriteMethod **);
  67. extern int smux_header_table (struct variable *, oid *, size_t *,
  68. int, size_t *, WriteMethod **);
  69. /* For traps, three OID are provided:
  70. 1. The enterprise OID to use (the last argument will be appended to
  71. it to form the SNMP trap OID)
  72. 2. The base OID for objects to be sent in traps.
  73. 3. The index OID for objects to be sent in traps. This index is used
  74. to designate a particular instance of a column.
  75. The provided trap object contains the bindings to be sent with the
  76. trap. The base OID will be prefixed to the provided OID and, if the
  77. length is positive, the requested OID is assumed to be a columnar
  78. object and the index OID will be appended.
  79. The two first arguments are the MIB registry used to locate the trap
  80. objects.
  81. The use of the arguments may differ depending on the implementation
  82. used.
  83. */
  84. extern int smux_trap (struct variable *, size_t,
  85. const oid *, size_t,
  86. const oid *, size_t,
  87. const oid *, size_t,
  88. const struct trap_object *, size_t,
  89. u_char);
  90. extern int oid_compare (const oid *, int, const oid *, int);
  91. extern void oid2in_addr (oid [], int, struct in_addr *);
  92. extern void *oid_copy (void *, const void *, size_t);
  93. extern void oid_copy_addr (oid [], struct in_addr *, int);
  94. #endif /* _ZEBRA_SNMP_H */