[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
| Title: | SNMP | 
|  | 
| Moderator: | MKNME::DANIELE | 
|  | 
| Created: | Mon Apr 02 1990 | 
| Last Modified: | Tue May 06 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 289 | 
| Total number of notes: | 900 | 
I can't seem to get the esnmp API callback function to work.  The callback
function does get invoked; however, referencing the parameters that were
passed
to it (int level and char* msg) seems wrong.  The code and output is below.
I'm compiling on a DU V3.2G AS 8200.
TIA!
-Keith Austin
esnmptrap.c
===========
/* cc -o esnmptrap esnmptrap.c -lesnmp */
#include <esnmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
void log_handler ( int level, char *msg );
int main(void)
{
int status = 0;
int rc = ESNMP_LIB_NOTOK;
int esnmp_subsocket = 0;
char conn_name[15];
        set_debug_level ( ERROR | WARNING | EXTERN_LOG,
                                   (LOG_CALLBACK_ROUTINE) log_handler ) ;
        sprintf(conn_name,"pid_%d",(int)getpid());
        status = esnmp_init(&esnmp_subsocket, conn_name);
        rc = esnmp_poll();
        ESNMP_LOG( WARNING, ("KEA"));
        esnmp_term();
        exit(0);
}
void log_handler ( int level, char* msg ) 
{
         printf("Level: ***%d***  Msg: ***%s***\n\n", level, msg);
         printf("Level: ***%d***  Msg: ***%s***\n", level, msg-25);
}
Actual Output
=============
Level: ***536865600***  Msg: ***EAdata***
Level: ***536865600***  Msg: ****EAdata***
.c line 26: KEAdata***
Expected Output
===============
Level: ***4096*** Msg: ***KEA***
Level: ***4096*** Msg: ***Some-String***
[Posted by WWW Notes gateway]
| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 282.1 |  | SMURF::DANIELE |  | Fri Feb 28 1997 09:52 | 14 | 
|  | From esnmp.h:
/* structure passed to the external log callback routine */
typedef struct _log_callback {
        int log_level;       /* TRACE, WARNING, ERROR */
        char *text;          /* pointer to buffer containing text of message */
        /* Note: Additional fields may be added in the future */
} LOG_CALLBACK;
typedef void(*LOG_CALLBACK_ROUTINE)(LOG_CALLBACK *);
So your routine is passed the address of LOG_CALLBACK.
Mike
 |