00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00046 #include <stdio.h>
00047 #include <string.h>
00048 #include <stdlib.h>
00049
00050 #include "../../modules/sl/sl.h"
00051 #include "sst_handlers.h"
00052
00053 #ifdef STATISTICS
00054 #include "../../lib/kcore/kstats_wrapper.h"
00055 #endif
00056
00057 MODULE_VERSION
00058
00059 static int mod_init(void);
00060
00061
00063 sl_api_t slb;
00064
00065
00066
00067
00068 int sst_enable_stats = 1;
00069 stat_var *expired_sst = 0;
00070
00077 pv_spec_t timeout_avp;
00078 static char* timeout_spec = 0;
00086 unsigned int sst_minSE = 90;
00087
00092 unsigned int sst_reject = 1;
00093
00095 static int sst_flag = -1;
00096
00097
00098
00099
00100
00101 struct dlg_binds dialog_st;
00102 struct dlg_binds *dlg_binds = &dialog_st;
00103
00104
00105
00106
00107 static cmd_export_t cmds[]={
00108 {"sstCheckMin", (cmd_function)sst_check_min, 1, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
00109 {0,0,0,0,0,0}
00110 };
00111
00112
00113
00114
00115 static param_export_t mod_params[]={
00116 { "enable_stats", INT_PARAM, &sst_enable_stats },
00117 { "min_se", INT_PARAM, &sst_minSE },
00118 { "timeout_avp", STR_PARAM, &timeout_spec },
00119 { "reject_to_small", INT_PARAM, &sst_reject },
00120 { "sst_flag", INT_PARAM, &sst_flag },
00121 { 0,0,0 }
00122 };
00123
00124 #ifdef STATISTICS
00125
00126
00127
00128 static stat_export_t mod_stats[] = {
00129 {"expired_sst", 0, &expired_sst},
00130 {0,0,0}
00131 };
00132 #endif
00133
00134 struct module_exports exports= {
00135 "sst",
00136 DEFAULT_DLFLAGS,
00137 cmds,
00138 mod_params,
00139 0,
00140 0,
00141 0,
00142 0,
00143 mod_init,
00144 0,
00145 0,
00146 0
00147 };
00148
00159 static int mod_init(void)
00160 {
00161 str s;
00162
00163 if (sst_enable_stats==0) {
00164 exports.stats = 0;
00165 }
00166
00167 #ifdef STATISTICS
00168
00169 if (sst_enable_stats!=0)
00170 {
00171 if (register_module_stats( exports.name, mod_stats)!=0 ) {
00172 LM_ERR("failed to register core statistics\n");
00173 return -1;
00174 }
00175 }
00176 #endif
00177
00178
00179 if (sst_flag == -1) {
00180 LM_ERR("no sst flag set!!\n");
00181 return -1;
00182 }
00183 else if (sst_flag > MAX_FLAG) {
00184 LM_ERR("invalid sst flag %d!!\n", sst_flag);
00185 return -1;
00186 }
00187
00188 if (timeout_spec != NULL) {
00189 LM_DBG("Dialog AVP is %s", timeout_spec);
00190 s.s = timeout_spec; s.len = strlen(s.s);
00191 if (pv_parse_spec(&s, &timeout_avp)==0
00192 && (timeout_avp.type != PVT_AVP)){
00193 LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n",
00194 timeout_spec);
00195 return -1;
00196 }
00197 }
00198
00199
00200 if (sl_load_api(&slb)!=0) {
00201 LM_ERR("cannot bind to SL API\n");
00202 return -1;
00203 }
00204
00205
00206 sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE,
00207 sst_flag, sst_reject);
00208
00209
00210 if (load_dlg_api(&dialog_st) != 0) {
00211 LM_ERR("failed to load dialog hooks");
00212 return(-1);
00213 }
00214
00215
00216 dialog_st.register_dlgcb(NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL);
00217
00218 return 0;
00219 }