int ksnmp_init (void) ---------------------
This function initializes SNMP for KLOE. It calls ksnmp_getenv to read all the appropriate environmental variables.
return value: KSNMP_OK, KSNMP_ERR_NOMIBFILE if the environmental variable MIBFILE is not defined.
void ksnmp_end (void) ---------------------
This function should be called at the end of
each program using the ksnmp libraries.
[ Top
| Index
| Bottom
| Source ]
struct snmp_pdu *ksnmp_get_next(struct snmp_session *ss, char *varname, int rootlen) -----------------------------------------------------------
This function sends a GETNEXT_REQ_MSG request to an SNMP daemon on a remote host.
ss: pointer to the SNMP session varname: name of the actual variable rootlen: length of the string containing the root of the desired MIB subtree return value: pointer to the pdu structure containing the next variable name and value, NULL if there are no other variables or in case of error.
struct snmp_pdu *ksnmp_get(struct snmp_session *ss, char **names, int n_names) -----------------------------------------------------
This function retrieves the values of n_names variables (whose names are in the vector names) using the SNMP session ss
ss: pointer to the SNMP session names: pointer to a vector of strings containing the names of the required variables n_names: number of required variables. return value: pointer to the pdu structure containing a list of variable names and values
struct snmp_pdu *ksnmp_set(struct snmp_session *ss, char **names, int n_names, int *vartype, char **values) -------------------------------------------------------
This function sets n_names variables (whose names are in the vector names) to the values in the vector values using the SNMP session ss. It can be used to send run control commands and requires ss to be a private SNMP session; in the KLOE standard environment it is called by the ksnmp_send_message.
ss: pointer to the SNMP session names: pointer to a vector of strings containing the names of the required variables n_names: number of required variables vartype: type of variables to be set values: pointer to a vector of strings containing the values of the required variables to be set return value: pointer to the pdu structure containing a list of variable names and values
int ksnmp_getenv (void) -----------------------
This function tests the environmental variables that can superseed the default values of the parameters. The environmental variable MIBFILE must be defined. This function is called by ksnmp_init and should not be used directly.
return value : KSNMP_OK if success, KSNMP_ERR_NOMIBFILE if MIBFILE is not defined.
int ksnmp_map_init (void) -------------------------
This function initializes the list containing the network map. The user must not call this function.
return value : an error code, KSNMP_OK if succeded, KSNMP_ERR_ALLOCFAIL if the network map allocation failed.
void ksnmp_map_close_knode_sessions (void) ------------------------------------------
This function closes all the private (or public)
sessions on the "KLOE nodes".
[ Top
| Index
| Bottom
| Source ]
void ksnmp_map_close_sessions (void) ------------------------------------
This function closes all the snmp sessions opened,
both on KLOE nodes and on the gigaswitch and arp_server.
[ Top
| Index
| Bottom
| Source ]
void ksnmp_map_free_network_map (void) --------------------------------------
This function is used to free the memory allocated
by the network map.
[ Top
| Index
| Bottom
| Source ]
int ksnmp_map_print_network_map (FILE *output, struct network_map *map) ----------------------------------------------------------------------
This function is useful for debugging or writing the network map to the disk.
output : pointer to the output file descriptor. stdout and stderr can be used. map : pointer to the list containing the network map. return value : KSNMP_OK if succeded, KSNMP_WAR_MAPNOTALL or KSNMP_WAR_EMPTYMAP if the map is not allocated or it is empty.
int ksnmp_map_init_knode_list (void) ------------------------------------
This function reads, if it exists, the KLOE node authorization file, putting the addresses of that nodes in a vector.
return value : KSNMP_OK if succeded, one of the following: KSNMP_ERR_KNFNOTOPEN, KSNMP_WAR_NOKNFILE otherwise.
int ksnmp_map_init_srvs (void) ------------------------------
This function creates two snmp sessions on the gigaswitch
and on the arp server.
[ Top
| Index
| Bottom
| Source ]
int ksnmp_map_network (void) ----------------------------
This function fills a map of a "KLOE-like" network.
return value: KSNMP_OK if success, an error code otherwise.
int ksnmp_map_network_remap (void) ----------------------------------
This function destroys the informations in the actual network map and refills it with up-to-date informations.
return value: KSNMP_OK if success or any error returned by ksnmp_map_network.
struct network_map *ksnmp_map_retrieve_network_map (void) ---------------------------------------------------------
This function allows the user to retrieve the pointer to the actual network map.
return value: pointer to the map
struct snmp_session *ksnmp_map_get_arp_ss (void) ------------------------------------------------
This function allows the user to retrieve the pointer to the arp server session.
return value: pointer to the arp server session
struct snmp_session *ksnmp_map_get_switch_ss (void) ---------------------------------------------------
This function allows the user to retrieve the pointer to the arp server session.
return value: pointer to the gigaswitch server session
int ksnmp_send_message (char *message, char *process, struct snmp_session *node_ss, int ackflag) ------------------------------------------------------------------
This function sends a generic message to a generic process in the DAQ system. It is useful for all the application, in particular to implement the ask command. If the sender has an snmp session opened on the remote node, it can supply it and the execution is faster; nevertheless, if the snmp session is not supplied (it can be NULL) it can be opened and closed before and after the execution of the command. If this operation fails, KSNMP_ERROR is returned. If ackflag is KSNMP_ACK_WAIT, the function waits for the completion of command execution on the remote node or reports an error code (KSNMP_ACK_TIMEOUT_CODE) in case of timeout. If the processing of the command failed on the remote node, KSNMP_ACK_FAULT is returned. The process address can be in the form <name> if the caller supplies node_ss or <name>@<node> otherwise. Warning: this function supports only messages to remote process. If the caller does not supply node_ss or <node> in process name it returns an error code (KSNMP_ERROR).
message: the message to be sent to a remote process process: the address of a process in the form <procname>@<node> or <procname> node_ss: address of an snmp session opened on remote node ackflag: flag to ask the function to wait for acknowledgement or not return value: an error code or KSNMP_ACK_OK if success
int ksnmp_get_ack (char *message, char *process, struct snmp_session *node_ss) ------------------------------------------------
This function get the acknowledgement referred to a generic message previously sent to a generic process in the DAQ system. It is useful for all the application, in particular to implement a parallel ask command or to receive acknowledgements when a command has been sent to several nodes and processes without waiting for the acknowledgement. If the sender has an snmp session opened on the remote node, it can supply it and the execution is faster; nevertheless, if the snmp session is not supplied (it can be NULL) it can be opened and closed before and after the execution of the command. If this operation fails, KSNMP_ERROR is returned. This function waits for the first-level acknowledgement and the completion of command execution on the remote node or reports an error code (KSNMP_ACK_TIMEOUT_CODE) in case of timeout. If the processing of the command failed on the remote node, KSNMP_ACK_FAULT is returned. The process address can be in the form <name> if the caller supplies node_ss or <name>@<node> otherwise. Warning: this function supports only messages to remote process. If the caller does not supply node_ss or <node> in process name it returns an error code (KSNMP_ERROR).
message: the message to send to a remote process process: the address of a process in the form <procname>@<node> or <procname> node_ss: address of an snmp session opened on remote node return value: an error code or KSNMP_ACK_OK if success.
int ksnmp_wait_for_var_val (struct snmp_session *ss, char *var, char *val, int type, char *exit_cond) -----------------------------------------------------------------
This function tests the variable var on remote node until it assumes the value val. A timeout is implemented. This is useful to implement an acknowledgement mechanism. To avoid to wait the timeout, an exit condition (i.e. a "fault" value) can be passed to this function.
ss: address of the snmp session opened on the remote node var: variable name val: variable value to wait for type: type of the variable var exit_cond: an exit condition for the function return value: KSNMP_ACK_OK or KSNMP_ACK_TIMEOUT.
int ksnmp_parse_message (char *message, char *command, char *args) ------------------------------------------------------------------
This function separates a command from the string containings its arguments.
message: a message containing a command and its arguments command: command to send args: a string containing the arguments of the command return value: length of the command string
int ksnmp_parse_procname (char *process, char *procname, char *node) --------------------------------------------------------------------
This function separates a process name from a node name (process is in the form <procname>@<node> or <procname>).
process: the address of a process in the form <procname>@<node> or <procname> procname: the process name node: a string containing the node name or address return value: length of the process name string.
struct snmp_session *ksnmp_session_init(char *hostname, char *community, int port) ----------------------------------------------------------------------
This function initializes an snmp session on an host with the given community name. The pointer to the snmp_session is automatically added to an hidden open session list from which the user can retrieve it using ksnmp_session_find.
hostname: name of the host on which the user wants to open the SNMP session. community: community name used. Using the public community, only get and getnext functions can be performed; however, private communities allow to perform set functions. port: the remote port can be redefined to overwrite the standard port, otherwise 0. Return value: pointer to the snmp session. It is a structure identifying the session and must be used when a set or get command are issued to identify the remote host. If an error occurred, NULL is returned.