RE: how to enable the encryption at time of installation

"Kumar Sanjay-XJD784" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Thanks Dave it works 

I have another issue 
For the reference I have attached the file(dot-c and dot-h)

When I run snmp on linux machine(Debian)
And do the snmpset it works properly:
/home/symbol/Sanjay/net-snmp-5.5/apps/snmpset -c private -v 2c
127.0.0.1:8161 ccAuditLogRowStatus.\"symbol\".81.2.33.21  i  4
Walk Result:
SYMBOL-CC-WS2000-MIB::ccAuditLogsnmpv3UserName."symbol".81.2.33.21 =
STRING: "symbol"
SYMBOL-CC-WS2000-MIB::ccAuditLogsnmpClientIpAddr."symbol".81.2.33.21 =
IpAddress: 81.2.33.21
SYMBOL-CC-WS2000-MIB::ccAuditLogRowStatus."symbol".81.2.33.21 = INTEGER:
1

Logs:
RESERVE2  -> ASN type 4 indxnum:2
RESERVE2  -> ASN type 64 indxnum:2
RESERVE2 -> IPAddr:51022115
Create Entry -> IPAddr:51022115
SET_ACTION -> Fun:ccAuditLoggingCfgTable_handler Line:486 colnum:3
COMMIT -> UserName:symbol
COMMIT -> Create and Go:
MODE_GET -> UserName:symbol **
MODE_GET -> Ip addr:51022115 **
MODE_GET -> row status:1 **


======>>>>>>
But I run the same code on MIPS platefom the 2nd index(ip Address) is
setting to "0.0.0.0"
Set command:

/home/symbol/net-snmp-5.5/apps/snmpset -v 3 -u symbol -l authPriv -a MD5
-A symbol11 -x DES -X symbol11 192.168.1.50
ccAuditLogRowStatus.\"symbol\".81.2.33.21  i  4

Snmpwalk Result:
SYMBOL-CC-WS2000-MIB::ccAuditLogsnmpv3UserName."symbol".0.0.0.0 =
STRING: "symbol"
SYMBOL-CC-WS2000-MIB::ccAuditLogsnmpClientIpAddr."symbol".0.0.0.0 =
IpAddress: 0.0.0.0
SYMBOL-CC-WS2000-MIB::ccAuditLogRowStatus."symbol".0.0.0.0 = INTEGER: 1

user.err snmpd: RESERVE2  ->IP address field vb_integer:6
Jan 14 07:21:11 (none) user.err snmpd: RESERVE2  -> ASN type 4 indxnum:2
Jan 14 07:21:11 (none) user.err snmpd: RESERVE2 **** string symbol len:6
Jan 14 07:21:11 (none) user.err snmpd: RESERVE2  ->IP address field
vb_integer:0
Jan 14 07:21:11 (none) user.err snmpd: RESERVE2  -> ASN type 64
indxnum:2
Jan 14 07:21:11 (none) user.err snmpd: RESERVE2  -> vb_integer:0 len:4
Jan 14 07:21:11 (none) user.err snmpd: RESERVE2 -> IPAddr:0
Jan 14 07:21:11 (none) user.err snmpd: Create Entry -> IPAddr:0
Jan eth0: topology change detected, propagating
14 07:21:11 (none) user.err snmpd: SET_ACTION -> Fun:ccAuditLoggeth0:
port 1(ate
ingCfgTable_
Jan 14 07:21:11 (none) user.err snmpd: COMMIT -> UserName:symbol
Jan 14 07:21:11 (none) user.err snmpd: COMMIT -> Create and Go:
Jan 14 07:21:11 (none) user.err snmpd: Audit Log: IPAddr: 192.168.1.40

Observation:
Basically variable binding for IP Addree is getting zero(0.0.0.0)
But I am getting current "ASN type 64"

Any Help :)

Thanks,
Sanjay


-----Original Message-----
From: Dave Shield [mailto:[email protected]] 
Sent: Tuesday, January 25, 2011 9:48 PM
To: Kumar Sanjay-XJD784
Cc: [email protected]
Subject: Re: how to enable the encryption at time of installation

On 25 January 2011 15:41, Kumar Sanjay-XJD784
<[email protected]> wrote:
> I am able to configure with openssl but as you pointed I am getting
following error:
>
> me/symbol/net-snmp-5.5/sanjay/lib
> ../../snmplib/.libs/libnetsnmp.so: undefined reference to `dlsym'
> ../../snmplib/.libs/libnetsnmp.so: undefined reference to `dlerror'
> ../../snmplib/.libs/libnetsnmp.so: undefined reference to `dladdr'
> ../../snmplib/.libs/libnetsnmp.so: undefined reference to `dlopen'
> ../../snmplib/.libs/libnetsnmp.so: undefined reference to `dlclose'


OK - add '--with-libs=-ldl' to the configure command.

Dave

------------------------------------------------------------------------
------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better
price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires February
28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
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

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d

_______________________________________________
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
ccAuditLoggingCfgTable.h (application/octet-stream, 759 B)
/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.iterate.conf 17695 2009-07-21 12:22:18Z dts12 $
 */
#ifndef CCAUDITLOGGINGCFGTABLE_H
#define CCAUDITLOGGINGCFGTABLE_H

/* function declarations */
void init_ccAuditLoggingCfgTable(void);
void initialize_table_ccAuditLoggingCfgTable(void);
Netsnmp_Node_Handler ccAuditLoggingCfgTable_handler;
Netsnmp_First_Data_Point  ccAuditLoggingCfgTable_get_first_data_point;
Netsnmp_Next_Data_Point   ccAuditLoggingCfgTable_get_next_data_point;

/* column number definitions for table ccAuditLoggingCfgTable */
       #define COLUMN_CCAUDITLOGSNMPV3USERNAME		1
       #define COLUMN_CCAUDITLOGSNMPCLIENTIPADDR		2
       #define COLUMN_CCAUDITLOGROWSTATUS		3
#endif /* CCAUDITLOGGINGCFGTABLE_H */
ccAuditLoggingCfgTable.c (application/octet-stream, 24.1 KB)
/*
 * Note: this file originally auto-generated by mib2c using
 *  : mib2c.iterate.conf 17695 2009-07-21 12:22:18Z 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 "ccAuditLoggingCfgTable.h"

/* Data structure for a row entry */
struct ccAuditLoggingCfgTable_entry {
    /* Index values */
    char ccAuditLogsnmpv3UserName[255];
    size_t ccAuditLogsnmpv3UserName_len;
    in_addr_t ccAuditLogsnmpClientIpAddr;

    char old_ccAuditLogsnmpv3UserName[255];
    size_t old_ccAuditLogsnmpv3UserName_len;
    in_addr_t old_ccAuditLogsnmpClientIpAddr;
    
    /* Column values */
    long ccAuditLogRowStatus;

    /* Illustrate using a simple linked list */
    int   valid;
    struct ccAuditLoggingCfgTable_entry *next;
};

struct ccAuditLoggingCfgTable_entry  *ccAuditLoggingCfgTable_head = NULL;

/*
 *  This Function will create a new row in Audit Log table
 */
struct ccAuditLoggingCfgTable_entry *
ccAuditLoggingCfgTable_createEntry(
                 char* ccAuditLogsnmpv3UserName,
                 size_t ccAuditLogsnmpv3UserName_len,
                 in_addr_t  ccAuditLogsnmpClientIpAddr);

/*
 * This Function will set the value in get data structure
 */
int
snmp_set_var_typed_integer(netsnmp_variable_list * newvar,
		u_char type, long val)
{
	newvar->type = type;
	return snmp_set_var_value(newvar, &val, sizeof(long));
}

/*
 * Inserts table_iterator specific data for a newly
 * created row into a request 
 */
#if 1
NETSNMP_INLINE void
netsnmp_insert_iterator_context(netsnmp_request_info *request, void *data)
{
    netsnmp_request_info       *req;
    netsnmp_table_request_info *table_info = NULL;
    netsnmp_variable_list      *this_index = NULL;
    netsnmp_variable_list      *that_index = NULL;
    oid      base_oid[] = {0, 0};	/* Make sure index OIDs are legal! */
    oid      this_oid[MAX_OID_LEN];
    oid      that_oid[MAX_OID_LEN];
    size_t   this_oid_len, that_oid_len;

    if (!request)
        return;

    /*
     * We'll add the new row information to any request
     * structure with the same index values as the request
     * passed in (which includes that one!).
     *
     * So construct an OID based on these index values.
     */

    table_info = netsnmp_extract_table_info(request);
    this_index = table_info->indexes;
    build_oid_noalloc(this_oid, MAX_OID_LEN, &this_oid_len,
                      base_oid, 2, this_index);

    /*
     * We need to look through the whole of the request list
     * (as received by the current handler), as there's no
     * guarantee that this routine will be called by the first
     * varbind that refers to this row.
     *   In particular, a RowStatus controlled row creation
     * may easily occur later in the variable list.
     *
     * So first, we rewind to the head of the list....
     */
    for (req=request; req->prev; req=req->prev)
        ;

    /*
     * ... and then start looking for matching indexes
     * (by constructing OIDs from these index values)
     */
    for (; req; req=req->next) {
        table_info = netsnmp_extract_table_info(req);
        that_index = table_info->indexes;
        build_oid_noalloc(that_oid, MAX_OID_LEN, &that_oid_len,
                          base_oid, 2, that_index);
      
        /*
         * This request has the same index values,
         * so add the newly-created row information.
         */
        if (snmp_oid_compare(this_oid, this_oid_len,
                             that_oid, that_oid_len) == 0) {
            netsnmp_request_add_list_data(req,
                netsnmp_create_data_list(TABLE_ITERATOR_NAME, data, NULL));
        }
    }
}
#endif

/** Initializes the ccAuditLoggingCfgTable module */
void
init_ccAuditLoggingCfgTable(void)
{
  /* here we initialize all the tables we're planning on supporting */
    initialize_table_ccAuditLoggingCfgTable();
}


/** Initialize the ccAuditLoggingCfgTable table by defining its contents and how it's structured */
void
initialize_table_ccAuditLoggingCfgTable(void)
{
    const oid ccAuditLoggingCfgTable_oid[] = {1,3,6,1,4,1,388,11,2,2,11,10};
    const size_t ccAuditLoggingCfgTable_oid_len   = OID_LENGTH(ccAuditLoggingCfgTable_oid);
    netsnmp_handler_registration    *reg;
    netsnmp_iterator_info           *iinfo;
    netsnmp_table_registration_info *table_info;

    //struct ccAuditLoggingCfgTable_entry *entry = NULL;

    DEBUGMSGTL(("ccAuditLoggingCfgTable:init", "initializing table ccAuditLoggingCfgTable\n"));

    reg = netsnmp_create_handler_registration("ccAuditLoggingCfgTable",     
		    			      ccAuditLoggingCfgTable_handler,  
				  	      ccAuditLoggingCfgTable_oid, 
					      ccAuditLoggingCfgTable_oid_len,
				              HANDLER_CAN_RWRITE);

    table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
    netsnmp_table_helper_add_indexes(table_info,
                           ASN_OCTET_STR,  /* index: ccAuditLogsnmpv3UserName */
                           ASN_IPADDRESS,  /* index: ccAuditLogsnmpClientIpAddr */
                           0);
    table_info->min_column = COLUMN_CCAUDITLOGSNMPV3USERNAME;
    table_info->max_column = COLUMN_CCAUDITLOGROWSTATUS;
    
    iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
    iinfo->get_first_data_point = ccAuditLoggingCfgTable_get_first_data_point;
    iinfo->get_next_data_point  = ccAuditLoggingCfgTable_get_next_data_point;
    iinfo->table_reginfo        = table_info;
    
    netsnmp_register_table_iterator( reg, iinfo );

    /* Initialise the contents of the table here */
#if 0
    entry = ccAuditLoggingCfgTable_createEntry("sanjay", 6, 1111); 
    entry->ccAuditLogRowStatus = RS_CREATEANDGO;
    entry->valid = 1;
#endif
    snmp_log( LOG_ERR,"After Init and Exiting-> Fun:%s Line:%d \n", __func__, __LINE__);
}

/* create a new row in the (unsorted) table */
struct ccAuditLoggingCfgTable_entry *
ccAuditLoggingCfgTable_createEntry(
                 char* ccAuditLogsnmpv3UserName,
                 size_t ccAuditLogsnmpv3UserName_len,
                 in_addr_t  ccAuditLogsnmpClientIpAddr
                ) 
{
    struct ccAuditLoggingCfgTable_entry *entry;

    entry = SNMP_MALLOC_TYPEDEF(struct ccAuditLoggingCfgTable_entry);
    if (!entry)
        return NULL;
    memset(entry, 0, sizeof(struct ccAuditLoggingCfgTable_entry));

    memcpy(entry->ccAuditLogsnmpv3UserName, ccAuditLogsnmpv3UserName, ccAuditLogsnmpv3UserName_len);
    entry->ccAuditLogsnmpv3UserName_len = ccAuditLogsnmpv3UserName_len;

    snmp_log( LOG_ERR,"Create Entry -> IPAddr:%x \n", ccAuditLogsnmpClientIpAddr);
    entry->ccAuditLogsnmpClientIpAddr = ccAuditLogsnmpClientIpAddr;
    entry->next = ccAuditLoggingCfgTable_head;
    ccAuditLoggingCfgTable_head = entry;
    return entry;
}

/* remove a row from the table */
void
ccAuditLoggingCfgTable_removeEntry( struct ccAuditLoggingCfgTable_entry *entry ) {
    struct ccAuditLoggingCfgTable_entry *ptr, *prev;

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

    for ( ptr  = ccAuditLoggingCfgTable_head, prev = NULL;
          ptr != NULL;
          prev = ptr, ptr = ptr->next ) {
        if ( ptr == entry ){
	 	snmp_log( LOG_ERR,"1 Actual Delete_entry-> UserName:%s **\n", entry->ccAuditLogsnmpv3UserName);
	 	snmp_log( LOG_ERR,"2 to Delete Delete_entry-> UserName:%s **\n", ptr->ccAuditLogsnmpv3UserName);
            break;
	}
    }
    if ( !ptr ){
	   snmp_log( LOG_ERR,"***Can't find the user to remove **** \n");
        return;    /* Can't find it */
    }

    if ( prev == NULL )
        ccAuditLoggingCfgTable_head = ptr->next;
    else
        prev->next = ptr->next;

    SNMP_FREE( entry );   /* XXX - release any other internal resources */
}


/* iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
ccAuditLoggingCfgTable_get_first_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    if(*my_loop_context != ccAuditLoggingCfgTable_head)
    	*my_loop_context = ccAuditLoggingCfgTable_head;
	  //snmp_log( LOG_ERR,"GET_FIRST -> Fun:%s Line:%d \n", __func__, __LINE__);
    return ccAuditLoggingCfgTable_get_next_data_point(my_loop_context, my_data_context,
                                    put_index_data,  mydata );
}

netsnmp_variable_list *
ccAuditLoggingCfgTable_get_next_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    struct ccAuditLoggingCfgTable_entry *entry = (struct ccAuditLoggingCfgTable_entry *)*my_loop_context;
    netsnmp_variable_list *idx = put_index_data;

    if ( entry ) {
        snmp_set_var_value( idx, entry->ccAuditLogsnmpv3UserName, strlen(entry->ccAuditLogsnmpv3UserName) );
	 //snmp_log( LOG_ERR,"In Func:get_next_data_point UserName:%s \n", entry->ccAuditLogsnmpv3UserName);
        idx = idx->next_variable;
        snmp_set_var_typed_integer( idx, ASN_IPADDRESS, entry->ccAuditLogsnmpClientIpAddr );
        idx = idx->next_variable;
        *my_data_context = (void *)entry;
        *my_loop_context = (void *)entry->next;
        return put_index_data;
    } else {
    	//snmp_log( LOG_ERR,"NULL Get_next-> Fun:%s Line:%d \n", __func__, __LINE__);
        return NULL;
    }
}


/** handles requests for the ccAuditLoggingCfgTable table */
int
ccAuditLoggingCfgTable_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 ccAuditLoggingCfgTable_entry          *table_entry;
    //struct ccAuditLoggingCfgTable_entry          *table_row = NULL;
    int ret = SNMPERR_SUCCESS;

    DEBUGMSGTL(("ccAuditLoggingCfgTable:handler", "Processing request (%d)\n", reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            table_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    	  
            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGSNMPV3USERNAME:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
	 	snmp_log( LOG_ERR,"MODE_GET -> UserName:%s **\n", table_entry->ccAuditLogsnmpv3UserName);
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                 (u_char*)table_entry->ccAuditLogsnmpv3UserName,
                                          table_entry->ccAuditLogsnmpv3UserName_len);
                break;
            case COLUMN_CCAUDITLOGSNMPCLIENTIPADDR:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
	 	snmp_log( LOG_ERR,"MODE_GET -> Ip addr:%x **\n", table_entry->ccAuditLogsnmpClientIpAddr);
                snmp_set_var_typed_integer( request->requestvb, ASN_IPADDRESS,
                                           ntohl(table_entry->ccAuditLogsnmpClientIpAddr));
                break;
            case COLUMN_CCAUDITLOGROWSTATUS:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
	 	snmp_log( LOG_ERR,"MODE_GET -> row status:%d **\n", table_entry->ccAuditLogRowStatus);
               snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ccAuditLogRowStatus);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;
    

#if 0
        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {

		table_entry = (struct ccAuditLoggingCfgTable_entry *)
			netsnmp_extract_iterator_context(request);
		table_info  =     netsnmp_extract_table_info(      request);

		if(NULL == table_info){
			snmp_log( LOG_ERR,"\n MODE_SET_RESERVE1 :Table Details are Empty-> Line:%d \n", __LINE__);
			return -1;
		}
	    snmp_log( LOG_ERR,"RESERVE1 2 return -> Fun:%s Line:%d \n", __func__, __LINE__);

            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGSNMPV3USERNAME:
	    snmp_log( LOG_ERR,"RESERVE1 col 1  \n");
#if 0
	        /* or possibly 'netsnmp_check_vb_type_and_size' */
                ret = netsnmp_check_vb_type_and_size(
                          request->requestvb, ASN_OCTET_STR, sizeof(table_entry->ccAuditLogsnmpv3UserName));
                if ( ret != SNMP_ERR_NOERROR ) {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
#endif
                break;
	    case COLUMN_CCAUDITLOGSNMPCLIENTIPADDR:
	    snmp_log( LOG_ERR,"RESERVE1 col 2  \n");
		/* or possibly 'netsnmp_check_vb_int_range' */
#if 0
		ret = netsnmp_check_vb_type_and_size(
				request->requestvb, ASN_INTEGER, sizeof(long));
		/* ret = netsnmp_check_vb_int( request->requestvb ); */
		if ( ret != SNMP_ERR_NOERROR ) {
			netsnmp_set_request_error( reqinfo, request, ret );
			return SNMP_ERR_NOERROR;
		}
#endif
		break;
            case COLUMN_CCAUDITLOGROWSTATUS:
	    snmp_log( LOG_ERR,"RESERVE1 col 3  \n");
                ret = netsnmp_check_vb_rowstatus(request->requestvb,
                         (RS_NONEXISTENT ));
                         //(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;

#endif
    case MODE_SET_RESERVE2:
        for (request=requests; request; request=request->next) {
            table_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
#if 1
	    if(NULL == table_entry){
	    	snmp_log( LOG_ERR,"\n MODE_SET_RESERVE2 :Table entry are not NULL \n");
	    }
#endif
	/* Get the index information */ 
	unsigned int    tmp_idx;
	netsnmp_variable_list *vb;
        char ccAuditLogsnmpv3UserName[255] = {0};
        size_t ccAuditLogsnmpv3UserName_len = 0;
        unsigned long  ccAuditLogsnmpClientIpAddr = 0;
	//vb = request->requestvb;
	for (tmp_idx = 0, vb = table_info->indexes; tmp_idx < table_info->number_indexes;
	//for (tmp_idx = 0; tmp_idx < table_info->number_indexes;
			++tmp_idx, vb = vb->next_variable) {
		snmp_log( LOG_ERR,"RESERVE2  ->IP address field vb_integer:%x len:%d \n", *vb->val.integer, vb->val_len);
		
		snmp_log( LOG_ERR,"RESERVE2  -> ASN type %d indxnum:%d\n", vb->type, table_info->number_indexes);
		if(vb->type == ASN_OCTET_STR){ /*User name index*/
			memcpy(ccAuditLogsnmpv3UserName, vb->val.string, vb->val_len);
			ccAuditLogsnmpv3UserName_len = vb->val_len;
			snmp_log( LOG_ERR,"RESERVE2 **** string %s len:%d  \n", vb->val.string, vb->val_len);
		}
		if(vb->type == ASN_IPADDRESS){ /*Ip address Index*/
			ccAuditLogsnmpClientIpAddr = *(unsigned long *)vb->val.integer;
			//ccAuditLogsnmpClientIpAddr = ntohl(*vb->val.integer);
			snmp_log( LOG_ERR,"RESERVE2  -> vb_integer:%x len:%d \n", *vb->val.integer, vb->val_len);
			snmp_log( LOG_ERR,"RESERVE2 -> IPAddr:%d \n", ccAuditLogsnmpClientIpAddr);
		}
	}
#if 0
			/*if(ccAuditLogsnmpClientIpAddr)
				ccAuditLogsnmpClientIpAddr = 111212;*/  /*To test*/ 
#endif
            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    table_entry = ccAuditLoggingCfgTable_createEntry(
                 		ccAuditLogsnmpv3UserName,
                 		ccAuditLogsnmpv3UserName_len,
                 		ccAuditLogsnmpClientIpAddr);
                    if (table_entry) {
                        netsnmp_insert_iterator_context(request, table_entry);
                    } else {
                        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_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
	    
	    if(NULL == table_info){
	    	snmp_log( LOG_ERR," MODE_SET_FREE :Table_info is NULL -> Fun:%s Line:%d \n", __func__, __LINE__);
		return -1;
	    }
	    snmp_log( LOG_ERR,"SET_FREE -> Fun:%s Line:%d \n", __func__, __LINE__);
    
            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
			if (table_entry && !table_entry->valid) {
				ccAuditLoggingCfgTable_removeEntry(table_entry);
				snmp_log( LOG_ERR,"SET_FREE 222-> Fun:%s Line:%d \n", __func__, __LINE__);
			}
                }
            }
        }
        break;

    case MODE_SET_ACTION:
        for (request=requests; request; request=request->next) {
            table_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);

	    if(NULL == table_entry || NULL == table_info){
	    	snmp_log( LOG_ERR," MODE_SET_ACTION :Table Details are Empty-> Fun:%s Line:%d \n", __func__, __LINE__);
		return -1;
	    }
	    snmp_log( LOG_ERR,"SET_ACTION -> Fun:%s Line:%d colnum:%d\n", __func__, __LINE__, table_info->colnum);
    
            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGSNMPV3USERNAME:
	    	snmp_log( LOG_ERR,"SET_ACTION user name -> Fun:%s Line:%d \n", __func__, __LINE__);
                memcpy( table_entry->old_ccAuditLogsnmpv3UserName,
                        table_entry->ccAuditLogsnmpv3UserName,
                        strlen(table_entry->ccAuditLogsnmpv3UserName));
                table_entry->old_ccAuditLogsnmpv3UserName_len =
                        table_entry->ccAuditLogsnmpv3UserName_len;
                memset( table_entry->ccAuditLogsnmpv3UserName, 0,
                        strlen(table_entry->ccAuditLogsnmpv3UserName));
                memcpy( table_entry->ccAuditLogsnmpv3UserName,
                        request->requestvb->val.string,
                        request->requestvb->val_len);
                table_entry->ccAuditLogsnmpv3UserName_len =
                        request->requestvb->val_len;
                break;
            case COLUMN_CCAUDITLOGSNMPCLIENTIPADDR:
	    	
		snmp_log( LOG_ERR,"ACTION  -> modifying **IP address %x \n", *request->requestvb->val.integer);

                table_entry->old_ccAuditLogsnmpClientIpAddr = table_entry->ccAuditLogsnmpClientIpAddr;
                table_entry->ccAuditLogsnmpClientIpAddr     = *request->requestvb->val.integer;
                break;
            }
        }
        /* Check the internal consistency of an active row */
#if 0
        for (request=requests; request; request=request->next) {
            table_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_ACTIVE:
                case RS_CREATEANDGO:
                /*   if (??) {
                        netsnmp_set_request_error( reqinfo, request,
                                                   SNMP_ERR_INCONSISTENTVALUE );
                        return SNMP_ERR_NOERROR;
                    }*/
                }
            }
        }
#endif
        break;

    case MODE_SET_UNDO:
        for (request=requests; request; request=request->next) {
            table_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
   
	    if(NULL == table_entry || NULL == table_info){
	    	snmp_log( LOG_ERR,"MODE_SET_UNDO Table Details are Empty-> Fun:%s Line:%d \n", __func__, __LINE__);
		return -1;
	    }
	    snmp_log( LOG_ERR,"SET_UNDO -> Fun:%s Line:%d \n", __func__, __LINE__);

            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGSNMPV3USERNAME:
                memcpy( table_entry->ccAuditLogsnmpv3UserName,
                        table_entry->old_ccAuditLogsnmpv3UserName,
                        strlen(table_entry->ccAuditLogsnmpv3UserName));
                memset( table_entry->old_ccAuditLogsnmpv3UserName, 0,
                        strlen(table_entry->ccAuditLogsnmpv3UserName));
                table_entry->ccAuditLogsnmpv3UserName_len =
                        table_entry->old_ccAuditLogsnmpv3UserName_len;
                break;
            case COLUMN_CCAUDITLOGSNMPCLIENTIPADDR:
                table_entry->ccAuditLogsnmpClientIpAddr     = table_entry->old_ccAuditLogsnmpClientIpAddr;
                table_entry->old_ccAuditLogsnmpClientIpAddr = 0;
                break;
            case COLUMN_CCAUDITLOGROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    if (table_entry && !table_entry->valid) {
                        ccAuditLoggingCfgTable_removeEntry(table_entry);
                    }
                }
                break;
            }
        }
        break;

    case MODE_SET_COMMIT:
        for (request=requests; request; request=request->next) {
            table_entry = (struct ccAuditLoggingCfgTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);

	    if(NULL == table_entry || NULL == table_info){
	    	snmp_log( LOG_ERR," MODE_SET_COMMIT :Table Details are Empty-> Fun:%s Line:%d \n", __func__, __LINE__);
		return -1;
	    }
	    snmp_log( LOG_ERR,"COMMIT -> UserName:%s \n", table_entry->ccAuditLogsnmpv3UserName);

            switch (table_info->colnum) {
            case COLUMN_CCAUDITLOGROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                    table_entry->valid = 1;
	    	snmp_log( LOG_ERR,"COMMIT -> Create and Go:\n");
                    /* Fall-through */
                case RS_ACTIVE:
                    table_entry->ccAuditLogRowStatus = RS_ACTIVE;
                    break;

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

                case RS_DESTROY:
	    	    snmp_log( LOG_ERR,"COMMIT -> RS_DESTROY \n");
                    ccAuditLoggingCfgTable_removeEntry(table_entry);
                }
            }
        }
        break;
    }
    return SNMP_ERR_NOERROR;
}
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.