Commit df7f3cc6 authored by Michal Wasiak's avatar Michal Wasiak

[Feature:#218] Export an output of rtu_stat and wrs_vlans via

Export a subset of BRIDGE-MIB and Q-BRIDGE-MIB

Implemented OIDs:
dot1dBase:
 --dot1dBaseBridgeAddress
 --dot1dBaseNumPorts
 --dot1dBaseType
dot1dBasePortTable:
 --dot1dBasePortIfIndex
 --dot1dBasePortCircuit
dot1dTpFdbTable:
 --dot1dTpFdbAddress
 --dot1dTpFdbPort
 --dot1dTpFdbStatus
dot1dStaticTable:
 --dot1dStaticAddress
 --dot1dStaticReceivePort
 --dot1dStaticAllowedToGoTo
 --dot1dStaticStatus
dot1qBase:
 --dot1qVlanVersionNumber
 --dot1qMaxVlanId
 --dot1qMaxSupportedVlans
 --dot1qNumVlans
 --dot1qGvrpStatus
dot1qFdbTable:
 --dot1qFdbDynamicCount
dot1qTpFdbTable:
 --dot1qTpFdbPort
 --dot1qTpFdbStatus
dot1qVlanCurrentTable:
 --dot1qVlanFdbId
 --dot1qVlanCurrentEgressPorts
 --dot1qVlanCurrentUntaggedPorts
 --dot1qVlanStatus
 --dot1qVlanCreationTime
dot1qVlanStaticTable:
 --dot1qVlanStaticName
 --dot1qVlanStaticEgressPorts
 --dot1qVlanForbiddenEgressPorts
 --dot1qVlanStaticUntaggedPorts
 --dot1qVlanStaticRowStatus
dot1qPortVlanTable:
 --dot1qPvid
 --dot1qPortAcceptableFrameTypes
 --dot1qPortIngressFiltering
 --dot1qPortGvrpStatus
 --dot1qPortGvrpFailedRegistrations
 --dot1qPortGvrpLastPduOrigin
 --dot1qPortRestrictedVlanRegistration
parents 18e2737a 60bd07ba
This diff is collapsed.
......@@ -63,6 +63,7 @@ static inline uint8_t *mac_clean(uint8_t mac[ETH_ALEN])
char *mac_to_string(uint8_t mac[ETH_ALEN]);
char *mac_to_buffer(uint8_t mac[ETH_ALEN], char buffer[ETH_ALEN_STR]);
char *mac_to_buffer_no_colons(uint8_t mac[ETH_ALEN], char buffer[2*ETH_ALEN+1]);
int mac_from_str(uint8_t *tomac, const char *fromstr);
int mac_verify(char *mac_str);
int mac_to_lower(char *mac_str);
......
......@@ -2,6 +2,7 @@
#define __LIBWR_RTU_SHMEM_H__
#include <stdint.h>
#include <sys/time.h>
#define RTU_ENTRIES 2048
#define RTU_BUCKETS 4
......@@ -18,6 +19,42 @@
#define ETH_ALEN 6
#define ETH_ALEN_STR 18
#define VALID_CONFIG 1<<31
#define VALID_QMODE 1<<0
#define VALID_PRIO 1<<1
#define VALID_VID 1<<2
#define VALID_FID 1<<3
#define VALID_UNTAG 1<<4
#define VALID_PMASK 1<<5
#define VALID_DROP 1<<6
#define QMODE_ACCESS 0
#define QMODE_TRUNK 1
#define QMODE_DISABLED 2
#define QMODE_UNQ 3
#define QMODE_INVALID 4
#define RTU_VID_MIN 0
#define RTU_VID_MAX 4094
#define RTU_FID_MIN 0
#define RTU_FID_MAX 4094
#define RTU_PRIO_MIN 0
#define RTU_PRIO_MAX 7
#define RTU_PRIO_DISABLE -1
#define PORT_PRIO_MIN RTU_PRIO_MIN
#define PORT_PRIO_MAX RTU_PRIO_MAX
#define PORT_PRIO_DISABLE RTU_PRIO_DISABLE
#define PORT_VID_MIN RTU_VID_MIN
#define PORT_VID_MAX RTU_VID_MAX
#define RTU_PMASK_MIN 0
#define RTU_PMASK_MAX(n_ports) ((1 << n_ports) - 1)
/* RTU entry address */
struct rtu_addr {
int hash;
......@@ -125,6 +162,7 @@ struct rtu_vlan_table_entry {
int prio_override; /* priority override
* (force per-VLAN priority) */
int drop; /* 1: drop the packet (VLAN not registered) */
struct timeval creation_time; /* timestamp of creation, used by SNMP */
};
/**
......@@ -137,15 +175,26 @@ struct rtu_mirror_info {
uint32_t dmask; /* Destination port mask */
};
/**
* \brief RTU port configuration
*/
struct rtu_port_entry {
uint8_t qmode; /* q mode of a port */
uint8_t fix_prio; /* is fix priority set */
uint8_t prio; /* VLAN priority */
uint8_t untag; /* untag */
uint16_t pvid; /* PVID */
uint8_t mac[ETH_ALEN]; /* MAC of a port */
};
/* This is the overall structure stored in shared memory */
#define RTU_SHMEM_VERSION 4 /* Version 3, changed wrs_shm_head */
#define RTU_SHMEM_VERSION 7 /* Version 7, add vlan creation_time */
struct rtu_shmem_header {
struct rtu_filtering_entry *filters;
struct rtu_vlan_table_entry *vlans;
struct rtu_mirror_info *mirror;
unsigned long filters_offset;
unsigned long vlans_offset;
unsigned long mirror_offset;
struct rtu_port_entry *rtu_ports;
uint32_t rtu_nports;
};
#endif /* __LIBWR_RTU_SHMEM_H__ */
......@@ -27,4 +27,10 @@ void strncpy_e(char *d, char *s, int len);
/* Create map */
void *create_map(unsigned long address, unsigned long size);
/* Count bits in a unsigned int */
unsigned int bitCount (unsigned int value);
/* Convert bitmask of ports from notation used by RTU (lowest port on lowest bit)
* to notation used by SNMP (lowrst port, most significant bit) */
void convert_portmask_to_snmp_bitmask(int nports, uint32_t port_mask, char *bitmask, size_t *snmp_bitmask_len);
#endif /* __LIBWR_HW_UTIL_H */
......@@ -53,6 +53,17 @@ char *mac_to_buffer(uint8_t mac[ETH_ALEN], char buffer[ETH_ALEN_STR])
return buffer;
}
/**
* \brief Write mac address into a buffer to avoid concurrent access on static variable.
*/
char *mac_to_buffer_no_colons(uint8_t mac[ETH_ALEN], char buffer[2*ETH_ALEN+1])
{
if (mac && buffer)
snprintf(buffer, ETH_ALEN_STR, "%02x%02x%02x%02x%02x%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return buffer;
}
/**
* \brief Function to retrieve mac address from text input (argument in terminal)
*/
......
......@@ -133,3 +133,35 @@ void *create_map(unsigned long address, unsigned long size)
return NULL;
return mapaddr + fragment;
}
unsigned int bitCount (unsigned int value) {
unsigned int count = 0;
while (value > 0) {
if ((value & 1) == 1)
count++;
value >>= 1;
}
return count;
}
/* Convert bitmask of ports from notation used by RTU (lowest port on lowest bit)
* to notation used by SNMP (lowrst port, most significant bit) */
void convert_portmask_to_snmp_bitmask(int nports, uint32_t port_mask, char *bitmask, size_t *snmp_bitmask_len)
{
int i;
/* round up number of ports to a number dividable by 8 */
nports = 8 * ((nports + 7) / 8);
for (i = 0; i < nports;i++){
*bitmask |= port_mask & 1;
port_mask >>= 1;
/* jump to next char */
if (i % 8 == 7) {
bitmask++;
*bitmask = 0;
}
*bitmask <<= 1;
}
/* count the number of bytes used */
*snmp_bitmask_len = nports / 8;
}
-include ../Makefile.specific
# We are now Kconfig-based
-include ../../.config
# include Makefile for bridge mib
BRIDGE_MIB_DIR:=bridge_mib
include ${BRIDGE_MIB_DIR}/Makefile
# if BRVER not defined use a wildcard
BRVER?=2*
SNMP_BUILD := $(wildcard $(WRS_OUTPUT_DIR)/build/buildroot-$(BRVER))
......@@ -23,6 +30,9 @@ OBJDUMP = $(CROSS_COMPILE)objdump
# There is a static variable in pp-printf.c to accumulate stuff
CONFIG_PRINT_BUFSIZE ?= 256
export CFLAGS_OPTIMIZATION:= ${shell echo $(CONFIG_OPTIMIZATION)}
CFLAGS += $(CFLAGS_OPTIMIZATION)
# defer running "net-snmp-config --cflags" so it is visible in make output
CFLAGS += -fPIC -Wall $$($(NET_SNMP_CONFIG) --cflags | sed s,-I/usr/include,,)
LDFLAGS = -shared $$($(NET_SNMP_CONFIG) --ldflags)
......@@ -62,6 +72,7 @@ SOURCES = \
wrsPtpDataTable.c \
wrsPortStatusTable.c \
wrsPtpInstanceTable.c \
$(BRIDGE_MIB_SRCS) \
init.c \
$(PPSI_SOURCES)
......
-include ../Makefile.specific
BRIDGE_DIRS= \
dot1dBasePortTable \
dot1dStaticTable \
dot1dTpFdbTable \
dot1qFdbTable \
dot1qPortVlanTable \
dot1qTpFdbTable \
dot1qVlanCurrentTable \
dot1qVlanStaticTable \
BRIDGE_INCLUDE_DIRS:=$(addsuffix /Makefile,$(BRIDGE_DIRS))
BRIDGE_INCLUDE_DIRS:=$(addprefix $(BRIDGE_MIB_DIR)/,$(BRIDGE_INCLUDE_DIRS))
include $(BRIDGE_INCLUDE_DIRS)
#BRIDGE_I_DIRS=$(addprefix -I$(BRIDGE_MIB_DIR)/,$(BRIDGE_DIRS))
CFLAGS += -I$(BRIDGE_MIB_DIR)
BRIDGE_MIB_SRCS += \
dot1dBase.c \
dot1qBase.c \
init_bridge_mib.c
BRIDGE_MIB_SRCS:=$(addprefix $(BRIDGE_MIB_DIR)/,$(BRIDGE_MIB_SRCS))
/*
* Note: this file originally auto-generated by mib2c using
* mib2c -c mib2c.scalar.conf BRIDGE-MIB::dot1dBase
* $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "dot1dBase.h"
#include "wrsSnmp.h"
#include "snmp_shmem.h"
/** Initializes the dot1dBase module */
void
init_dot1dBase(void)
{
const oid dot1dBaseBridgeAddress_oid[] = { 1,3,6,1,2,1,17,1,1 };
const oid dot1dBaseNumPorts_oid[] = { 1,3,6,1,2,1,17,1,2 };
const oid dot1dBaseType_oid[] = { 1,3,6,1,2,1,17,1,3 };
DEBUGMSGTL(("dot1dBase", "Initializing\n"));
netsnmp_register_scalar(
netsnmp_create_handler_registration("dot1dBaseBridgeAddress", handle_dot1dBaseBridgeAddress,
dot1dBaseBridgeAddress_oid, OID_LENGTH(dot1dBaseBridgeAddress_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("dot1dBaseNumPorts", handle_dot1dBaseNumPorts,
dot1dBaseNumPorts_oid, OID_LENGTH(dot1dBaseNumPorts_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("dot1dBaseType", handle_dot1dBaseType,
dot1dBaseType_oid, OID_LENGTH(dot1dBaseType_oid),
HANDLER_CAN_RONLY
));
}
int
handle_dot1dBaseBridgeAddress(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
int i;
switch(reqinfo->mode) {
case MODE_GET:
/* look for a first port */
for (i = 0; i < hal_nports_local; i++) {
if (!strcmp(hal_ports[i].name, FIRST_PORT_NAME)) {
/* First port found */
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
hal_ports[i].hw_addr,
ETH_ALEN);
/* no need for more checks */
return SNMP_ERR_NOERROR;
}
}
snmp_log(LOG_ERR, "Port name (%s) not found for handle_dot1dBaseBridgeAddress!\n", FIRST_PORT_NAME);
return SNMP_ERR_GENERR;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_dot1dBaseBridgeAddress\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_dot1dBaseNumPorts(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
/* Get the port number from HAL */
int port_num = hal_nports_local;
switch(reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
&port_num,
sizeof(port_num));
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_dot1dBaseNumPorts\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_dot1dBaseType(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
int baseType = BASETYPE_TRANSPARENT_ONLY;
switch(reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
&baseType,
sizeof(baseType));
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_dot1dBaseType\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
/*
* Note: this file originally auto-generated by mib2c using
* $
*/
#ifndef DOT1DBASE_H
#define DOT1DBASE_H
/* Defines */
#define BASETYPE_UNKNOWN 1
#define BASETYPE_TRANSPARENT_ONLY 2
#define BASETYPE_SOURCEROUTE_ONLY 3
#define BASETYPE_SRT 4
#define FIRST_PORT_NAME "wri1"
/* function declarations */
void init_dot1dBase(void);
Netsnmp_Node_Handler handle_dot1dBaseBridgeAddress;
Netsnmp_Node_Handler handle_dot1dBaseNumPorts;
Netsnmp_Node_Handler handle_dot1dBaseType;
#endif /* DOT1DBASE_H */
BRIDGE_MIB_SRCS += \
dot1dBasePortTable/dot1dBasePortTable.c \
dot1dBasePortTable/dot1dBasePortTable_data_get.c \
dot1dBasePortTable/dot1dBasePortTable_data_set.c \
dot1dBasePortTable/dot1dBasePortTable_data_access.c \
dot1dBasePortTable/dot1dBasePortTable_interface.c
########################################################################
##
## mib2c node setting for dot1dBasePort
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = long@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = 1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 0@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
##
## mib2c node setting for dot1dBasePortCircuit
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = oid@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = 1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 1@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
## Allow realloc when data size exceeds length? If your data
## store for this node is a pointer allocated with one of the
## alloc family functions, you can set this to 1 to use realloc
## when a new value length exceeds the old lenght. If you are
## using a fixed size buffer, this value should be 0.
##
## @eval $m2c_node_realloc = 0@
########################################################################
##
## mib2c node setting for dot1dBasePortDelayExceededDiscards
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = u_long@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = 1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 0@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
##
## mib2c node setting for dot1dBasePortIfIndex
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = long@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = 1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 0@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
##
## mib2c node setting for dot1dBasePortMtuExceededDiscards
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = u_long@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = 1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 0@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
## ########################################################################
##
## mib2c Table setting for dot1dBasePortTable
##
## ########################################################################
##
## User context structure type
##
@eval $m2c_context_reg = "netsnmp_data_list"@
##
## ########################################################################
##
## Allocate data structure in row structure? (vs embedd)
##
@eval $m2c_data_allocate = 0@
##
## ########################################################################
##
## Generate code to cache data?
##
@eval $m2c_data_cache = 0@
##
## ########################################################################
##
## Data context structure type
##
@eval $m2c_data_context = "generated"@ [generated|NAME]
##
## ########################################################################
##
## Generate function to initialize row context when created?
##
@eval $m2c_data_init = 1@
##
## ########################################################################
##
## Persistence of data context
## // 0:persistent, 1:semi-transient, 2:transient
##
@eval $m2c_data_transient = 0@
##
## ########################################################################
##
## Include some example code?
##
@eval $m2c_include_examples = 1@
##
## ########################################################################
##
## Generate code for irreversible_commit mode?
##
@eval $m2c_irreversible_commit = 0@
##
## ########################################################################
##
## Data access method
##
@eval $m2c_table_access = "container-cached"@
##
## ########################################################################
##
## Generate row dependency function?
##
@eval $m2c_table_dependencies = 0@
##
## ########################################################################
##
## Generate data store/restore functions for persistent storage?
##
@eval $m2c_table_persistent = 0@
##
## ########################################################################
##
## Generate code for dynamic row creation?
##
@eval $m2c_table_row_creation = 0@
##
## ########################################################################
##
## Generate code for settable objects?
##
@eval $m2c_table_settable = 0@
##
## ########################################################################
##
## Skip mapping between data context and MIB formats?
## // 0:generate maps, 1:skip maps, -1:skip unless enum/oid
##
@eval $m2c_table_skip_mapping = 1@
##
## ########################################################################
##
## Generate code for sparse tables?
##
@eval $m2c_table_sparse = 0@
##
## ########################################################################
##
## Generate Makefile/AgentX code?
##
@eval $mfd_generate_makefile = 1@
@eval $mfd_generate_subagent = 1@
##
************************************************************************
dot1dBasePortTable README
------------------------------------------------------------------------
This document describes the results of the mib2c code generation
system using the mfd code generation template. The resulting files
are documented both in this README file as well as per-table specific
README files. All of the files generated by this run of mib2c will
begin with the dot1dBasePortTable prefix.
Quick Start
-----------
For those interested in a quick start, to get a pseudo-todo list, try
this command in directory with the generated code:
grep -n "TODO:" *.[ch] | sed 's/\([^ ]*\) \(.*\)TODO\(.*\)/\3 (\1)/' | sort -n
Key:
:o: Optional
:r: Recommended
:M: Mandatory
:A: Advanced users
This will give you and ordered list of places in the code that you
may (or must) take a closer look at).
You may also want to take a look at the on-line tutorial, found here:
http://www.net-snmp.org/tutorial/tutorial-5/toolkit/mfd/index.html
MIBs For Dummies Overview
-------------------------
The MIBs For Dummies (MFD) configuration files have been written to help
SNMP novices implement SNMP MIBs. This section will be a brief
introduction to some of the general concepts you should be familar with.
Managed Information Base (MIB)
------------------------------
A SNMP MIB (Managed information base) is a text file that describes the
syntax for some set of data objects. The MIB creates a correlation
between an ASCII name for an object and a number OID (Object Identifier).
The SNMP protocol communicates information using the OIDs, and the MIB
allows tools to display a name, which we humans find easier to deal with.
To use an analogy, a MIB is much like a menu at a restaurant. If you've
ever been to a reataurant and ordered a meal, and later received a bill
that simply had '#6' on it, you get the idea. The name is easier for
the customers to remember, and the waiters and chefs use the number for
efficency.
Scalars
-------
A scalar variable is a unique object in a MIB which can represent
a single value. For example, the SNMP standard MIB-II defines a
variable, sysContact.0, which is a string containing the contact
information for the person in charge of a particular agent. Note
that scalar variable always end with '.0'.
Rows and Tables
---------------
When a group of related attributes occur more than once, they can be
grouped together in a table. A table has an index, which uniquely
identifies a particular row, and data columns, which contain the
attributes for that row.
For example, the SNMP standard MIB-II defines a table, ifTable, which
contains information on the ethernet interfaces on a system.
Data Structures
---------------
The code generated by the MFD configuration files has a few important
structures.
The Data Context
----------------
The data context structure should contain the necessary information
to provide the data for the columns in a given row. As long as you
can extract the data for a column for the data context, the data context
can be anything you want: a pointer to an existing structure, the
parameters needed for a function call or an actual copy of the data.
By default, a data context structure is generated with storage for
all the data in a row. Information on changing the default is presented
later on in this help.
The MIB Context
---------------
The MIB context structure is generated with storage for all the
indexes of a table. This data will be used when searching for the
correct row to process for a request.
The Row Request Context
-----------------------
Each table will have a unique data structure for holding data during
the processing of a particular row. The row request context contains
the registration context (that you supply during initilization),
the data context, the MIB context, the undo context (for settable
tables) and other data. There is also a netsnmp_data_list, which can
be used to temporary storage during processing.
The Table Registration Pointer
------------------------------
During initilization, you may provide a pointer to arbitrary data for
you own use. This pointer will be saved in the row request context,
and is passed as a parameter to several functions. It is not required,
and is provided as a way for you to access table specific data in
the generated code.
These files are top-level files potentially useful for all the tables:
------------------------------------------------------------------------
File : dot1dBasePortTable_Makefile
----------------------------------------------------------------------
Purpose : Make file for compiling a (sub)agent. This file is only
useful if you don't want to compile your code directly
into the Net-SNMP master agent.
Editable: Optional
Usage : make -f dot1dBasePortTable_Makefile
File : dot1dBasePortTable_subagent.c
----------------------------------------------------------------------
Purpose : This file contains a main() function for an agent or
sub-agent and is compiled using the Makefile above.
Table specific README files
------------------------------------------------------------------------
Each table for which code was generated has its own README file
describing the files specifically associated with each table. You
should probably read these next:
dot1dBasePortTable-README-dot1dBasePortTable.txt
These are miscellaneous auto-generated code files you generally
shouldn't edit. They contain code that ties your code together with
the Net-SNMP agent.
------------------------------------------------------------------------
File : dot1dBasePortTable.h
Purpose : Header file for the module set. Includes config_require
macros to auto-load the other code pieces when compiled
into the agent.
File : dot1dBasePortTable_oids.h
Purpose : C #define definitions of the tables, columns, and OIDs
File : dot1dBasePortTable_enums.h
Purpose : C #define definitions of the enumerated type values for
each column of each table that requires them.
File : dot1dBasePortTable_interface.c
Purpose : MFD interface to Net-SNMP. This auto-generated code ties the
functions you will fill out to the code that the agent needs.
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*/
/** \page MFD helper for dot1dBasePortTable
*
* \section intro Introduction
* Introductory text.
*
*/
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* include our parent header */
#include "dot1dBasePortTable.h"
#include <net-snmp/agent/mib_modules.h>
#include "dot1dBasePortTable_interface.h"
const oid dot1dBasePortTable_oid[] = { DOT1DBASEPORTTABLE_OID };
const int dot1dBasePortTable_oid_size = OID_LENGTH(dot1dBasePortTable_oid);
dot1dBasePortTable_registration dot1dBasePortTable_user_context;
void initialize_table_dot1dBasePortTable(void);
void shutdown_table_dot1dBasePortTable(void);
/**
* Initializes the dot1dBasePortTable module
*/
void
init_dot1dBasePortTable(void)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:init_dot1dBasePortTable","called\n"));
/*
* TODO:300:o: Perform dot1dBasePortTable one-time module initialization.
*/
/*
* here we initialize all the tables we're planning on supporting
*/
if (should_init("dot1dBasePortTable"))
initialize_table_dot1dBasePortTable();
} /* init_dot1dBasePortTable */
/**
* Shut-down the dot1dBasePortTable module (agent is exiting)
*/
void
shutdown_dot1dBasePortTable(void)
{
if (should_init("dot1dBasePortTable"))
shutdown_table_dot1dBasePortTable();
}
/**
* Initialize the table dot1dBasePortTable
* (Define its contents and how it's structured)
*/
void
initialize_table_dot1dBasePortTable(void)
{
dot1dBasePortTable_registration * user_context;
u_long flags;
DEBUGMSGTL(("verbose:dot1dBasePortTable:initialize_table_dot1dBasePortTable","called\n"));
/*
* TODO:301:o: Perform dot1dBasePortTable one-time table initialization.
*/
/*
* TODO:302:o: |->Initialize dot1dBasePortTable user context
* if you'd like to pass in a pointer to some data for this
* table, allocate or set it up here.
*/
/*
* a netsnmp_data_list is a simple way to store void pointers. A simple
* string token is used to add, find or remove pointers.
*/
user_context = netsnmp_create_data_list("dot1dBasePortTable", NULL, NULL);
/*
* No support for any flags yet, but in the future you would
* set any flags here.
*/
flags = 0;
/*
* call interface initialization code
*/
_dot1dBasePortTable_initialize_interface(user_context, flags);
} /* initialize_table_dot1dBasePortTable */
/**
* Shutdown the table dot1dBasePortTable
*/
void
shutdown_table_dot1dBasePortTable(void)
{
/*
* call interface shutdown code
*/
_dot1dBasePortTable_shutdown_interface(&dot1dBasePortTable_user_context);
}
/**
* extra context initialization (eg default values)
*
* @param rowreq_ctx : row request context
* @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate)
*
* @retval MFD_SUCCESS : no errors
* @retval MFD_ERROR : error (context allocate will fail)
*/
int
dot1dBasePortTable_rowreq_ctx_init(dot1dBasePortTable_rowreq_ctx *rowreq_ctx,
void *user_init_ctx)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortTable_rowreq_ctx_init","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
/*
* TODO:210:o: |-> Perform extra dot1dBasePortTable rowreq initialization. (eg DEFVALS)
*/
return MFD_SUCCESS;
} /* dot1dBasePortTable_rowreq_ctx_init */
/**
* extra context cleanup
*
*/
void dot1dBasePortTable_rowreq_ctx_cleanup(dot1dBasePortTable_rowreq_ctx *rowreq_ctx)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortTable_rowreq_ctx_cleanup","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
/*
* TODO:211:o: |-> Perform extra dot1dBasePortTable rowreq cleanup.
*/
} /* dot1dBasePortTable_rowreq_ctx_cleanup */
/**
* pre-request callback
*
*
* @retval MFD_SUCCESS : success.
* @retval MFD_ERROR : other error
*/
int
dot1dBasePortTable_pre_request(dot1dBasePortTable_registration * user_context)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortTable_pre_request","called\n"));
/*
* TODO:510:o: Perform dot1dBasePortTable pre-request actions.
*/
return MFD_SUCCESS;
} /* dot1dBasePortTable_pre_request */
/**
* post-request callback
*
* Note:
* New rows have been inserted into the container, and
* deleted rows have been removed from the container and
* released.
*
* @param user_context
* @param rc : MFD_SUCCESS if all requests succeeded
*
* @retval MFD_SUCCESS : success.
* @retval MFD_ERROR : other error (ignored)
*/
int
dot1dBasePortTable_post_request(dot1dBasePortTable_registration * user_context, int rc)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortTable_post_request","called\n"));
/*
* TODO:511:o: Perform dot1dBasePortTable post-request actions.
*/
return MFD_SUCCESS;
} /* dot1dBasePortTable_post_request */
/** @{ */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*/
#ifndef DOT1DBASEPORTTABLE_H
#define DOT1DBASEPORTTABLE_H
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup misc misc: Miscellaneous routines
*
* @{
*/
#include <net-snmp/library/asn1.h>
/* other required module components */
/* *INDENT-OFF* */
config_add_mib(BRIDGE-MIB)
config_require(BRIDGE-MIB/dot1dBasePortTable/dot1dBasePortTable_interface)
config_require(BRIDGE-MIB/dot1dBasePortTable/dot1dBasePortTable_data_access)
config_require(BRIDGE-MIB/dot1dBasePortTable/dot1dBasePortTable_data_get)
config_require(BRIDGE-MIB/dot1dBasePortTable/dot1dBasePortTable_data_set)
/* *INDENT-ON* */
/* OID and column number definitions for dot1dBasePortTable */
#include "dot1dBasePortTable_oids.h"
/* enum definions */
#include "dot1dBasePortTable_enums.h"
/* *********************************************************************
* function declarations
*/
void init_dot1dBasePortTable(void);
void shutdown_dot1dBasePortTable(void);
/* *********************************************************************
* Table declarations
*/
/**********************************************************************
**********************************************************************
***
*** Table dot1dBasePortTable
***
**********************************************************************
**********************************************************************/
/*
* BRIDGE-MIB::dot1dBasePortTable is subid 4 of dot1dBase.
* Its status is Current.
* OID: .1.3.6.1.2.1.17.1.4, length: 9
*/
/* *********************************************************************
* When you register your mib, you get to provide a generic
* pointer that will be passed back to you for most of the
* functions calls.
*
* TODO:100:r: Review all context structures
*/
/*
* TODO:101:o: |-> Review dot1dBasePortTable registration context.
*/
typedef netsnmp_data_list dot1dBasePortTable_registration;
/**********************************************************************/
/*
* TODO:110:r: |-> Review dot1dBasePortTable data context structure.
* This structure is used to represent the data for dot1dBasePortTable.
*/
/*
* This structure contains storage for all the columns defined in the
* dot1dBasePortTable.
*/
typedef struct dot1dBasePortTable_data_s {
/*
* dot1dBasePortIfIndex(2)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H
*/
long dot1dBasePortIfIndex;
/*
* dot1dBasePortCircuit(3)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h
*/
oid dot1dBasePortCircuit[128];
size_t dot1dBasePortCircuit_len; /* # of oid elements, not bytes */
} dot1dBasePortTable_data;
/*
* TODO:120:r: |-> Review dot1dBasePortTable mib index.
* This structure is used to represent the index for dot1dBasePortTable.
*/
typedef struct dot1dBasePortTable_mib_index_s {
/*
* dot1dBasePort(1)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
*/
long dot1dBasePort;
} dot1dBasePortTable_mib_index;
/*
* TODO:121:r: | |-> Review dot1dBasePortTable max index length.
* If you KNOW that your indexes will never exceed a certain
* length, update this macro to that length.
*/
#define MAX_dot1dBasePortTable_IDX_LEN 1
/* *********************************************************************
* TODO:130:o: |-> Review dot1dBasePortTable Row request (rowreq) context.
* When your functions are called, you will be passed a
* dot1dBasePortTable_rowreq_ctx pointer.
*/
typedef struct dot1dBasePortTable_rowreq_ctx_s {
/** this must be first for container compare to work */
netsnmp_index oid_idx;
oid oid_tmp[MAX_dot1dBasePortTable_IDX_LEN];
dot1dBasePortTable_mib_index tbl_idx;
dot1dBasePortTable_data data;
/*
* flags per row. Currently, the first (lower) 8 bits are reserved
* for the user. See mfd.h for other flags.
*/
u_int rowreq_flags;
/*
* TODO:131:o: | |-> Add useful data to dot1dBasePortTable rowreq context.
*/
/*
* storage for future expansion
*/
netsnmp_data_list *dot1dBasePortTable_data_list;
} dot1dBasePortTable_rowreq_ctx;
typedef struct dot1dBasePortTable_ref_rowreq_ctx_s {
dot1dBasePortTable_rowreq_ctx *rowreq_ctx;
} dot1dBasePortTable_ref_rowreq_ctx;
/* *********************************************************************
* function prototypes
*/
int dot1dBasePortTable_pre_request(dot1dBasePortTable_registration * user_context);
int dot1dBasePortTable_post_request(dot1dBasePortTable_registration * user_context,
int rc);
int dot1dBasePortTable_rowreq_ctx_init(dot1dBasePortTable_rowreq_ctx *rowreq_ctx,
void *user_init_ctx);
void dot1dBasePortTable_rowreq_ctx_cleanup(dot1dBasePortTable_rowreq_ctx *rowreq_ctx);
dot1dBasePortTable_rowreq_ctx *
dot1dBasePortTable_row_find_by_mib_index(dot1dBasePortTable_mib_index *mib_idx);
extern const oid dot1dBasePortTable_oid[];
extern const int dot1dBasePortTable_oid_size;
#include "dot1dBasePortTable_interface.h"
#include "dot1dBasePortTable_data_access.h"
#include "dot1dBasePortTable_data_get.h"
#include "dot1dBasePortTable_data_set.h"
/*
* DUMMY markers, ignore
*
* TODO:099:x: *************************************************************
* TODO:199:x: *************************************************************
* TODO:299:x: *************************************************************
* TODO:399:x: *************************************************************
* TODO:499:x: *************************************************************
*/
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_H */
/** @} */
CC=gcc
TABLE_PREFIX=dot1dBasePortTable
NETSNMPCONFIG=net-snmp-config
# uncomment this if you have GNU make
#NETSNMPCFLAGS := $(shell $(NETSNMPCONFIG) --base-cflags)
#NETSNMPLIBS := $(shell $(NETSNMPCONFIG) --agent-libs)
NETSNMPCFLAGS=`$(NETSNMPCONFIG) --base-cflags`
NETSNMPLIBS=`$(NETSNMPCONFIG) --agent-libs`
LIBS=$(NETSNMPLIBS)
STRICT_FLAGS = -Wall -Wstrict-prototypes
CFLAGS=-I. $(NETSNMPCFLAGS) $(STRICT_FLAGS)
USER_SRCS = \
$(TABLE_PREFIX)_data_get.c \
$(TABLE_PREFIX)_data_set.c \
$(TABLE_PREFIX)_data_access.c
SRCS = $(USER_SRCS) \
$(TABLE_PREFIX).c \
$(TABLE_PREFIX)_subagent.c \
$(TABLE_PREFIX)_interface.c
USER_OBJS = \
$(TABLE_PREFIX)_data_get.o \
$(TABLE_PREFIX)_data_set.o \
$(TABLE_PREFIX)_data_access.o
OBJS = $(USER_OBJS) \
$(TABLE_PREFIX).o \
$(TABLE_PREFIX)_subagent.o \
$(TABLE_PREFIX)_interface.o
TARGETS=$(TABLE_PREFIX)
.SUFFIXES:
.SUFFIXES: .c .o .deps
all: $(TARGETS)
user: $(USER_OBJS)
$(TARGETS): $(LIB_DEPS)
$(TABLE_PREFIX): $(OBJS) $(TABLE_PREFIX)_Makefile
$(CC) -o $(TABLE_PREFIX) $(OBJS) $(LIBS)
clean:
rm -f $(OBJS) $(TARGETS)
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*/
#ifndef DOT1DBASEPORTTABLE_DATA_ACCESS_H
#define DOT1DBASEPORTTABLE_DATA_ACCESS_H
#ifdef __cplusplus
extern "C" {
#endif
/* *********************************************************************
* function declarations
*/
/* *********************************************************************
* Table declarations
*/
/**********************************************************************
**********************************************************************
***
*** Table dot1dBasePortTable
***
**********************************************************************
**********************************************************************/
/*
* BRIDGE-MIB::dot1dBasePortTable is subid 4 of dot1dBase.
* Its status is Current.
* OID: .1.3.6.1.2.1.17.1.4, length: 9
*/
int dot1dBasePortTable_init_data(dot1dBasePortTable_registration * dot1dBasePortTable_reg);
void dot1dBasePortTable_container_init(netsnmp_container **container_ptr_ptr);
void dot1dBasePortTable_container_shutdown(netsnmp_container *container_ptr);
int dot1dBasePortTable_container_load(netsnmp_container *container);
void dot1dBasePortTable_container_free(netsnmp_container *container);
/*
***************************************************
*** START EXAMPLE CODE ***
***---------------------------------------------***/
/* *********************************************************************
* Since we have no idea how you really access your data, we'll go with
* a worst case example: a flat text file.
*/
#define MAX_LINE_SIZE 256
/*
***---------------------------------------------***
*** END EXAMPLE CODE ***
***************************************************/
int dot1dBasePortTable_row_prep( dot1dBasePortTable_rowreq_ctx *rowreq_ctx);
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_DATA_ACCESS_H */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*/
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* include our parent header */
#include "dot1dBasePortTable.h"
/** @defgroup data_get data_get: Routines to get data
*
* TODO:230:M: Implement dot1dBasePortTable get routines.
* TODO:240:M: Implement dot1dBasePortTable mapping routines (if any).
*
* These routine are used to get the value for individual objects. The
* row context is passed, along with a pointer to the memory where the
* value should be copied.
*
* @{
*/
/**********************************************************************
**********************************************************************
***
*** Table dot1dBasePortTable
***
**********************************************************************
**********************************************************************/
/*
* BRIDGE-MIB::dot1dBasePortTable is subid 4 of dot1dBase.
* Its status is Current.
* OID: .1.3.6.1.2.1.17.1.4, length: 9
*/
/* ---------------------------------------------------------------------
* TODO:200:r: Implement dot1dBasePortTable data context functions.
*/
/**
* set mib index(es)
*
* @param tbl_idx mib index structure
* @param dot1dBasePort_val
*
* @retval MFD_SUCCESS : success.
* @retval MFD_ERROR : other error.
*
* @remark
* This convenience function is useful for setting all the MIB index
* components with a single function call. It is assume that the C values
* have already been mapped from their native/rawformat to the MIB format.
*/
int
dot1dBasePortTable_indexes_set_tbl_idx(dot1dBasePortTable_mib_index *tbl_idx, long dot1dBasePort_val)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortTable_indexes_set_tbl_idx","called\n"));
/* dot1dBasePort(1)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h */
tbl_idx->dot1dBasePort = dot1dBasePort_val;
return MFD_SUCCESS;
} /* dot1dBasePortTable_indexes_set_tbl_idx */
/**
* @internal
* set row context indexes
*
* @param reqreq_ctx the row context that needs updated indexes
*
* @retval MFD_SUCCESS : success.
* @retval MFD_ERROR : other error.
*
* @remark
* This function sets the mib indexs, then updates the oid indexs
* from the mib index.
*/
int
dot1dBasePortTable_indexes_set(dot1dBasePortTable_rowreq_ctx *rowreq_ctx, long dot1dBasePort_val)
{
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortTable_indexes_set","called\n"));
if(MFD_SUCCESS != dot1dBasePortTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx
, dot1dBasePort_val
))
return MFD_ERROR;
/*
* convert mib index to oid index
*/
rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);
if(0 != dot1dBasePortTable_index_to_oid(&rowreq_ctx->oid_idx,
&rowreq_ctx->tbl_idx)) {
return MFD_ERROR;
}
return MFD_SUCCESS;
} /* dot1dBasePortTable_indexes_set */
/*---------------------------------------------------------------------
* BRIDGE-MIB::dot1dBasePortEntry.dot1dBasePortIfIndex
* dot1dBasePortIfIndex is subid 2 of dot1dBasePortEntry.
* Its status is Current, and its access level is ReadOnly.
* OID: .1.3.6.1.2.1.17.1.4.1.2
* Description:
The value of the instance of the ifIndex object,
defined in IF-MIB, for the interface corresponding
to this port.
*
* Attributes:
* accessible 1 isscalar 0 enums 0 hasdefval 0
* readable 1 iscolumn 1 ranges 1 hashint 1
* settable 0
* hint: d
*
* Ranges: 1 - 2147483647;
*
* Its syntax is InterfaceIndex (based on perltype INTEGER32)
* The net-snmp type is ASN_INTEGER. The C type decl is long (long)
*/
/**
* Extract the current value of the dot1dBasePortIfIndex data.
*
* Set a value using the data context for the row.
*
* @param rowreq_ctx
* Pointer to the row request context.
* @param dot1dBasePortIfIndex_val_ptr
* Pointer to storage for a long variable
*
* @retval MFD_SUCCESS : success
* @retval MFD_SKIP : skip this node (no value for now)
* @retval MFD_ERROR : Any other error
*/
int
dot1dBasePortIfIndex_get( dot1dBasePortTable_rowreq_ctx *rowreq_ctx, long * dot1dBasePortIfIndex_val_ptr )
{
/** we should have a non-NULL pointer */
netsnmp_assert( NULL != dot1dBasePortIfIndex_val_ptr );
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortIfIndex_get","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
/*
* TODO:231:o: |-> Extract the current value of the dot1dBasePortIfIndex data.
* copy (* dot1dBasePortIfIndex_val_ptr ) from rowreq_ctx->data
*/
(* dot1dBasePortIfIndex_val_ptr ) = rowreq_ctx->data.dot1dBasePortIfIndex;
return MFD_SUCCESS;
} /* dot1dBasePortIfIndex_get */
/*---------------------------------------------------------------------
* BRIDGE-MIB::dot1dBasePortEntry.dot1dBasePortCircuit
* dot1dBasePortCircuit is subid 3 of dot1dBasePortEntry.
* Its status is Current, and its access level is ReadOnly.
* OID: .1.3.6.1.2.1.17.1.4.1.3
* Description:
For a port that (potentially) has the same value of
dot1dBasePortIfIndex as another port on the same bridge.
This object contains the name of an object instance
unique to this port. For example, in the case where
multiple ports correspond one-to-one with multiple X.25
virtual circuits, this value might identify an (e.g.,
the first) object instance associated with the X.25
virtual circuit corresponding to this port.
For a port which has a unique value of
dot1dBasePortIfIndex, this object can have the value
{ 0 0 }.
*
* Attributes:
* accessible 1 isscalar 0 enums 0 hasdefval 0
* readable 1 iscolumn 1 ranges 0 hashint 0
* settable 0
*
*
* Its syntax is OBJECTID (based on perltype OBJECTID)
* The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid)
* This data type requires a length.
*/
/**
* Extract the current value of the dot1dBasePortCircuit data.
*
* Set a value using the data context for the row.
*
* @param rowreq_ctx
* Pointer to the row request context.
* @param dot1dBasePortCircuit_val_ptr_ptr
* Pointer to storage for a oid variable
* @param dot1dBasePortCircuit_val_ptr_len_ptr
* Pointer to a size_t. On entry, it will contain the size (in bytes)
* pointed to by dot1dBasePortCircuit.
* On exit, this value should contain the data size (in bytes).
*
* @retval MFD_SUCCESS : success
* @retval MFD_SKIP : skip this node (no value for now)
* @retval MFD_ERROR : Any other error
*
* @note If you need more than (*dot1dBasePortCircuit_val_ptr_len_ptr) bytes of memory,
* allocate it using malloc() and update dot1dBasePortCircuit_val_ptr_ptr.
* <b>DO NOT</b> free the previous pointer.
* The MFD helper will release the memory you allocate.
*
* @remark If you call this function yourself, you are responsible
* for checking if the pointer changed, and freeing any
* previously allocated memory. (Not necessary if you pass
* in a pointer to static memory, obviously.)
*/
int
dot1dBasePortCircuit_get( dot1dBasePortTable_rowreq_ctx *rowreq_ctx, oid **dot1dBasePortCircuit_val_ptr_ptr, size_t *dot1dBasePortCircuit_val_ptr_len_ptr )
{
/** we should have a non-NULL pointer and enough storage */
netsnmp_assert( (NULL != dot1dBasePortCircuit_val_ptr_ptr) && (NULL != *dot1dBasePortCircuit_val_ptr_ptr));
netsnmp_assert( NULL != dot1dBasePortCircuit_val_ptr_len_ptr );
DEBUGMSGTL(("verbose:dot1dBasePortTable:dot1dBasePortCircuit_get","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
/*
* TODO:231:o: |-> Extract the current value of the dot1dBasePortCircuit data.
* copy (* dot1dBasePortCircuit_val_ptr_ptr ) data and (* dot1dBasePortCircuit_val_ptr_len_ptr ) from rowreq_ctx->data
*/
/*
* make sure there is enough space for dot1dBasePortCircuit data
*/
if ((NULL == (* dot1dBasePortCircuit_val_ptr_ptr )) ||
((* dot1dBasePortCircuit_val_ptr_len_ptr ) <
(rowreq_ctx->data.dot1dBasePortCircuit_len* sizeof(rowreq_ctx->data.dot1dBasePortCircuit[0])))) {
/*
* allocate space for dot1dBasePortCircuit data
*/
(* dot1dBasePortCircuit_val_ptr_ptr ) = malloc(rowreq_ctx->data.dot1dBasePortCircuit_len* sizeof(rowreq_ctx->data.dot1dBasePortCircuit[0]));
if(NULL == (* dot1dBasePortCircuit_val_ptr_ptr )) {
snmp_log(LOG_ERR,"could not allocate memory (rowreq_ctx->data.dot1dBasePortCircuit)\n");
return MFD_ERROR;
}
}
(* dot1dBasePortCircuit_val_ptr_len_ptr ) = rowreq_ctx->data.dot1dBasePortCircuit_len* sizeof(rowreq_ctx->data.dot1dBasePortCircuit[0]);
memcpy( (* dot1dBasePortCircuit_val_ptr_ptr ), rowreq_ctx->data.dot1dBasePortCircuit, rowreq_ctx->data.dot1dBasePortCircuit_len* sizeof(rowreq_ctx->data.dot1dBasePortCircuit[0]) );
return MFD_SUCCESS;
} /* dot1dBasePortCircuit_get */
/** @} */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*
* @file dot1dBasePortTable_data_get.h
*
* @addtogroup get
*
* Prototypes for get functions
*
* @{
*/
#ifndef DOT1DBASEPORTTABLE_DATA_GET_H
#define DOT1DBASEPORTTABLE_DATA_GET_H
#ifdef __cplusplus
extern "C" {
#endif
/* *********************************************************************
* GET function declarations
*/
/* *********************************************************************
* GET Table declarations
*/
/**********************************************************************
**********************************************************************
***
*** Table dot1dBasePortTable
***
**********************************************************************
**********************************************************************/
/*
* BRIDGE-MIB::dot1dBasePortTable is subid 4 of dot1dBase.
* Its status is Current.
* OID: .1.3.6.1.2.1.17.1.4, length: 9
*/
/*
* indexes
*/
int dot1dBasePortIfIndex_get( dot1dBasePortTable_rowreq_ctx *rowreq_ctx, long * dot1dBasePortIfIndex_val_ptr );
int dot1dBasePortCircuit_get( dot1dBasePortTable_rowreq_ctx *rowreq_ctx, oid **dot1dBasePortCircuit_val_ptr_ptr, size_t *dot1dBasePortCircuit_val_ptr_len_ptr );
int dot1dBasePortTable_indexes_set_tbl_idx(dot1dBasePortTable_mib_index *tbl_idx, long dot1dBasePort_val);
int dot1dBasePortTable_indexes_set(dot1dBasePortTable_rowreq_ctx *rowreq_ctx, long dot1dBasePort_val);
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_DATA_GET_H */
/** @} */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*
*/
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* include our parent header */
#include "dot1dBasePortTable.h"
/** @defgroup data_set data_set: Routines to set data
*
* These routines are used to set the value for individual objects. The
* row context is passed, along with the new value.
*
* @{
*/
/** @} */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*/
#ifndef DOT1DBASEPORTTABLE_DATA_SET_H
#define DOT1DBASEPORTTABLE_DATA_SET_H
#ifdef __cplusplus
extern "C" {
#endif
/* *********************************************************************
* SET function declarations
*/
/* *********************************************************************
* SET Table declarations
*/
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_DATA_SET_H */
/*
* Note: this file originally auto-generated by mib2c using
* $
*
* $Id:$
*/
#ifndef DOT1DBASEPORTTABLE_ENUMS_H
#define DOT1DBASEPORTTABLE_ENUMS_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* NOTES on enums
* ==============
*
* Value Mapping
* -------------
* If the values for your data type don't exactly match the
* possible values defined by the mib, you should map them
* below. For example, a boolean flag (1/0) is usually represented
* as a TruthValue in a MIB, which maps to the values (1/2).
*
*/
/*************************************************************************
*************************************************************************
*
* enum definitions for table dot1dBasePortTable
*
*************************************************************************
*************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_ENUMS_H */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*/
/** @ingroup interface: Routines to interface to Net-SNMP
*
* \warning This code should not be modified, called directly,
* or used to interpret functionality. It is subject to
* change at any time.
*
* @{
*/
/*
* *********************************************************************
* *********************************************************************
* *********************************************************************
* *** ***
* *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE ***
* *** ***
* *** ***
* *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. ***
* *** ***
* *** ***
* *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND ***
* *** ***
* *** ***
* *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. ***
* *** ***
* *** ***
* *********************************************************************
* *********************************************************************
* *********************************************************************
*/
#ifndef DOT1DBASEPORTTABLE_INTERFACE_H
#define DOT1DBASEPORTTABLE_INTERFACE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "dot1dBasePortTable.h"
/* ********************************************************************
* Table declarations
*/
/* PUBLIC interface initialization routine */
void _dot1dBasePortTable_initialize_interface(dot1dBasePortTable_registration * user_ctx,
u_long flags);
void _dot1dBasePortTable_shutdown_interface(dot1dBasePortTable_registration * user_ctx);
dot1dBasePortTable_registration *
dot1dBasePortTable_registration_get( void );
dot1dBasePortTable_registration *
dot1dBasePortTable_registration_set( dot1dBasePortTable_registration * newreg );
netsnmp_container *dot1dBasePortTable_container_get( void );
int dot1dBasePortTable_container_size( void );
dot1dBasePortTable_rowreq_ctx * dot1dBasePortTable_allocate_rowreq_ctx(void *);
void dot1dBasePortTable_release_rowreq_ctx(dot1dBasePortTable_rowreq_ctx *rowreq_ctx);
int dot1dBasePortTable_index_to_oid(netsnmp_index *oid_idx,
dot1dBasePortTable_mib_index *mib_idx);
int dot1dBasePortTable_index_from_oid(netsnmp_index *oid_idx,
dot1dBasePortTable_mib_index *mib_idx);
/*
* access to certain internals. use with caution!
*/
void dot1dBasePortTable_valid_columns_set(netsnmp_column_info *vc);
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_INTERFACE_H */
/** @} */
/*
* Note: this file originally auto-generated by mib2c using
* $
*
* $Id:$
*/
#ifndef DOT1DBASEPORTTABLE_OIDS_H
#define DOT1DBASEPORTTABLE_OIDS_H
#ifdef __cplusplus
extern "C" {
#endif
/* column number definitions for table dot1dBasePortTable */
#define DOT1DBASEPORTTABLE_OID 1,3,6,1,2,1,17,1,4
#define COLUMN_DOT1DBASEPORT 1
#define COLUMN_DOT1DBASEPORTIFINDEX 2
#define COLUMN_DOT1DBASEPORTCIRCUIT 3
#define COLUMN_DOT1DBASEPORTDELAYEXCEEDEDDISCARDS 4
#define COLUMN_DOT1DBASEPORTMTUEXCEEDEDDISCARDS 5
#define DOT1DBASEPORTTABLE_MIN_COL COLUMN_DOT1DBASEPORT
#define DOT1DBASEPORTTABLE_MAX_COL COLUMN_DOT1DBASEPORTMTUEXCEEDEDDISCARDS
#ifdef __cplusplus
}
#endif
#endif /* DOT1DBASEPORTTABLE_OIDS_H */
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*/
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* include our parent header */
#include "dot1dBasePortTable.h"
#include <signal.h>
/*
* If compiling within the net-snmp source code, this will trigger the feature
* detection mechansim to ensure the agent_check_and_process() function
* is left available even if --enable-minimialist is turned on. If you
* have configured net-snmp using --enable-minimialist and want to compile
* this code externally to the Net-SNMP code base, then please add
* --with-features="agent_check_and_process enable_stderrlog" to your
* configure line.
*/
netsnmp_feature_require(agent_check_and_process)
netsnmp_feature_require(enable_stderrlog)
static int keep_running;
static RETSIGTYPE
stop_server(int a) {
keep_running = 0;
}
static void usage(void) {
printf("usage: dot1dBasePortTable [-D<tokens>] [-f] [-L] [-M] [-H] [LISTENING ADDRESSES]\n"
"\t-f Do not fork() from the calling shell.\n"
"\t-DTOKEN[,TOKEN,...]\n"
"\t\tTurn on debugging output for the given TOKEN(s).\n"
"\t\tWithout any tokens specified, it defaults to printing\n"
"\t\tall the tokens (which is equivalent to the keyword 'ALL').\n"
"\t\tYou might want to try ALL for extremely verbose output.\n"
"\t\tNote: You can't put a space between the -D and the TOKENs.\n"
"\t-H\tDisplay a list of configuration file directives\n"
"\t\tunderstood by the agent and then exit.\n"
"\t-M\tRun as a normal SNMP Agent instead of an AgentX sub-agent.\n"
"\t-x ADDRESS\tconnect to master agent at ADDRESS (default /var/agentx/master).\n"
"\t-L\tDo not open a log file; print all messages to stderr.\n");
exit(0);
}
int
main (int argc, char **argv) {
int agentx_subagent=1; /* change this if you want to be a SNMP master agent */
/* Defs for arg-handling code: handles setting of policy-related variables */
int ch;
extern char *optarg;
int dont_fork = 0, use_syslog = 0;
char *agentx_socket = NULL;
while ((ch = getopt(argc, argv, "D:fHLMx:")) != EOF)
switch(ch) {
case 'D':
debug_register_tokens(optarg);
snmp_set_do_debugging(1);
break;
case 'f':
dont_fork = 1;
break;
case 'H':
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
init_agent("dot1dBasePortTable"); /* register our .conf handlers */
init_dot1dBasePortTable();
init_snmp("dot1dBasePortTable");
fprintf(stderr, "Configuration directives understood:\n");
read_config_print_usage(" ");
exit(0);
case 'M':
agentx_subagent = 0;
break;
case 'L':
use_syslog = 0; /* use stderr */
break;
case 'x':
agentx_socket = optarg;
break;
default:
fprintf(stderr,"unknown option %c\n", ch);
usage();
}
if (optind < argc) {
int i;
/*
* There are optional transport addresses on the command line.
*/
DEBUGMSGTL(("snmpd/main", "optind %d, argc %d\n", optind, argc));
for (i = optind; i < argc; i++) {
char *c, *astring;
if ((c = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_PORTS))) {
astring = malloc(strlen(c) + 2 + strlen(argv[i]));
if (astring == NULL) {
fprintf(stderr, "malloc failure processing argv[%d]\n", i);
exit(1);
}
sprintf(astring, "%s,%s", c, argv[i]);
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_PORTS, astring);
SNMP_FREE(astring);
} else {
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_PORTS, argv[i]);
}
}
DEBUGMSGTL(("snmpd/main", "port spec: %s\n",
netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_PORTS)));
}
/* we're an agentx subagent? */
if (agentx_subagent) {
/* make us a agentx client. */
netsnmp_enable_subagent();
if (NULL != agentx_socket)
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_X_SOCKET, agentx_socket);
}
snmp_disable_log();
if (use_syslog)
snmp_enable_calllog();
else
snmp_enable_stderrlog();
/* daemonize */
if(!dont_fork) {
int rc = netsnmp_daemonize(1,!use_syslog);
if(rc)
exit(-1);
}
/* initialize tcp/ip if necessary */
SOCK_STARTUP;
/* initialize the agent library */
init_agent("dot1dBasePortTable");
/* init dot1dBasePortTable mib code */
init_dot1dBasePortTable();
/* read dot1dBasePortTable.conf files. */
init_snmp("dot1dBasePortTable");
/* If we're going to be a snmp master agent, initial the ports */
if (!agentx_subagent)
init_master_agent(); /* open the port to listen on (defaults to udp:161) */
/* In case we recevie a request to stop (kill -TERM or kill -INT) */
keep_running = 1;
signal(SIGTERM, stop_server);
signal(SIGINT, stop_server);
/* you're main loop here... */
while(keep_running) {
/* if you use select(), see snmp_select_info() in snmp_api(3) */
/* --- OR --- */
agent_check_and_process(1); /* 0 == don't block */
}
/* at shutdown time */
snmp_shutdown("dot1dBasePortTable");
SOCK_CLEANUP;
exit(0);
}
BRIDGE_MIB_SRCS += \
dot1dStaticTable/dot1dStaticTable.c \
dot1dStaticTable/dot1dStaticTable_data_get.c \
dot1dStaticTable/dot1dStaticTable_data_set.c \
dot1dStaticTable/dot1dStaticTable_data_access.c \
dot1dStaticTable/dot1dStaticTable_interface.c
########################################################################
##
## mib2c node setting for dot1dStaticAddress
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = char@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = -1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 1@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
## Allow realloc when data size exceeds length? If your data
## store for this node is a pointer allocated with one of the
## alloc family functions, you can set this to 1 to use realloc
## when a new value length exceeds the old lenght. If you are
## using a fixed size buffer, this value should be 0.
##
## @eval $m2c_node_realloc = 0@
########################################################################
##
## mib2c node setting for dot1dStaticAllowedToGoTo
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = char@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = -1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 1@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
## Allow realloc when data size exceeds length? If your data
## store for this node is a pointer allocated with one of the
## alloc family functions, you can set this to 1 to use realloc
## when a new value length exceeds the old lenght. If you are
## using a fixed size buffer, this value should be 0.
##
## @eval $m2c_node_realloc = 0@
########################################################################
##
## mib2c node setting for dot1dStaticReceivePort
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = long@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = -1@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 0@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
########################################################################
##
## mib2c node setting for dot1dStaticStatus
##
## Remove the '##' comment delimeter to change settings
##
########################################################################
## Node declaration type? This is the C type to be used when
## declaring a variable to hold a value for this column. It
## is strongly recommended that you do not change this value.
## If you do, it is likely to break lots of generated code that
## you will have to fix.
##
## @eval $m2c_decl = u_long@
##
########################################################################
## Generate/use mapping functions? Useful if the MIB defines
## a different format or enumerations than you data store uses.
##
## @eval $m2c_node_skip_mapping = 0@
##
########################################################################
## Need a length for the value? Most OCTET-STRING based values will
## need a length, most other types will not. Do not change this one
## unless you know what you are doing! You will almost certainly need
## to fix lots of generated code if you do.
##
## @eval $m2c_node_needlength = 0@
##
########################################################################
## Skip get? Set this to 1 if you do not want to implement a value
## for this column.
##
## @eval $m2c_node_skip_get = 0@
##
## ########################################################################
##
## mib2c Table setting for dot1dStaticTable
##
## ########################################################################
##
## User context structure type
##
@eval $m2c_context_reg = "netsnmp_data_list"@
##
## ########################################################################
##
## Allocate data structure in row structure? (vs embedd)
##
@eval $m2c_data_allocate = 0@
##
## ########################################################################
##
## Generate code to cache data?
##
@eval $m2c_data_cache = 1@
##
## ########################################################################
##
## Data context structure type
##
@eval $m2c_data_context = "generated"@ [generated|NAME]
##
## ########################################################################
##
## Generate function to initialize row context when created?
##
@eval $m2c_data_init = 1@
##
## ########################################################################
##
## Persistence of data context
## // 0:persistent, 1:semi-transient, 2:transient
##
@eval $m2c_data_transient = 2@
##
## ########################################################################
##
## Include some example code?
##
@eval $m2c_include_examples = 1@
##
## ########################################################################
##
## Generate code for irreversible_commit mode?
##
@eval $m2c_irreversible_commit = 0@
##
## ########################################################################
##
## Data access method
##
@eval $m2c_table_access = "container-cached"@
##
## ########################################################################
##
## Generate row dependency function?
##
@eval $m2c_table_dependencies = 0@
##
## ########################################################################
##
## Generate data store/restore functions for persistent storage?
##
@eval $m2c_table_persistent = 0@
##
## ########################################################################
##
## Generate code for dynamic row creation?
##
@eval $m2c_table_row_creation = 0@
##
## ########################################################################
##
## Generate code for settable objects?
##
@eval $m2c_table_settable = 0@
##
## ########################################################################
##
## Skip mapping between data context and MIB formats?
## // 0:generate maps, 1:skip maps, -1:skip unless enum/oid
##
@eval $m2c_table_skip_mapping = -1@
##
## ########################################################################
##
## Generate code for sparse tables?
##
@eval $m2c_table_sparse = 0@
##
## ########################################################################
##
## Generate Makefile/AgentX code?
##
@eval $mfd_generate_makefile = 1@
@eval $mfd_generate_subagent = 1@
##
************************************************************************
dot1dStaticTable README
------------------------------------------------------------------------
This document describes the results of the mib2c code generation
system using the mfd code generation template. The resulting files
are documented both in this README file as well as per-table specific
README files. All of the files generated by this run of mib2c will
begin with the dot1dStaticTable prefix.
Quick Start
-----------
For those interested in a quick start, to get a pseudo-todo list, try
this command in directory with the generated code:
grep -n "TODO:" *.[ch] | sed 's/\([^ ]*\) \(.*\)TODO\(.*\)/\3 (\1)/' | sort -n
Key:
:o: Optional
:r: Recommended
:M: Mandatory
:A: Advanced users
This will give you and ordered list of places in the code that you
may (or must) take a closer look at).
You may also want to take a look at the on-line tutorial, found here:
http://www.net-snmp.org/tutorial/tutorial-5/toolkit/mfd/index.html
MIBs For Dummies Overview
-------------------------
The MIBs For Dummies (MFD) configuration files have been written to help
SNMP novices implement SNMP MIBs. This section will be a brief
introduction to some of the general concepts you should be familar with.
Managed Information Base (MIB)
------------------------------
A SNMP MIB (Managed information base) is a text file that describes the
syntax for some set of data objects. The MIB creates a correlation
between an ASCII name for an object and a number OID (Object Identifier).
The SNMP protocol communicates information using the OIDs, and the MIB
allows tools to display a name, which we humans find easier to deal with.
To use an analogy, a MIB is much like a menu at a restaurant. If you've
ever been to a reataurant and ordered a meal, and later received a bill
that simply had '#6' on it, you get the idea. The name is easier for
the customers to remember, and the waiters and chefs use the number for
efficency.
Scalars
-------
A scalar variable is a unique object in a MIB which can represent
a single value. For example, the SNMP standard MIB-II defines a
variable, sysContact.0, which is a string containing the contact
information for the person in charge of a particular agent. Note
that scalar variable always end with '.0'.
Rows and Tables
---------------
When a group of related attributes occur more than once, they can be
grouped together in a table. A table has an index, which uniquely
identifies a particular row, and data columns, which contain the
attributes for that row.
For example, the SNMP standard MIB-II defines a table, ifTable, which
contains information on the ethernet interfaces on a system.
Data Structures
---------------
The code generated by the MFD configuration files has a few important
structures.
The Data Context
----------------
The data context structure should contain the necessary information
to provide the data for the columns in a given row. As long as you
can extract the data for a column for the data context, the data context
can be anything you want: a pointer to an existing structure, the
parameters needed for a function call or an actual copy of the data.
By default, a data context structure is generated with storage for
all the data in a row. Information on changing the default is presented
later on in this help.
The MIB Context
---------------
The MIB context structure is generated with storage for all the
indexes of a table. This data will be used when searching for the
correct row to process for a request.
The Row Request Context
-----------------------
Each table will have a unique data structure for holding data during
the processing of a particular row. The row request context contains
the registration context (that you supply during initilization),
the data context, the MIB context, the undo context (for settable
tables) and other data. There is also a netsnmp_data_list, which can
be used to temporary storage during processing.
The Table Registration Pointer
------------------------------
During initilization, you may provide a pointer to arbitrary data for
you own use. This pointer will be saved in the row request context,
and is passed as a parameter to several functions. It is not required,
and is provided as a way for you to access table specific data in
the generated code.
These files are top-level files potentially useful for all the tables:
------------------------------------------------------------------------
File : dot1dStaticTable_Makefile
----------------------------------------------------------------------
Purpose : Make file for compiling a (sub)agent. This file is only
useful if you don't want to compile your code directly
into the Net-SNMP master agent.
Editable: Optional
Usage : make -f dot1dStaticTable_Makefile
File : dot1dStaticTable_subagent.c
----------------------------------------------------------------------
Purpose : This file contains a main() function for an agent or
sub-agent and is compiled using the Makefile above.
Table specific README files
------------------------------------------------------------------------
Each table for which code was generated has its own README file
describing the files specifically associated with each table. You
should probably read these next:
dot1dStaticTable-README-dot1dStaticTable.txt
These are miscellaneous auto-generated code files you generally
shouldn't edit. They contain code that ties your code together with
the Net-SNMP agent.
------------------------------------------------------------------------
File : dot1dStaticTable.h
Purpose : Header file for the module set. Includes config_require
macros to auto-load the other code pieces when compiled
into the agent.
File : dot1dStaticTable_oids.h
Purpose : C #define definitions of the tables, columns, and OIDs
File : dot1dStaticTable_enums.h
Purpose : C #define definitions of the enumerated type values for
each column of each table that requires them.
File : dot1dStaticTable_interface.c
Purpose : MFD interface to Net-SNMP. This auto-generated code ties the
functions you will fill out to the code that the agent needs.
This diff is collapsed.
This diff is collapsed.
/*
* Note: this file originally auto-generated by mib2c using
* version $ of $
*
* $Id:$
*
*/
/* standard Net-SNMP includes */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* include our parent header */
#include "dot1dStaticTable.h"
/** @defgroup data_set data_set: Routines to set data
*
* These routines are used to set the value for individual objects. The
* row context is passed, along with the new value.
*
* @{
*/
/** @} */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment