snmp_mibII.h revision 122394
1122394Sharti/* 2122394Sharti * Copyright (c) 2001-2003 3122394Sharti * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4122394Sharti * All rights reserved. 5122394Sharti * 6122394Sharti * Author: Harti Brandt <harti@freebsd.org> 7122394Sharti * 8122394Sharti * Redistribution of this software and documentation and use in source and 9122394Sharti * binary forms, with or without modification, are permitted provided that 10122394Sharti * the following conditions are met: 11122394Sharti * 12122394Sharti * 1. Redistributions of source code or documentation must retain the above 13122394Sharti * copyright notice, this list of conditions and the following disclaimer. 14122394Sharti * 2. Redistributions in binary form must reproduce the above copyright 15122394Sharti * notice, this list of conditions and the following disclaimer in the 16122394Sharti * documentation and/or other materials provided with the distribution. 17122394Sharti * 3. Neither the name of the Institute nor the names of its contributors 18122394Sharti * may be used to endorse or promote products derived from this software 19122394Sharti * without specific prior written permission. 20122394Sharti * 21122394Sharti * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS 22122394Sharti * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23122394Sharti * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24122394Sharti * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25122394Sharti * FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26122394Sharti * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27122394Sharti * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 28122394Sharti * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29122394Sharti * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30122394Sharti * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31122394Sharti * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32122394Sharti * 33122394Sharti * $Begemot: bsnmp/snmp_mibII/snmp_mibII.h,v 1.13 2002/03/21 11:18:51 hbb Exp $ 34122394Sharti * 35122394Sharti * Implementation of the interfaces and IP groups of MIB-II. 36122394Sharti */ 37122394Sharti#ifndef snmp_mibII_h_ 38122394Sharti#define snmp_mibII_h_ 39122394Sharti 40122394Sharti/* forward declaration */ 41122394Shartistruct mibif; 42122394Sharti 43122394Shartienum mibif_notify { 44122394Sharti MIBIF_NOTIFY_DESTROY 45122394Sharti}; 46122394Sharti 47122394Shartitypedef void (*mibif_notify_f)(struct mibif *, enum mibif_notify, void *); 48122394Sharti 49122394Sharti/* 50122394Sharti * Interfaces. This structure describes one interface as seen in the MIB. 51122394Sharti * Interfaces are indexed by ifindex. This is not the same as the index 52122394Sharti * used by the system because of the rules in RFC-2863 section 3.1.5. This 53122394Sharti * RFC requires, that an ifindex is not to be re-used for ANOTHER dynamically 54122394Sharti * interfaces once the interface was deleted. The system's ifindex is in 55122394Sharti * sysindex. Mapping is via the mapping table below. 56122394Sharti */ 57122394Shartistruct mibif { 58122394Sharti TAILQ_ENTRY(mibif) link; 59122394Sharti u_int flags; 60122394Sharti u_int index; /* the logical ifindex */ 61122394Sharti u_int sysindex; 62122394Sharti char name[IFNAMSIZ]; 63122394Sharti char descr[256]; 64122394Sharti struct ifmibdata mib; 65122394Sharti u_int32_t mibtick; 66122394Sharti void *specmib; 67122394Sharti size_t specmiblen; 68122394Sharti u_char *physaddr; 69122394Sharti u_int physaddrlen; 70122394Sharti int has_connector; 71122394Sharti int trap_enable; 72122394Sharti u_int32_t counter_disc; 73122394Sharti 74122394Sharti /* 75122394Sharti * This is needed to handle interface type specific information 76122394Sharti * in sub-modules. It contains a function pointer which handles 77122394Sharti * notifications and a data pointer to arbitrary data. 78122394Sharti * Should be set via the mibif_notify function. 79122394Sharti */ 80122394Sharti mibif_notify_f xnotify; 81122394Sharti void *xnotify_data; 82122394Sharti const struct lmodule *xnotify_mod; 83122394Sharti}; 84122394Sharti 85122394Sharti/* 86122394Sharti * Interface IP-address table. 87122394Sharti */ 88122394Shartistruct mibifa { 89122394Sharti TAILQ_ENTRY(mibifa) link; 90122394Sharti struct in_addr inaddr; 91122394Sharti struct in_addr inmask; 92122394Sharti struct in_addr inbcast; 93122394Sharti struct asn_oid index; /* index for table search */ 94122394Sharti u_int ifindex; 95122394Sharti u_int flags; 96122394Sharti}; 97122394Sharti 98122394Sharti/* 99122394Sharti * Interface receive addresses. Interface link-level multicast, broadcast 100122394Sharti * and hardware addresses are handled automatically. 101122394Sharti */ 102122394Shartistruct mibrcvaddr { 103122394Sharti TAILQ_ENTRY(mibrcvaddr) link; 104122394Sharti struct asn_oid index; 105122394Sharti u_int ifindex; 106122394Sharti u_char addr[ASN_MAXOIDLEN]; 107122394Sharti size_t addrlen; 108122394Sharti u_int flags; 109122394Sharti}; 110122394Shartienum { 111122394Sharti MIBRCVADDR_VOLATILE = 0x00000001, 112122394Sharti MIBRCVADDR_BCAST = 0x00000002, 113122394Sharti MIBRCVADDR_HW = 0x00000004, 114122394Sharti}; 115122394Sharti 116122394Sharti/* network socket */ 117122394Shartiextern int mib_netsock; 118122394Sharti 119122394Sharti/* set an interface name to dynamic mode */ 120122394Shartivoid mib_if_set_dyn(const char *); 121122394Sharti 122122394Sharti/* re-read the systems interface list */ 123122394Shartivoid mib_refresh_iflist(void); 124122394Sharti 125122394Sharti/* find interface by index */ 126122394Shartistruct mibif *mib_find_if(u_int); 127122394Shartistruct mibif *mib_find_if_sys(u_int); 128122394Shartistruct mibif *mib_find_if_name(const char *); 129122394Sharti 130122394Sharti/* iterate through all interfaces */ 131122394Shartistruct mibif *mib_first_if(void); 132122394Shartistruct mibif *mib_next_if(const struct mibif *); 133122394Sharti 134122394Sharti/* register for interface creations */ 135122394Shartiint mib_register_newif(int (*)(struct mibif *), const struct lmodule *); 136122394Shartivoid mib_unregister_newif(const struct lmodule *); 137122394Sharti 138122394Sharti/* get fresh MIB data */ 139122394Shartiint mib_fetch_ifmib(struct mibif *); 140122394Sharti 141122394Sharti/* change the ADMIN status of an interface and refresh the MIB */ 142122394Shartiint mib_if_admin(struct mibif *, int up); 143122394Sharti 144122394Sharti/* find interface address by address */ 145122394Shartistruct mibifa *mib_find_ifa(struct in_addr); 146122394Sharti 147122394Sharti/* find first/next address for a given interface */ 148122394Shartistruct mibifa *mib_first_ififa(const struct mibif *); 149122394Shartistruct mibifa *mib_next_ififa(struct mibifa *); 150122394Sharti 151122394Sharti/* create/delete stacking entries */ 152122394Shartiint mib_ifstack_create(const struct mibif *lower, const struct mibif *upper); 153122394Shartivoid mib_ifstack_delete(const struct mibif *lower, const struct mibif *upper); 154122394Sharti 155122394Sharti/* find receive address */ 156122394Shartistruct mibrcvaddr *mib_find_rcvaddr(u_int, const u_char *, size_t); 157122394Sharti 158122394Sharti/* create/delete receive addresses */ 159122394Shartistruct mibrcvaddr *mib_rcvaddr_create(struct mibif *, const u_char *, size_t); 160122394Shartivoid mib_rcvaddr_delete(struct mibrcvaddr *); 161122394Sharti 162122394Sharti/* register for interface notification */ 163122394Shartivoid *mibif_notify(struct mibif *, const struct lmodule *, mibif_notify_f, 164122394Sharti void *); 165122394Shartivoid mibif_unnotify(void *); 166122394Sharti 167122394Sharti#endif 168