Hello Bruce,

back to OID length question...
command line works.

On Fedora-3 2.6.9-1.667 with net-snmp-5.1.2-11
it is the same behaviour as on solaris - after long
OID string short OID does not work.

Here is code example:

/****** main *******/

static char *oid2 = ".1.3.6.1.2.1.1.1.0";
static char *oid1 = ".1.3.6.1.4.1.9.3.6.7.0";
char *peer = "10.200.10.62";

int main(int argc, char **argv)
{
  char *s;

  snmp_init();

  s = snmp_get(peer,oid1);
  if (!s)
    buffer_puts(buffer_1,"snmp_get failed\n");
  else
    buffer_puts(buffer_1,s);
  buffer_puts(buffer_1,"\n\n");

  s = snmp_get(peer,oid2);
  if (!s)
    buffer_puts(buffer_1,"snmp_get failed\n");
  else
    buffer_puts(buffer_1,s);
  buffer_puts(buffer_1,"\n\n");

/* at this point it will not work */
  s = snmp_get(peer,oid1);
  if (!s)
    buffer_puts(buffer_1,"snmp_get failed\n");
  else
    buffer_puts(buffer_1,s);
  buffer_puts(buffer_1,"\n\n");
  _exit(0);
}

/********* snmp_get *********/
#define COMMUNITY "testRW"

struct snmp_session session, *ss;
struct snmp_pdu *pdu, *response;
struct variable_list *vars;            

oid serial_oid[MAX_OID_LEN];
size_t serial_len = MAX_OID_LEN;

static char rval[512];

char *snmp_get(char *peer, char *oidstr)
{
  int rc = 0;
  int status;

  byte_zero(&session, sizeof session);

  snmp_sess_init(&session);
  session.version   = SNMP_VERSION_2c;            
session.community = COMMUNITY;
  session.community_len = str_len(session.community);
  session.peername = peer;
  ss = snmp_open(&session);

  if (!ss) {
    strerr_warn2(FATAL, "unable open snmp session",0);
    return 0;
  }

  pdu = snmp_pdu_create(SNMP_MSG_GET);
  rc = 0;
  status = snmp_synch_response(ss, pdu, &response);
  if (status == STAT_SUCCESS) {
    if (response->errstat == SNMP_ERR_NOERROR) {
      byte_zero(rval,512);
      vars=response->variables;
      if (!vars)
        strerr_warn2(FATAL, "unable get return
value",0);
      else {
        rc++;
        snprint_value(rval, 512, vars->name,
vars->name_length, vars);
      }
    }
    else
      strerr_warn3(FATAL, "error in packet:
",snmp_errstring(response->errstat),0);
  }
  else if (status == STAT_TIMEOUT)
    strerr_warn3(FATAL, "timeout: ",peer,0);
  else
    snmp_sess_perror("snmp_get",ss);
  
  if (response) snmp_free_pdu(response);
  snmp_close(ss);  
  return rc ? rval : (char *)rc;
}

/*****************/

i will appriciate any suggestion.

with kind regards,
German



--- Bruce Shaw <[EMAIL PROTECTED]> wrote:
> That's odd.  Can you post some example code?
> 
> >question is related to net-snmp 5.2.1 on SunOS host
> 5.9 Generic_117171-17
> sun4u sparc SUNW,Ultra-5_10
> 
> >i use snmp-api example available on website - just
> to snmpget some data
> from cisco.
> 
> >make 3 calls (one by one) in one programm for
> different oids. "call" is
> done in the function that makes session init and at
> the end frees pdu/close
> session.
> 
> >if oids were called in the next order order:
> >1 call: .1.3.6.1.4.1.9.9.43.1.1.3.0
> >2 call: .1.3.6.1.4.1.9.3.6.7.0
> >3 call: .1.3.6.1.2.1.1.1.0
> >it works ok - can get data for each call
> 
> >if to call in this order:
> >1 call:  .1.3.6.1.2.1.1.1.0
> >2 call:  .1.3.6.1.4.1.9.3.6.7.0
> >3 call:  .1.3.6.1.4.1.9.9.43.1.1.3.0
> 
> >then 1st call is ok but 2nd and 3rd return error:
> >"No Such Object available on this agent at this
> OID"
> 
> >if to call like this:
> >1 call:  .1.3.6.1.4.1.9.9.43.1.1.3.0
> >2 call:  .1.3.6.1.2.1.1.1.0
> >3 call:  .1.3.6.1.4.1.9.3.6.7.0
> >then 1st and 2nd is ok but 3rd is failed.
> 
> Have you tried this using command line?
> 
> Have you tried this on a different platform?
> 
>               
> 
> 
> This communication is intended for the use of the
> recipient to which it is
> addressed, and may contain confidential, personal
> and or privileged
> information. Please contact us immediately if you
> are not the intended
> recipient of this communication, and do not copy,
> distribute, or take action
> relying on it. Any communication received in error,
> or subsequent reply,
> should be deleted or destroyed.
> 
> 


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to