[prev in list] [next in list] [prev in thread] [next in thread]
List: net-snmp-support
Subject: [ net-snmp-Support Requests-413715 ] Can a MSG_GET be used in multi-sessions?
From: noreply () sourceforge ! net
Date: 2001-04-05 12:44:04
[Download RAW message or body]
Support Requests item #413715, was updated on 2001-04-04 07:51
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=212694&aid=413715&group_id=12694
Category: None
Group: None
> Status: Closed
Priority: 5
Submitted By: Jean-François Beaulieu (jfbeaulieu)
Assigned to: Wes Hardaker (hardaker)
Summary: Can a MSG_GET be used in multi-sessions?
Initial Comment:
As long that I'm using
snmp_open(&session)
snmp_close(&session)
there is no problem, a set on a specific variable works perfectly. If I'm
using:
snmp_sess_open(&session)
snmp_sess_close(&session)
I get the message:
snmpset: Unknown Error 825241136
error: undefined error in snmpplugin_set
But with a MSG_GET and a MSG_GET_NEXT I hadn't this problem, it seems
limited only to MSG_SET. Do I have to do something or is it a bug in net-snmp?
----------------------------------------------------------------------
> Comment By: Jean-François Beaulieu (jfbeaulieu)
Date: 2001-04-05 05:44
Message:
Logged In: YES
user_id=150034
thanks
----------------------------------------------------------------------
Comment By: Dave Shield (dts12)
Date: 2001-04-05 04:48
Message:
Logged In: YES
user_id=88893
Yes - 'snmp_synch_response' is part of the "traditional API"
so you can't use it with the SSI session pointers.
But why not just use the SSI equivalent
'snmp_sess_synch_response' ?
Note that the type of request (GET/GETNEXT/SET/TRAP/etc)
is completely separate from the session API used.
They both take *precisely* the same PDU structure.
Dave
----------------------------------------------------------------------
Comment By: Jean-François Beaulieu (jfbeaulieu)
Date: 2001-04-05 04:35
Message:
Logged In: YES
user_id=150034
Dave wrote:
> How are you actually sending the request?
Ok. I'll give you the piece of code here, but I think you are rigth. I suppose
I have to use snmp_sess_send rather than snmp_synch_response(..) since
I don't have a valid snmp_session as you said. However in apps/snmptest.c
(source-forge stuff) snmp_sess_send(...) seems to be use only in connection with \
message traps, otherwise it is snmp_synch_response(...). Wheter snmp_sess_send(..) is \
sufficient for a MSG_SET is another question, I may not rely too much on \
apps/snmptest.c as a valid pattern. Here's the code with the switch:
int set(SnmpParams &par, SnmpElement *snmp_elements, dsd_ctx *ctx, value_t **ar
gv)
{
char buff_error[200];
int failures = 0;
void *opak;
struct snmp_session session, *ss;
struct snmp_pdu *pdu, *response = NULL;
oid oid_int[MAX_OID_LEN];//okenized oid in 'integers' elements
size_t nb_oid_segments; // nb elements in array oid_int
int count;
size_t nb_oid_segments; // nb elements in array oid_int
int count;
int status;
int exitval = 0;
snmp_sess_init( &session );
assign_session(session, par); //populate session
/* get object names, types, and values */
SOCK_STARTUP;
/* open an SNMP session */
#if ONE_SESS
ss = (snmp_session *) snmp_open(&session);
#else
opak = snmp_sess_open(&session);
#endif
if (ss == NULL){
log_error("can't initialize snmp_set","");
dsd_report_error( ctx,argv[0],"can't initialize snmp_set" );
snmp_sess_perror("snmpset", &session);
SOCK_CLEANUP;
return -1;
}
pdu = snmp_pdu_create(SNMP_MSG_SET);
for(count = 0; count < 1; count++){
nb_oid_segments = MAX_OID_LEN;
if (snmp_parse_oid(snmp_elements[0].oid,
oid_int, &nb_oid_segments) == NULL) {
snmp_perror(snmp_elements[0].oid);
failures++;
} else {
if (snmp_add_var(pdu, oid_int, nb_oid_segments,
(char )snmp_elements[0].type,
snmp_elements[0].value)) {
failures++;
}
}
}
if (failures) {
sprintf(buff_error,
"can't build pdu for oid %s type %d probably wrong.\n",
snmp_elements[0].oid,snmp_elements[0].type
);
dsd_report_error( ctx, argv[0], buff_error );
#if ONE_SESS
snmp_close(ss);
#else
snmp_sess_close(opak);
#endif
SOCK_CLEANUP;
return -1;
}
retry3:
/* do the request */
#if ONE_SESS
status = snmp_synch_response(ss, pdu, &response);
#else
status = snmp_sess_send(opak, pdu);
#endif
if (status == STAT_SUCCESS){
if (response->errstat == SNMP_ERR_NOERROR){
;
} else {
//build_error( pdu,response, ctx, argv);
snmp_elements[0].oid,
snmp_errstring(response->errstat));
dsd_report_error( ctx, argv[0], buff_error );
exitval = SOME_OIDS_MISSING;
}
/* retry if the errored variable was successfully removed */
if (!ds_get_boolean(DS_APPLICATION_ID, DS_APP_DONT_FIX_PDUS)) {
pdu = snmp_fix_pdu(response, SNMP_MSG_SET);
snmp_free_pdu(response);
response = NULL;
if (pdu != NULL)
goto retry3;
}
} else if (status == STAT_TIMEOUT){
dsd_report_error( ctx,argv[0],"snmpplugin_set; timeout" );
exitval = -1;
snmp_sess_perror("snmpset", ss);
}
if (response)
snmp_free_pdu(response);
#if ONE_SESS
snmp_close(ss);
#else
snmp_sess_close(ss);
#endif
SOCK_CLEANUP;
return exitval;
}
PS: by the way, snmp_sess_error(..) takes 2 parameters to an integer * and seems to
return an array of chars *(third param). Fine but if I'm using snmp_send(..) it is \
just returning an integer. So why 2 params: int *pcliberr, int *psnmperr to \
snmp_sess_error in this case?
----------------------------------------------------------------------
Comment By: Dave Shield (dts12)
Date: 2001-04-05 03:07
Message:
Logged In: YES
user_id=88893
But 'snmp_sess_open()' does *not* return a
'snmp_session' pointer. It returns an opaque pointer,
which is intended for use with the SSI API routines.
This is not the same structure as the 'struct snmp_session'
returned by the traditional API (i.e. 'snmp_open()' and
friends).
These are two completely different sets of routines,
and you can't mix-and-match.
How are you actually sending the request?
Dave
----------------------------------------------------------------------
Comment By: Jean-François Beaulieu (jfbeaulieu)
Date: 2001-04-05 02:17
Message:
Logged In: YES
user_id=150034
I reopened the bug, see my comment 2001-04-05 09:13
----------------------------------------------------------------------
Comment By: Jean-François Beaulieu (jfbeaulieu)
Date: 2001-04-05 02:13
Message:
Logged In: YES
user_id=150034
The thitle should be "can a MSG_SET..." but anyway
Sorry, I wrote from memory; indeed, I'm using
struct snmp_session *ss;
ss = (snmp_session *) snmp_sess_open(&session);
[....]
snmp_sess_close(ss);
But I'm getting
error: not a valid OID
with snmp V2 this time. However with the same parameters and OID and ss \
ss=snmp_open(&session) [........]
snmp_close(ss)
everything is fine, there is no error message and the OID is changed. So according to \
your reply it is not a current
problem in net-snmp?
----------------------------------------------------------------------
Comment By: Wes Hardaker (hardaker)
Date: 2001-04-04 08:22
Message:
Logged In: YES
user_id=76242
You're supposde to use:
ss = snmp_sess_open(&session);
snmp_sess_close(ss);
instead.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=212694&aid=413715&group_id=12694
_______________________________________________
Net-snmp-support mailing list
Net-snmp-support@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/net-snmp-support
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic