/************************************************************
 *
 *  Initialize the alarmModelTable table by defining its contents
 *  and how it's structured
 */
int initialize_table_alarmModelTable(void)
{
  netsnmp_table_registration_info *table_info;

  if (my_handler)
  {
    // LCOV_EXCL_START
    TRC_ERROR("initialize_table_alarmModelTable called again");
    return SNMP_ERR_NOERROR;
    // LCOV_EXCL_STOP
  }

  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("alarmModelTable",
                                                   netsnmp_table_array_helper_handler,
                                                   alarmModelTable_oid,
                                                   alarmModelTable_oid_len,
                                                   HANDLER_CAN_RONLY);
            
  if (!my_handler || !table_info)
  {
    // LCOV_EXCL_START
    TRC_ERROR("malloc failed: initialize_table_alarmModelTable");
    return SNMP_ERR_GENERR;
    // LCOV_EXCL_STOP
  }

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

  /** index: alarmListName */
  netsnmp_table_helper_add_index(table_info, ASN_OCTET_STR);
  /** index: alarmModelIndex */
  netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
  /** index: alarmModelState */
  netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

  table_info->min_column = alarmModelTable_COL_MIN;
  table_info->max_column = alarmModelTable_COL_MAX;

  /*
   * registering the table with the master agent
   */
  cb.get_value = alarmModelTable_get_value;
  cb.container = netsnmp_container_find("alarmModelTable_primary:"
                                        "alarmModelTable:"
                                        "table_container");
  cb.can_set = 0;

  DEBUGMSGTL(("initialize_table_alarmModelTable", "Registering as table array\n"));

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

  return SNMP_ERR_NOERROR;
}
Example #2
0
int
netsnmp_table_array_register (netsnmp_handler_registration * reginfo,
                              netsnmp_table_registration_info * tabreg,
                              netsnmp_table_array_callbacks * cb, netsnmp_container * container, int group_rows)
{
    netsnmp_inject_handler (reginfo, netsnmp_create_handler (reginfo->handlerName, netsnmp_table_array_helper_handler));
    return netsnmp_table_container_register (reginfo, tabreg, cb, container, group_rows);
}
/************************************************************
 *
 * Initialize the radiusAccClientExtTable table by defining its contents and how it's structured
 */
void
initialize_table_radiusAccClientExtTable(void)
{
    netsnmp_table_registration_info *table_info;

    if (my_handler) {
        snmp_log(LOG_ERR,
                 "initialize_table_radiusAccClientExtTable_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("radiusAccClientExtTable",
                                            netsnmp_table_array_helper_handler,
                                            radiusAccClientExtTable_oid,
                                            radiusAccClientExtTable_oid_len,
                                            HANDLER_CAN_RONLY);

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

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

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

    table_info->min_column = radiusAccClientExtTable_COL_MIN;
    table_info->max_column = radiusAccClientExtTable_COL_MAX;

    /***************************************************
     * registering the table with the master agent
     */
    cb.get_value = radiusAccClientExtTable_get_value;
    cb.container =
        netsnmp_container_find("radiusAccClientExtTable_primary:"
                               "radiusAccClientExtTable:"
                               "table_container");
    DEBUGMSGTL(("initialize_table_radiusAccClientExtTable",
                "Registering table radiusAccClientExtTable "
                "as a table array\n"));
    netsnmp_table_container_register(my_handler, table_info, &cb,
                                     cb.container, 1);
}
/* Initialize the openserSIPMethodSupportedTable by defining its structure and
 * callback mechanisms */
void initialize_table_openserSIPMethodSupportedTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_openserSIPMethodSupported"
				"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(
			"openserSIPMethodSupportedTable",
			netsnmp_table_array_helper_handler,
			openserSIPMethodSupportedTable_oid,
			openserSIPMethodSupportedTable_oid_len,
			HANDLER_CAN_RONLY);

	if (!my_handler || !table_info) {
		snmp_log(LOG_ERR, "malloc failed in initialize_table_openser"
				"SIPMethodSupportedTable_handler\n");
		if (table_info)
			SNMP_FREE(table_info);
		return;
	}

	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

	table_info->min_column = openserSIPMethodSupportedTable_COL_MIN;
	table_info->max_column = openserSIPMethodSupportedTable_COL_MAX;

	/***************************************************
	 * registering the table with the master agent
	 */
	cb.get_value = openserSIPMethodSupportedTable_get_value;
	cb.container =
		netsnmp_container_find("openserSIPMethodSupportedTable_primary:"
			"openserSIPMethodSupportedTable:" "table_container");

	DEBUGMSGTL(("initialize_table_openserSIPMethodSupportedTable",
				"Registering table openserSIPMethodSupportedTable"
				"as a table array\n"));

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

}
Example #5
0
/*
 * Initialize the kamailioSIPRegUserTable table by defining its contents and how
 * it's structured
 */
void initialize_table_kamailioSIPRegUserTable(void)
{
	netsnmp_table_registration_info *table_info;

	if(my_handler) {
		snmp_log(LOG_ERR, "initialize_table_kamailioSIPRegUserTable_hand"
				"ler 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(
			"kamailioSIPRegUserTable",
			netsnmp_table_array_helper_handler, 
			kamailioSIPRegUserTable_oid,
			kamailioSIPRegUserTable_oid_len,
			HANDLER_CAN_RONLY);

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

	netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);

	table_info->min_column = kamailioSIPRegUserTable_COL_MIN;
	table_info->max_column = kamailioSIPRegUserTable_COL_MAX;

	cb.get_value = kamailioSIPRegUserTable_get_value;
	cb.container = netsnmp_container_find("kamailioSIPRegUserTable_primary:"
			"kamailioSIPRegUserTable:" "table_container");

	DEBUGMSGTL(("initialize_table_kamailioSIPRegUserTable",
				"Registering table kamailioSIPRegUserTable "
				"as a table array\n"));

	netsnmp_table_container_register(my_handler, table_info, &cb, 
			cb.container, 1);
}
/************************************************************
 *
 * 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);
}
Example #8
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");
}
Example #9
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);
}
Example #10
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);

}
/*
 * 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);
}
Example #12
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);
}