Esempio n. 1
0
/** 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_iterator(my_handler, iinfo);
}
/* Initialize the kamailioSIPMethodSupportedTable by defining its structure and
 * callback mechanisms */
void initialize_table_kamailioSIPMethodSupportedTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_kamailioSIPMethodSupported"
				"Table_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(
			"kamailioSIPMethodSupportedTable",
			netsnmp_table_array_helper_handler,
			kamailioSIPMethodSupportedTable_oid,
			kamailioSIPMethodSupportedTable_oid_len,
			HANDLER_CAN_RONLY);
			
	if (!my_handler || !table_info) {
		snmp_log(LOG_ERR, "malloc failed in initialize_table_kamailio"
				"SIPMethodSupportedTable_handler\n");
		return; 
	}

	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

	table_info->min_column = kamailioSIPMethodSupportedTable_COL_MIN;
	table_info->max_column = kamailioSIPMethodSupportedTable_COL_MAX;

	/***************************************************
	 * registering the table with the master agent
	 */
	cb.get_value = kamailioSIPMethodSupportedTable_get_value;
	cb.container = 
		netsnmp_container_find("kamailioSIPMethodSupportedTable_primary:"
			"kamailioSIPMethodSupportedTable:" "table_container");
	
	DEBUGMSGTL(("initialize_table_kamailioSIPMethodSupportedTable", 
				"Registering table kamailioSIPMethodSupportedTable"
				"as a table array\n"));

	netsnmp_table_container_register(my_handler, table_info, &cb,
			cb.container, 1);

}
Esempio n. 3
0
/* Initialize the openserSIPPortTable table by defining how it is structured */
void initialize_table_openserSIPPortTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_openserSIPPortTable_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("openserSIPPortTable",
			netsnmp_table_array_helper_handler,
			openserSIPPortTable_oid,
			openserSIPPortTable_oid_len,
			HANDLER_CAN_RONLY);
    
	if (!my_handler || !table_info) {
		snmp_log(LOG_ERR, "malloc failed in "
			 "initialize_table_openserSIPPortTable_handler\n");
		return; /** mallocs failed */
	}

	/* Set up the table's structural definition */
	
	/* index: openserSIPPortIndex */
	netsnmp_table_helper_add_index(table_info, ASN_OCTET_STR);

	table_info->min_column = openserSIPPortTable_COL_MIN;
	table_info->max_column = openserSIPPortTable_COL_MAX;

	/* register the table with the master agent */
	cb.get_value = openserSIPPortTable_get_value;
	cb.container = netsnmp_container_find("openserSIPPortTable_primary:"
			"openserSIPPortTable:"
			"table_container");

	
	DEBUGMSGTL(("initialize_table_openserSIPPortTable",
				"Registering table openserSIPPortTable "
				"as a table array\n"));
	
	netsnmp_table_container_register(my_handler, table_info, &cb,
			cb.container, 1);
}
void
init_vacm_context(void)
{
    /*
     * table vacm_context
     */
    netsnmp_handler_registration *my_handler;
    netsnmp_table_registration_info *table_info;
    netsnmp_iterator_info *iinfo;

    my_handler = netsnmp_create_handler_registration("vacm_context",
                                                     vacm_context_handler,
                                                     vacm_context_oid,
                                                     sizeof
                                                     (vacm_context_oid) /
                                                     sizeof(oid),
                                                     HANDLER_CAN_RONLY);

    if (!my_handler)
        return;

    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);

    if (!table_info || !iinfo) {
        SNMP_FREE(table_info);
        SNMP_FREE(iinfo);
        return;
    }

    netsnmp_table_helper_add_index(table_info, ASN_OCTET_STR)
        table_info->min_column = 1;
    table_info->max_column = 1;
    iinfo->get_first_data_point = get_first_context;
    iinfo->get_next_data_point = get_next_context;
    iinfo->table_reginfo = table_info;
    netsnmp_register_table_iterator(my_handler, iinfo);
}
Esempio n. 5
0
/************************************************************
 *
 * Initialize the saHpiDomainEventTable table by defining its contents and how it's structured
 */
void
initialize_table_saHpiDomainEventTable(void)
{
    netsnmp_table_registration_info *table_info;

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

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

    /** create the table structure itself */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_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("saHpiDomainEventTable",
                                             netsnmp_table_array_helper_handler,
                                             saHpiDomainEventTable_oid,
                                             saHpiDomainEventTable_oid_len,
                                             HANDLER_CAN_RWRITE);
            
    if (!my_handler || !table_info) {
        snmp_log(LOG_ERR, "malloc failed in "
                 "initialize_table_saHpiDomainEventTable_handler\n");
        return; /** mallocs failed */
    }

    /***************************************************
     * Setting up the table's definition
     */
    /*
     * TODO: add any external indexes here.
     */
        /** TODO: add code for external index(s)! */

    /*
     * internal indexes
     */
        /** index: saHpiDomainId */
        netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
        /** index: saHpiDomainEventEntryId */
        netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
        /** index: saHpiEventSeverity */
        netsnmp_table_helper_add_index(table_info, ASN_INTEGER);

    table_info->min_column = saHpiDomainEventTable_COL_MIN;
    table_info->max_column = saHpiDomainEventTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
    cb.get_value = saHpiDomainEventTable_get_value;
    cb.container = netsnmp_container_find("saHpiDomainEventTable_primary:"
                                          "saHpiDomainEventTable:"
                                          "table_container");

    netsnmp_container_add_index(cb.container,
                                netsnmp_container_find("saHpiDomainEventTable_secondary:"
                                                       "saHpiDomainEventTable:"
                                                       "table_container"));
    cb.container->next->compare = saHpiDomainEventTable_cmp;


    cb.can_set = 1;

    cb.create_row = (UserRowMethod*)saHpiDomainEventTable_create_row;

    cb.duplicate_row = (UserRowMethod*)saHpiDomainEventTable_duplicate_row;
    cb.delete_row = (UserRowMethod*)saHpiDomainEventTable_delete_row;
    cb.row_copy = (Netsnmp_User_Row_Operation *)saHpiDomainEventTable_row_copy;

    cb.can_activate = (Netsnmp_User_Row_Action *)saHpiDomainEventTable_can_activate;
    cb.can_deactivate = (Netsnmp_User_Row_Action *)saHpiDomainEventTable_can_deactivate;
    cb.can_delete = (Netsnmp_User_Row_Action *)saHpiDomainEventTable_can_delete;

    cb.set_reserve1 = saHpiDomainEventTable_set_reserve1;
    cb.set_reserve2 = saHpiDomainEventTable_set_reserve2;
    cb.set_action = saHpiDomainEventTable_set_action;
    cb.set_commit = saHpiDomainEventTable_set_commit;
    cb.set_free = saHpiDomainEventTable_set_free;
    cb.set_undo = saHpiDomainEventTable_set_undo;

    DEBUGMSGTL(("initialize_table_saHpiDomainEventTable",
                "Registering table saHpiDomainEventTable "
                "as a table array\n"));
    netsnmp_table_container_register(my_handler, table_info, &cb,
                                     cb.container, 1);
}
/*
 * Initialize the openserSIPStatusCodesTable table by defining how it is
 * structured. 
 *
 * This function is mostly auto-generated.
 */
void initialize_table_openserSIPStatusCodesTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_openserSIPStatusCodes"
				"Table_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(
			"openserSIPStatusCodesTable",
			netsnmp_table_array_helper_handler,
			openserSIPStatusCodesTable_oid,
			openserSIPStatusCodesTable_oid_len,
			HANDLER_CAN_RWRITE);
			
	if (!my_handler || !table_info) {
		snmp_log(LOG_ERR, "malloc failed in initialize_table_openserSIP"
				"StatusCodesTable_handler\n");
		return; /** mallocs failed */
	}

	/** index: openserSIPStatusCodeMethod */
	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
	/** index: openserSIPStatusCodeValue */
	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

	table_info->min_column = openserSIPStatusCodesTable_COL_MIN;
	table_info->max_column = openserSIPStatusCodesTable_COL_MAX;

	/***************************************************
	 * registering the table with the master agent
	 */
	cb.get_value = openserSIPStatusCodesTable_get_value;

	cb.container = 
		netsnmp_container_find("openserSIPStatusCodesTable_primary:"
				"openserSIPStatusCodesTable:"
				"table_container");

