snmpSIPStatusCodesTable.h

00001 /*
00002  * $Id$
00003  *
00004  * SNMPStats Module 
00005  * Copyright (C) 2006 SOMA Networks, INC.
00006  * Written by: Jeffrey Magder (jmagder@somanetworks.com)
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify it
00011  * under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023  * USA
00024  *
00025  * History:
00026  * --------
00027  * 2006-11-23 initial version (jmagder)
00028  * 2007-02-16 Moved all OID registrations from the experimental branch to 
00029  *            OpenSER's IANA assigned enterprise branch. (jmagder)
00030  * 
00031  * Note: this file originally auto-generated by mib2c using
00032  * mib2c.array-user.conf
00033  *
00034  * The file implements the openserSIPStatusCodesTable.  For a full description
00035  * of the table, please see the OPENSER-SIP-COMMON-MIB.
00036  *
00037  * This file consists of many more functions than the other header files.  
00038  * This is because this table is writable, bringing a lot of SNMP overhead.
00039  *
00040  * Most of the contents are auto-generated (aside from white space and comment
00041  * changes), and can be ignored.  The functions that have been modified are:
00042  *
00043  * 1) openserSIPStatusCodesTable_create_row()
00044  *
00045  * 2) openserSIPStatusCodesTable_extract_index() 
00046  *
00047  * 3) openserSIPStatusCodesTable_can_[activate|deactivate|delete]()
00048  *   
00049  * 4) openserSIPStatusCodesTable_set_reserve1()
00050  *
00051  * 5) openserSIPStatusCodesTable_get_value()
00052  *
00053  * Full details can be found in openserSIPStatusCodesTable.c.  You can safely
00054  * ignore the other functions.
00055  *
00056  */
00057 
00058 #ifndef OPENSERSIPSTATUSCODESTABLE_H
00059 #define OPENSERSIPSTATUSCODESTABLE_H
00060 
00061 #ifdef __cplusplus
00062 extern "C" {
00063 #endif
00064 
00065         
00066 #include <net-snmp/net-snmp-config.h>
00067 #include <net-snmp/library/container.h>
00068 #include <net-snmp/agent/table_array.h>
00069 
00070 #include "../../config.h"
00071 
00072 /* 
00073  * The structure has been mostly auto-generated, but its semantics have been
00074  * changed.  
00075  *
00076  * Specifically, the openserSIPStatusCodeIns and openserSIPStatusCodeOuts
00077  * variables don't store the total number of messages sent or received from the
00078  * system at the time of a SNMP GET request.  Instead, they store the number of
00079  * messages in or out (with respect to the message code specified by
00080  * openserSIPStatusCodeValue) at the time of the rows *creation*. 
00081  *
00082  * When the get request is received, the statistics framework will be queried,
00083  * and these values subtracted from that query.  This effectively gives us how
00084  * many of the given message codes have occured since the creation of the row,
00085  * insead of since OpenSER first loaded up.
00086  */
00087 typedef struct openserSIPStatusCodesTable_context_s {
00088         
00089         /* The container interface requires that this be first. */
00090         netsnmp_index index; 
00091 
00092         /* The first index. */
00093         unsigned long openserSIPStatusCodeMethod;
00094         
00095         /* The second index, specifying which status code to monitor */
00096         unsigned long openserSIPStatusCodeValue;
00097 
00098         /* Stores the current status code value - startingInStatusCodeValue 
00099          * (at the time this row was created)  */
00100         unsigned long openserSIPStatusCodeIns;
00101 
00102         /* Stores the current status code value - startingOutStatusCodeValue 
00103          * (at the time this row was created)  */
00104         unsigned long openserSIPStatusCodeOuts;
00105 
00106         /* Initialized to zero at startup to signify uninitialized.  This can
00107          * only be assigned createAndGo(4) at this point.  It can also be 
00108          * assigned destroy(6), but only if the value is in the active(1) state.
00109          */
00110         long openserSIPStatusCodeRowStatus;
00111 
00112         /* Added automatically, but not really used by us. */
00113         void * data;
00114 
00115         long startingInStatusCodeValue;
00116         long startingOutStatusCodeValue;
00117 
00118 } openserSIPStatusCodesTable_context;
00119 
00120 /* 
00121  * Initializes the openserSIPStatusCodesTable module.  This step is easier
00122  * than in the other tables because there is no table population.  All table
00123  * population takes place during run time. 
00124  */
00125 void init_openserSIPStatusCodesTable(void);
00126 
00127 /*
00128  * Initialize the openserSIPStatusCodesTable table by defining how it is
00129  * structured. 
00130  *
00131  * This function is mostly auto-generated.
00132  */
00133 void initialize_table_openserSIPStatusCodesTable(void);
00134 
00135 /*
00136  * This function is called to handle SNMP GET requests.  
00137  *
00138  * The row which this function is called with, will store a message code.  The
00139  * function will retrieve the 'number of messages in' and 'number of messages
00140  * out' statistic for this particular message code from the statistics
00141  * framework.  
00142  *
00143  * The function will then subtract from this value the value it was initialized
00144  * with when the row was first created.  In this sense, the row shows how many
00145  * ins and how many outs have been received (With respect to the message code)
00146  * since this row was created. 
00147  */
00148 int   openserSIPStatusCodesTable_get_value(netsnmp_request_info *, 
00149                 netsnmp_index *, netsnmp_table_request_info *);
00150 
00151 const openserSIPStatusCodesTable_context * 
00152         openserSIPStatusCodesTable_get_by_idx(netsnmp_index *);
00153 
00154 const openserSIPStatusCodesTable_context * 
00155         openserSIPStatusCodesTable_get_by_idx_rs(netsnmp_index *, 
00156                         int row_status);
00157 
00158 /* oid declarations */
00159 extern oid openserSIPStatusCodesTable_oid[];
00160 extern size_t openserSIPStatusCodesTable_oid_len;
00161 
00162 #define openserSIPStatusCodesTable_TABLE_OID OPENSER_OID,3,1,1,1,5,1
00163         
00164 /* column number definitions for table openserSIPStatusCodesTable */
00165 #define COLUMN_OPENSERSIPSTATUSCODEMETHOD    1
00166 #define COLUMN_OPENSERSIPSTATUSCODEVALUE     2
00167 #define COLUMN_OPENSERSIPSTATUSCODEINS       3
00168 #define COLUMN_OPENSERSIPSTATUSCODEOUTS      4
00169 #define COLUMN_OPENSERSIPSTATUSCODEROWSTATUS 5
00170 
00171 #define openserSIPStatusCodesTable_COL_MIN 3
00172 #define openserSIPStatusCodesTable_COL_MAX 5
00173 
00174 /* Handles index extraction for row creation */
00175 int openserSIPStatusCodesTable_extract_index( 
00176                 openserSIPStatusCodesTable_context * ctx, netsnmp_index * hdr );
00177 
00178 /* Handle RESERVE1 and RESERVE2 phases of an SNMP SET */
00179 void openserSIPStatusCodesTable_set_reserve1( netsnmp_request_group * );
00180 void openserSIPStatusCodesTable_set_reserve2( netsnmp_request_group * );
00181 
00182 /* Handle the SET and ACTION phases of an SNMP SET */
00183 void openserSIPStatusCodesTable_set_action( netsnmp_request_group * );
00184 void openserSIPStatusCodesTable_set_commit( netsnmp_request_group * );
00185 
00186 /* Handle Resource cleanup if the ACTION or RESERVE1/RESERVE2 phases of an
00187  * SNMPSET fail */
00188 void openserSIPStatusCodesTable_set_free( netsnmp_request_group * );
00189 void openserSIPStatusCodesTable_set_undo( netsnmp_request_group * );
00190 
00191 openserSIPStatusCodesTable_context * openserSIPStatusCodesTable_duplicate_row(
00192                 openserSIPStatusCodesTable_context* );
00193 
00194 
00195 netsnmp_index * openserSIPStatusCodesTable_delete_row( 
00196                 openserSIPStatusCodesTable_context* );
00197 
00198 /* Used to check if there is a reason why a row can't be activated 
00199  * (There is no reason in our implementation)
00200  */
00201 int openserSIPStatusCodesTable_can_activate(
00202                 openserSIPStatusCodesTable_context *undo_ctx,
00203                 openserSIPStatusCodesTable_context *row_ctx,
00204                 netsnmp_request_group * rg);
00205 
00206 /* Used to check if there is a reason why a row can't be deactivated 
00207  * (There is no reason in our implementation)
00208  */
00209 int openserSIPStatusCodesTable_can_deactivate(
00210                 openserSIPStatusCodesTable_context *undo_ctx,
00211                 openserSIPStatusCodesTable_context *row_ctx,
00212                 netsnmp_request_group * rg);
00213 
00214 /* Used to check if there is a reason why a row can't be deleted
00215  * (There is no reason in our implementation)
00216  */
00217 int openserSIPStatusCodesTable_can_delete(
00218                 openserSIPStatusCodesTable_context *undo_ctx,
00219                 openserSIPStatusCodesTable_context *row_ctx,
00220                 netsnmp_request_group * rg);
00221         
00222         
00223 openserSIPStatusCodesTable_context * 
00224                 openserSIPStatusCodesTable_create_row( netsnmp_index* );
00225 
00226 
00227 #ifdef __cplusplus
00228 }
00229 #endif
00230 
00231 #endif