/*
*
* U.S. Government Rights - Commercial software. Government users are subject to
* the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements.
*
*
* This distribution may include materials developed by third parties. Sun, Sun
* Microsystems, the Sun logo and Solaris are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
*/
/*
* Note: this file originally auto-generated by mib2c using :
* mib2c.iterate.conf,v 1.1.1.1 2003/03/26 18:12:29 pcarroll Exp $
*/
#include <stdio.h>
#include <errno.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include "demo_module_5.h"
/*
* MAXNAMELEN is the maximum permissible file name defined in param.h
*/
/** Initialize the me5FileTable table by defining its contents and how it's structured */
void
{
/* create the table structure itself */
/*
* if your table is read only, it's easiest to change the
* HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY
*/
return; /* mallocs failed */
}
/***************************************************
* Setting up the table's definition
*/
ASN_UNSIGNED, /* index: me5FileIndex */
0);
/* iterator access routines */
/***************************************************
* registering the table with the master agent
*/
DEBUGMSGTL(("initialize_table_me5FileTable",
"Registering table me5FileTable as a table iterator\n"));
}
/** Initializes the demo_module_5 module */
void
init_demo_module_5(void)
{
/* here we initialize all the tables we're planning on supporting */
/*
* These are the default files that are monitored by the module if there
* is no persistent data (file names to be monitored). This is likely
* during the first running on the module, when the .conf file does not
* have any file related information.
*/
/*
* Register for tokens from demo_module_5.conf file. The names of the
* tokens are demo5_file1,demo5_file2,demo5_file3,demo5_file4. The function
* demo5_load_tokens is called whenever these 4 tokens are encountered in
* demo_module_5.conf file.
*/
/*
* Register for a callback when all the configuration files are read. The
* callback function here is demo5_post_read_config
*/
}
/** returns the first data point within the me5FileTable table data.
Set the my_loop_context variable to the first data point structure
of your choice (from which you can find the next one). This could
be anything from the first node in a linked list, to an integer
pointer containing the beginning of an array variable.
Set the my_data_context variable to something to be returned to
you later that will provide you with the data to return in a given
row. This could be the same pointer as what my_loop_context is
set to, or something different.
The put_index_data variable contains a list of snmp variable
bindings, one for each index in your table. Set the values of
each appropriately according to the data matching the first row
and return the put_index_data variable at the end of the function.
*/
{
if (!firstFile) {
return NULL;
}
return put_index_data;
}
/** functionally the same as me5FileTable_get_first_data_point, but
my_loop_context has already been set to a previous value and should
be updated to the next in the list. For example, if it was a
linked list, you might want to cast it and the return
my_loop_context->next. The my_data_context pointer should be set
to something you need later and the indexes in put_index_data
updated again. */
{
if (!nextNode) {
return NULL;
}
return put_index_data;
}
/** handles requests for the me5FileTable table, if anything else needs to be done */
int
{
char *undofn;
int len;
continue;
/*
* the following extracts the my_data_context pointer set in the loop
* functions above. You can then use the results to help return data
* for the columns of the me5FileTable table in question
*/
} else {
}
continue;
} else {
} else {
}
}
/* extracts the information about the table from the request */
/* table_info->colnum contains the column number requested */
/*
* table_info->indexes contains a linked list of snmp variable
* bindings for the indexes of the table. Values in the list have
* been set corresponding to the indexes of the request
*/
if (table_info == NULL) {
continue;
}
/*
* the table_iterator helper should change all GETNEXTs into GETs
* for you automatically, so you don't have to worry about the
* GETNEXT case. Only GETs and SETs need to be dealt with here
*/
case MODE_GET:
switch (table_info->colnum) {
case COLUMN_ME5FILEINDEX:
break;
case COLUMN_ME5FILENAME:
break;
case COLUMN_ME5FILESIZE:
break;
case COLUMN_ME5FILEPERM:
break;
default:
/* We shouldn't get here */
"problem encountered in me5FileTable_handler: unknown column\n");
}
break;
case MODE_SET_RESERVE1:
/* set handling... */
switch (table_info->colnum) {
/*
* Check that the value being set is acceptable
*/
case COLUMN_ME5FILENAME:
return SNMP_ERR_WRONGTYPE;
}
return SNMP_ERR_WRONGVALUE;
}
break;
default:
/* We shouldn't get here */
"problem encountered in me5FileTable_handler: unknown column\n");
return SNMP_ERR_NOTWRITABLE;
}
break;
case MODE_SET_RESERVE2:
/*
* This is conventially where any necesary resources are
* allocated (e.g. calls to malloc)
*/
/* Store old info for undo later */
if (undofn) {
} else
free));
}
break;
case MODE_SET_FREE:
/*
* This is where any of the above resources are freed again
* (because one of the other values being SET failed for some
* reason).
*/
/*
* The netsnmp_free_list_data should take care of the alocated
* resources
*/
break;
case MODE_SET_ACTION:
/*
* Set the variable as requested. Note that this may need to be
* reversed, so save any information needed to do this.
*/
}
break;
case MODE_SET_COMMIT:
/*
* Everything worked, so we can discard any saved information,
* and make the change permanent (e.g. write to the config file).
* We also free any allocated resources.
*
*/
/* Persist the file information */
/*
* The netsnmp_free_list_data should take care of the alocated
* resources
*/
break;
case MODE_SET_UNDO:
/*
* Something failed, so re-set the variable to its previous value
* (and free any allocated resources).
*/
/******* Get the saved value ************/
}
}
break;
default:
"problem encountered in me5FileTable_handler: unsupported mode\n");
}
}
return SNMP_ERR_NOERROR;
}
/* Function to add a fileName to the linked list of files */
int
{
return FALSE;
}
/*
* Unable to get the file information, it could be more than file not
* exists if (errno == ENOENT) { return FALSE; } return FALSE;
*/
}
}
} else {
}
return TRUE;
}
/*
* Function to change the file for a particular index. This function is
* called when a snmp set request arrives to change the list of files being
* monitored.
*/
int
{
return FALSE;
}
switch(fileIndex) {
case 1:
case 2:
case 3:
case 4:
}
return TRUE;
}
}
return FALSE;
}
/* Function to return the filename corresponding to an index */
char *
{
}
}
return NULL;
}
/*
* Function that is called whenever interested tokens are encountered in
* demo_module_5.conf file. The token values represent the persistent filename
* information.
*/
void
{
} else {
/* Do Nothing */
}
return;
}
/*
* Function that persists file information. This is called by the agent
* whenever data needs to be persisted.
*/
int
demo5_persist_data(int a, int b, void *c, void *d)
{
}
/*
* Callback function that is called after all the configuration files are
* read by the agent. See init_demo_module_5 function to see how this
* callback is specified.
*
* When this function is called, any persistent file information would have been
* read into the module. These files are added to the file list.
*
* The callback function to persist data (demo5_persist_data) is registered.
*/
int
demo5_post_read_config(int a, int b, void *c, void *d)
{
}