#ifdef openserSIPStatusCodesTable_CUSTOM_SORT
	netsnmp_container_add_index(cb.container,
			netsnmp_container_find(
				"openserSIPStatusCodesTable_custom:"
				"openserSIPStatusCodesTable:"
				"table_container"));

	cb.container->next->compare = openserSIPStatusCodesTable_cmp;
#endif
	cb.can_set = 1;

	cb.create_row    =
		(UserRowMethod*)openserSIPStatusCodesTable_create_row;

	cb.duplicate_row = 
		(UserRowMethod*)openserSIPStatusCodesTable_duplicate_row;

	cb.delete_row    = 
		(UserRowMethod*)openserSIPStatusCodesTable_delete_row;

	cb.row_copy      = (Netsnmp_User_Row_Operation *)
		openserSIPStatusCodesTable_row_copy;

	cb.can_activate  = (Netsnmp_User_Row_Action *)
		openserSIPStatusCodesTable_can_activate;

	cb.can_deactivate = (Netsnmp_User_Row_Action *)
		openserSIPStatusCodesTable_can_deactivate;

	cb.can_delete     = 
		(Netsnmp_User_Row_Action *)openserSIPStatusCodesTable_can_delete;

	cb.set_reserve1   = openserSIPStatusCodesTable_set_reserve1;
	cb.set_reserve2   = openserSIPStatusCodesTable_set_reserve2;
	
	cb.set_action = openserSIPStatusCodesTable_set_action;
	cb.set_commit = openserSIPStatusCodesTable_set_commit;
	
	cb.set_free = openserSIPStatusCodesTable_set_free;
	cb.set_undo = openserSIPStatusCodesTable_set_undo;
	
	DEBUGMSGTL(("initialize_table_openserSIPStatusCodesTable",
				"Registering table openserSIPStatusCodesTable "
				"as a table array\n"));
	
	netsnmp_table_container_register(my_handler, table_info, &cb,
			cb.container, 1);
}
Esempio n. 7
0
/* General initialization */
void init_custom_queries(void)
{
    netsnmp_table_registration_info *table_info;
    pgsnmpd_query *curquery;
    int i;
    PGresult *res;

    if (custom_query_config_file == NULL) 
        return;

    /*
        ASN_INTEGER = 0
        ASN_FLOAT = 1
        ASN_BOOLEAN = 2
        ASN_OCTET_STR = 3
    */

    res = PQprepare(dbconn, "TYPEQUERY", 
        "SELECT CASE "
            "WHEN typname LIKE 'int%' OR typname = 'xid' OR typname = 'oid'"
                "THEN 0 "
            "WHEN typname LIKE 'float%' THEN 1 "
            "WHEN typname = 'bool' THEN 2 "
            "ELSE 3 "
        "END "
        "FROM pg_catalog.pg_type WHERE oid = $1", 1, NULL);
    if (PQresultStatus(res) != PGRES_COMMAND_OK) {
        snmp_log(LOG_ERR, "Failed to prepare statement (error: %s)\n", PQresStatus(PQresultStatus(res)));
        return;
    }
    PQclear(res);

    head = parse_config(custom_query_config_file);
    if (head == NULL) {
        snmp_log(LOG_INFO, "No custom queries initialized\n");
        return;
    }

    for (curquery = head; curquery != NULL; curquery = curquery->next) {
        run_query(curquery);
        if (curquery->typeslen < curquery->colcount)
            curquery->types = realloc(curquery->types, sizeof(u_char) * curquery->colcount);
        if (curquery->types == NULL) {
            snmp_log(LOG_ERR, "Memory allocation problem");
            return;
        }
        init_types_array(curquery->types, curquery->typeslen, curquery->colcount);
        fill_query_column_types(curquery);
        if (curquery->my_handler) {
            snmp_log(LOG_ERR,
                "init_custom_queries called again for query %s\n",
                curquery->table_name);
            return;
        }

        memset(&(curquery->cb), 0x00, sizeof(curquery->cb));

        /** create the table structure itself */
        snmp_log(LOG_INFO, "Initializing table name %s\n", curquery->table_name);
        table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
        curquery->my_handler = netsnmp_create_handler_registration(
            curquery->table_name,
            netsnmp_table_array_helper_handler,
            curquery->table_oid,
            curquery->oid_len,
            HANDLER_CAN_RONLY
        );

        if (!curquery->my_handler || !table_info) {
            snmp_log(LOG_ERR, "malloc failed in init_custom_queries\n");
            return; /** mallocs failed */
        }

        netsnmp_table_helper_add_index(table_info, ASN_INTEGER); /* pgsnmpdConnID */
        netsnmp_table_helper_add_index(table_info, ASN_INTEGER); /* rdbmsDbIndex */
        for (i = 0; i < curquery->num_indexes; i++)
            netsnmp_table_helper_add_index(table_info, curquery->types[i]);

        table_info->min_column = curquery->min_colnum;
        table_info->max_column = curquery->colcount;

        curquery->cb.get_value = custom_query_get_value;
        curquery->cb.container = netsnmp_container_find("table_container");

        DEBUGMSGTL(("init_custom_queries",
                    "Registering table for query "
                    "as a table array\n"));
        switch (netsnmp_table_container_register(curquery->my_handler,
                    table_info, &curquery->cb,
                    curquery->cb.container, 1)) {
            case MIB_REGISTRATION_FAILED:
                snmp_log(LOG_INFO, "Failed to register table %s\n", curquery->table_name);
                break;
            case MIB_DUPLICATE_REGISTRATION:
                snmp_log(LOG_INFO, "Duplicate registration for table %s\n", curquery->table_name);
                break;
            case MIB_REGISTERED_OK:
                DEBUGMSGTL(("init_custom_queries",
                            "Successfully registered table %s\n", curquery->table_name));
                break;
            default:
                snmp_log(LOG_INFO, "Unknown registration result for table %s\n", curquery->table_name);
        }

        /* Having set everything up, fill the table's container with data */
        fill_query_container(curquery);
    }
    snmp_log(LOG_DEBUG, "Finished intializing queries\n");
}
Esempio n. 8
0
/************************************************************
 *
 * Initialize the memTable table by defining its contents and how it's structured
 */
void
initialize_table_memTable(void)
{
    netsnmp_table_registration_info *table_info;

    if (my_handler) {
        log_print(LOGN_CRI,
                 "initialize_table_memTable_handler called again\n");
        return;
    }

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

    /** create the table structure itself */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_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("memTable",
                                                     netsnmp_table_array_helper_handler,
                                                     memTable_oid,
                                                     memTable_oid_len,
                                                     HANDLER_CAN_RWRITE);

    if (!my_handler || !table_info) {
        log_print(LOGN_CRI, "malloc failed in "
                 "initialize_table_memTable_handler\n");
        return; /** mallocs failed */
    }

    /***************************************************
     * Setting up the table's definition
     */
    /*
     * TODO: add any external indexes here.
     */

    /*
     * internal indexes
     */
        /** index: memIndex */
    netsnmp_table_helper_add_index(table_info, ASN_INTEGER);

    table_info->min_column = memTable_COL_MIN;
    table_info->max_column = memTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
    cb.get_value = memTable_get_value;
    cb.container = netsnmp_container_find("memTable_primary:"
                                          "memTable:" "table_container");
#ifdef memTable_IDX2
    netsnmp_container_add_index(cb.container,
                                netsnmp_container_find
                                ("memTable_secondary:" "memTable:"
                                 "table_container"));
    cb.container->next->compare = memTable_cmp;
#endif
#ifdef memTable_SET_HANDLING
    cb.can_set = 1;
#ifdef memTable_ROW_CREATION
    cb.create_row = (UserRowMethod *) memTable_create_row;
#endif
    cb.duplicate_row = (UserRowMethod *) memTable_duplicate_row;
    cb.delete_row = (UserRowMethod *) memTable_delete_row;
    cb.row_copy = (Netsnmp_User_Row_Operation *) memTable_row_copy;

    cb.can_delete = (Netsnmp_User_Row_Action *) memTable_can_delete;

    cb.set_reserve1 = memTable_set_reserve1;
    cb.set_reserve2 = memTable_set_reserve2;
    cb.set_action = memTable_set_action;
    cb.set_commit = memTable_set_commit;
    cb.set_free = memTable_set_free;
    cb.set_undo = memTable_set_undo;
#endif
    DEBUGMSGTL(("initialize_table_memTable",
                "Registering table memTable " "as a table array\n"));
    netsnmp_table_container_register(my_handler, table_info, &cb,
                                     cb.container, 1);
}
Esempio n. 9
0
/************************************************************
 *
 * Initialize the saHpiRdrTable table by defining its contents and how it's structured
 */
