Table's String index does not work

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

 

* Net-snmp version: 5.5

* Scenario: Using snmpB I perform "walk" on the table.

 

I have a table with string type index (see below).

On the get-next-entry function (full code is below as well) retrieving
the index fails, and "val.string" is empty, val_len=0 but type is
ASN_OCTET_STR.

Also attached the my log file with debug prints.

 

I also tried to simply get one parameter in specific index:

~ # ./data/net/naamab/snmpget -m ALL -M /data/sw/snmp/snmp_mib_lnk/ -v
2c -c private 127.0.0.1
1.3.6.1.4.1.37576.4.1.4.1.1.3.3."committed-switch"

1.3.6.1.4.1.37576.4.1.4.1.1.3.3.committed-switch: Unknown Object
Identifier (Index out of range: committed-switch
(nsDemodConfigDiseqcName))

 

~ # ./data/net/naamab/snmpget -m ALL -M /data/sw/snmp/snmp_mib_lnk/ -v
2c -c private 127.0.0.1 1.3.6.1.4.1.37576.4.1.4.1.1.3."committed-switch"

1.3.6.1.4.1.37576.4.1.4.1.1.3.committed-switch: Unknown Object
Identifier (Index out of range: committed-switch
(nsDemodConfigDiseqcName))

 

~ # ./data/net/naamab/snmpget -m ALL -M /data/sw/snmp/snmp_mib_lnk/ -v
2c -c private 127.0.0.1
1.3.6.1.4.1.37576.4.1.4.1.1.3.3.6."committed-switch"

1.3.6.1.4.1.37576.4.1.4.1.1.3.3.6.committed-switch: Unknown Object
Identifier (Index out of range: committed-switch
(nsDemodConfigDiseqcName))

 

 

================================================

===     MIB 

================================================

nsDemodConfigDiseqc  OBJECT-IDENTITY

        STATUS current

        DESCRIPTION

              "Demodulator MIB branch that holds all Demodulator DiSEqC
parameters."

        ::= { nsDemodConfig 4 }

 

nsDemodConfigDiseqcTable OBJECT-TYPE

    SYNTAX SEQUENCE OF DemodConfigDiseqcEntry

    MAX-ACCESS not-accessible

    STATUS current

    DESCRIPTION

        "A list of Diseqc parameters"

    ::= { nsDemodConfigDiseqc 1 } 

 

nsDemodConfigDiseqcEntry OBJECT-TYPE

    SYNTAX      DemodConfigDiseqcEntry

    MAX-ACCESS  not-accessible

    STATUS      current

    DESCRIPTION "Conceptual row in table for each DiSEqC."

    INDEX   { nsDemodConfigDiseqcName }

    ::= { nsDemodConfigDiseqcTable 1 }

        

DemodConfigDiseqcEntry ::=

    SEQUENCE {

        nsDemodConfigDiseqcName             DisplayString,

        nsDemodConfigDiseqcHeaderBytes      Unsigned64,

        nsDemodConfigDiseqcNumDataBytes     Unsigned32,

        nsDemodConfigDiseqcToneBurstMode    INTEGER,

        nsDemodConfigDiseqcNotifyRowStatus  RowStatus

    } 

    

nsDemodConfigDiseqcName  OBJECT-TYPE

        SYNTAX  DisplayString 

        MAX-ACCESS  not-accessible

        STATUS  current

        DESCRIPTION

                "This parameter holds DiSEqC command's name."

        ::= { nsDemodConfigDiseqcEntry  1 }

 

nsDemodConfigDiseqcHeaderBytes  OBJECT-TYPE

        SYNTAX  Unsigned32 

        MAX-ACCESS  read-create

        STATUS  current

        DESCRIPTION

                "This parameter holds DiSEqC command's header bytes."

        ::= { nsDemodConfigDiseqcEntry  2 }

 

nsDemodConfigDiseqcNumDataBytes  OBJECT-TYPE

        SYNTAX  Unsigned32 

        MAX-ACCESS  read-create

        STATUS  current

        DESCRIPTION

                "This parameter holds DiSEqC command's number of data
bytes."

        ::= { nsDemodConfigDiseqcEntry  3 }

        

nsDemodConfigDiseqcToneBurstMode  OBJECT-TYPE

        SYNTAX  INTEGER {

            auto (0),

            unmodulated (1),

            modulated (2),

            none (3),

            notApplicable (255)

        }

        MAX-ACCESS  read-create

        STATUS  current

        DESCRIPTION

                "This parameter holds DiSEqC command's tone burst mode."

        ::= { nsDemodConfigDiseqcEntry  4 } 

               

nsDemodConfigDiseqcNotifyRowStatus  OBJECT-TYPE

        SYNTAX      RowStatus

        MAX-ACCESS  read-create

        STATUS      current

        DESCRIPTION

                "Used to create new rows or delete in the table.

                 Note that all rows are active(1) at all times, since 

                 default values are given to empty parameters. 

                 Value createAndGo(4) is used when all row parameters

                 are inserted at once, while createAndWait(5) is used

                 to create row with default values. 

                 Value destroy(6) is used to remove a row"

        ::= { nsDemodConfigDiseqcEntry 5 }

================================================

 

================================================

===     get next function 

================================================

static struct nsDemodConfigDiseqcTable_entry *

nsDemodConfigDiseqcTable_get_next_entry(netsnmp_handler_registration

                                        *reginfo,

                                        netsnmp_request_info *request,

                                        int column,

                                        netsnmp_variable_list * indexes)

{

    struct nsDemodConfigDiseqcTable_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_diseqc_core_tbl_record_t
*tbl_record_pointer;

                char
*key_pointer;

    int
ret=0;

    bool
is_writable;

    bool
is_visible;

    NS_SYSLOG_SNMP(LOG_ALERT,
"=======================================nbm: get next entry-1");

 

                tbl_record_pointer = (ns_db_diseqc_core_tbl_record_t *)
ns_ipcc_mem_alloc(sizeof(ns_db_diseqc_core_tbl_record_t));

                key_pointer = (uint8_t *)
ns_ipcc_mem_alloc(sizeof(char)*NS_TBL_FLD_MAX_LEN);

 

                if ((!key_pointer) || (!tbl_record_pointer)) {

                                ns_ipcc_mem_free();

                                return NULL;

                }

    NS_SYSLOG_SNMP(LOG_ALERT, "====nbm: 2. index-type=%d, oct-str=%d,
len=%d, str=%s, int=%d, c0=%c, c1=%c, c2=%c, c0=%d, c1=%d, c2=%d",
idx->type, ASN_OCTET_STR, idx->val_len, idx->val.string,
idx->val.integer, (idx->val.string)[0], (idx->val.string)[1],
(idx->val.string)[2], (idx->val.string)[0], (idx->val.string)[1],
(idx->val.string)[2]);

 

                strncpy(key_pointer, idx->val.string,
NS_TBL_FLD_MAX_LEN);

    NS_SYSLOG_SNMP(LOG_ALERT, "====nbm: 3, key_pointer=%s",
key_pointer);

    /*

     * XXX - Use the 'indexes' parameter to identify the

     * next row in the table.... 

     */

                if (!ns_db_tbl_get_next_record(NS_DB_TBL_ID_DISEQC_CORE,
key_pointer, tbl_record_pointer)) {

                                NS_SYSLOG_SNMP(LOG_ALERT, "====nbm: 4");

 
strncpy(DemodConfigDiseqc_entry.nsDemodConfigDiseqcName,
tbl_record_pointer->name, NS_TBL_FLD_MAX_LEN);

 
DemodConfigDiseqc_entry.nsDemodConfigDiseqcName_len =
strlen(tbl_record_pointer->name);

 
DemodConfigDiseqc_entry.nsDemodConfigDiseqcHeaderBytes =
tbl_record_pointer->header;

 
DemodConfigDiseqc_entry.nsDemodConfigDiseqcNumDataBytes =
tbl_record_pointer->nr_data_bytes;

 
DemodConfigDiseqc_entry.nsDemodConfigDiseqcToneBurstMode =
tbl_record_pointer->tone_burst;

 

 
DemodConfigDiseqc_entry.nsDemodConfigDiseqcNotifyRowStatus = 1;

                                NS_SYSLOG_SNMP(LOG_ALERT, "====nbm: 5,
header=0x%lx, num=%d, tbm=%d",
DemodConfigDiseqc_entry.nsDemodConfigDiseqcHeaderBytes,
DemodConfigDiseqc_entry.nsDemodConfigDiseqcNumDataBytes,
DemodConfigDiseqc_entry.nsDemodConfigDiseqcToneBurstMode);

 

                                /* get row */

                                row = &DemodConfigDiseqc_entry;

 

                                /*

                                * XXX   .... update the 'indexes'
parameter with the

                                * appropriate index values ...

                                */

                                NS_SYSLOG_SNMP(LOG_ALERT, "====nbm: 6,
key_pointer=%s", key_pointer);

                                strncpy(idx->val.string, key_pointer,
NS_TBL_FLD_MAX_LEN);

                                NS_SYSLOG_SNMP(LOG_ALERT, "====nbm: 7,
idx->val.string=%s", idx->val.string);

 

                                /*

                                * ... 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;

}

 

-----------------------log file prints:---------------------

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[196]>
=======================================nbm: get next entry-1

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[205]> ====nbm: 2.
index-type=4, oct-str=4, len=0, str=, int=538944032, c0=

Jan 20 16:05:02 (none) user.notice , c1=

Jan 20 16:05:02 (none) user.notice , c2=

Jan 20 16:05:02 (none) user.notice , c0=0, c1=0, c2=0

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[208]> ====nbm: 3,
key_pointer=

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[214]> ====nbm: 4

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[222]> ====nbm: 5,
header=0xe01038, num=1, tbm=0

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[231]> ====nbm: 6,
key_pointer=committed-switch

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[233]> ====nbm: 7,
idx->val.string=committed-switch

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[196]>
=======================================nbm: get next entry-1

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[205]> ====nbm: 2.
index-type=4, oct-str=4, len=0, str=, int=538944032, c0=

Jan 20 16:05:02 (none) user.notice , c1=

Jan 20 16:05:02 (none) user.notice , c2=

Jan 20 16:05:02 (none) user.notice , c0=0, c1=0, c2=0

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[208]> ====nbm: 3,
key_pointer=

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[214]> ====nbm: 4

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[222]> ====nbm: 5,
header=0xe01038, num=1, tbm=0

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[231]> ====nbm: 6,
key_pointer=committed-switch

Jan 20 16:05:02 (none) user.alert snmpd:
<SNMP:nsDemodConfigDiseqcTable_get_next_entry[233]> ====nbm: 7,
idx->val.string=committed-switch

 

 

Best Regards,

 

Naama Bar Menachem

SW Eng.

 

 

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient or have received this e-mail in error
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

------------------------------------------------------------------------------
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
image001.jpg (image/jpeg, 13.7 KB) - not displayed
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.