/** Initialize the mteEventTable table by defining its contents and how it's structured */
void
initialize_table_mteEventTable(void)
{
    static oid      mteEventTable_oid[] =
        { 1, 3, 6, 1, 2, 1, 88, 1, 4, 2 };
    size_t          mteEventTable_oid_len = OID_LENGTH(mteEventTable_oid);

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

    /*
     * comment this out or delete if you don't support creation of new rows 
     */
    table_set->allow_creation = 1;
    /* mark the row status column */
    table_set->rowstatus_column = COLUMN_MTEEVENTENTRYSTATUS;

    /***************************************************
     * Adding indexes
     */
    DEBUGMSGTL(("initialize_table_mteEventTable",
                "adding indexes to table mteEventTable\n"));
    netsnmp_table_set_add_indexes(table_set,
                                  ASN_OCTET_STR,   /* index: mteOwner */
                                  ASN_PRIV_IMPLIED_OCTET_STR, /* index: mteEventName */
                                  0);

    DEBUGMSGTL(("initialize_table_mteEventTable",
                "adding column types to table mteEventTable\n"));
    netsnmp_table_set_multi_add_default_row(table_set,
                                            COLUMN_MTEEVENTNAME,
                                            ASN_OCTET_STR, 0, NULL, 0,
                                            COLUMN_MTEEVENTCOMMENT,
                                            ASN_OCTET_STR, 1, NULL, 0,
                                            COLUMN_MTEEVENTACTIONS,
                                            ASN_OCTET_STR, 1, NULL, 0,
                                            COLUMN_MTEEVENTENABLED,
                                            ASN_INTEGER, 1, NULL, 0,
                                            COLUMN_MTEEVENTENTRYSTATUS,
                                            ASN_INTEGER, 1, NULL, 0, 0);

    /* keep index values around for comparisons later */
    table_set->table->store_indexes = 1;
    /*
     * registering the table with the master agent 
     */
    /*
     * note: if you don't need a subhandler to deal with any aspects
     * of the request, change mteEventTable_handler to "NULL" 
     */
    netsnmp_register_table_data_set(netsnmp_create_handler_registration
                                    ("mteEventTable",
                                     mteEventTable_handler,
                                     mteEventTable_oid,
                                     mteEventTable_oid_len,
                                     HANDLER_CAN_RWRITE), table_set, NULL);
}
Пример #2
0
/** Initializes the mgPIDECMTable module */
void
init_mgPIDECMTable(void) {

    /* here we initialize all the tables we're planning on supporting */
    /* create the table structure itself */
    table_set = netsnmp_create_table_data_set("mgPIDECMTable");

    netsnmp_mib_handler *cache_handler;

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

    /***************************************************
     * Adding indexes
     */
    DEBUGMSGTL(("initialize_table_mgPIDECMTable",
            "adding indexes to table mgPIDECMTable\n"));
    netsnmp_table_set_add_indexes(table_set,
            ASN_INTEGER, /* index: mgPIDECMInputNumber */
            ASN_INTEGER, /* index: mgPIDECMServiceNumber */
            ASN_INTEGER, /* index: mgPIDECMPID */
            0);

    DEBUGMSGTL(("initialize_table_mgPIDECMTable",
            "adding column types to table mgPIDECMTable\n"));
    netsnmp_table_set_multi_add_default_row(table_set,
            COLUMN_MGPIDECMINPUTNUMBER, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMSERVICENUMBER, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMPID, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMCAPID, ASN_INTEGER, 0,
            NULL, 0,
            COLUMN_MGPIDECMCASYSTEMID, ASN_INTEGER, 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 mgPIDECMTable_handler to "NULL" */
    netsnmp_handler_registration *reginfo = netsnmp_create_handler_registration("mgPIDECMTable", NULL,
            mgPIDECMTable_oid,
            OID_LENGTH(mgPIDECMTable_oid),
            HANDLER_CAN_RWRITE);
    netsnmp_register_table_data_set(reginfo, table_set, NULL);

    DEBUGMSGTL(("mgPIDECMTable", "Done initalizing mgPIDECMTable module\n"));

    cache_handler = netsnmp_get_cache_handler(LONGCACHETIMEOUT, /* how long a cache is valid for */
            cache_load, /* a pointer to the cache loading function */
            cache_free, /* a pointer to the cache freeing function */
            mgPIDECMTable_oid, OID_LENGTH(mgPIDECMTable_oid)); /* the OID of the registration point */

    netsnmp_inject_handler(reginfo, cache_handler);
}
Пример #3
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);
}
Пример #4
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;
}
Пример #5
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;
}
Пример #6
0
/** Initialize the sipRegUserTable table by defining it's contents and 
 * how it's structured */
