/contrib/bsnmp/snmp_mibII/snmp_mibII.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 169 lines · 75 code · 24 blank · 70 comment · 0 complexity · e4aba361e9ae399eb949c8788d6b6058 MD5 · raw file

  1. /*
  2. * Copyright (c) 2001-2003
  3. * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
  4. * All rights reserved.
  5. *
  6. * Author: Harti Brandt <harti@freebsd.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * $Begemot: bsnmp/snmp_mibII/snmp_mibII.h,v 1.18 2006/02/14 09:04:19 brandt_h Exp $
  30. *
  31. * Implementation of the interfaces and IP groups of MIB-II.
  32. */
  33. #ifndef snmp_mibII_h_
  34. #define snmp_mibII_h_
  35. /* forward declaration */
  36. struct mibif;
  37. enum mibif_notify {
  38. MIBIF_NOTIFY_DESTROY
  39. };
  40. typedef void (*mibif_notify_f)(struct mibif *, enum mibif_notify, void *);
  41. /*
  42. * Interfaces. This structure describes one interface as seen in the MIB.
  43. * Interfaces are indexed by ifindex. This is not the same as the index
  44. * used by the system because of the rules in RFC-2863 section 3.1.5. This
  45. * RFC requires, that an ifindex is not to be re-used for ANOTHER dynamically
  46. * interfaces once the interface was deleted. The system's ifindex is in
  47. * sysindex. Mapping is via the mapping table below.
  48. */
  49. struct mibif {
  50. TAILQ_ENTRY(mibif) link;
  51. u_int flags;
  52. u_int index; /* the logical ifindex */
  53. u_int sysindex;
  54. char name[IFNAMSIZ];
  55. char descr[256];
  56. struct ifmibdata mib;
  57. uint64_t mibtick;
  58. void *specmib;
  59. size_t specmiblen;
  60. u_char *physaddr;
  61. u_int physaddrlen;
  62. int has_connector;
  63. int trap_enable;
  64. uint64_t counter_disc;
  65. /*
  66. * This is needed to handle interface type specific information
  67. * in sub-modules. It contains a function pointer which handles
  68. * notifications and a data pointer to arbitrary data.
  69. * Should be set via the mibif_notify function.
  70. */
  71. mibif_notify_f xnotify;
  72. void *xnotify_data;
  73. const struct lmodule *xnotify_mod;
  74. /* to be set by ifType specific modules. This is ifSpecific. */
  75. struct asn_oid spec_oid;
  76. /* private data - don't touch */
  77. void *private;
  78. };
  79. /*
  80. * Interface IP-address table.
  81. */
  82. struct mibifa {
  83. TAILQ_ENTRY(mibifa) link;
  84. struct in_addr inaddr;
  85. struct in_addr inmask;
  86. struct in_addr inbcast;
  87. struct asn_oid index; /* index for table search */
  88. u_int ifindex;
  89. u_int flags;
  90. };
  91. /*
  92. * Interface receive addresses. Interface link-level multicast, broadcast
  93. * and hardware addresses are handled automatically.
  94. */
  95. struct mibrcvaddr {
  96. TAILQ_ENTRY(mibrcvaddr) link;
  97. struct asn_oid index;
  98. u_int ifindex;
  99. u_char addr[ASN_MAXOIDLEN];
  100. size_t addrlen;
  101. u_int flags;
  102. };
  103. enum {
  104. MIBRCVADDR_VOLATILE = 0x00000001,
  105. MIBRCVADDR_BCAST = 0x00000002,
  106. MIBRCVADDR_HW = 0x00000004,
  107. };
  108. /* network socket */
  109. extern int mib_netsock;
  110. /* set an interface name to dynamic mode */
  111. void mib_if_set_dyn(const char *);
  112. /* re-read the systems interface list */
  113. void mib_refresh_iflist(void);
  114. /* find interface by index */
  115. struct mibif *mib_find_if(u_int);
  116. struct mibif *mib_find_if_sys(u_int);
  117. struct mibif *mib_find_if_name(const char *);
  118. /* iterate through all interfaces */
  119. struct mibif *mib_first_if(void);
  120. struct mibif *mib_next_if(const struct mibif *);
  121. /* register for interface creations */
  122. int mib_register_newif(int (*)(struct mibif *), const struct lmodule *);
  123. void mib_unregister_newif(const struct lmodule *);
  124. /* get fresh MIB data */
  125. int mib_fetch_ifmib(struct mibif *);
  126. /* change the ADMIN status of an interface and refresh the MIB */
  127. int mib_if_admin(struct mibif *, int up);
  128. /* find interface address by address */
  129. struct mibifa *mib_find_ifa(struct in_addr);
  130. /* find first/next address for a given interface */
  131. struct mibifa *mib_first_ififa(const struct mibif *);
  132. struct mibifa *mib_next_ififa(struct mibifa *);
  133. /* create/delete stacking entries */
  134. int mib_ifstack_create(const struct mibif *lower, const struct mibif *upper);
  135. void mib_ifstack_delete(const struct mibif *lower, const struct mibif *upper);
  136. /* find receive address */
  137. struct mibrcvaddr *mib_find_rcvaddr(u_int, const u_char *, size_t);
  138. /* create/delete receive addresses */
  139. struct mibrcvaddr *mib_rcvaddr_create(struct mibif *, const u_char *, size_t);
  140. void mib_rcvaddr_delete(struct mibrcvaddr *);
  141. /* register for interface notification */
  142. void *mibif_notify(struct mibif *, const struct lmodule *, mibif_notify_f,
  143. void *);
  144. void mibif_unnotify(void *);
  145. #endif