Exemple #1
0
/** Initializes the channel module */
void
init_channel(void)
{
    static oid channel_oid[] = { 1,3,6,1,3,108,0,0 };

  DEBUGMSGTL(("channel", "Initializing\n"));

    netsnmp_register_scalar(
        netsnmp_create_handler_registration("channel", handle_channel,
                               channel_oid, OID_LENGTH(channel_oid),
                               HANDLER_CAN_RWRITE
        ));
}
/** Initialize the nsTransactionTable table by defining it's contents
   and how it's structured */
void
initialize_table_nsTransactionTable(void)
{
    const oid nsTransactionTable_oid[] = { 1, 3, 6, 1, 4, 1, 8072, 1, 8, 1 };
    netsnmp_table_registration_info *table_info;
    netsnmp_handler_registration *my_handler;
    netsnmp_iterator_info *iinfo;

    /*
     * create the table structure itself 
     */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);

    /*
     * if your table is read only, it's easiest to change the
     * HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY 
     */
    my_handler = netsnmp_create_handler_registration(
        "nsTransactionTable", nsTransactionTable_handler,
        nsTransactionTable_oid, OID_LENGTH(nsTransactionTable_oid),
        HANDLER_CAN_RONLY);

    if (!my_handler || !table_info || !iinfo) {
        if (my_handler)
            netsnmp_handler_registration_free(my_handler);
        SNMP_FREE(table_info);
        SNMP_FREE(iinfo);
        return;                 /* mallocs failed */
    }

    /***************************************************
     * Setting up the table's definition
     */
    netsnmp_table_helper_add_index(table_info, ASN_INTEGER);    /* index:
                                                                 * * nsTransactionID 
                                                                 */

    table_info->min_column = 2;
    table_info->max_column = 2;
    iinfo->get_first_data_point = nsTransactionTable_get_first_data_point;
    iinfo->get_next_data_point = nsTransactionTable_get_next_data_point;
    iinfo->table_reginfo = table_info;

    /***************************************************
     * registering the table with the master agent
     */
    DEBUGMSGTL(("initialize_table_nsTransactionTable",
                "Registering table nsTransactionTable as a table iterator\n"));
    netsnmp_register_table_iterator2(my_handler, iinfo);
}
/**
 * 
 * @return: 
 */