static int initialize_table_sipRegUserTable()
{
	static oid sipRegUserTable_oid[] = {1,3,6,1,2,1,9991,1,7,2};
	size_t sipRegUserTable_oid_len = OID_LENGTH(sipRegUserTable_oid);
	const char *func = "snmp_mod";

	/* create the table structure itself */
	sipRegUserTable = netsnmp_create_table_data_set("sipRegUserTable");
	if(!sipRegUserTable) {
		LOG(L_ERR, "%s: Error creating table\n", func);
		return -1;
	}
	
	/***************************************************
	 * Adding indexes
	 */
	netsnmp_table_dataset_add_index(sipRegUserTable, ASN_INTEGER);
	netsnmp_table_dataset_add_index(sipRegUserTable, ASN_UNSIGNED);
	
	netsnmp_table_set_multi_add_default_row(
		sipRegUserTable,
		COLUMN_SIPUSERINDEX, ASN_UNSIGNED, 0, NULL, 0,
		COLUMN_SIPUSERURI, ASN_OCTET_STR, 1, NULL, 0,
		COLUMN_SIPUSERAUTHENTICATIONFAILURES, ASN_COUNTER, 0, NULL, 0,
		COLUMN_SIPUSERTABLEROWSTATUS, 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 sipRegUserTable_handler to "NULL" */
	netsnmp_register_table_data_set(
			netsnmp_create_handler_registration(
				"sipRegUserTable", 
				sipRegUserTable_handler,
				sipRegUserTable_oid,
				sipRegUserTable_oid_len,
				HANDLER_CAN_RWRITE),
			sipRegUserTable, NULL);

	return 0;
}
Пример #7
0
/** Initialize the sipRegCfgTable table by defining it's contents and 
 * how it's structured */
static int initialize_table_sipRegCfgTable()
{
	static oid sipRegCfgTable_oid[] = {1,3,6,1,2,1,9991,1,7,1};
	size_t sipRegCfgTable_oid_len = OID_LENGTH(sipRegCfgTable_oid);
	const char *func = "snmp_mod";

	/* create the table structure itself */
	sipRegCfgTable = netsnmp_create_table_data_set("sipRegCfgTable");
	if(!sipRegCfgTable) {
		LOG(L_ERR, "%s: Error creating table\n", func);
		return -1;
	}
	
	/***************************************************
	 * Adding indexes
	 */
	netsnmp_table_dataset_add_index(sipRegCfgTable, ASN_INTEGER);
	
	netsnmp_table_set_multi_add_default_row(
		sipRegCfgTable,
		COLUMN_SIPREGALLOWTHIRDPARTY, ASN_INTEGER, 1, NULL, 0,
		COLUMN_SIPREGMAXCONTACTEXPIRYDATE, ASN_UNSIGNED, 1, NULL, 0,
		COLUMN_SIPREGMAXUSERS, ASN_UNSIGNED, 0, NULL, 0,
		COLUMN_SIPREGCURRENTUSERS, ASN_GAUGE, 0, NULL, 0,
		COLUMN_SIPREGDFLTREGACTIVEINTERVAL, ASN_UNSIGNED, 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 sipRegCfgTable_handler to "NULL" */
	netsnmp_register_table_data_set(
			netsnmp_create_handler_registration(
				"sipRegCfgTable", 
				sipRegCfgTable_handler,
				sipRegCfgTable_oid,
				sipRegCfgTable_oid_len,
				HANDLER_CAN_RWRITE),
			sipRegCfgTable, NULL);

	return 0;
}
Пример #8
0
/** Initialize the sipOtherStatsTable table by defining it's contents and 
 * how it's structured */
static int initialize_table_sipOtherStatsTable()
{
	static oid sipOtherStatsTable_oid[] = {1,3,6,1,2,1,9990,1,10,1};
	size_t sipOtherStatsTable_oid_len = OID_LENGTH(sipOtherStatsTable_oid);
	const char *func = "snmp_mod";

	/* create the table structure itself */
	sipOtherStatsTable = netsnmp_create_table_data_set("sipOtherStatsTable");
	if(!sipOtherStatsTable) {
		LOG(L_ERR, "%s: Error creating table\n", func);
		return -1;
	}
	
	/***************************************************
	 * Adding indexes
	 */
	netsnmp_table_dataset_add_index(sipOtherStatsTable, ASN_INTEGER);
	
	netsnmp_table_set_multi_add_default_row(
		sipOtherStatsTable,
		COLUMN_SIPNUMUNSUPPORTEDURIS, ASN_COUNTER, 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 sipOtherStatsTable_handler to "NULL" */
	netsnmp_register_table_data_set(
			netsnmp_create_handler_registration(
				"sipOtherStatsTable", 
				sipOtherStatsTable_handler,
				sipOtherStatsTable_oid,
				sipOtherStatsTable_oid_len,
				HANDLER_CAN_RWRITE),
			sipOtherStatsTable, NULL);

	return 0;
}
Пример #9
0
/** @internal */
void
netsnmp_config_parse_table_set(const char *token, char *line)
{
    oid             name[MAX_OID_LEN], table_name[MAX_OID_LEN];
    size_t          name_length = MAX_OID_LEN, table_name_length =
        MAX_OID_LEN;
    struct tree    *tp, *indexnode;
    netsnmp_table_data_set *table_set;
    data_set_tables *tables;
    struct index_list *index;
    unsigned int    mincol = 0xffffff, maxcol = 0;
    u_char          type;
    char           *pos;

    /*
     * instatiate a fake table based on MIB information 
     */
    DEBUGMSGTL(("9:table_set_add_table", "processing '%s'\n", line));
    if (NULL != (pos = strchr(line,' '))) {
        config_pwarn("ignoring extra tokens on line");
        snmp_log(LOG_WARNING,"  ignoring '%s'\n", pos);
        *pos = '\0';
    }

    /*
     * check for duplicate table
     */
    tables = (data_set_tables *) netsnmp_get_list_data(auto_tables, line);
    if (NULL != tables) {
        config_pwarn("duplicate table definition");
        return;
    }

    /*
     * parse oid and find tree structure
     */
    if (!snmp_parse_oid(line, table_name, &table_name_length)) {
        config_pwarn
            ("can't instatiate table since I can't parse the table name");
        return;
    }
    if(NULL == (tp = get_tree(table_name, table_name_length,
                              get_tree_head()))) {
        config_pwarn("can't instatiate table since "
                     "I can't find mib information about it");
        return;
    }

    if (NULL == (tp = tp->child_list) || NULL == tp->child_list) {
        config_pwarn("can't instatiate table since it doesn't appear to be "
                     "a proper table (no children)");
        return;
    }

    /*
     * check for augments indexes
     */
    if (NULL != tp->augments) {
        if (!snmp_parse_oid(tp->augments, table_name, &table_name_length)) {
            config_pwarn("I can't parse the augment tabel name");
            snmp_log(LOG_WARNING, "  can't parse %s\n", tp->augments);
            return;
        }
        if(NULL == (tp = get_tree(table_name, table_name_length,
                                  get_tree_head()))) {
            config_pwarn("can't instatiate table since "
                         "I can't find mib information about augment table");
            snmp_log(LOG_WARNING, "  table %s not found in tree\n",
                     tp->augments);
            return;
        }

        table_set = netsnmp_create_table_data_set(line);
    
        /*
         * loop through indexes and add types 
         */
        for (index = tp->indexes; index; index = index->next) {
            if (!snmp_parse_oid(index->ilabel, name, &name_length) ||
                (NULL ==
                 (indexnode = get_tree(name, name_length, get_tree_head())))) {
                config_pwarn("can't instatiate table since "
                             "I don't know anything about one index");
                snmp_log(LOG_WARNING, "  index %s not found in tree\n",
                         index->ilabel);
                return;             /* xxx mem leak */
            }
            
            type = mib_to_asn_type(indexnode->type);
            if (type == (u_char) - 1) {
                config_pwarn("unknown index type");
                return;             /* xxx mem leak */
            }
            if (index->isimplied)   /* if implied, mark it as such */
                type |= ASN_PRIVATE;
            
            DEBUGMSGTL(("table_set_add_row",
                        "adding default index of type %d\n", type));
            netsnmp_table_dataset_add_index(table_set, type);
        }
    }
    else
        table_set = netsnmp_create_table_data_set(line);
    
    /*
     * loop through indexes and add types 
     */
    for (index = tp->indexes; index; index = index->next) {
        if (!snmp_parse_oid(index->ilabel, name, &name_length) ||
            (NULL ==
             (indexnode = get_tree(name, name_length, get_tree_head())))) {
            config_pwarn("can't instatiate table since "
                         "I don't know anything about one index");
            snmp_log(LOG_WARNING, "  index %s not found in tree\n",
                     index->ilabel);
            return;             /* xxx mem leak */
        }

        type = mib_to_asn_type(indexnode->type);
        if (type == (u_char) - 1) {
            config_pwarn("unknown index type");
            return;             /* xxx mem leak */
        }
        if (index->isimplied)   /* if implied, mark it as such */
            type |= ASN_PRIVATE;

        DEBUGMSGTL(("table_set_add_row",
                    "adding default index of type %d\n", type));
        netsnmp_table_dataset_add_index(table_set, type);
    }

    /*
     * loop through children and add each column info 
     */
    for (tp = tp->child_list; tp; tp = tp->next_peer) {
        int             canwrite = 0;
        type = mib_to_asn_type(tp->type);
        if (type == (u_char) - 1) {
            config_pwarn("unknown column type");
            return;             /* xxx mem leak */
        }

        DEBUGMSGTL(("table_set_add_row",
                    "adding column %s(%d) of type %d (access %d)\n",
                    tp->label, tp->subid, type, tp->access));

        switch (tp->access) {
        case MIB_ACCESS_CREATE:
            table_set->allow_creation = 1;
        case MIB_ACCESS_READWRITE:
        case MIB_ACCESS_WRITEONLY:
            canwrite = 1;
        case MIB_ACCESS_READONLY:
            DEBUGMSGTL(("table_set_add_row",
                        "adding column %d of type %d\n", tp->subid, type));
            netsnmp_table_set_add_default_row(table_set, tp->subid, type,
                                              canwrite, NULL, 0);
            mincol = SNMP_MIN(mincol, tp->subid);
            maxcol = SNMP_MAX(maxcol, tp->subid);
            break;

        case MIB_ACCESS_NOACCESS:
        case MIB_ACCESS_NOTIFY:
            break;

        default:
            config_pwarn("unknown column access type");
            break;
        }
    }

    /*
     * register the table 
     */
    netsnmp_register_table_data_set(netsnmp_create_handler_registration
                                    (line, NULL, table_name,
                                     table_name_length,
                                     HANDLER_CAN_RWRITE), table_set, NULL);

    netsnmp_register_auto_data_table(table_set, NULL);
}
Пример #10
0
/*
 * (to get called, the function name must match init_FILENAME() 
 */
     void init_data_set (void)
{
    netsnmp_table_row *row;

    /*
     * the OID we want to register our integer at.  This should be the
     * * OID node for the entire table.  In our case this is the
     * * netSnmpIETFWGTable oid definition 
     */
    oid my_registration_oid[] = { 1, 3, 6, 1, 4, 1, 8072, 2, 2, 1 };

    /*
     * a debugging statement.  Run the agent with -Dexample_data_set to see
     * * the output of this debugging statement. 
     */
    DEBUGMSGTL (("example_data_set", "Initalizing example dataset table\n"));

    /*
     * It's going to be the "working group chairs" table, since I'm
     * * sitting at an IETF convention while I'm writing this.
     * *
     * *  column 1 = index = string = WG name
     * *  column 2 = string = chair #1
     * *  column 3 = string = chair #2  (most WGs have 2 chairs now)
     */

    table_set = netsnmp_create_table_data_set ("netSnmpIETFWGTable");

    /*
     * allow the creation of new rows via SNMP SETs 
     */
    table_set->allow_creation = 1;

    /*
     * set up what a row "should" look like, starting with the index 
     */
    netsnmp_table_dataset_add_index (table_set, ASN_OCTET_STR);

    /*
     * define what the columns should look like.  both are octet strings here 
     */
    netsnmp_table_set_multi_add_default_row (table_set,
                                             /*
                                              * column 2 = OCTET STRING,
                                              * writable = 1,
                                              * default value = NULL,
                                              * default value len = 0 
                                              */
                                             2, ASN_OCTET_STR, 1, NULL, 0,
                                             /*
                                              * similar 
                                              */
                                             3, ASN_OCTET_STR, 1, NULL, 0, 0 /* done */ );

    /*
     * register the table 
     */
    /*
     * if we wanted to handle specific data in a specific way, or note
     * * when requests came in we could change the NULL below to a valid
     * * handler method in which we could over ride the default
     * * behaviour of the table_dataset helper 
     */
    netsnmp_register_table_data_set (netsnmp_create_handler_registration
                                     ("netSnmpIETFWGTable", NULL,
                                      my_registration_oid,
                                      OID_LENGTH (my_registration_oid), HANDLER_CAN_RWRITE), table_set, NULL);


    /*
     * create the a row for the table, and add the data 
     */
    row = netsnmp_create_table_data_row ();
    /*
     * set the index to the IETF WG name "snmpv3" 
     */
    netsnmp_table_row_add_index (row, ASN_OCTET_STR, "snmpv3", strlen ("snmpv3"));


    /*
     * set column 2 to be the WG chair name "Russ Mundy" 
     */
    netsnmp_set_row_column (row, 2, ASN_OCTET_STR, "Russ Mundy", strlen ("Russ Mundy"));
    netsnmp_mark_row_column_writable (row, 2, 1);    /* make writable via SETs */

    /*
     * set column 3 to be the WG chair name "David Harrington" 
     */
    netsnmp_set_row_column (row, 3, ASN_OCTET_STR, "David Harrington", strlen ("David Harrington"));
    netsnmp_mark_row_column_writable (row, 3, 1);    /* make writable via SETs */

    /*
     * add the row to the table 
     */
    netsnmp_table_dataset_add_row (table_set, row);

#ifdef ADD_MORE_DATA
    /*
     * add the data, for the second row 
     */
    row = netsnmp_create_table_data_row ();
    netsnmp_table_row_add_index (row, ASN_OCTET_STR, "snmpconf", strlen ("snmpconf"));
    netsnmp_set_row_column (row, 2, ASN_OCTET_STR, "David Partain", strlen ("David Partain"));
    netsnmp_mark_row_column_writable (row, 2, 1);    /* make writable */
    netsnmp_set_row_column (row, 3, ASN_OCTET_STR, "Jon Saperia", strlen ("Jon Saperia"));
    netsnmp_mark_row_column_writable (row, 3, 1);    /* make writable */
    netsnmp_table_dataset_add_row (table_set, row);
#endif

    /*
     * Finally, this actually allows the "add_row" token it the
     * * snmpd.conf file to add rows to this table.
     * * Example snmpd.conf line:
     * *   add_row netSnmpIETFWGTable eos "Glenn Waters" "Dale Francisco"
     */
    netsnmp_register_auto_data_table (table_set, NULL);

    DEBUGMSGTL (("example_data_set", "Done initializing.\n"));
}
Пример #11
0
/** Initialize the lightingTable table by defining its contents and how it's structured */
void
initialize_table_lightingTable(void)
{
    const oid lightingTable_oid[] = {1,3,6,1,4,1,12620,5,2};
    netsnmp_table_data_set *table_set;

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

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

    /***************************************************
     * Adding indexes
     */
    DEBUGMSGTL(("initialize_table_lightingTable",
                "adding indexes to table lightingTable\n"));
    //netsnmp_table_set_add_indexes(table_set,
    //                       ASN_INTEGER,  /* index: lightIndex */
    //                       0);
    //DEBUGMSGTL(("gpDroneMIB","pt-1\n"));
	netsnmp_table_dataset_add_index(table_set,
                           ASN_INTEGER);  /* index: lightIndex */
                       

    DEBUGMSGTL(("initialize_table_lightingTable",
                "adding column types to table lightingTable\n"));
    //DEBUGMSGTL(("gpDroneMIB","pt1\n"));			 
    /*netsnmp_table_set_multi_add_default_row(table_set,
                                            COLUMN_LIGHTDESCRIPTION, ASN_OCTET_STR, 0,
                                            NULL, 0,
                                            COLUMN_LIGHTTOGGLE, ASN_INTEGER, 1,
                                            NULL, 0,
                                            COLUMN_LIGHTINDEX, ASN_INTEGER, 0,
                                            NULL, 0,
                              0);
    */
	netsnmp_table_set_multi_add_default_row(table_set,
                                            COLUMN_LIGHTINDEX, ASN_INTEGER, 0,
                                            NULL, 0,
                                            COLUMN_LIGHTDESCRIPTION, ASN_OCTET_STR, 0,
                                            NULL, 0,
                                            COLUMN_LIGHTTOGGLE, ASN_INTEGER, 1,
                                            NULL, 0,
                              0);
    //DEBUGMSGTL(("gpDroneMIB","pt2\n"));			 
    /* registering the table with the master agent */
    /* note: if you don't need a subhandler to deal with any aspects
       of the request, change lightingTable_handler to "NULL" */
    netsnmp_register_table_data_set(netsnmp_create_handler_registration("lightingTable", lightingTable_handler,
                                                        lightingTable_oid,
                                                        OID_LENGTH(lightingTable_oid),
                                                        HANDLER_CAN_RWRITE),
                            table_set, NULL);
	my_table = (struct tb_entry*)malloc(sizeof(struct tb_entry)*5);
	int i;
	for(i = 1; i <= 5; i++){
		my_table[i-1].index = (long)i;
		strncpy(my_table[i-1].descr,l_table[i-1].descr,256);
		my_table[i-1].toggle = 0;//TODO: initialize
		int index = i;
		netsnmp_table_row *row = netsnmp_create_table_data_row();
		netsnmp_table_row_add_index(row,ASN_INTEGER,&index,sizeof(index));
		netsnmp_set_row_column(row,1,ASN_INTEGER,&index,sizeof(index));
		netsnmp_mark_row_column_writable(row,1,0);	
		netsnmp_set_row_column(row,2,ASN_OCTET_STR,l_table[i-1].descr,strlen(l_table[i-1].descr));
		netsnmp_mark_row_column_writable(row,2,0);
		netsnmp_set_row_column(row,3,ASN_INTEGER,&index,sizeof(index));
		netsnmp_mark_row_column_writable(row,3,1);
		netsnmp_table_dataset_add_row(table_set,row);
	}
	/*FILE *f = fopen("result.txt","w");
	fprintf(f,"Index\t\tDescr\t\tToggle\n");
	for(i = 1; i <= 5; i++){
		fprintf(f,"%d\t\t%s\t\t%d\n",my_table[i-1].index,my_table[i-1].descr,my_table[i-1].toggle);
	}
	fclose(f);
	*/
}
Пример #12
0
void init_netflow(void)
{
	netsnmp_handler_registration *reg;
	struct snmp_vars *sys;

	/* snmpd -f -L -Dnetflow,dlmod */
	DEBUGMSGTL(("netflow", "init_netflow\n"));

	netsnmp_register_scalar_group(
	    netsnmp_create_handler_registration(
		    "iptNetflowModule",
		    iptNetflowModule_handler,
		    iptNetflowModule_oid,
		    OID_LENGTH(iptNetflowModule_oid),
		    HANDLER_CAN_RONLY),
	    1, var_max(modinfos));

	netsnmp_register_scalar_group(
	    netsnmp_create_handler_registration(
		    "iptNetflowSysctl",
		    iptNetflowSysctl_handler,
		    iptNetflowSysctl_oid,
		    OID_LENGTH(iptNetflowSysctl_oid),
		    HANDLER_CAN_RWRITE),
	    1, var_max(sysctls));

	netsnmp_register_scalar_group(
	    netsnmp_create_handler_registration(
		    "iptNetflowTotals",
		    iptNetflowTotals_handler,
		    iptNetflowTotals_oid,
		    OID_LENGTH(iptNetflowTotals_oid),
		    HANDLER_CAN_RONLY),
	    1, var_max(totals));

	/* Register first table. */
	reg = netsnmp_create_handler_registration(
	    "iptNetflowCpuTable", /* no handler */ NULL,
	    iptNetflowCpuTable_oid, OID_LENGTH(iptNetflowCpuTable_oid),
	    HANDLER_CAN_RONLY);

	/* set up columns */
	cpu_data_set = netsnmp_create_table_data_set("iptNetflowCpuDataSet");
	netsnmp_table_set_add_indexes(cpu_data_set, ASN_INTEGER, 0);
	/* I include cpuIndex into columns, which is not SMIv2'ish */
	for (sys = cputable; sys->obj; sys++)
		netsnmp_table_set_add_default_row(cpu_data_set, sys->obj, sys->type, 0, NULL, 0);
	netsnmp_register_table_data_set(reg, cpu_data_set, NULL);

	/* cache handler will load actual data, and it needs to be
	 * injected in front of dataset handler to be called first */
	stat_cache = netsnmp_cache_create(
	    /* no timeout */ -1,
	    stat_cache_load, dummy_cache_free,
	    iptNetflowCpuTable_oid, OID_LENGTH(iptNetflowCpuTable_oid));
	netsnmp_inject_handler(reg, netsnmp_cache_handler_get(stat_cache));

	/* Register second table. */
	reg = netsnmp_create_handler_registration(
	    "iptNetflowSockTable", /* no handler */ NULL,
	    iptNetflowSockTable_oid, OID_LENGTH(iptNetflowSockTable_oid),
	    HANDLER_CAN_RONLY);

	/* set up columns */
	sock_data_set = netsnmp_create_table_data_set("iptNetflowSockDataSet");
	/* I don't include sockIndex into columns, which is more SMIv2'ish */
	netsnmp_table_set_add_indexes(sock_data_set, ASN_INTEGER, 0);
	for (sys = &socktable[1]; sys->obj; sys++)
		netsnmp_table_set_add_default_row(sock_data_set, sys->obj, sys->type, 0, NULL, 0);
	netsnmp_register_table_data_set(reg, sock_data_set, NULL);

	/* as before, cache handler will load actual data, and it needs
	 * to be injected in front of dataset handler to be called first */
	stat_cache = netsnmp_cache_create(
	    /* no timeout */ -1,
	    stat_cache_load, dummy_cache_free,
	    iptNetflowSockTable_oid, OID_LENGTH(iptNetflowSockTable_oid));
	netsnmp_inject_handler(reg, netsnmp_cache_handler_get(stat_cache));
}
Пример #13
0
/** Initialize the nlmLogTable table by defining it's contents and how it's structured */
void
initialize_table_nlmLogTable(void)
{
    static oid      nlmLogTable_oid[] = { 1, 3, 6, 1, 2, 1, 92, 1, 3, 1 };
    size_t          nlmLogTable_oid_len = OID_LENGTH(nlmLogTable_oid);

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

    /***************************************************
     * Adding indexes
     */
    /*
     * declaring the nlmLogIndex index
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding index nlmLogName of type ASN_OCTET_STR to table nlmLogTable\n"));
    netsnmp_table_dataset_add_index(nlmLogTable, ASN_OCTET_STR);

    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding index nlmLogIndex of type ASN_UNSIGNED to table nlmLogTable\n"));
    netsnmp_table_dataset_add_index(nlmLogTable, ASN_UNSIGNED);

    /*
     * adding column nlmLogTime of type ASN_TIMETICKS and access of
     * ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogTime (#2) of type ASN_TIMETICKS to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable, COLUMN_NLMLOGTIME,
                                      ASN_TIMETICKS, 0, NULL, 0);
    /*
     * adding column nlmLogDateAndTime of type ASN_OCTET_STR and access of 
     * ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogDateAndTime (#3) of type ASN_OCTET_STR to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable,
                                      COLUMN_NLMLOGDATEANDTIME,
                                      ASN_OCTET_STR, 0, NULL, 0);
    /*
     * adding column nlmLogEngineID of type ASN_OCTET_STR and access of
     * ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogEngineID (#4) of type ASN_OCTET_STR to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable, COLUMN_NLMLOGENGINEID,
                                      ASN_OCTET_STR, 0, NULL, 0);
    /*
     * adding column nlmLogEngineTAddress of type ASN_OCTET_STR and access 
     * of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogEngineTAddress (#5) of type ASN_OCTET_STR to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable,
                                      COLUMN_NLMLOGENGINETADDRESS,
                                      ASN_OCTET_STR, 0, NULL, 0);
    /*
     * adding column nlmLogEngineTDomain of type ASN_OBJECT_ID and access
     * of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogEngineTDomain (#6) of type ASN_OBJECT_ID to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable,
                                      COLUMN_NLMLOGENGINETDOMAIN,
                                      ASN_OBJECT_ID, 0, NULL, 0);
    /*
     * adding column nlmLogContextEngineID of type ASN_OCTET_STR and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogContextEngineID (#7) of type ASN_OCTET_STR to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable,
                                      COLUMN_NLMLOGCONTEXTENGINEID,
                                      ASN_OCTET_STR, 0, NULL, 0);
    /*
     * adding column nlmLogContextName of type ASN_OCTET_STR and access of 
     * ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogContextName (#8) of type ASN_OCTET_STR to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable,
                                      COLUMN_NLMLOGCONTEXTNAME,
                                      ASN_OCTET_STR, 0, NULL, 0);
    /*
     * adding column nlmLogNotificationID of type ASN_OBJECT_ID and access 
     * of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogTable",
                "adding column nlmLogNotificationID (#9) of type ASN_OBJECT_ID to table nlmLogTable\n"));
    netsnmp_table_set_add_default_row(nlmLogTable,
                                      COLUMN_NLMLOGNOTIFICATIONID,
                                      ASN_OBJECT_ID, 0, NULL, 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 nlmLogTable_handler to "NULL" 
     */
    netsnmp_register_table_data_set(netsnmp_create_handler_registration
                                    ("nlmLogTable", nlmLogTable_handler,
                                     nlmLogTable_oid, nlmLogTable_oid_len,
                                     HANDLER_CAN_RWRITE), nlmLogTable,
                                    NULL);

    /*
     * hmm...  5 minutes seems like a reasonable time to check for out
     * dated notification logs right? 
     */
    snmp_alarm_register(300, SA_REPEAT, check_log_size, NULL);
}
Пример #14
0
/** Initialize the nlmLogVariableTable table by defining it's contents and how it's structured */
void
initialize_table_nlmLogVariableTable(void)
{
    static oid      nlmLogVariableTable_oid[] =
        { 1, 3, 6, 1, 2, 1, 92, 1, 3, 2 };
    size_t          nlmLogVariableTable_oid_len =
        OID_LENGTH(nlmLogVariableTable_oid);
    netsnmp_table_data_set *table_set;

    /*
     * create the table structure itself 
     */
    table_set = netsnmp_create_table_data_set("nlmLogVariableTable");
    nlmLogVarTable = table_set;
    nlmLogVarTable->table->store_indexes = 1;

    /***************************************************
     * Adding indexes
     */
    /*
     * declaring the nlmLogName index
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding index nlmLogName of type ASN_OCTET_STR to table nlmLogVariableTable\n"));
    netsnmp_table_dataset_add_index(table_set, ASN_OCTET_STR);
    /*
     * declaring the nlmLogIndex index
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding index nlmLogIndex of type ASN_UNSIGNED to table nlmLogVariableTable\n"));
    netsnmp_table_dataset_add_index(table_set, ASN_UNSIGNED);
    /*
     * declaring the nlmLogVariableIndex index
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding index nlmLogVariableIndex of type ASN_UNSIGNED to table nlmLogVariableTable\n"));
    netsnmp_table_dataset_add_index(table_set, ASN_UNSIGNED);

    /*
     * adding column nlmLogVariableIndex of type ASN_UNSIGNED and access
     * of NoAccess 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableIndex (#1) of type ASN_UNSIGNED to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEINDEX,
                                      ASN_UNSIGNED, 0, NULL, 0);
    /*
     * adding column nlmLogVariableID of type ASN_OBJECT_ID and access of
     * ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableID (#2) of type ASN_OBJECT_ID to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set, COLUMN_NLMLOGVARIABLEID,
                                      ASN_OBJECT_ID, 0, NULL, 0);
    /*
     * adding column nlmLogVariableValueType of type ASN_INTEGER and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableValueType (#3) of type ASN_INTEGER to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEVALUETYPE,
                                      ASN_INTEGER, 0, NULL, 0);
    /*
     * adding column nlmLogVariableCounter32Val of type ASN_COUNTER and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableCounter32Val (#4) of type ASN_COUNTER to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLECOUNTER32VAL,
                                      ASN_COUNTER, 0, NULL, 0);
    /*
     * adding column nlmLogVariableUnsigned32Val of type ASN_UNSIGNED and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableUnsigned32Val (#5) of type ASN_UNSIGNED to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEUNSIGNED32VAL,
                                      ASN_UNSIGNED, 0, NULL, 0);
    /*
     * adding column nlmLogVariableTimeTicksVal of type ASN_TIMETICKS and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableTimeTicksVal (#6) of type ASN_TIMETICKS to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLETIMETICKSVAL,
                                      ASN_TIMETICKS, 0, NULL, 0);
    /*
     * adding column nlmLogVariableInteger32Val of type ASN_INTEGER and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableInteger32Val (#7) of type ASN_INTEGER to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEINTEGER32VAL,
                                      ASN_INTEGER, 0, NULL, 0);
    /*
     * adding column nlmLogVariableOctetStringVal of type ASN_OCTET_STR
     * and access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableOctetStringVal (#8) of type ASN_OCTET_STR to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEOCTETSTRINGVAL,
                                      ASN_OCTET_STR, 0, NULL, 0);
    /*
     * adding column nlmLogVariableIpAddressVal of type ASN_IPADDRESS and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableIpAddressVal (#9) of type ASN_IPADDRESS to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEIPADDRESSVAL,
                                      ASN_IPADDRESS, 0, NULL, 0);
    /*
     * adding column nlmLogVariableOidVal of type ASN_OBJECT_ID and access 
     * of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableOidVal (#10) of type ASN_OBJECT_ID to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEOIDVAL,
                                      ASN_OBJECT_ID, 0, NULL, 0);
    /*
     * adding column nlmLogVariableCounter64Val of type ASN_COUNTER64 and
     * access of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableCounter64Val (#11) of type ASN_COUNTER64 to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLECOUNTER64VAL,
                                      ASN_COUNTER64, 0, NULL, 0);
    /*
     * adding column nlmLogVariableOpaqueVal of type ASN_OPAQUE and access 
     * of ReadOnly 
     */
    DEBUGMSGTL(("initialize_table_nlmLogVariableTable",
                "adding column nlmLogVariableOpaqueVal (#12) of type ASN_OPAQUE to table nlmLogVariableTable\n"));
    netsnmp_table_set_add_default_row(table_set,
                                      COLUMN_NLMLOGVARIABLEOPAQUEVAL,
                                      ASN_OPAQUE, 0, NULL, 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 nlmLogVariableTable_handler to "NULL" 
     */
    netsnmp_register_table_data_set(netsnmp_create_handler_registration
                                    ("nlmLogVariableTable",
                                     nlmLogVariableTable_handler,
                                     nlmLogVariableTable_oid,
                                     nlmLogVariableTable_oid_len,
                                     HANDLER_CAN_RWRITE), table_set, NULL);
}