RE: How to delete/add line from raw table?

"Naama Bar Menachem" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi Dave

There is no double-free problem. The free is only called once and
crashes on the first time.
However, there is something I don't understand. As I said the data is
not stored locally on the agent, but on kernel. When the device is
loaded, there is always 5 rows in the table. Where those 5 rows are
allocated and stored in the local agent table?

In addition, I added a new row, and immediately destroyed it. I printed
the address the entry is pointing to, and it seems that in
"create_entry" the allocated entry is pointing to "0x1201f6160", while
on "remove_entry" it is pointing to "0x555aa6dc98". 

I am attaching the C file again.

Thank you,
Naama



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Dave Shield
Sent: Tuesday, July 31, 2012 12:20 AM
To: Naama Bar Menachem
Cc: [email protected]
Subject: Re: How to delete/add line from raw table?

On 30 July 2012 17:18, Naama Bar Menachem
<[email protected]> wrote:
> I track "entry"'s address and it seems fine (entry=0x555826b818). Not 
> NULL at no stage.
> On the other hand- when I remove the call for SNMP_FREE it does not 
> crash.

That sounds more like a double-free problem.

Dave

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
nsCommonConfigDataForwardPolicyRoute.c (application/octet-stream, 24.1 KB)
	/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.raw-table.conf 17436 2009-03-31 15:12:19Z dts12 $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "nsCommonConfigDataForwardPolicyRoute.h"
#include "ns_mibs.h"
#include "ns_logger.h"
#include "ns_db_tables.h"
#include "ns_db_utils.h"
#include "ns_ipc_client.h"
#include "ns_types.h"
#include "ns_errors_utils.h"
#include "ns_mibs_common_convert_db_mibs.h"


/*
 * column number definitions for table nsCommonConfigDataForwardPolicyRouteTable
 */
#define COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINDEX				1
#define COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID		2
#define COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEROUTINGTABLEID		3
#define COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS		4

    /*
     * Typical data structure for a row entry 
     */
struct nsCommonConfigDataForwardPolicyRouteTable_entry {
    /*
     * Index values 
     */
    u_long          nsCommonConfigDataForwardPolicyRouteIndex;

    /*
     * Column values 
     */
    u_long          nsCommonConfigDataForwardPolicyRouteInputInterfaceId;
    u_long          old_nsCommonConfigDataForwardPolicyRouteInputInterfaceId;
    u_long          nsCommonConfigDataForwardPolicyRouteRoutingTableId;
    u_long          old_nsCommonConfigDataForwardPolicyRouteRoutingTableId;
    long            nsCommonConfigDataForwardPolicyRouteNotifyRowStatus;

    int             valid;
};


struct nsCommonConfigDataForwardPolicyRouteTable_entry DataForwardPolicyRoute_entry;

/*
 * create a new row in the table 
 */
static struct nsCommonConfigDataForwardPolicyRouteTable_entry *
nsCommonConfigDataForwardPolicyRouteTable_createEntry(int dummy,
                                                      u_long
                                                      nsCommonConfigDataForwardPolicyRouteIndex)
{
	struct nsCommonConfigDataForwardPolicyRouteTable_entry *entry;
	uint8_t	key_uint8;
	int		ret=0;

    entry =
        SNMP_MALLOC_TYPEDEF(struct
                            nsCommonConfigDataForwardPolicyRouteTable_entry);
    if (!entry)
        return NULL;

    key_uint8 = (uint8_t)nsCommonConfigDataForwardPolicyRouteIndex;
    //
    //nbm-table: need to use ns-hal-data function that receives also the index
    //           ns_db_util_add_table_row_with_user_index(...,...)
    //
    //ret = ns_db_util_add_table_row_with_user_index(NS_DB_TBL_ID_POLICY_ROUTING, &key_uint8);
    //
    //
    //ret = ns_db_util_add_table_row(NS_DB_TBL_ID_POLICY_ROUTING);
    ret = ns_db_util_add_table_row_with_user_index(NS_DB_TBL_ID_POLICY_ROUTING, &key_uint8);

    if (ret) {
    	NS_SYSLOG_SNMP(LOG_ALERT, "Failed to add new record. (%d)", ret);
    	return NULL;
    }

    return entry;
}

/*
 * remove a row from the table 
 */
static void
nsCommonConfigDataForwardPolicyRouteTable_removeEntry(struct
                                                      nsCommonConfigDataForwardPolicyRouteTable_entry
                                                      *entry)
{
	uint8_t	key_uint8;
	int		ret=0;

    if (!entry)
        return;                 /* Nothing to remove */

    /*
     * XXX - remove entry from local data structure 
     */
    key_uint8 = (uint8_t) (entry->nsCommonConfigDataForwardPolicyRouteIndex);
    ret = ns_db_util_delete_table_row(NS_DB_TBL_ID_POLICY_ROUTING, &key_uint8);

    if (ret) {
    	NS_SYSLOG_SNMP(LOG_ALERT, "Failed to delete record. (%d)", ret);
    } else {
    	if (entry) {
    		SNMP_FREE(entry);       /* XXX - release any other internal resources */
    	}
    }
}


/** determine the appropriate row for an exact request */
static struct nsCommonConfigDataForwardPolicyRouteTable_entry *
nsCommonConfigDataForwardPolicyRouteTable_get_entry(netsnmp_variable_list *
                                                    indexes)
{
	struct nsCommonConfigDataForwardPolicyRouteTable_entry *row = NULL;
    netsnmp_variable_list 								 *idx = indexes;
    ns_db_policy_routing_tbl_record_t					 *tbl_record_pointer;
    uint8_t											 	 *key_pointer;

	tbl_record_pointer = (ns_db_policy_routing_tbl_record_t *) ns_ipcc_mem_alloc(sizeof(ns_db_policy_routing_tbl_record_t));
	key_pointer = (uint8_t *) ns_ipcc_mem_alloc(sizeof(uint8_t));

	if ((!key_pointer) || (!tbl_record_pointer)) {
		ns_ipcc_mem_free();
		return NULL;
	}

	*key_pointer = (uint8_t)(*(idx->val.integer));

    /*
     * XXX - Use the 'indexes' parameter to retrieve the data
     * structure for the requested row, and return this.
     */
	if (!ns_db_tbl_get_record(NS_DB_TBL_ID_POLICY_ROUTING, key_pointer, tbl_record_pointer)) {
		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteIndex = tbl_record_pointer->index;
		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteInputInterfaceId = tbl_record_pointer->input_interface;
		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteRoutingTableId = tbl_record_pointer->set_table_id;

		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteNotifyRowStatus = 1;

		/* get row */
		row = &DataForwardPolicyRoute_entry;
	}

	ns_ipcc_mem_free();
    return row;
}