void
initialize_table_saHpiRdrTable (void)
{
  netsnmp_table_registration_info *table_info;

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

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

    /** create the table structure itself */
  table_info = SNMP_MALLOC_TYPEDEF (netsnmp_table_registration_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 ("saHpiRdrTable",
						    netsnmp_table_array_helper_handler,
						    saHpiRdrTable_oid,
						    saHpiRdrTable_oid_len,
						    HANDLER_CAN_RONLY);

  if (!my_handler || !table_info)
    {
      snmp_log (LOG_ERR, "malloc failed in "
		"initialize_table_saHpiRdrTable_handler\n");
      return;	/** mallocs failed */
    }


	/** index: saHpiRdrRecordId */
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
	/** index: saHpiRdrType */
  netsnmp_table_helper_add_index (table_info, ASN_INTEGER);

  table_info->min_column = saHpiRdrTable_COL_MIN;
  table_info->max_column = saHpiRdrTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
  cb.get_value = saHpiRdrTable_get_value;
  cb.container = netsnmp_container_find ("saHpiRdrTable_primary:"
					 "saHpiRdrTable:" "table_container");

  cb.create_row = (UserRowMethod *) saHpiRdrTable_create_row;


  DEBUGMSGTL (("initialize_table_saHpiRdrTable",
	       "Registering table saHpiRdrTable " "as a table array\n"));

  netsnmp_table_container_register (my_handler, table_info, &cb,
				    cb.container, 1);

  netsnmp_register_read_only_counter32_instance ("rdr_count",
						 saHpiRdrCount_oid,
						 OID_LENGTH
						 (saHpiRdrCount_oid),
						 &rdr_count, NULL);

}
Esempio n. 10
0
/*
 * Initialize the kamailioSIPRegUserLookupTable table by defining how it is
 * structured. 
 *
 * This function is mostly auto-generated.
 */
void initialize_table_kamailioSIPRegUserLookupTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_kamailioSIPRegUserLookup"
				"Table_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(
			"kamailioSIPRegUserLookupTable",
			netsnmp_table_array_helper_handler,
			kamailioSIPRegUserLookupTable_oid,
			kamailioSIPRegUserLookupTable_oid_len,
			HANDLER_CAN_RWRITE);
			
	if (!my_handler || !table_info) {
		snmp_log(LOG_ERR, "malloc failed in "
				 "initialize_table_kamailioSIPRegUserLookup"
				 "Table_handler\n");
		return; /** mallocs failed */
	}

	/*
	 * Setting up the table's definition
	 */

	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

	table_info->min_column = kamailioSIPRegUserLookupTable_COL_MIN;
	table_info->max_column = kamailioSIPRegUserLookupTable_COL_MAX;

	/*
	 * registering the table with the master agent
	 */
	cb.get_value = kamailioSIPRegUserLookupTable_get_value;
	cb.container = netsnmp_container_find(
			"kamailioSIPRegUserLookupTable_primary:"
			"kamailioSIPRegUserLookupTable:"
			"table_container");

	cb.can_set = 1;
	cb.create_row    = 
		(UserRowMethod*)kamailioSIPRegUserLookupTable_create_row;
	cb.duplicate_row = 
		(UserRowMethod*)kamailioSIPRegUserLookupTable_duplicate_row;
	cb.delete_row    = 
		(UserRowMethod*)kamailioSIPRegUserLookupTable_delete_row;
	cb.row_copy      = 
		(Netsnmp_User_Row_Operation *)
			kamailioSIPRegUserLookupTable_row_copy;

	cb.can_activate   = (Netsnmp_User_Row_Action *)
		kamailioSIPRegUserLookupTable_can_activate;
	cb.can_deactivate = (Netsnmp_User_Row_Action *)
		kamailioSIPRegUserLookupTable_can_deactivate;
	cb.can_delete     = (Netsnmp_User_Row_Action *)
		kamailioSIPRegUserLookupTable_can_delete;

	cb.set_reserve1 = kamailioSIPRegUserLookupTable_set_reserve1;
	cb.set_reserve2 = kamailioSIPRegUserLookupTable_set_reserve2;
	cb.set_action   = kamailioSIPRegUserLookupTable_set_action;
	cb.set_commit   = kamailioSIPRegUserLookupTable_set_commit;
	cb.set_free     = kamailioSIPRegUserLookupTable_set_free;
	cb.set_undo     = kamailioSIPRegUserLookupTable_set_undo;

	DEBUGMSGTL(("initialize_table_kamailioSIPRegUserLookupTable",
				"Registering table kamailioSIPRegUserLookupTable "
				"as a table array\n"));
	
	netsnmp_table_container_register(my_handler, table_info, &cb, 
			cb.container, 1);
}
Esempio n. 11
0
/************************************************************
 *
 * Initialize the saHpiSensorTable table by defining its contents and how it's structured
 */