int initialize_table_saHpiDomainEventLogLifetimeChanges(void)
{

        DEBUGMSGTL ((AGENT, "initialize_table_saHpiDomainEventLogLifetimeChanges, called\n"));

        netsnmp_register_scalar(
                                netsnmp_create_handler_registration(
				        "saHpiDomainEventLogLifetimeChanges", 
					handle_saHpiDomainEventLogLifetimeChanges,
                                        saHpiDomainEventLogLifetimeChanges_oid, 
					OID_LENGTH(saHpiDomainEventLogLifetimeChanges_oid),
                                        HANDLER_CAN_RONLY ));
        return SNMP_ERR_NOERROR;
}
Exemple #4
0
int initialize_table_saHpiEventEntryCountTotal(void)
{
        DEBUGMSGTL ((AGENT, "initialize_table_saHpiEventEntryCountTotal, called\n"));

        netsnmp_register_scalar(
                netsnmp_create_handler_registration(
                        "saHpiEventEntryCountTotal", 
                        handle_saHpiEventEntryCountTotal,
                        saHpiEventEntryCountTotal_oid, 
                        OID_LENGTH(saHpiEventEntryCountTotal_oid),
                        HANDLER_CAN_RONLY ));

    return 0;
}
Exemple #5
0
/** Initializes the hypervisor module */
void
init_vmInfo(void)
{
    const oid vmNumber_oid[] = { 1,3,6,1,2,1,VM_MIB_OID,1,2 };
    const oid vmTableLastChange_oid[] = { 1,3,6,1,2,1,VM_MIB_OID,1,3 };

    DEBUGMSGTL(("vmInfo", "Initializing\n"));

    netsnmp_register_instance(
        netsnmp_create_handler_registration("vmNumber",
                                            handle_vmNumber,
                                            vmNumber_oid,
                                            OID_LENGTH(vmNumber_oid),
                                            HANDLER_CAN_RONLY
            ));
    netsnmp_register_instance(
        netsnmp_create_handler_registration("vmTableLastChange",
                                            handle_vmTableLastChange,
                                            vmTableLastChange_oid,
                                            OID_LENGTH(vmTableLastChange_oid),
                                            HANDLER_CAN_RONLY
            ));
}
Exemple #6
0
/** Initializes the ifNumber module */
void
init_ifNumber(void) {
  static oid ifNumber_oid[] = { 1,3,6,1,2,1,2,1 };

  DEBUGMSGTL(("ifNumber", "Initializing\n"));

  netsnmp_register_scalar(
    netsnmp_create_handler_registration("ifNumber",
                                        handle_ifNumber,
                                        ifNumber_oid,
                                        OID_LENGTH(ifNumber_oid),
                                        HANDLER_CAN_RONLY
                                       ));
}
Exemple #7
0
void init_ifmib(void)
{
    oid ifNumber_oid[] = { 1,3,6,1,2,1,2,1 };

    DEBUGMSGTL(("interfaces", "Initializing\n"));

    netsnmp_register_scalar(
        netsnmp_create_handler_registration("ifNumber", mib_handle_ifNumber,
                               ifNumber_oid, OID_LENGTH(ifNumber_oid),
                               HANDLER_CAN_RONLY)
                            );
	init_ifTable_dp();
	init_ifXTable_dp();
}
/** Initializes the dot11ConfigSysLogServerGroup module */
void
init_dot11ConfigSysLogServerGroup(void)
{
    static oid SyslogServerIPAddr_oid[128] = {0};
    static oid SyslogServerPort_oid[128] = {0};

  size_t public_oid_len   = 0;

  mad_dev_oid(SyslogServerIPAddr_oid,LOGSERVERADDR,&public_oid_len,enterprise_pvivate_oid);
  mad_dev_oid(SyslogServerPort_oid,LOGSERVERPORT,&public_oid_len,enterprise_pvivate_oid);
  DEBUGMSGTL(("dot11ConfigSysLogServerGroup", "Initializing\n"));

    netsnmp_register_scalar(
        netsnmp_create_handler_registration("SyslogServerIPAddr", handle_SyslogServerIPAddr,
                               SyslogServerIPAddr_oid, public_oid_len,
                               HANDLER_CAN_RWRITE
        ));
    netsnmp_register_scalar(
        netsnmp_create_handler_registration("SyslogServerPort", handle_SyslogServerPort,
                               SyslogServerPort_oid, public_oid_len,
                               HANDLER_CAN_RWRITE
        ));
}
/** Initializes the dot11AcInterface module */
void
init_dot11AcInterface(void)
{
	static oid acIfPortNum_oid[128] = { 0 };
	static oid acPhyPortNum_oid[128] = { 0 };
	
	size_t public_oid_len = 0;
	mad_dev_oid(acIfPortNum_oid,ACIFPORTNUM,&public_oid_len,enterprise_pvivate_oid);
	mad_dev_oid(acPhyPortNum_oid,ACPHYPORTNUM,&public_oid_len,enterprise_pvivate_oid);
	
	DEBUGMSGTL(("dot11AcInterface", "Initializing\n"));
	
	netsnmp_register_scalar(
		netsnmp_create_handler_registration("acIfPortNum", handle_acIfPortNum,
							acIfPortNum_oid, public_oid_len,
							HANDLER_CAN_RONLY
		));
	netsnmp_register_scalar(
		netsnmp_create_handler_registration("acPhyPortNum", handle_acPhyPortNum,
							acPhyPortNum_oid, public_oid_len,
							HANDLER_CAN_RONLY
		));
}
/*
 * Initialize the openserSIPContactTable table by defining its contents and how
 * it's structured.
 *
 * This function is mostly auto-generated.
 */