/** determine the appropriate row for an fuzzy request */
static struct nsCommonConfigDataForwardPolicyRouteTable_entry *
nsCommonConfigDataForwardPolicyRouteTable_get_next_entry
    (netsnmp_handler_registration *reginfo, netsnmp_request_info *request,
     int column, netsnmp_variable_list * indexes)
{
    struct nsCommonConfigDataForwardPolicyRouteTable_entry *row = NULL;
    oid             build_space[MAX_OID_LEN];
    size_t          build_space_len = 0;
    size_t          index_oid_len = 0;
    netsnmp_variable_list 								 *idx = indexes;
    ns_db_policy_routing_tbl_record_t					 *tbl_record_pointer;
    uint8_t											 	 *key_pointer;
    int													  ret=0;
    bool 												  is_writable;
    bool 												  is_visible;

	tbl_record_pointer = (ns_db_policy_routing_tbl_record_t *) ns_ipcc_mem_alloc(sizeof(ns_db_policy_routing_tbl_record_t));
	key_pointer = (uint8_t *) ns_ipcc_mem_alloc(sizeof(uint8_t));

	if ((!key_pointer) || (!tbl_record_pointer)) {
		ns_ipcc_mem_free();
		return NULL;
	}
	*key_pointer = (uint8_t)(*(idx->val.integer));

    /*
     * XXX - Use the 'indexes' parameter to identify the
     * next row in the table.... 
     */

	if (!ns_db_tbl_get_next_record(NS_DB_TBL_ID_POLICY_ROUTING, key_pointer, tbl_record_pointer)) {
		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteIndex = tbl_record_pointer->index;
		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteInputInterfaceId = tbl_record_pointer->input_interface;
		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteRoutingTableId = tbl_record_pointer->set_table_id;

		DataForwardPolicyRoute_entry.nsCommonConfigDataForwardPolicyRouteNotifyRowStatus = 1;

		/* get row */
		row = &DataForwardPolicyRoute_entry;

	    /*
	     * XXX   .... update the 'indexes' parameter with the
	     * appropriate index values ...
	     */
		*(idx->val.integer) = *key_pointer;

	    /*
	     * ... and update the requested OID to match this instance
	     */
	    memcpy(build_space, reginfo->rootoid,       /* registered oid */
	           reginfo->rootoid_len * sizeof(oid));
	    build_space_len = reginfo->rootoid_len;
	    build_space[build_space_len++] = 1; /* entry */
	    build_space[build_space_len++] = column;    /* column */
	    build_oid_noalloc(build_space + build_space_len,
	                      MAX_OID_LEN - build_space_len, &index_oid_len,
	                      NULL, 0, indexes);
	    snmp_set_var_objid(request->requestvb, build_space,
	                       build_space_len + index_oid_len);
	}

    /*
     * Finally, return the data structure for this row 
     */
	ns_ipcc_mem_free();
    return row;
}


