nfs-ganesha 1.4
Classes | Defines | Typedefs | Enumerations | Functions

snmp_adm.h File Reference

snmp_adm.h : snmp_adm API More...

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>

Go to the source code of this file.

Classes

union  type_union_e
struct  register_scal_s
struct  register_get_set_s
struct  register_proc_s

Defines

#define SNMP_ADM_ACCESS_RO   HANDLER_CAN_RONLY
#define SNMP_ADM_ACCESS_RW   HANDLER_CAN_RWRITE
#define TRIGGER_OID   3
#define INPUT_OID   0
#define OUTPUT_OID   1
#define SNMP_ADM_MAX_STR   4096

Typedefs

typedef union type_union_e snmp_adm_type_union
typedef struct register_scal_s register_scal
typedef int(* fct_get )(snmp_adm_type_union *param, void *opt_arg)
typedef int(* fct_set )(const snmp_adm_type_union *param, void *opt_arg)
typedef struct register_get_set_s register_get_set
typedef int(* proc )(const snmp_adm_type_union **tab_in, snmp_adm_type_union **tab_out, void *opt_arg)
typedef struct register_proc_s register_proc
typedef int(* trap_test )(void *arg)

Enumerations

enum  { NAME_OID, DESC_OID, VAR_OID }
enum  { TYPE_OID, VAL_OID }
enum  {
  STAT_OID, LOG_OID, CONF_OID, PROC_OID,
  NUM_BRANCH
}
enum  type_number {
  SNMP_ADM_INTEGER, SNMP_ADM_STRING, SNMP_ADM_IP, SNMP_ADM_REAL,
  SNMP_ADM_BIGINT, SNMP_ADM_TIMETICKS
}
enum  trigger_state { SNMP_ADM_READY, SNMP_ADM_PROGRESS, SNMP_ADM_DONE, SNMP_ADM_ERROR }

Functions

int snmp_adm_config_daemon (char *agent_x_socket, char *filelog, int prod_id)
int snmp_adm_register_scalars (int branch, register_scal *tab, int len)
int snmp_adm_register_get_set_function (int branch, register_get_set *tab, int len)
int snmp_adm_register_procedure (register_proc *tab, int len)
int snmp_adm_unregister (char *label)
void snmp_adm_send_trap (unsigned char type, snmp_adm_type_union value)
int snmp_adm_register_poll_trap (unsigned int second, trap_test test_fct, void *args, unsigned char type, snmp_adm_type_union value)
int snmp_adm_start ()
void snmp_adm_close ()
void snmp_adm_log (char *format,...)

Detailed Description

snmp_adm.h : snmp_adm API

Author:
Cedric CABESSA

Definition in file snmp_adm.h.


Define Documentation

#define INPUT_OID   0

OID number for inputs.

Definition at line 67 of file snmp_adm.h.

#define OUTPUT_OID   1

OID number for outputs.

Definition at line 69 of file snmp_adm.h.

#define SNMP_ADM_ACCESS_RO   HANDLER_CAN_RONLY

Read only value

Definition at line 16 of file snmp_adm.h.

#define SNMP_ADM_ACCESS_RW   HANDLER_CAN_RWRITE

Read write value

Definition at line 18 of file snmp_adm.h.

#define SNMP_ADM_MAX_STR   4096

Maximum length for a string

Definition at line 88 of file snmp_adm.h.

#define TRIGGER_OID   3

OID number for trigger.

Definition at line 65 of file snmp_adm.h.


Typedef Documentation

typedef int(* fct_get)(snmp_adm_type_union *param, void *opt_arg)

A getter.

Parameters:
paramthe function have to fill the value.
opt_argoptionnal argument, the optional argument set during registration is available here.
See also:
register_get_set_s
Returns:
value should be 0 on success.

Definition at line 122 of file snmp_adm.h.

typedef int(* fct_set)(const snmp_adm_type_union *param, void *opt_arg)

A setter.

Parameters:
paramthe function have to read this value to change internal data.
opt_argoptionnal argument, the optional argument set during registration is available here.
See also:
register_get_set_s
Returns:
value should be 0 on success.

Definition at line 131 of file snmp_adm.h.

typedef int(* proc)(const snmp_adm_type_union **tab_in, snmp_adm_type_union **tab_out, void *opt_arg)

A procedure.

Parameters:
tab_inArray of inputs. The length is set during registration.
tab_inArray of outputs. The length is set during registration.
opt_argoptionnal argument, the optional argument set during registration is available here.
See also:
register_get_set_s
Returns:
value should be 0 on success.

Definition at line 155 of file snmp_adm.h.

get/set information.

Procedure information.

Scalar information.

The type of variables handle by the library.

typedef int(* trap_test)(void *arg)

A trap testing function.

Parameters:
argargument of the function.
See also:
snmp_adm_register_poll_trap.
Returns:
if not 0, the trap is sent.

Definition at line 178 of file snmp_adm.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
NAME_OID 
DESC_OID 
VAR_OID 

Definition at line 20 of file snmp_adm.h.

anonymous enum

A var is made of this two

Enumerator:
TYPE_OID 

contain a string with the type

VAL_OID 

contain the value

Definition at line 28 of file snmp_adm.h.

anonymous enum
Enumerator:
STAT_OID 
LOG_OID 
CONF_OID 
PROC_OID 
NUM_BRANCH 

Definition at line 34 of file snmp_adm.h.

The different states of the trigger branch of a procedure. ROOT.prodid.PROC_OID.numproc.TRIGGER_OID.

Enumerator:
SNMP_ADM_READY 

A set (whatever the value) will call the procedure.