void initialize_table_openserSIPContactTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_openserSIPContactTable_"
				"handler called again\n");
		return;
	}

	memset(&cb, 0x00, sizeof(cb));

	/** create the table structure itself */
	table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);

	my_handler = netsnmp_create_handler_registration(
			"openserSIPContactTable",
			netsnmp_table_array_helper_handler,
			openserSIPContactTable_oid,
			openserSIPContactTable_oid_len,
			HANDLER_CAN_RONLY);
			
	if (!my_handler || !table_info) {
		snmp_log(LOG_ERR, "malloc failed in initialize_table_openser"
				"SIPContactTable_handler\n");
		return; /** mallocs failed */
	}

	/** index: openserSIPUserIndex */
	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
	/** index: openserSIPContactIndex */
	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

	table_info->min_column = openserSIPContactTable_COL_MIN;
	table_info->max_column = openserSIPContactTable_COL_MAX;

	/***************************************************
	 * registering the table with the master agent
	 */
	cb.get_value = openserSIPContactTable_get_value;
	cb.container = netsnmp_container_find("openserSIPContactTable_primary:"
			"openserSIPContactTable:" "table_container");
	
	DEBUGMSGTL(("initialize_table_openserSIPContactTable",
				"Registering table openserSIPContactTable "
				"as a table array\n"));
	
	netsnmp_table_container_register(my_handler, table_info, &cb, 
			cb.container, 1);
}
Exemple #11
0
int
netsnmp_register_read_only_uint_instance(const char *name,
                                         const oid * reg_oid,
                                         size_t reg_oid_len,
                                         unsigned int *it,
                                         Netsnmp_Node_Handler * subhandler)
{
    return netsnmp_register_watched_instance(
               netsnmp_create_handler_registration(
                   name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
               netsnmp_create_watcher_info(
                   (void *)it, sizeof(unsigned int),
                   ASN_UNSIGNED, WATCHER_FIXED_SIZE));
}
Exemple #12
0
void
init_snmpMPDStats(void)
{
    netsnmp_handler_registration* s =
        netsnmp_create_handler_registration(
            "snmpMPDStats", NULL, snmpMPDStats, OID_LENGTH(snmpMPDStats),
            HANDLER_CAN_RONLY);
    if (s &&
	NETSNMP_REGISTER_STATISTIC_HANDLER(s, 1, MPD) == MIB_REGISTERED_OK) {
        REGISTER_SYSOR_ENTRY(snmpMPDCompliance,
                             "The MIB for Message Processing and Dispatching.");
        snmpMPDStats_reg = s;
    }
}
Exemple #13
0
/** Initialize the mytestTable table by defining its contents and how it's structured */
void
initialize_table_mytestTable(void)
{
    static oid      mytestTable_oid[] =
        { 1, 3, 6, 1, 4, 1, 8072, 2, 70, 1, 3 };
    size_t          mytestTable_oid_len = OID_LENGTH(mytestTable_oid);
    netsnmp_table_data_set *table_set;

    /*
     * create the table structure itself
     */
    table_set = netsnmp_create_table_data_set("mytestTable");

    /*
     * comment this out or delete if you don't support creation of new rows
     */
    table_set->allow_creation = 1;

    table_set->rowstatus_column = COLUMN_MYTESTROWSTATUS;

    /***************************************************
     * Adding indexes
     */
    DEBUGMSGTL(("initialize_table_mytestTable",
                "adding indexes to table mytestTable\n"));
    netsnmp_table_set_add_indexes(table_set, ASN_INTEGER,       /* index: mytestIndex */
                                  0);

    DEBUGMSGTL(("initialize_table_mytestTable",
                "adding column types to table mytestTable\n"));
    netsnmp_table_set_multi_add_default_row(table_set,
                                            COLUMN_MYTESTINDEX,
                                            ASN_INTEGER, 0, NULL, 0,
                                            COLUMN_MYTESTCOLUMN1,
                                            ASN_INTEGER, 1, NULL, 0,
                                            COLUMN_MYTESTROWSTATUS,
                                            ASN_INTEGER, 1, NULL, 0, 0);

    /*
     * registering the table with the master agent
     */
    /*
     * note: if you don't need a subhandler to deal with any aspects
     * of the request, change mytestTable_handler to "NULL"
     */
    netsnmp_register_table_data_set(netsnmp_create_handler_registration
                                    ("mytestTable", mytestTable_handler,
                                     mytestTable_oid, mytestTable_oid_len,
                                     HANDLER_CAN_RWRITE), table_set, NULL);
}
Exemple #14
0
void
init_wtpIpv6Info(void)
{
	static oid wtpIpv6Prefix_oid[128] 			= { 0};
	static oid wtpIpv6Type_oid[128] 				= { 0 };
	size_t public_oid_len   = 0;
	mad_dev_oid(wtpIpv6Prefix_oid,WTPIPV6PREFIX,&public_oid_len,enterprise_pvivate_oid);
	mad_dev_oid(wtpIpv6Type_oid,WTPIPV6TYPE,&public_oid_len,enterprise_pvivate_oid);
    

  DEBUGMSGTL(("wtpIpv6Info", "Initializing\n"));

    netsnmp_register_scalar(
        netsnmp_create_handler_registration("wtpIpv6Prefix", handle_wtpIpv6Prefix,
                               wtpIpv6Prefix_oid, public_oid_len,
                               HANDLER_CAN_RONLY
        ));
    netsnmp_register_scalar(
        netsnmp_create_handler_registration("wtpIpv6Type", handle_wtpIpv6Type,
                               wtpIpv6Type_oid, public_oid_len,
                               HANDLER_CAN_RONLY
        ));
}
/*
 * int initialize_table_saHpiCtrlAnalogEntryCount(void)
 */
int initialize_table_saHpiCtrlAnalogEntryCount(void)
{

    DEBUGMSGTL ((AGENT, "initialize_table_saHpiCtrlAnalogEntryCount, called\n"));

    netsnmp_register_scalar(
        netsnmp_create_handler_registration(
            "saHpiCtrlAnalogEntryCount",
            handle_saHpiCtrlAnalogEntryCount,
            saHpiCtrlAnalogEntryCount_oid,
            OID_LENGTH(saHpiCtrlAnalogEntryCount_oid),
            HANDLER_CAN_RONLY));
    return 0;
}
Exemple #16
0
void
init_httpError501(void)
{
    static oid      httpError501_oid[] =
        { MOD_SNMP_OID 5, 501 };

    DEBUGMSGTL(("httpError501", "Initializing\n"));

    netsnmp_register_scalar(netsnmp_create_handler_registration
                            ("httpError501", handle_httpError501,
                             httpError501_oid,
                             OID_LENGTH(httpError501_oid),
                             HANDLER_CAN_RWRITE));
}
Exemple #17
0
/* Initializes the mteEventSetTable module */
     void init_mteEventSetTable (void)
{
    static oid mteEventSetTable_oid[] = { 1, 3, 6, 1, 2, 1, 88, 1, 4, 4 };
    size_t mteEventSetTable_oid_len = OID_LENGTH (mteEventSetTable_oid);

    netsnmp_handler_registration *reg;

    /*
     * Ensure the (combined) table container is available...
     */
    init_event_table_data ();

    /*
     * ... then set up the MIB interface to the mteEventSetTable slice
     */
#ifndef NETSNMP_NO_WRITE_SUPPORT
    reg = netsnmp_create_handler_registration ("mteEventSetTable",
                                               mteEventSetTable_handler,
                                               mteEventSetTable_oid, mteEventSetTable_oid_len, HANDLER_CAN_RWRITE);
#else                            /* !NETSNMP_NO_WRITE_SUPPORT */
    reg = netsnmp_create_handler_registration ("mteEventSetTable",
                                               mteEventSetTable_handler,
                                               mteEventSetTable_oid, mteEventSetTable_oid_len, HANDLER_CAN_RONLY);
#endif                            /* !NETSNMP_NO_WRITE_SUPPORT */

    table_info = SNMP_MALLOC_TYPEDEF (netsnmp_table_registration_info);
    netsnmp_table_helper_add_indexes (table_info, ASN_OCTET_STR,    /* index: mteOwner     */
                                      /* index: mteEventName */
                                      ASN_PRIV_IMPLIED_OCTET_STR, 0);

    table_info->min_column = COLUMN_MTEEVENTSETOBJECT;
    table_info->max_column = COLUMN_MTEEVENTSETCONTEXTNAMEWILDCARD;

    /* Register this using the (common) event_table_data container */
    netsnmp_tdata_register (reg, event_table_data, table_info);
    DEBUGMSGTL (("disman:event:init", "Event Set Table container (%p)\n", event_table_data));
}
Exemple #18
0
/** Initialize the sipProxyCfgTable table by defining it's contents and 
 * how it's structured */
static int initialize_table_sipProxyCfgTable()
{
	static oid sipProxyCfgTable_oid[] = {1,3,6,1,2,1,9991,1,3,1};
	size_t sipProxyCfgTable_oid_len = OID_LENGTH(sipProxyCfgTable_oid);
	const char *func = "snmp_mod";

	/* create the table structure itself */
	sipProxyCfgTable = netsnmp_create_table_data_set("sipProxyCfgTable");
	if(!sipProxyCfgTable) {
		LOG(L_ERR, "%s: Error creating table\n", func);
		return -1;
	}
	
	/***************************************************
	 * Adding indexes
	 */
	netsnmp_table_dataset_add_index(sipProxyCfgTable, ASN_INTEGER);
	
	netsnmp_table_set_multi_add_default_row(
		sipProxyCfgTable,
		COLUMN_SIPREQUESTMAXEXPIRES, ASN_UNSIGNED, 1, NULL, 0,
		COLUMN_SIPPROXYSTATEFULNESS, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYSENDSCANCEL, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYFORWARDALL1XX, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYRECURSION, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYPROVIDEALTERNATIVES, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYRECORDROUTE, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYSTATETIMEOUT, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYAUTHMETHOD, ASN_OCTET_STR, 1, NULL, 0,
		COLUMN_SIPPROXYAUTHPGPALGORITHM, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPROXYAUTHREALM, ASN_OCTET_STR, 1, NULL, 0,
		COLUMN_SIPPROXYNONCELIFETIME, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPPGPPRIVATEKEY, ASN_OCTET_STR, 1, NULL, 0,
		0);
	
	/* registering the table with the master agent */
	/* note: if you don't need a subhandler to deal with any aspects
	 * of the request, change sipProxyCfgTable_handler to "NULL" */
	netsnmp_register_table_data_set(
			netsnmp_create_handler_registration(
				"sipProxyCfgTable", 
				sipProxyCfgTable_handler,
				sipProxyCfgTable_oid,
				sipProxyCfgTable_oid_len,
				HANDLER_CAN_RWRITE),
			sipProxyCfgTable, NULL);

	return 0;
}
Exemple #19
0
/*
 * our initialization routine, automatically called by the agent 
 * (to get called, the function name must match init_FILENAME()) 
 */
void
init_serverName(void)
{
   static oid      serverName_oid[] =
        { MOD_SNMP_OID 1 , 1};

/*strcpy(serverName_str, "myString Value" );*/
        
    /*
     * a debugging statement.  Run the agent with -DserverName to see
     * the output of this debugging statement. 
     */
    DEBUGMSGTL(("serverName", "Initializing the serverName module\n"));


    /*
     * the line below registers our variables defined above as
     * accessible and makes them writable.  A read only version of any
     * of these registrations would merely call
     * register_read_only_int_instance() instead.  The functions
     * called below should be consistent with your MIB, however.
     * 
     * If you wanted a callback when the value was retrieved or set
     * (even though the details of doing this are handled for you),
     * you could change the NULL pointer below to a valid handler
     * function. 
     */
/*
   netsnmp_register_int_instance("serverName",
                                  serverName_oid,
                                  OID_LENGTH(serverName_oid),
                                  &serverName, NULL);
*/

    netsnmp_register_watched_scalar(
        netsnmp_create_handler_registration(
            "serverName", 
            NULL,
            serverName_oid,
            OID_LENGTH(serverName_oid),
            HANDLER_CAN_RWRITE),
        netsnmp_create_watcher_info(
            &serverName_str, sizeof(serverName_str),
            ASN_OCTET_STR, WATCHER_MAX_SIZE)
        );

 
    DEBUGMSGTL(("serverName", "Done initalizing serverName module\n"));
}
Exemple #20
0
int
netsnmp_register_read_only_counter32_instance(const char *name,
                                              const oid * reg_oid,
                                              size_t reg_oid_len,
                                              u_long * it,
                                              Netsnmp_Node_Handler *
                                              subhandler)
{
    return netsnmp_register_watched_instance(
               netsnmp_create_handler_registration(
                   name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RONLY),
               netsnmp_create_watcher_info(
                   (void *)it, sizeof(u_long),
                   ASN_COUNTER, WATCHER_FIXED_SIZE));
}
/*
 * Initializes the swRaidMIB module
 */
void init_swRaidMIB(void)
{
  static oid swRaidMIB_oid[] = { SWRAIDMIB_OID };
  static oid swRaidErrorFlag_oid[] = { SWRAIDERRORFLAG_OID };
  static oid swRaidErrMessage_oid[] = { SWRAIDERRMESSAGE_OID };

  DEBUGMSGTL(("swRaidMIB", "Initializing swRaidMIB\n"));

  /*
   * Perform swRaidMIB one-time module initialization.
   */
  netsnmp_register_scalar(netsnmp_create_handler_registration
                          ("swRaidErrorFlag", swRaidErrorFlag_handler,
                           swRaidErrorFlag_oid,
                           OID_LENGTH(swRaidErrorFlag_oid),
                           HANDLER_CAN_RONLY));
  netsnmp_register_scalar(netsnmp_create_handler_registration
                          ("swRaidErrMessage", swRaidErrMessage_handler,
                           swRaidErrMessage_oid,
                           OID_LENGTH(swRaidErrMessage_oid),
                           HANDLER_CAN_RONLY));

  /*
   * here we initialize all the tables we're planning on supporting
   */
  initialize_table_swRaidTable();

  /*
   * initialize the cache handler for the entire swRaidMIB branch
   */
  netsnmp_register_cache_handler(netsnmp_create_handler_registration
                                 ("swRaidMIBCache", NULL,
                                  swRaidMIB_oid, OID_LENGTH(swRaidMIB_oid), 0),
                                 SWRAID_CACHE_TIMEOUT,
                                 swRaidMIB_load, swRaidMIB_free);
}
 /**
 * 
 * @return: 
 */
int 
initialize_table_saHpiSoftwareEventEntryCount(void)
{
        DEBUGMSGTL ((AGENT, "initialize_table_saHpiSoftwareEventEntryCount, called\n"));
    
        netsnmp_register_scalar(
                               netsnmp_create_handler_registration(
			       "saHpiSoftwareEventEntryCount", 
			       handle_saHpiSoftwareEventEntryCount,
                               saHpiSoftwareEventEntryCount_oid, 
			       OID_LENGTH(saHpiSoftwareEventEntryCount_oid),
                               HANDLER_CAN_RONLY ));
			       
        return SNMP_ERR_NOERROR;			       
}
Exemple #23
0
int
netsnmp_register_read_only_int_scalar(const char *name,
                              const oid * reg_oid, size_t reg_oid_len,
                              int * it,
                              Netsnmp_Node_Handler * subhandler)
{
    return netsnmp_register_watched_scalar(
               netsnmp_create_handler_registration(
                   name, subhandler,
                   reg_oid, reg_oid_len,
                   HANDLER_CAN_RONLY ),
               netsnmp_create_watcher_info(
                   (void *)it, sizeof( int ),
                   ASN_INTEGER, WATCHER_FIXED_SIZE ));
}
Exemple #24
0
int
netsnmp_register_ulong_scalar(const char *name,
                              const oid * reg_oid, size_t reg_oid_len,
                              u_long * it,
                              Netsnmp_Node_Handler * subhandler)
{
    return netsnmp_register_watched_scalar(
               netsnmp_create_handler_registration(
                   name, subhandler,
                   reg_oid, reg_oid_len,
                   HANDLER_CAN_RWRITE ),
               netsnmp_create_watcher_info(
                   (void *)it, sizeof( u_long ),
                   ASN_UNSIGNED, WATCHER_FIXED_SIZE ));
}
Exemple #25
0
int
netsnmp_register_long_instance_context(const char *name,
                                       const oid * reg_oid, size_t reg_oid_len,
                                       long *it,
                                       Netsnmp_Node_Handler * subhandler,
                                       const char *contextName)
{
    netsnmp_handler_registration *myreg =
      netsnmp_create_handler_registration(
          name, subhandler, reg_oid, reg_oid_len, HANDLER_CAN_RWRITE);
    if (myreg && contextName)
      myreg->contextName = strdup(contextName);
    return netsnmp_register_watched_instance(
        myreg, netsnmp_create_watcher_info(
            (void *)it, sizeof(long), ASN_INTEGER, WATCHER_FIXED_SIZE));
}
Exemple #26
0
/** Initialize the sipContactTable table by defining it's contents and 
 * how it's structured */
static int initialize_table_sipContactTable()
{
	static oid sipContactTable_oid[] = {1,3,6,1,2,1,9991,1,7,3};
	size_t sipContactTable_oid_len = OID_LENGTH(sipContactTable_oid);
	const char *func = "snmp_mod";

	/* create the table structure itself */
	sipContactTable = netsnmp_create_table_data_set("sipContactTable");
	if(!sipContactTable) {
		LOG(L_ERR, "%s: Error creating table\n", func);
		return -1;
	}
	
	/***************************************************
	 * Adding indexes
	 */
	netsnmp_table_dataset_add_index(sipContactTable, ASN_INTEGER);
	netsnmp_table_dataset_add_index(sipContactTable, ASN_UNSIGNED);
	netsnmp_table_dataset_add_index(sipContactTable, ASN_UNSIGNED);
	
	netsnmp_table_set_multi_add_default_row(
		sipContactTable,
		COLUMN_SIPCONTACTINDEX, ASN_UNSIGNED, 0, NULL, 0,
		COLUMN_SIPCONTACTDISPLAYNAME, ASN_OCTET_STR, 0, NULL, 0,
		COLUMN_SIPCONTACTURI, ASN_OCTET_STR, 0, NULL, 0,
		COLUMN_SIPCONTACTLASTUPDATED, ASN_TIMETICKS, 0, NULL, 0,
		COLUMN_SIPCONTACTEXPIRY, ASN_OCTET_STR, 0, NULL, 0,
		COLUMN_SIPCONTACTPREFERENCE, ASN_OCTET_STR, 0, NULL, 0,
		COLUMN_SIPCONTACTACTION, ASN_INTEGER, 0, NULL, 0,
		COLUMN_SIPCONTACTRETRYAFTER, ASN_OCTET_STR, 0, NULL, 0,
		0);
	
	/* registering the table with the master agent */
	/* note: if you don't need a subhandler to deal with any aspects
	 * of the request, change sipContactTable_handler to "NULL" */
	netsnmp_register_table_data_set(
			netsnmp_create_handler_registration(
				"sipContactTable", 
				sipContactTable_handler,
				sipContactTable_oid,
				sipContactTable_oid_len,
				HANDLER_CAN_RWRITE),
			sipContactTable, NULL);

	return 0;
}
Exemple #27
0
void
init_nsLogging(void)
{
    netsnmp_table_registration_info *table_info;
    netsnmp_iterator_info           *iinfo;

    const oid nsLoggingTable_oid[] = { 1, 3, 6, 1, 4, 1, 8072, 1, 7, 2, 1};

    /*
     * Register the table.
     * We need to define the column structure and indexing....
     */

    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    if (!table_info) {
        return;
    }
    netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,
                                                 ASN_PRIV_IMPLIED_OCTET_STR, 0);
    table_info->min_column = NSLOGGING_TYPE;
    table_info->max_column = NSLOGGING_STATUS;


    /*
     * .... and the iteration information ....
     */
    iinfo      = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
    if (!iinfo) {
        return;
    }
    iinfo->get_first_data_point = get_first_logging_entry;
    iinfo->get_next_data_point  = get_next_logging_entry;
    iinfo->table_reginfo        = table_info;


    /*
     * .... and register the table with the agent.
     */
    netsnmp_register_table_iterator2(
        netsnmp_create_handler_registration(
            "tzLoggingTable", handle_nsLoggingTable,
            nsLoggingTable_oid, OID_LENGTH(nsLoggingTable_oid),
            HANDLER_CAN_RWRITE),
        iinfo);
}
Exemple #28
0
void
init_tcp(void)
{
    netsnmp_handler_registration *reginfo;
    int rc;

    /*
     * register ourselves with the agent as a group of scalars...
     */
    DEBUGMSGTL(("mibII/tcpScalar", "Initialising TCP scalar group\n"));
    reginfo = netsnmp_create_handler_registration("tcp", tcp_handler,
		    tcp_oid, OID_LENGTH(tcp_oid), HANDLER_CAN_RONLY);
    rc = netsnmp_register_scalar_group(reginfo, TCPRTOALGORITHM, TCPOUTRSTS);
    if (rc != SNMPERR_SUCCESS)
        return;

    /*
     * .... with a local cache
     *    (except for HP-UX 11, which extracts objects individually)
     */
#ifndef hpux11
    netsnmp_inject_handler( reginfo,
		    netsnmp_get_cache_handler(TCP_STATS_CACHE_TIMEOUT,
			   		tcp_load, tcp_free,
					tcp_oid, OID_LENGTH(tcp_oid)));
#endif

    REGISTER_SYSOR_ENTRY(tcp_module_oid,
                         "The MIB module for managing TCP implementations");

#if !defined(_USE_FIRST_PROTOCOL)
#ifdef TCPSTAT_SYMBOL
    auto_nlist(TCPSTAT_SYMBOL, 0, 0);
#endif
#ifdef TCP_SYMBOL
    auto_nlist(TCP_SYMBOL, 0, 0);
#endif
#ifdef freebsd4
    hz = sysconf(_SC_CLK_TCK);  /* get ticks/s from system */
#endif
#ifdef solaris2
    init_kernel_sunos5();
#endif
#endif
}
Exemple #29
0
/** Initializes the snmp module */
void
init_snmp_mib(void)
{
    DEBUGMSGTL(("snmp", "Initializing\n"));

    NETSNMP_REGISTER_STATISTIC_HANDLER(
        netsnmp_create_handler_registration(
            "mibII/snmp", handle_snmp, snmp_oid, OID_LENGTH(snmp_oid),
            HANDLER_CAN_RONLY),
        1, SNMP);
    {
        oid snmpEnableAuthenTraps_oid[] = { SNMP_OID, 30, 0 };
	static netsnmp_watcher_info enableauthen_info;
        netsnmp_handler_registration *reg =
#ifndef NETSNMP_NO_WRITE_SUPPORT
            netsnmp_create_update_handler_registration(
                "mibII/snmpEnableAuthenTraps",
                snmpEnableAuthenTraps_oid,
                OID_LENGTH(snmpEnableAuthenTraps_oid),
                HANDLER_CAN_RWRITE, &snmp_enableauthentrapsset);
#else  /* !NETSNMP_NO_WRITE_SUPPORT */
            netsnmp_create_update_handler_registration(
                "mibII/snmpEnableAuthenTraps",
                snmpEnableAuthenTraps_oid,
                OID_LENGTH(snmpEnableAuthenTraps_oid),
                HANDLER_CAN_RONLY, &snmp_enableauthentrapsset);
#endif /* !NETSNMP_NO_WRITE_SUPPORT */

        netsnmp_inject_handler(reg, netsnmp_get_truthvalue());
        netsnmp_register_watched_instance(
            reg,
            netsnmp_init_watcher_info(
		&enableauthen_info,
                &snmp_enableauthentraps, sizeof(snmp_enableauthentraps),
                ASN_INTEGER, WATCHER_FIXED_SIZE));
    }

#ifdef USING_MIBII_SYSTEM_MIB_MODULE
    if (++system_module_count == 3)
        REGISTER_SYSOR_TABLE(system_module_oid, system_module_oid_len,
                             "The MIB module for SNMPv2 entities");
#endif
    snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
                           snmp_enableauthentraps_store, NULL);
}
void
init_delayed_instance(void)
{
    static oid      my_delayed_oid[] =
        { 1, 3, 6, 1, 4, 1, 8072, 2, 1, 2, 0 };
    /*
     * delayed handler test
     */
    netsnmp_handler_registration *my_test;

    my_test =
        netsnmp_create_handler_registration("delayed_instance_example",
                                            delayed_instance_handler,
                                            my_delayed_oid,
                                            OID_LENGTH(my_delayed_oid),
                                            HANDLER_CAN_RWRITE);

    netsnmp_register_instance(my_test);
}