void
initialize_table_saHpiSensorTable (void)
{
  netsnmp_table_registration_info *table_info;

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

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

    /** create the table structure itself */
  table_info = SNMP_MALLOC_TYPEDEF (netsnmp_table_registration_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 ("saHpiSensorTable",
						    netsnmp_table_array_helper_handler,
						    saHpiSensorTable_oid,
						    saHpiSensorTable_oid_len,
						    HANDLER_CAN_RWRITE);

  if (!my_handler || !table_info)
    {
      snmp_log (LOG_ERR, "malloc failed in "
		"initialize_table_saHpiSensorTable_handler\n");
      return;	/** mallocs failed */
    }

    /***************************************************
     * Setting up the table's definition
     */

  /*
   * internal indexes
   */
	/** index: saHpiSensorIndex */
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);
  netsnmp_table_helper_add_index (table_info, ASN_UNSIGNED);

  table_info->min_column = saHpiSensorTable_COL_MIN;
  table_info->max_column = saHpiSensorTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
  cb.get_value = saHpiSensorTable_get_value;

  cb.container = netsnmp_container_find ("saHpiSensorTable_primary:"
					 "saHpiSensorTable:"
					 "table_container");



  //    cb.can_set = 1;

  cb.create_row = (UserRowMethod *) saHpiSensorTable_create_row;

  cb.duplicate_row = (UserRowMethod *) saHpiSensorTable_duplicate_row;
  cb.delete_row = (UserRowMethod *) saHpiSensorTable_delete_row;
  cb.row_copy = (Netsnmp_User_Row_Operation *) saHpiSensorTable_row_copy;

  cb.can_delete = (Netsnmp_User_Row_Action *) saHpiSensorTable_can_delete;

  cb.set_reserve1 = saHpiSensorTable_set_reserve1;
  cb.set_reserve2 = saHpiSensorTable_set_reserve2;
  cb.set_action = saHpiSensorTable_set_action;
  cb.set_commit = saHpiSensorTable_set_commit;
  cb.set_free = saHpiSensorTable_set_free;
  cb.set_undo = saHpiSensorTable_set_undo;

  DEBUGMSGTL (("initialize_table_saHpiSensorTable",
	       "Registering table saHpiSensorTable " "as a table array\n"));

  netsnmp_table_container_register (my_handler, table_info, &cb,
				    cb.container, 1);


  netsnmp_register_read_only_counter32_instance ("sensor_count",
						 saHpiSensorCount_oid,
						 OID_LENGTH
						 (saHpiSensorCount_oid),
						 &sensor_count, NULL);
}