SNMP_ADM_PROGRESS 

Procedure not terminated. Cannot set trigger or inputs

SNMP_ADM_DONE 

Procedure terminated with success, user can read values. User must set the value to 0 to pass in READY state. Other values are ignored. Inputs cannot be set.

SNMP_ADM_ERROR 

like DONE but procedure was terminated with error

Definition at line 75 of file snmp_adm.h.

Enum of available type number

Enumerator:
SNMP_ADM_INTEGER 

32 bits integer

SNMP_ADM_STRING 

null terminated

SNMP_ADM_IP 

Ip address (4 octets in network byte-order)

SNMP_ADM_REAL 

64 bits floating point (double)

SNMP_ADM_BIGINT 

64 bits integer

SNMP_ADM_TIMETICKS 

Match ASN_TIMETICKS meaning hundredths of a second since some epoch (not EPOCH). It is encoded in a unsigned int, so time range is quite short. You should use description field to identifies the reference epoch.

WARNING As people use second in their code, values are converted in second. The value pointed for a register have to be in second (it is probably what you already use), but the set request have to be in 1/100s (as SNMP says)

Definition at line 47 of file snmp_adm.h.


Function Documentation

void snmp_adm_close ( )

Close the snmp thread.

Definition at line 711 of file libdaemon.c.

int snmp_adm_config_daemon ( char *  agent_x_socket,
char *  filelog,
int  prod_id 
)

Configure daemon. Should be called before registering values.

Parameters:
agent_x_socketagentX socket name (eg:"/tmp/agentx" or "tcp:192.168.67.19:31415"). This parametre should be set according to the snmpd config.
prod_idproduct id, unique identifier of this daemon.
filelogfile to record log messages or "syslog".
Returns:
0 on success.

Configure daemon. Should be called before registering values.

Parameters:
agent_x_socketagentX socket name (eg:"/tmp/agentx/master" or "tcp:192.168.67.19:31415"). This parametre should be set according to the snmpd config.
prod_idproduct id, unique identifier of this daemon.
filelogfile to record log messages or "syslog".
Returns:
0 on success.

Definition at line 426 of file libdaemon.c.

void snmp_adm_log ( char *  format,
  ... 
)

Log a message.

See also:
init_daemon.

Definition at line 794 of file libdaemon.c.

int snmp_adm_register_get_set_function ( int  branch,
register_get_set tab,
int  len 
)

Register get/set functions. Note for label and desc in snmp_adm_register_* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
branchthe branch number (STAT_OID or CONF_OID).
tabthe functions to register.
lenthe array's length.
Returns:
0 on success.

Register get/set functions. Note for label & desc in register_scal* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
branchthe branch number (STAT_OID or CONF_OID).
tabthe functions to register.
lenthe array's length.
Returns:
0 on success.

Definition at line 515 of file libdaemon.c.

int snmp_adm_register_poll_trap ( unsigned int  second,
trap_test  test_fct,
void *  args,
unsigned char  type,
snmp_adm_type_union  value 
)

Register a polling fonction.

Parameters:
secondpolling time.
test_fctfonction called each "second", send a trap if return 1.
argsarguments of test_fct.
typetype of the variable.
valuevalue of the variable.
Returns:
0 on success.

Register a polling fonction.

Parameters:
secondpolling time.
test_fctfonction called each "second", send a trap if return 1.
argsarguments of test_fct.
typetype of the variable.
valuevalue of the variable.

Definition at line 661 of file libdaemon.c.

int snmp_adm_register_procedure ( register_proc tab,
int  len 
)

Register procedures. Note for label and desc in snmp_adm_register_* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
tabthe procedures to register.
lenthe array's length.
Returns:
0 on success.

Register procedures. Note for label & desc in register_scal* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
tabthe procedures to register.
lenthe array's length.
Returns:
0 on success.

Definition at line 547 of file libdaemon.c.

int snmp_adm_register_scalars ( int  branch,
register_scal tab,
int  len 
)

Register scalars. Note for strings : string provided in code MUST be readonly (ACCESS_RO). string MUST be allocated with SNMP_ADM_MAX_STR. Note for label and desc in snmp_adm_register_* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
branchthe branch number (STAT_OID or CONF_OID).
tabthe values to register.
lenthe array's length.
Returns:
0 on success.

Register scalars. Note for strings : string provided in code MUST be readonly (ACCESS_RO). string MUST be allocated with SNMP_ADM_MAX_STR. Note for label & desc in register_scal* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
branchthe branch number (STAT_OID or CONF_OID).
tabthe values to register.
lenthe array's length.
Returns:
0 on success.

Definition at line 485 of file libdaemon.c.

void snmp_adm_send_trap ( unsigned char  type,
snmp_adm_type_union  value 
)

Send a SNMPv2 trap.

Parameters:
typetype of the variable.
valuevalue of the variable.
Returns:
0 on success.

Send a SNMPv2 trap.

Parameters:
typetype of the variable.
valuevalue of the variable.

Definition at line 607 of file libdaemon.c.

int snmp_adm_start ( )

Launch the thread.

Returns:
1: nothing was recorded. 2: daemon not configured, or problem with snmpd. 3: cannot create the thread.
0 on success.

Launch the thread. FIXME after this, nothing should be registered, net-snmp bug?

Returns:
1: nothing was recorded. 2: daemon not configured, or problem with snmpd. 3: cannot create the thread.

Definition at line 763 of file libdaemon.c.

int snmp_adm_unregister ( char *  label)

Unregister an instance.

Parameters:
labelname of the instance.
Returns:
0 on success.

Definition at line 572 of file libdaemon.c.