Path: blob/main/contrib/bsnmp/snmp_mibII/snmp_mibII.h
39478 views
/*1* Copyright (c) 2001-20032* Fraunhofer Institute for Open Communication Systems (FhG Fokus).3* All rights reserved.4*5* Author: Harti Brandt <[email protected]>6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*28* $Begemot: bsnmp/snmp_mibII/snmp_mibII.h,v 1.18 2006/02/14 09:04:19 brandt_h Exp $29*30* Implementation of the interfaces and IP groups of MIB-II.31*/32#ifndef snmp_mibII_h_33#define snmp_mibII_h_3435/* forward declaration */36struct mibif;3738enum mibif_notify {39MIBIF_NOTIFY_DESTROY40};4142typedef void (*mibif_notify_f)(struct mibif *, enum mibif_notify, void *);4344/*45* Interfaces. This structure describes one interface as seen in the MIB.46* Interfaces are indexed by ifindex. This is not the same as the index47* used by the system because of the rules in RFC-2863 section 3.1.5. This48* RFC requires, that an ifindex is not to be re-used for ANOTHER dynamically49* interfaces once the interface was deleted. The system's ifindex is in50* sysindex. Mapping is via the mapping table below.51*/52struct mibif {53TAILQ_ENTRY(mibif) link;54u_int flags;55u_int index; /* the logical ifindex */56u_int sysindex;57char name[IFNAMSIZ];58char descr[256];59struct ifmibdata mib;60uint64_t mibtick;61void *specmib;62size_t specmiblen;63u_char *physaddr;64u_int physaddrlen;65int has_connector;66int trap_enable;67uint64_t counter_disc;6869/*70* This is needed to handle interface type specific information71* in sub-modules. It contains a function pointer which handles72* notifications and a data pointer to arbitrary data.73* Should be set via the mibif_notify function.74*/75mibif_notify_f xnotify;76void *xnotify_data;77const struct lmodule *xnotify_mod;7879/* to be set by ifType specific modules. This is ifSpecific. */80struct asn_oid spec_oid;8182char *alias;83size_t alias_size;8485/* private data - don't touch */86void *private;87};8889/*90* Interface IP-address table.91*/92struct mibifa {93TAILQ_ENTRY(mibifa) link;94struct in_addr inaddr;95struct in_addr inmask;96struct in_addr inbcast;97struct asn_oid index; /* index for table search */98u_int ifindex;99u_int flags;100};101102/*103* Interface receive addresses. Interface link-level multicast, broadcast104* and hardware addresses are handled automatically.105*/106struct mibrcvaddr {107TAILQ_ENTRY(mibrcvaddr) link;108struct asn_oid index;109u_int ifindex;110u_char addr[ASN_MAXOIDLEN];111size_t addrlen;112u_int flags;113};114enum {115MIBRCVADDR_VOLATILE = 0x00000001,116MIBRCVADDR_BCAST = 0x00000002,117MIBRCVADDR_HW = 0x00000004,118};119120/* network socket */121extern int mib_netsock;122123/* set an interface name to dynamic mode */124void mib_if_set_dyn(const char *);125126/* re-read the systems interface list */127void mib_refresh_iflist(void);128129/* find interface by index */130struct mibif *mib_find_if(u_int);131struct mibif *mib_find_if_sys(u_int);132struct mibif *mib_find_if_name(const char *);133134/* iterate through all interfaces */135struct mibif *mib_first_if(void);136struct mibif *mib_next_if(const struct mibif *);137138/* register for interface creations */139int mib_register_newif(int (*)(struct mibif *), const struct lmodule *);140void mib_unregister_newif(const struct lmodule *);141142/* get fresh MIB data */143int mib_fetch_ifmib(struct mibif *);144145/* change the ADMIN status of an interface and refresh the MIB */146int mib_if_admin(struct mibif *, int up);147148/* find interface address by address */149struct mibifa *mib_find_ifa(struct in_addr);150151/* find first/next address for a given interface */152struct mibifa *mib_first_ififa(const struct mibif *);153struct mibifa *mib_next_ififa(struct mibifa *);154155/* create/delete stacking entries */156int mib_ifstack_create(const struct mibif *lower, const struct mibif *upper);157void mib_ifstack_delete(const struct mibif *lower, const struct mibif *upper);158159/* find receive address */160struct mibrcvaddr *mib_find_rcvaddr(u_int, const u_char *, size_t);161162/* create/delete receive addresses */163struct mibrcvaddr *mib_rcvaddr_create(struct mibif *, const u_char *, size_t);164void mib_rcvaddr_delete(struct mibrcvaddr *);165166/* register for interface notification */167void *mibif_notify(struct mibif *, const struct lmodule *, mibif_notify_f,168void *);169void mibif_unnotify(void *);170171#endif172173174