openserObjects.c

Go to the documentation of this file.
00001 /*
00002  * $Id: openserObjects.c 5769 2009-03-26 21:47:59Z osas $
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  *            Kamailio's IANA assigned enterprise branch. (jmagder)
00030  * 
00031  * Note: this file originally auto-generated by mib2c using
00032  *    : mib2c.scalar.conf,v 1.9 2005/01/07 09:37:18 dts12 Exp $
00033  *
00034  * This file defines all registration and handling of all scalars defined in the
00035  * OPENSER-MIB.  Please see OPENSER-MIB for the complete descriptions of the
00036  * individual scalars.
00037  */
00038 
00039 #include <string.h>
00040 
00041 #include "openserObjects.h"
00042 
00043 #include "../../dprint.h"
00044 #include "../../statistics.h"
00045 #include "../../config.h"
00046 
00047 #include "snmpstats_globals.h"
00048 #include "utilities.h"
00049 #include "alarm_checks.h"
00050 
00051 /* 
00052  * Initializes the openserObjects module.  This involves:
00053  *
00054  *  - Registering all OID's
00055  *  - Setting up handlers for all OID's
00056  *
00057  * This function is mostly auto-generated.
00058  */
00059 void init_openserObjects(void)
00060 {
00061    static oid openserMsgQueueDepth_oid[]            =  
00062       { OPENSER_OID,3,1,3,1,2,3,1 };
00063 
00064    static oid openserMsgQueueMinorThreshold_oid[]   = 
00065       { OPENSER_OID,3,1,3,1,2,3,2 };
00066 
00067    static oid openserMsgQueueMajorThreshold_oid[]   = 
00068       { OPENSER_OID,3,1,3,1,2,3,3 };
00069 
00070    static oid openserMsgQueueDepthAlarmStatus_oid[] = 
00071       { OPENSER_OID,3,1,3,1,2,4,1 };
00072   
00073    static oid openserMsgQueueDepthMinorAlarm_oid[]  = 
00074       { OPENSER_OID,3,1,3,1,2,4,2 };
00075 
00076    static oid openserMsgQueueDepthMajorAlarm_oid[]  = 
00077       { OPENSER_OID,3,1,3,1,2,4,3 };
00078 
00079    static oid openserCurNumDialogs_oid[]            = 
00080       { OPENSER_OID,3,1,3,1,3,2,1 };
00081 
00082    static oid openserCurNumDialogsInProgress_oid[]  = 
00083       { OPENSER_OID,3,1,3,1,3,2,2 };
00084 
00085    static oid openserCurNumDialogsInSetup_oid[]     = 
00086       { OPENSER_OID,3,1,3,1,3,2,3 };
00087 
00088    static oid openserTotalNumFailedDialogSetups_oid[] = 
00089       { OPENSER_OID,3,1,3,1,3,2,4 };
00090 
00091    static oid openserDialogLimitMinorThreshold_oid[]  = 
00092       { OPENSER_OID,3,1,3,1,3,2,5 };
00093 
00094    static oid openserDialogLimitMajorThreshold_oid[]  = 
00095       { OPENSER_OID,3,1,3,1,3,2,6 };
00096 
00097    static oid openserDialogUsageState_oid[]       = 
00098       { OPENSER_OID,3,1,3,1,3,3,1 };
00099 
00100    static oid openserDialogLimitAlarmStatus_oid[] = 
00101       { OPENSER_OID,3,1,3,1,3,4,1 };
00102 
00103    static oid openserDialogLimitMinorAlarm_oid[]  = 
00104       { OPENSER_OID,3,1,3,1,3,4,2 };
00105 
00106    static oid openserDialogLimitMajorAlarm_oid[]  = 
00107       { OPENSER_OID,3,1,3,1,3,4,3 };
00108 
00109 
00110   DEBUGMSGTL(("openserObjects", "Initializing\n"));
00111 
00112    netsnmp_register_scalar(
00113       netsnmp_create_handler_registration(
00114          "openserMsgQueueDepth", 
00115          handle_openserMsgQueueDepth,
00116          openserMsgQueueDepth_oid, 
00117          OID_LENGTH(openserMsgQueueDepth_oid),
00118          HANDLER_CAN_RONLY)
00119       );
00120 
00121    netsnmp_register_scalar(
00122       netsnmp_create_handler_registration(
00123          "openserMsgQueueMinorThreshold", 
00124          handle_openserMsgQueueMinorThreshold,
00125          openserMsgQueueMinorThreshold_oid, 
00126          OID_LENGTH(openserMsgQueueMinorThreshold_oid),
00127          HANDLER_CAN_RONLY)
00128       );
00129 
00130    netsnmp_register_scalar(
00131       netsnmp_create_handler_registration(
00132          "openserMsgQueueMajorThreshold", 
00133          handle_openserMsgQueueMajorThreshold,
00134          openserMsgQueueMajorThreshold_oid, 
00135          OID_LENGTH(openserMsgQueueMajorThreshold_oid),
00136          HANDLER_CAN_RONLY)
00137       );
00138 
00139    netsnmp_register_scalar(
00140       netsnmp_create_handler_registration(
00141          "openserMsgQueueDepthAlarmStatus", 
00142          handle_openserMsgQueueDepthAlarmStatus,
00143          openserMsgQueueDepthAlarmStatus_oid, 
00144          OID_LENGTH(openserMsgQueueDepthAlarmStatus_oid),
00145          HANDLER_CAN_RONLY)
00146       );
00147 
00148    netsnmp_register_scalar(
00149       netsnmp_create_handler_registration(
00150          "openserMsgQueueDepthMinorAlarm", 
00151          handle_openserMsgQueueDepthMinorAlarm,
00152          openserMsgQueueDepthMinorAlarm_oid, 
00153          OID_LENGTH(openserMsgQueueDepthMinorAlarm_oid),
00154          HANDLER_CAN_RONLY)
00155       );
00156   
00157    netsnmp_register_scalar(
00158       netsnmp_create_handler_registration(
00159          "openserMsgQueueDepthMajorAlarm", 
00160          handle_openserMsgQueueDepthMajorAlarm,
00161          openserMsgQueueDepthMajorAlarm_oid, 
00162          OID_LENGTH(openserMsgQueueDepthMajorAlarm_oid),
00163          HANDLER_CAN_RONLY)
00164       );
00165 
00166    netsnmp_register_scalar(
00167       netsnmp_create_handler_registration(
00168          "openserCurNumDialogs", 
00169          handle_openserCurNumDialogs,
00170          openserCurNumDialogs_oid, 
00171          OID_LENGTH(openserCurNumDialogs_oid),
00172          HANDLER_CAN_RONLY)
00173       );
00174    
00175    netsnmp_register_scalar(
00176       netsnmp_create_handler_registration(
00177          "openserCurNumDialogsInProgress", 
00178          handle_openserCurNumDialogsInProgress,
00179          openserCurNumDialogsInProgress_oid, 
00180          OID_LENGTH(openserCurNumDialogsInProgress_oid),
00181          HANDLER_CAN_RONLY)
00182       );
00183    
00184    netsnmp_register_scalar(
00185       netsnmp_create_handler_registration(
00186          "openserCurNumDialogsInSetup", 
00187          handle_openserCurNumDialogsInSetup,
00188          openserCurNumDialogsInSetup_oid, 
00189          OID_LENGTH(openserCurNumDialogsInSetup_oid),
00190          HANDLER_CAN_RONLY)
00191       );
00192   
00193    netsnmp_register_scalar(
00194       netsnmp_create_handler_registration(
00195          "openserTotalNumFailedDialogSetups", 
00196       handle_openserTotalNumFailedDialogSetups,
00197       openserTotalNumFailedDialogSetups_oid, 
00198       OID_LENGTH(openserTotalNumFailedDialogSetups_oid),
00199       HANDLER_CAN_RONLY)
00200       );
00201    
00202    netsnmp_register_scalar(
00203       netsnmp_create_handler_registration(
00204          "openserDialogLimitMinorThreshold", 
00205          handle_openserDialogLimitMinorThreshold,
00206          openserDialogLimitMinorThreshold_oid, 
00207          OID_LENGTH(openserDialogLimitMinorThreshold_oid),
00208           HANDLER_CAN_RONLY)
00209       );
00210 
00211    netsnmp_register_scalar(
00212       netsnmp_create_handler_registration(
00213          "openserDialogLimitMajorThreshold", 
00214          handle_openserDialogLimitMajorThreshold,
00215          openserDialogLimitMajorThreshold_oid, 
00216          OID_LENGTH(openserDialogLimitMajorThreshold_oid),
00217          HANDLER_CAN_RONLY)
00218       );
00219 
00220    netsnmp_register_scalar(
00221       netsnmp_create_handler_registration(
00222          "openserDialogUsageState", 
00223          handle_openserDialogUsageState,
00224          openserDialogUsageState_oid, 
00225          OID_LENGTH(openserDialogUsageState_oid),
00226          HANDLER_CAN_RONLY)
00227       );
00228   
00229    netsnmp_register_scalar(
00230       netsnmp_create_handler_registration(
00231          "openserDialogLimitAlarmStatus", 
00232          handle_openserDialogLimitAlarmStatus,
00233          openserDialogLimitAlarmStatus_oid, 
00234          OID_LENGTH(openserDialogLimitAlarmStatus_oid),
00235          HANDLER_CAN_RONLY)
00236       );
00237    
00238    netsnmp_register_scalar(
00239       netsnmp_create_handler_registration(
00240          "openserDialogLimitMinorAlarm", 
00241          handle_openserDialogLimitMinorAlarm,
00242          openserDialogLimitMinorAlarm_oid, 
00243          OID_LENGTH(openserDialogLimitMinorAlarm_oid),
00244          HANDLER_CAN_RONLY)
00245       );
00246  
00247    netsnmp_register_scalar(
00248       netsnmp_create_handler_registration(
00249          "openserDialogLimitMajorAlarm", 
00250          handle_openserDialogLimitMajorAlarm,
00251          openserDialogLimitMajorAlarm_oid, 
00252          OID_LENGTH(openserDialogLimitMajorAlarm_oid),
00253          HANDLER_CAN_RONLY)
00254       );
00255 }
00256 
00257 
00258 /* 
00259  * The following are thresholds used by:
00260  * 
00261  * - The alarm monitoring process, to decide when to send out traps.  
00262  * - All scalars involving alarm status's and thresholds.  
00263  *
00264  * By default they are initialized to -1, which disables alarm checks.
00265  * These are set through the kamailio.cfg file with the following modparams to
00266  * the snmpstats module:
00267  *
00268  *  - dlg_minor_threshold  
00269  *  - dlg_major_threshold  
00270  *
00271  *  - MsgQueueMinorThreshold
00272  *  - MsgQueueMajorThreshold
00273  *
00274  */
00275 static int dialog_minor_threshold = -1;
00276 static int dialog_major_threshold = -1;
00277 
00278 static int msgQueueMinorThreshold = -1;
00279 static int msgQueueMajorThreshold = -1;
00280 
00281 
00282 int handle_openserMsgQueueDepth(netsnmp_mib_handler *handler,
00283       netsnmp_handler_registration *reginfo,
00284       netsnmp_agent_request_info   *reqinfo,
00285       netsnmp_request_info         *requests)
00286 {
00287    int bytesWaiting;
00288    
00289    bytesWaiting = get_total_bytes_waiting();
00290 
00291    if (reqinfo->mode == MODE_GET) {
00292       snmp_set_var_typed_value(requests->requestvb, ASN_GAUGE,
00293          (u_char *) &bytesWaiting, sizeof(int));
00294       return SNMP_ERR_NOERROR;
00295    }
00296 
00297    return SNMP_ERR_GENERR;
00298 }
00299 
00300 int handle_openserMsgQueueMinorThreshold(netsnmp_mib_handler *handler,
00301       netsnmp_handler_registration *reginfo,
00302       netsnmp_agent_request_info   *reqinfo,
00303       netsnmp_request_info         *requests)
00304 {
00305    if (reqinfo->mode == MODE_GET) {
00306       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00307          (u_char *) &msgQueueMinorThreshold, sizeof(int));
00308       return SNMP_ERR_NOERROR;
00309    } 
00310 
00311    return SNMP_ERR_GENERR;
00312 }
00313 
00314 int handle_openserMsgQueueMajorThreshold(netsnmp_mib_handler *handler,
00315       netsnmp_handler_registration *reginfo,
00316       netsnmp_agent_request_info   *reqinfo,
00317       netsnmp_request_info         *requests)
00318 {
00319    if (reqinfo->mode == MODE_GET) {
00320       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00321          (u_char *) &msgQueueMajorThreshold, sizeof(int));
00322       return SNMP_ERR_NOERROR;
00323    }
00324 
00325    return SNMP_ERR_GENERR;
00326 }
00327 
00328 int handle_openserMsgQueueDepthAlarmStatus(netsnmp_mib_handler *handler,
00329       netsnmp_handler_registration *reginfo,
00330       netsnmp_agent_request_info   *reqinfo,
00331       netsnmp_request_info         *requests)
00332 {
00333 
00334    /* The MIB specifications say the scalar should be set to 'clear' if
00335     * everything is ok.  According the X731AlarmStatus specification,
00336     * this means that no bits are toggled.  So we set the state to zero by
00337     * default */
00338    unsigned int state = 0;
00339    
00340    if (check_msg_queue_alarm(msgQueueMinorThreshold)) {
00341       state |=  TC_ALARM_STATUS_MINOR;
00342    }
00343 
00344    if (check_msg_queue_alarm(msgQueueMajorThreshold)) {
00345       state |=  TC_ALARM_STATUS_MAJOR;
00346    }
00347 
00348    if (reqinfo->mode == MODE_GET) {
00349       snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
00350          (u_char *)&state, 1);
00351       return SNMP_ERR_NOERROR;
00352    }
00353 
00354    return SNMP_ERR_GENERR;
00355 }
00356 
00357 int handle_openserMsgQueueDepthMinorAlarm(netsnmp_mib_handler *handler,
00358       netsnmp_handler_registration *reginfo,
00359       netsnmp_agent_request_info   *reqinfo,
00360       netsnmp_request_info         *requests)
00361 {
00362    int x731AlarmState = TC_ALARM_STATE_CLEAR;
00363 
00364    if (check_msg_queue_alarm(msgQueueMinorThreshold)) {  
00365       x731AlarmState = TC_ALARM_STATE_MINOR;
00366    }
00367 
00368    if (reqinfo->mode == MODE_GET) {
00369       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00370          (u_char *) &x731AlarmState, sizeof(int));
00371       return SNMP_ERR_NOERROR;
00372    }
00373 
00374    return SNMP_ERR_GENERR;
00375 }
00376 
00377 int handle_openserMsgQueueDepthMajorAlarm(netsnmp_mib_handler *handler,
00378       netsnmp_handler_registration *reginfo,
00379       netsnmp_agent_request_info   *reqinfo,
00380       netsnmp_request_info         *requests)
00381 {
00382    int x731AlarmState = TC_ALARM_STATE_CLEAR;
00383 
00384    if (check_msg_queue_alarm(msgQueueMajorThreshold)) {  
00385       x731AlarmState = TC_ALARM_STATE_MAJOR;
00386    }
00387    
00388    if (reqinfo->mode == MODE_GET) {
00389       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00390          (u_char *) &x731AlarmState, sizeof(int));
00391       return SNMP_ERR_NOERROR;
00392    }
00393 
00394    return SNMP_ERR_GENERR;
00395 }
00396 
00397 int handle_openserCurNumDialogs(netsnmp_mib_handler *handler,
00398       netsnmp_handler_registration *reginfo,
00399       netsnmp_agent_request_info   *reqinfo,
00400       netsnmp_request_info         *requests)
00401 {
00402    /* This scalar is defined as the number of dialogs in both the EARLY and
00403     * the CONFIRMED state.  */
00404    int result = get_statistic("active_dialogs");
00405 
00406    if (reqinfo->mode == MODE_GET) {
00407       snmp_set_var_typed_value(requests->requestvb, ASN_GAUGE,
00408          (u_char *) &result, sizeof(int));
00409       return SNMP_ERR_NOERROR;
00410    }
00411 
00412    return SNMP_ERR_GENERR;
00413 }
00414 
00415 int handle_openserCurNumDialogsInProgress(netsnmp_mib_handler *handler,
00416       netsnmp_handler_registration *reginfo,
00417       netsnmp_agent_request_info   *reqinfo,
00418       netsnmp_request_info         *requests)
00419 {
00420    /* This scalar is defined as the number of dialogs in the CONFIRMED
00421     * state only.  active_dialogs includes both confirmed and early, so
00422     * we subtract out early_dialogs from active_dialogs. */
00423    int result = 
00424       get_statistic("active_dialogs") -
00425       get_statistic("early_dialogs");
00426    
00427    if (reqinfo->mode == MODE_GET) {
00428       snmp_set_var_typed_value(requests->requestvb, ASN_GAUGE,
00429          (u_char *) &result, sizeof(int));
00430       return SNMP_ERR_NOERROR;
00431    }
00432 
00433    return SNMP_ERR_GENERR;
00434 }
00435 
00436 int handle_openserCurNumDialogsInSetup(netsnmp_mib_handler *handler,
00437       netsnmp_handler_registration *reginfo,
00438       netsnmp_agent_request_info   *reqinfo,
00439       netsnmp_request_info         *requests)
00440 {
00441    /* This scalar is defined as the number of dialogs in the EARLY state.
00442     * */
00443    int result = get_statistic("early_dialogs");
00444    
00445    if (reqinfo->mode == MODE_GET) {
00446       snmp_set_var_typed_value(requests->requestvb, ASN_GAUGE,
00447          (u_char *) &result, sizeof(int));
00448       return SNMP_ERR_NOERROR;
00449    }
00450 
00451    return SNMP_ERR_GENERR;
00452 }
00453 
00454 int handle_openserTotalNumFailedDialogSetups(netsnmp_mib_handler *handler,
00455       netsnmp_handler_registration *reginfo,
00456       netsnmp_agent_request_info   *reqinfo,
00457       netsnmp_request_info         *requests)
00458 {
00459    int result = get_statistic("failed_dialogs");
00460    
00461    if (reqinfo->mode == MODE_GET) {
00462       snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
00463          (u_char *) &result, sizeof(int));
00464       return SNMP_ERR_NOERROR;
00465    }
00466 
00467    return SNMP_ERR_GENERR;
00468 }
00469 
00470 int handle_openserDialogLimitMinorThreshold(netsnmp_mib_handler *handler,
00471       netsnmp_handler_registration *reginfo,
00472       netsnmp_agent_request_info   *reqinfo,
00473       netsnmp_request_info         *requests)
00474 {
00475    if (reqinfo->mode == MODE_GET) {
00476       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00477          (u_char *) &dialog_minor_threshold, sizeof(int));
00478       return SNMP_ERR_NOERROR;
00479    }
00480 
00481    return SNMP_ERR_GENERR;
00482 }
00483 
00484 int handle_openserDialogLimitMajorThreshold(netsnmp_mib_handler *handler,
00485       netsnmp_handler_registration *reginfo,
00486       netsnmp_agent_request_info   *reqinfo,
00487       netsnmp_request_info         *requests)
00488 {
00489    if (reqinfo->mode == MODE_GET) {
00490       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00491          (u_char *) &dialog_major_threshold, sizeof(int));
00492       return SNMP_ERR_NOERROR;
00493    }
00494 
00495    return SNMP_ERR_GENERR;
00496 }
00497 
00498 int handle_openserDialogUsageState(netsnmp_mib_handler *handler,
00499       netsnmp_handler_registration *reginfo,
00500       netsnmp_agent_request_info   *reqinfo,
00501       netsnmp_request_info         *requests)
00502 {
00503    /* Return value follows the X731UsageState Textual Convention 
00504     *
00505     * We default to 'unknown' */
00506    int usage_state = TC_USAGE_STATE_UNKNOWN;
00507 
00508    int num_dialogs = get_statistic("active_dialogs");
00509 
00510    if (num_dialogs==0) {
00511       usage_state = TC_USAGE_STATE_IDLE;
00512    } else {
00513       usage_state = TC_USAGE_STATE_ACTIVE;
00514    }
00515 
00516    if ((dialog_major_threshold > -1) && (num_dialogs > 
00517           dialog_major_threshold)) {
00518       usage_state = TC_USAGE_STATE_BUSY;
00519    }
00520    
00521    if (reqinfo->mode == MODE_GET) {
00522       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00523          (u_char *) &usage_state, sizeof(int));
00524       return SNMP_ERR_NOERROR;
00525    }
00526 
00527    return SNMP_ERR_GENERR;
00528 }
00529 
00530 
00531 int handle_openserDialogLimitAlarmStatus(netsnmp_mib_handler *handler,
00532       netsnmp_handler_registration *reginfo,
00533       netsnmp_agent_request_info   *reqinfo,
00534       netsnmp_request_info         *requests)
00535 {
00536    /* The MIB specifications say the scalar should be set to 'clear' if
00537     * everything is ok.  According the X731AlarmStatus specification,
00538     * this means that no bits are toggled.  So we set the state to zero by
00539     * default */
00540    unsigned int state = 0;
00541    
00542    if (check_dialog_alarm(dialog_minor_threshold)) {
00543       state |=  TC_ALARM_STATUS_MINOR;
00544    }
00545 
00546    if (check_dialog_alarm(dialog_major_threshold)) {
00547       state |=  TC_ALARM_STATUS_MAJOR;
00548    }
00549 
00550    
00551    if (reqinfo->mode == MODE_GET) {
00552       snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
00553          (u_char *) &state, 1);
00554       return SNMP_ERR_NOERROR;
00555    }
00556 
00557    return SNMP_ERR_GENERR;
00558 }
00559 
00560 
00561 
00562 int handle_openserDialogLimitMinorAlarm(netsnmp_mib_handler *handler,
00563       netsnmp_handler_registration *reginfo,
00564       netsnmp_agent_request_info   *reqinfo,
00565       netsnmp_request_info         *requests)
00566 {
00567    int x731AlarmState = TC_ALARM_STATE_CLEAR;
00568 
00569    if (check_dialog_alarm(dialog_minor_threshold))
00570    {
00571       x731AlarmState = TC_ALARM_STATE_MINOR;
00572    }
00573    
00574    if (reqinfo->mode == MODE_GET) {
00575       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00576          (u_char *) &x731AlarmState, sizeof(int));
00577       return SNMP_ERR_NOERROR;
00578    }
00579 
00580    return SNMP_ERR_GENERR;
00581 }
00582 
00583 int handle_openserDialogLimitMajorAlarm(netsnmp_mib_handler *handler,
00584       netsnmp_handler_registration *reginfo,
00585       netsnmp_agent_request_info   *reqinfo,
00586       netsnmp_request_info         *requests)
00587 {
00588    int x731AlarmState = TC_ALARM_STATE_CLEAR;
00589 
00590    if (check_dialog_alarm(dialog_major_threshold))
00591    {
00592       x731AlarmState = TC_ALARM_STATE_MAJOR;
00593    }
00594    
00595    if (reqinfo->mode == MODE_GET) {
00596       snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
00597          (u_char *) &x731AlarmState, sizeof(int));
00598       return SNMP_ERR_NOERROR;
00599    }
00600 
00601    return SNMP_ERR_GENERR;
00602 }
00603 
00604 /* If a proper integer is passed that is >= -1, then newValue will be set to
00605  * val, and 0 returned.  Otherwise -1 is returned. */
00606 static int set_if_valid_threshold(modparam_t type, void *val, char *varStr, 
00607    int *newVal) 
00608 {
00609    if (val==0) {
00610       LM_ERR("%s called with a null value!\n", varStr);
00611       return -1;
00612    }
00613 
00614    if (type != INT_PARAM) {
00615       LM_ERR("%s called with type %d instead of %d!\n",
00616             varStr, type, INT_PARAM);
00617       return -1;
00618    }
00619    
00620    int new_threshold = (int)(long)(int *)val;
00621 
00622    if (new_threshold < -1) {
00623       LM_ERR("%s called with an invalid threshold=%d!\n",
00624             varStr, new_threshold); 
00625       return -1;
00626    }
00627    
00628    *newVal = new_threshold;
00629 
00630    return 0;
00631 }
00632 
00633 /* 
00634  * Paramater Configuration Functions 
00635  */
00636 
00637 /* Handles setting of the message queue minor alarm threshold */
00638 int set_queue_minor_threshold(modparam_t type, void *val) {
00639    return set_if_valid_threshold(type, val, "MsgQueueMinorThreshold",
00640          &msgQueueMinorThreshold);
00641 }
00642 
00643 
00644 /* Handles setting of the message queue major alarm threshold */
00645 int set_queue_major_threshold(modparam_t type, void *val) {
00646    return set_if_valid_threshold(type, val, "MsgQueueMajorThreshold",
00647          &msgQueueMajorThreshold);
00648 }
00649 
00650 
00651 /* Handles setting of the dialog minor threshold */
00652 int set_dlg_minor_threshold(modparam_t type, void *val) {
00653    return set_if_valid_threshold(type, val, "set_dlg_minor_threshold", 
00654       &dialog_minor_threshold);
00655 }
00656 
00657 
00658 /* Handles setting of the dialog major threshold */
00659 int set_dlg_major_threshold(modparam_t type, void *val) {
00660    return set_if_valid_threshold(type, val, "set_dlg_major_threshold", 
00661       &dialog_major_threshold);
00662 }
00663 
00664 int get_msg_queue_minor_threshold(void) 
00665 {
00666    return msgQueueMinorThreshold;
00667 }
00668 
00669 int get_msg_queue_major_threshold(void) 
00670 {
00671    return msgQueueMajorThreshold;
00672 }
00673 
00674 int get_dialog_minor_threshold(void)
00675 {
00676    return dialog_minor_threshold;
00677 }
00678 
00679 int get_dialog_major_threshold(void)
00680 {
00681    return dialog_major_threshold;
00682 }

Generated on Wed May 23 20:00:28 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6