Get IPAddress type inside Table from created MIB timeout

António Mendes <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <[email protected]>
Hi. I'm struggling with this for 3 days now...


I do not understand why, but when I try to get a IPAddress from a table inside my MIB, it always gets timeout and all other types work. I tried with SNMPb and the GET works just fine.


With snmpget command does not work either.


Tried with version 5.8 and 5.8.1.pre2


Below, I leave my C client code and my MIB.


############################## CLIENT CODE###################################


   netsnmp_session *sess_handle = setup_snmp_session(SNMP_VERSION_2c,(unsigned char *)("public"),(unsigned char *)ip);
    if(sess_handle != NULL)
    {
        int count=1;
        netsnmp_pdu *pdu;
        netsnmp_pdu *response;
        netsnmp_variable_list *vars;

        oid anOID[MAX_OID_LEN];
        size_t anOID_len;
        int status;

        pdu = snmp_pdu_create(SNMP_MSG_GET);

        anOID_len = MAX_OID_LEN;
        if (!get_node(oidname, anOID, &anOID_len))
        {
            snmp_perror(oidname);
            return 0;
        }


        oid o[] = { 1,3,6,1,4,1,26364,2,1,1,1,4,0};
        snmp_add_null_var(pdu, o, OID_LENGTH(o));
        //snmp_add_null_var(pdu, anOID, anOID_len);


        status = snmp_synch_response(sess_handle, pdu, &response);


        /*
     * Process the response.
     */
        if (status == STAT_SUCCESS )
        {
            if(response->errstat == SNMP_ERR_NOERROR)
            {
                /* manipuate the information ourselves */
                for(vars = response->variables; vars; vars = vars->next_variable)
                {
                    fprint_variable(stderr, vars->name, vars->name_length, vars);


                    if (vars->type == ASN_IPADDRESS)
                    {
                        char auxIp[INET_ADDRSTRLEN];

                        memset(auxIp, 0, sizeof(auxIp));

                        inet_ntop( AF_INET, &(vars->val.counter64->high), auxIp, sizeof(auxIp));

                        fprintf(stderr,"%s\n", auxIp);
                    }
                    else
                    {
                        if (vars->type == ASN_INTEGER)
                        {
                            fprintf(stderr,"%d\n", vars->val.counter64->high);
                        }
                        else if (vars->type == ASN_OCTET_STR)
                        {
                            fprintf(stderr,"%s\n",vars->val.string);
                        }
                        else if (vars->type == ASN_UNSIGNED)
                        {
                            fprintf(stderr,"%lu\n", vars->val.counter64->high);
                        }
                        else
                        {

                            fprintf(stderr,"value #%d is NOT a integer! Ack!\n", count++);
                        }
                    }
                }
            }
            else {
                /*
                         * error in response, print it
                         */
                if (response->errstat == SNMP_ERR_NOSUCHNAME) {
                    fprintf(stderr,"End of MIB.\n");
                } else {
                    fprintf(stderr, "Error in packet.\nReason: %s\n",
                            snmp_errstring(response->errstat));
                    if (response->errindex != 0) {
                        fprintf(stderr, "Failed object: ");
                        for (count = 1, vars = response->variables;
                             vars && (count != response->errindex);
                             vars = vars->next_variable, count++)
                            /*EMPTY*/;
                        if (vars)
                            fprint_objid(stderr, vars->name,
                                         vars->name_length);
                        fprintf(stderr, "\n");
                    }
                }
            }
        } else {
            /*
              * FAILURE: print what went wrong!
              */

            if (status == STAT_SUCCESS)
            {
                fprintf(stderr, "Error in packet\nReason: %s\n",snmp_errstring(response->errstat));
            }
            else if (status == STAT_TIMEOUT)
            {
                fprintf(stderr, "Timeout: No response from %s.\n", sess_handle->peername);
            }
            else
            {
                snmp_sess_perror("snmpdemoapp", sess_handle);
            }
        }
    }
    snmp_close(sess_handle);
    return 0;



########MIB  ##########################


connectionTable OBJECT-TYPE
    SYNTAX      SEQUENCE OF ConnectionEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
    "Table with the Connections available to iccs7 application"
    ::= { network 1 }

connectionEntry OBJECT-TYPE
    SYNTAX      ConnectionEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
    "Connection Information"
    INDEX   { connectionIndex }
    ::= { connectionTable 1 }

ConnectionEntry ::= SEQUENCE {
    connectionIndex        Unsigned32,
    connectionName             OCTET STRING,
    connectionMethod           OCTET STRING,
    connectionIpAddress      IpAddress,
    connectionNetmask          Unsigned32,
    connectionGatewayAddress  IpAddress
}


connectionIndex OBJECT-TYPE
    SYNTAX      Unsigned32
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
    "Connection Index"
    ::= { connectionEntry 1 }

connectionName OBJECT-TYPE
    SYNTAX      OCTET STRING (SIZE(0..64))
    MAX-ACCESS  read-create
    STATUS      current
    DESCRIPTION
    "Connection Name"
    ::= { connectionEntry 2 }

connectionMethod OBJECT-TYPE
    SYNTAX      OCTET STRING
    MAX-ACCESS  read-create
    STATUS      current
    DESCRIPTION
    "The method to obtain IP address"
    ::= { connectionEntry 3 }

connectionIpAddress OBJECT-TYPE
    SYNTAX      IpAddress
    MAX-ACCESS  read-create
    STATUS      current
    DESCRIPTION
    "IP Address Connection"
    ::= { connectionEntry 4 }

connectionNetmask OBJECT-TYPE
    SYNTAX      Unsigned32 (0..32)
    MAX-ACCESS  read-create
    STATUS      current
    DESCRIPTION
    "IP Netmask"
    ::= { connectionEntry 5 }

connectionGatewayAddress OBJECT-TYPE
    SYNTAX      IpAddress
    MAX-ACCESS  read-create
    STATUS      current
    DESCRIPTION
    "Gateway Address"
    ::= { connectionEntry 6 }


Thank you



www.eid.pt

EID, S.A.
Capital Social €1.100.000
N° de matricula unico 501 400 699

DISCLAIMER
nubisnetworks.com; spf=pass [email protected] smtp.helo=eid.pt

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
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.