/** handles requests for the nsCommonConfigDataForwardPolicyRouteTable table */
static int
nsCommonConfigDataForwardPolicyRouteTable_handler(netsnmp_mib_handler
                                                  *handler,
                                                  netsnmp_handler_registration
                                                  *reginfo,
                                                  netsnmp_agent_request_info
                                                  *reqinfo,
                                                  netsnmp_request_info
                                                  *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    struct nsCommonConfigDataForwardPolicyRouteTable_entry *table_entry;
    int             ret;
    uint8_t			key_uint8;
    uint8_t			val_uint8;
    uint32_t		val_uint32;

    switch (reqinfo->mode) {
        /*
         * Read-support
         */
    case MODE_GET:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            table_entry =
                nsCommonConfigDataForwardPolicyRouteTable_get_entry
                (table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID:
                if (!table_entry)
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb,
                                           ASN_UNSIGNED,
                                           table_entry->
                                           nsCommonConfigDataForwardPolicyRouteInputInterfaceId);
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEROUTINGTABLEID:
                if (!table_entry)
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb,
                                           ASN_UNSIGNED,
                                           table_entry->
                                           nsCommonConfigDataForwardPolicyRouteRoutingTableId);
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
                if (!table_entry)
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->
                                           nsCommonConfigDataForwardPolicyRouteNotifyRowStatus);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;

    case MODE_GETNEXT:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            table_entry =
                nsCommonConfigDataForwardPolicyRouteTable_get_next_entry
                (reginfo, request, table_info->colnum,
                 table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID:
                if (!table_entry)
                {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ENDOFMIBVIEW);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb,
                                           ASN_UNSIGNED,
                                           table_entry->
                                           nsCommonConfigDataForwardPolicyRouteInputInterfaceId);
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEROUTINGTABLEID:
                if (!table_entry)
                {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ENDOFMIBVIEW);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb,
                                           ASN_UNSIGNED,
                                           table_entry->
                                           nsCommonConfigDataForwardPolicyRouteRoutingTableId);
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
                if (!table_entry)
                {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ENDOFMIBVIEW);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           table_entry->
                                           nsCommonConfigDataForwardPolicyRouteNotifyRowStatus);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request, SNMP_ENDOFMIBVIEW);
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
        	table_info = netsnmp_extract_table_info(request);
        	table_entry = nsCommonConfigDataForwardPolicyRouteTable_get_entry(table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID:
                /*
                 * or possibly 'netsnmp_check_vb_int_range' 
                 */
                ret =
                    netsnmp_check_vb_uint(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEROUTINGTABLEID:
                /*
                 * or possibly 'netsnmp_check_vb_int_range' 
                 */
                ret =
                    netsnmp_check_vb_uint(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
            	ret = netsnmp_check_vb_rowstatus(request->requestvb,
                                                 (table_entry ? RS_ACTIVE :
                                                  RS_NONEXISTENT));
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
            	netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            //nbm: table_entry = nsCommonConfigDataForwardPolicyRouteTable_get_entry(table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
                switch (*request->requestvb->val.
                        integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    table_entry =
                        nsCommonConfigDataForwardPolicyRouteTable_createEntry
                        (0, *table_info->indexes->val.integer);
                    if (!table_entry) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_RESOURCEUNAVAILABLE);
                        return SNMP_ERR_NOERROR;
                    }
                }
            }
        }
        break;

    case MODE_SET_FREE:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            table_entry =
                nsCommonConfigDataForwardPolicyRouteTable_get_entry
                (table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
                switch (*request->requestvb->val.
                        integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    if (table_entry && !table_entry->valid) {
                        nsCommonConfigDataForwardPolicyRouteTable_removeEntry
                            (table_entry);
                    }
                }
            }
        }
        break;

    case MODE_SET_ACTION:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            table_entry =
                nsCommonConfigDataForwardPolicyRouteTable_get_entry
                (table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID:
            	key_uint8  = (uint32_t)(table_entry->nsCommonConfigDataForwardPolicyRouteIndex);
				val_uint32 = (uint32_t)(*(request->requestvb->val.integer));

				ret = ns_db_util_set_table(	NS_DB_TBL_ID_POLICY_ROUTING,
											NS_DB_POLICY_ROUTING_TBL_FLD_INPUT_INTERFACE,
											&key_uint8,
											&val_uint32);
				if (ret) {
					if (ret==ns_err_get_err_num_by_id(NS_ERR_DB_VALUE_NOT_ALLOWED)) {
						netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_BADVALUE);
					} else if (ret==ns_err_get_err_num_by_id(NS_ERR_DB_FIELD_READ_ONLY)) {
						netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_READONLY);
					} else {
						netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_GENERR);
					}
				} else {
					//update snmp table value
					table_entry->old_nsCommonConfigDataForwardPolicyRouteInputInterfaceId =
						table_entry->nsCommonConfigDataForwardPolicyRouteInputInterfaceId;
					table_entry->nsCommonConfigDataForwardPolicyRouteInputInterfaceId =
						*request->requestvb->val.integer;
				}
				break;

            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEROUTINGTABLEID:
				key_uint8 = (uint32_t)(table_entry->nsCommonConfigDataForwardPolicyRouteIndex);
				val_uint8 = (uint8_t)(*(request->requestvb->val.integer));

				ret = ns_db_util_set_table(	NS_DB_TBL_ID_POLICY_ROUTING,
											NS_DB_POLICY_ROUTING_TBL_FLD_SET_TABLE_ID,
											&key_uint8,
											&val_uint8);
				if (ret) {
					if (ret==ns_err_get_err_num_by_id(NS_ERR_DB_VALUE_NOT_ALLOWED)) {
						netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_BADVALUE);
					} else if (ret==ns_err_get_err_num_by_id(NS_ERR_DB_FIELD_READ_ONLY)) {
						netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_READONLY);
					} else {
						netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_GENERR);
					}
				} else {
					//update snmp table value
					table_entry->old_nsCommonConfigDataForwardPolicyRouteRoutingTableId =
						table_entry->nsCommonConfigDataForwardPolicyRouteRoutingTableId;
					table_entry->nsCommonConfigDataForwardPolicyRouteRoutingTableId =
						*request->requestvb->val.integer;
				}
				break;

            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
                switch (*request->requestvb->val.
                        integer) {
                case RS_ACTIVE:
                case RS_CREATEANDGO:
                	break;
                }
                break;
            }
        }
        break;

    case MODE_SET_UNDO:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            table_entry =
                nsCommonConfigDataForwardPolicyRouteTable_get_entry
                (table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID:
                table_entry->nsCommonConfigDataForwardPolicyRouteInputInterfaceId =
                    table_entry->old_nsCommonConfigDataForwardPolicyRouteInputInterfaceId;
                table_entry->old_nsCommonConfigDataForwardPolicyRouteInputInterfaceId = 0;
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEROUTINGTABLEID:
                table_entry->nsCommonConfigDataForwardPolicyRouteRoutingTableId =
                    table_entry->old_nsCommonConfigDataForwardPolicyRouteRoutingTableId;
                table_entry->old_nsCommonConfigDataForwardPolicyRouteRoutingTableId = 0;
                break;
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
                switch (*request->requestvb->val.
                        integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    if (table_entry && !table_entry->valid) {
                        nsCommonConfigDataForwardPolicyRouteTable_removeEntry
                            (table_entry);
                    }
                }
                break;
            }
        }
        break;

    case MODE_SET_COMMIT:
    	for (request = requests; request; request = request->next) {
            table_info = netsnmp_extract_table_info(request);
            table_entry =
                nsCommonConfigDataForwardPolicyRouteTable_get_entry
                (table_info->indexes);

            switch (table_info->colnum) {
            case COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS:
            	switch (*request->requestvb->val.
                        integer) {
                case RS_CREATEANDGO:
                	table_entry->valid = 1;
                    /*
                     * Fall-through 
                     */
                case RS_ACTIVE:
                	table_entry->
                        nsCommonConfigDataForwardPolicyRouteNotifyRowStatus
                        = RS_ACTIVE;
                    break;

                case RS_CREATEANDWAIT:
                	table_entry->valid = 1;
                    /*
                     * Fall-through 
                     */
                case RS_NOTINSERVICE:
                	table_entry->
                        nsCommonConfigDataForwardPolicyRouteNotifyRowStatus
                        = RS_NOTINSERVICE;
                    break;

                case RS_DESTROY:
                	nsCommonConfigDataForwardPolicyRouteTable_removeEntry
                        (table_entry);
                }
            }
        }
        break;
    }
    return SNMP_ERR_NOERROR;
}

