Dear All:
I meet a problem of how to debug snmp codes, my version is net-snmp-5.3.1
and the environment is Fedora 5.
the following is my codes which comes from the net-snmp web sites samples:
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.old-api.conf,v 1.6 2006/04/18 17:36:16 hardaker Exp $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "ustScalarSet.h"
oid ustScalarSet_variables_oid[] =
{ 1, 3, 6, 1, 4, 1, 2021, 13, 4242, 1, 1 };
struct variable7 ustScalarSet_variables[] = {
#define USTSSSIMPLESTRING 1
{USTSSSIMPLESTRING, ASN_OCTET_STR, RWRITE, var_ustScalarSet, 1, {1}},
#define USTSSSECONDSSINCECHANGED 2
{USTSSSECONDSSINCECHANGED, ASN_TIMETICKS, RONLY, var_ustScalarSet, 1,
{2}},
};
void
init_ustScalarSet(void)
{
DEBUGMSGTL(("ustScalarSet", "Initializing\n"));
REGISTER_MIB("ustScalarSet", ustScalarSet_variables, variable4,
ustScalarSet_variables_oid);
unsigned char *
var_ustScalarSet(struct variable *vp,
oid * name,
size_t *length,
int exact, size_t *var_len, WriteMethod ** write_method)
{
static long long_ret;
static u_long ulong_ret;
static unsigned char string[SPRINT_MAX_LEN];
static oid objid[MAX_OID_LEN];
static struct counter64 c64;
if (header_generic(vp, name, length, exact, var_len, write_method)
== MATCH_FAILED)
return NULL;
switch (vp->magic) {
case USTSSSIMPLESTRING:
*write_method = write_ustSSSimpleString;
printf("check some thing");
return (u_char *);
case USTSSSECONDSSINCECHANGED:
printf("check error , this is snmpget");
return (u_char *);
default:
ERROR_MSG("This is main check ");
}
return NULL;
}
int
write_ustSSSimpleString(int action,
u_char * var_val,
u_char var_val_type,
size_t var_val_len,
u_char * statP, oid * name, size_t name_len)
{
char value;
int size;
switch (action) {
case RESERVE1:
if (var_val_type != ASN_OCTET_STR) {
fprintf(stderr, "write to ustScalarSet not ASN_OCTET_STR\n");
return SNMP_ERR_WRONGTYPE;
}
if (var_val_len > sizeof(char)) {
fprintf(stderr, "write to ustScalarSet: bad length\n");
return SNMP_ERR_WRONGLENGTH;
}
break;
case RESERVE2:
size = var_val_len;
value = *(char *) var_val;
break;
case FREE:
break;
case ACTION:
break;
case UNDO:
break;
case COMMIT:
break;
}
return SNMP_ERR_NOERROR;
}
After I give the command as belowed:
gcc -I/usr/local/include -fPIC -shared –c –o ustScalarSet.c ustScalarSet.o
gcc -I/usr/local/include -fPIC -shared –o ustScalarSet.so ustScalarSet.o
and add a line to snmpd.conf : dlmod ustScalarSet
/usr/local/temp/ustScalarSet.so
After I pass the gcc compile, when I use snmpget, the message show there
doesn't
exist such objet, I don't know why, and how to give the exact command to
debug the
above codes and how to find out the problem where it is . can anybody who
has the
experience of building snmp agent can share the experience or any
instruction.
Thank you.
Best Regards,
Clement Hsu
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders