[applogies if the post show twice, the first was a mistake]
Hi,

I'm trying to write a simple snmp program to query some values of a  
sensor server. Following the tutorial as an example, all seemed fine,  
until I tried executing the program on different platforms.
Compiliation is fine on all, but running the programm often segfaults  
or gives other errors.

I am using protocol version 1 (because the sensor server only supports  
that), and I don't know the versions of the library (where can I find  
what I am using?).
On linux machines, be it 32 or 64 bit, centos 5.3 or fedora4, 10, 11  
or whatever, I get a segfault if I use the init_snmp() function (with  
a parameter of "snmpapp"), but on

Mac OS X 10.4.11 ppc and 10.5.8 intel all's fine. (And, in fact, for  
the ppc it is required!)

Unfortunately, the docs are absolutely not clear as to whether this  
function *must* be called, and about what the value of the paramter  
should be.

As mentioned, the program runs fine on all linux intel systems when  
*not* using snmp_init, but fails on ppc (big-endian problem?)


The relevant parts of the program are:

  /* Initialize snmp. */
  init_snmp("snmpapp"); // <- segfaults on linux
        
  /* Initialize the connection. */
  struct snmp_session session;
  struct snmp_session *sess_handle;

  snmp_sess_init( &session );
  session.version = SNMP_VERSION_1;
  session.community = "public";
  session.community_len = strlen((const char *)session.community);
  session.peername = "my.host.this.domain";
  sess_handle = snmp_open(&session);

  /* Set up the object for reading. We will read all at once! */
  pdu = snmp_pdu_create(SNMP_MSG_GET);

  size_t status_len = MAX_OID_LEN;
  oid status_oid[MAX_OID_LEN];
  read_objid(".1.3.6.1.4.1.3854.1.2.2.1.16.1.4.0", status_oid,  
&status_len);
  snmp_add_null_var(pdu, status_oid, status_len);

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

  if ((status == STAT_SUCCESS) && (response->errstat ==  
SNMP_ERR_NOERROR) && response->variables) {
    for (d = 0, vars = response->variables; vars; vars = vars- 
 >next_variable, d++) {
      // process the values here
    }
  } else {
    // report the error here
  }

I'd be very grateful for any help or even just further questions!


Thanks in advance
Robert
Departement Informatik   FGB   tel   +41 (0)61 267 14 66
Universität Basel                          fax. +41 (0)61 267 14 61
Robert Frank
Klingelbergstrasse 50                 [email protected]
CH-4056 Basel
Switzerland                                   
http://www.informatik.unibas.ch/personen/frank_r.html




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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

Reply via email to