/** Initialize the nsCommonConfigDataForwardPolicyRouteTable table by defining its contents and how it's structured */
static void
initialize_table_nsCommonConfigDataForwardPolicyRouteTable(void)
{
    const oid       nsCommonConfigDataForwardPolicyRouteTable_oid[] =
        { 1, 3, 6, 1, 4, 1, 37576, 2, 1, 7, 4, 1, 1 };
    netsnmp_handler_registration *reg;
    netsnmp_table_registration_info *table_info;

    reg =
        netsnmp_create_handler_registration
        ("nsCommonConfigDataForwardPolicyRouteTable",
         nsCommonConfigDataForwardPolicyRouteTable_handler,
         nsCommonConfigDataForwardPolicyRouteTable_oid,
         OID_LENGTH(nsCommonConfigDataForwardPolicyRouteTable_oid),
         HANDLER_CAN_RWRITE);

    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    netsnmp_table_helper_add_indexes(table_info, ASN_UNSIGNED,  /* index: nsCommonConfigDataForwardPolicyRouteIndex */
                                     0);

    table_info->min_column =
        COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTEINPUTINTERFACEID;
    table_info->max_column =
        COLUMN_NSCOMMONCONFIGDATAFORWARDPOLICYROUTENOTIFYROWSTATUS;

    netsnmp_register_table(reg, table_info);

    /*
     * Initialise the contents of the table here 
     */
}

/** Initializes the nsCommonConfigDataForwardPolicyRoute module */
void
init_nsCommonConfigDataForwardPolicyRoute(void)
{
    /*
     * here we initialize all the tables we're planning on supporting 
     */
    initialize_table_nsCommonConfigDataForwardPolicyRouteTable();
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.