diff --git a/Makefile.defs b/Makefile.defs index 545ffea6e95..943da47cf5c 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -97,7 +97,7 @@ INSTALL_FLAVOUR=$(FLAVOUR) VERSION = 4 PATCHLEVEL = 3 SUBLEVEL = 0 -EXTRAVERSION = -dev4 +EXTRAVERSION = -dev5 # memory manager switcher # 0 - f_malloc (fast malloc) diff --git a/Makefile.groups b/Makefile.groups index 7d5cb54827a..999e0fd7254 100644 --- a/Makefile.groups +++ b/Makefile.groups @@ -14,7 +14,8 @@ mod_list_basic=async auth benchmark blst cfg_rpc cfgutils corex counters \ mediaproxy mi_datagram mi_fifo mi_rpc mqueue \ nat_traversal nathelper path pike pv ratelimit rr rtimer \ rtpproxy sanity sdpops siputils sl statistics textops \ - textopsx tm tmx topoh xlog rtpengine stun sipt tcpops + textopsx tm tmx topoh xlog rtpengine stun sipt tcpops \ + auth_xkeys # - extra used modules, with no extra dependency mod_list_extra=avp auth_diameter call_control dmq domainpolicy msrp pdb \ diff --git a/main.c b/main.c index 8e6e9c822a3..8451e979f3e 100644 --- a/main.c +++ b/main.c @@ -2301,12 +2301,15 @@ int main(int argc, char** argv) fprintf(stderr, "bad user name/uid number: -u %s\n", user); goto error; } + sock_uid = uid; + sock_gid = gid; } if (group){ if (group2gid(&gid, group)<0){ fprintf(stderr, "bad group name/gid number: -u %s\n", group); goto error; } + sock_gid = gid; } if (fix_all_socket_lists()!=0){ fprintf(stderr, "failed to initialize list addresses\n"); diff --git a/modules/auth_xkeys/Makefile b/modules/auth_xkeys/Makefile new file mode 100644 index 00000000000..ecfed105021 --- /dev/null +++ b/modules/auth_xkeys/Makefile @@ -0,0 +1,14 @@ +# +# WARNING: do not run this directly, it should be run by the master Makefile + +include ../../Makefile.defs +auto_gen= +NAME=auth_xkeys.so +LIBS= + +DEFS+=-DKAMAILIO_MOD_INTERFACE + +SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/srutils/srutils +SER_LIBS+=$(SERLIBPATH)/kcore/kcore +include ../../Makefile.modules diff --git a/modules/auth_xkeys/README b/modules/auth_xkeys/README new file mode 100644 index 00000000000..c2cd6aa5adc --- /dev/null +++ b/modules/auth_xkeys/README @@ -0,0 +1,179 @@ +AUTH_XKEYS Module + +Daniel-Constantin Mierla + + + +Edited by + +Daniel-Constantin Mierla + + + + Copyright © 2015 asipto.com + __________________________________________________________________ + + Table of Contents + + 1. Admin Guide + + 1. Overview + 2. Dependencies + + 2.1. Kamailio Modules + 2.2. External Libraries or Applications + + 3. Parameters + + 3.1. xkey (str) + + 4. Functions + + 4.1. auth_xkeys_add(hdr, kid, alg, data) + 4.2. auth_xkeys_check(hdr, kid, alg, data) + + List of Examples + + 1.1. Set xkey parameter + 1.2. auth_xkeys_add usage + 1.3. auth_xkeys_check usage + +Chapter 1. Admin Guide + + Table of Contents + + 1. Overview + 2. Dependencies + + 2.1. Kamailio Modules + 2.2. External Libraries or Applications + + 3. Parameters + + 3.1. xkey (str) + + 4. Functions + + 4.1. auth_xkeys_add(hdr, kid, alg, data) + 4.2. auth_xkeys_check(hdr, kid, alg, data) + +1. Overview + + This module provides a custom mechanism to authenticate a SIP entity + using a list of shared keys. + + It is similar to the API key based authentication used by many web + services. In short, the sender adds a particular header with a hash + token computed with the shared key and some values from the SIP request + (e.g., local IP, From/To/R-URI username, Call-ID, CSeq). The receiver + will check the hash value and decide whether the SIP message is + authenticated or not. The sender and receiver have to agree beforehand + on the name of the server, shared secret, algorithm to be used and what + data is going to be hashed. + + The module is designed to work with many shared keys on the same group, + for more flexibility in adding/removing keys. The last added key in the + group is used to add the header, but older ones are used for matching + the hash value. That allows to change the active shared key without + affecting ongoing traffic. If one decides to use a new share key, add + it first to receiver (it will still authenticate with older key) and + then to the sender. Once both nodes are provisioned with the new key, + the older one can be removed. + + For proper protection, it is recommended to use this authentication + mechanism over a secure channel (e.g., TLS, VPN, private network). + + The benefit is avoiding the extra traffic and processing required by + WWW-Digest authentication schema (no more 401/407 and a follow up + request with credentials). + + Another goal is to provide more elasticity for scalability needs of the + core SIP network nodes. Most of the nodes in the core network or the + interconnecting peers trust each other based on IP address. But adding + a new node requires updates to the exiting ones to trust the IP address + of the new node. On large deployments, that can become rather complex. + For example, as a replacement for IP trust relationships, the sender + can hash the local IP with the secret shared key, add it in the header + and the receiver will check if the source ip hased with the key results + in the same value. + + Not being a challenge-reply mechanism, this can be used to authenticate + SIP responses from trusted peers. + +2. Dependencies + + 2.1. Kamailio Modules + 2.2. External Libraries or Applications + +2.1. Kamailio Modules + + The following modules must be loaded before this module: + * none. + +2.2. External Libraries or Applications + + The following libraries or applications must be installed before + running Kamailio with this module loaded: + * none + +3. Parameters + + 3.1. xkey (str) + +3.1. xkey (str) + + Specify the attributes for a shared secret. The value is in the format + 'name1=value1;name2=value2;...'. The attributes can be: + * id - the id of the group for keys + * name - the name of the key within group + * value - the value of the key + * expires - expiration time (seconds) + + Default value is empty. + + Example 1.1. Set xkey parameter +... +modparam("auth_xkeys", "xkey", "id=abc;name=xyz;value=secret;expires=72000") +... + +4. Functions + + 4.1. auth_xkeys_add(hdr, kid, alg, data) + 4.2. auth_xkeys_check(hdr, kid, alg, data) + +4.1. auth_xkeys_add(hdr, kid, alg, data) + + Add a header computed with the first key in the group kid, hasing with + algorithm alg over the content of parameter data. The parameters can + include variables. + + The algorithm can be: sha256, sha384, sha512. + + This function can be used from ANY_ROUTE. + + Example 1.2. auth_xkeys_add usage +... +auth_xkeys_add("X-My-Key", "abc", "sha256", "$Ri:$fu:$ru:$hdr(CSeq)"); +... + +4.2. auth_xkeys_check(hdr, kid, alg, data) + + Check if the value of header hdr matches the value computed with the + first key in the group kid, hasing with algorithm alg over the content + of parameter data. The parameters can include variables. + + The algorithm can be: sha256, sha384, sha512. + + Note that the header is not removed by the function, it is recommended + to remove it if sending to untrusted destination. + + This function can be used from ANY_ROUTE. + + Example 1.3. auth_xkeys_check usage +... +if(!auth_xkeys_add("X-My-Key", "abc", "sha256", "$si:$fu:$ru:$hdr(CSeq)")) { + send_reply("403", "Forbidden"); + exit; +} +remove_hf("X-My-Key"); +... diff --git a/modules/auth_xkeys/auth_xkeys.c b/modules/auth_xkeys/auth_xkeys.c new file mode 100644 index 00000000000..36002b97f2c --- /dev/null +++ b/modules/auth_xkeys/auth_xkeys.c @@ -0,0 +1,381 @@ +/** + * Copyright (C) 2015 Daniel-Constantin Mierla (asipto.com) + * + * This file is part of Kamailio, a free SIP server. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "../../dprint.h" +#include "../../ut.h" +#include "../../trim.h" +#include "../../pvapi.h" +#include "../../data_lump.h" +#include "../../mem/shm_mem.h" +#include "../../parser/hf.h" +#include "../../parser/parse_param.h" +#include "../../parser/msg_parser.h" +#include "../../lib/srutils/shautils.h" +#include "../../lib/kcore/cmpapi.h" + +#include "auth_xkeys.h" + +typedef struct _auth_xkey { + str kid; + str kname; + str kvalue; + time_t kexpires; + struct _auth_xkey *next; + struct _auth_xkey *next_id; +} auth_xkey_t; + +static auth_xkey_t **_auth_xkeys_list = NULL; + +/** + * + */ +int auth_xkeys_list_init(void) +{ + if(_auth_xkeys_list!=NULL) + return 0; + _auth_xkeys_list = shm_malloc(sizeof(auth_xkey_t)); + if(_auth_xkeys_list==NULL) { + LM_ERR("no more shared memory\n"); + return -1; + } + memset(_auth_xkeys_list, 0, sizeof(auth_xkey_t*)); + return 0; +} + +/** + * + */ +int authx_xkey_insert(auth_xkey_t *nkey) +{ + auth_xkey_t *ukey; + auth_xkey_t *itp; + auth_xkey_t *itc; + int ksize; + char *p; + + if(auth_xkeys_list_init()) + return -1; + if(nkey==NULL) + return -1; + + ksize = sizeof(auth_xkey_t) + nkey->kid.len + nkey->kname.len + + nkey->kvalue.len + 3; + ukey = (auth_xkey_t*)shm_malloc(ksize); + if(ukey==NULL) { + LM_ERR("no more shared memory\n"); + return -1; + } + memset(ukey, 0, ksize); + p = (char*)ukey + sizeof(auth_xkey_t); + + ukey->kid.len = nkey->kid.len; + ukey->kid.s = p; + strncpy(ukey->kid.s, nkey->kid.s, ukey->kid.len); + ukey->kid.s[ukey->kid.len] = '\0'; + p += ukey->kid.len + 1; + + ukey->kname.len = nkey->kname.len; + ukey->kname.s = p; + strncpy(ukey->kname.s, nkey->kname.s, ukey->kname.len); + ukey->kname.s[ukey->kname.len] = '\0'; + p += ukey->kname.len + 1; + + ukey->kvalue.len = nkey->kvalue.len; + ukey->kvalue.s = p; + strncpy(ukey->kvalue.s, nkey->kvalue.s, ukey->kvalue.len); + ukey->kvalue.s[ukey->kvalue.len] = '\0'; + p += ukey->kvalue.len + 1; + + ukey->kexpires = nkey->kexpires; + + if(*_auth_xkeys_list==NULL) { + *_auth_xkeys_list = ukey; + return 0; + } + + itp = NULL; + for(itc = *_auth_xkeys_list; itc; itc = itc->next_id) { + if(itc->kid.len==ukey->kid.len + && strncasecmp(itc->kid.s, ukey->kid.s, ukey->kid.len)==0) + break; + itp = itc; + } + if(itc==NULL) { + /* new id */ + ukey->next_id = *_auth_xkeys_list; + *_auth_xkeys_list = ukey; + return 0; + } + + if(itp!=NULL) { + itp->next_id = ukey; + } else { + *_auth_xkeys_list = ukey; + } + ukey->next_id = itc->next_id; + ukey->next = itc; + itc->next_id = NULL; + return 0; +} + +/** + * + */ +int authx_xkey_add_params(str *sparam) +{ + param_t* params_list = NULL; + param_hooks_t phooks; + param_t *pit=NULL; + auth_xkey_t tmp; + unsigned int uv; + + if (parse_params(sparam, CLASS_ANY, &phooks, ¶ms_list)<0) + return -1; + + memset(&tmp, 0, sizeof(auth_xkey_t)); + + for (pit = params_list; pit; pit=pit->next) + { + if (pit->name.len==2 + && strncasecmp(pit->name.s, "id", 2)==0) { + tmp.kid = pit->body; + } else if(pit->name.len==4 + && strncasecmp(pit->name.s, "name", 4)==0) { + tmp.kname = pit->body; + } else if(pit->name.len==5 + && strncasecmp(pit->name.s, "value", 5)==0) { + tmp.kvalue = pit->body; + } else if(pit->name.len==7 + && strncasecmp(pit->name.s, "expires", 7)==0) { + str2int(&pit->body, &uv); + tmp.kexpires = time(NULL) + uv; + } + } + if(tmp.kid.len<=0 || tmp.kname.len<=0 || tmp.kvalue.len<=0) { + LM_ERR("invalid parameters (%d/%d/%d)\n", tmp.kid.len, + tmp.kname.len, tmp.kvalue.len); + return -1; + } + + if(authx_xkey_insert(&tmp)<0) { + LM_ERR("unable to insert the key [%.*s:%.*s]\n", + tmp.kid.len, tmp.kid.s, tmp.kname.len, tmp.kname.s); + return -1; + } + + return 0; +} + +/** + * + */ +int auth_xkeys_add(sip_msg_t* msg, str *hdr, str *key, + str *alg, str *data) +{ + str xdata; + auth_xkey_t *itc; + char xout[SHA512_DIGEST_STRING_LENGTH]; + struct lump* anchor; + + if(_auth_xkeys_list==NULL || _auth_xkeys_list==NULL) { + LM_ERR("no stored keys\n"); + return -1; + } + if(parse_headers(msg, HDR_EOH_F, 0)<0) { + LM_ERR("error parsing headers\n"); + return -1; + } + + for(itc = *_auth_xkeys_list; itc; itc = itc->next_id) { + if(itc->kid.len==key->len + && strncasecmp(itc->kid.s, key->s, key->len)==0) + break; + } + if(itc==NULL) { + LM_DBG("no key chain id [%.*s]\n", key->len, key->s); + return -1; + } + + xdata.s = pv_get_buffer(); + xdata.len = data->len + itc->kvalue.len + 1; + if(xdata.len + 1 >= pv_get_buffer_size()) { + LM_ERR("size of data and key is too big\n"); + return -1; + } + + strncpy(xdata.s, itc->kvalue.s, itc->kvalue.len); + xdata.s[itc->kvalue.len] = ':'; + strncpy(xdata.s + itc->kvalue.len + 1, data->s, data->len); + if(alg->len==6 && strncasecmp(alg->s, "sha256", 6)==0) { + compute_sha256(xout, (u_int8_t*)xdata.s, xdata.len); + xdata.len = SHA256_DIGEST_STRING_LENGTH - 1; + } else if(alg->len==6 && strncasecmp(alg->s, "sha384", 6)==0) { + compute_sha384(xout, (u_int8_t*)xdata.s, xdata.len); + xdata.len = SHA384_DIGEST_STRING_LENGTH - 1; + } else if(alg->len==6 && strncasecmp(alg->s, "sha512", 6)==0) { + compute_sha512(xout, (u_int8_t*)xdata.s, xdata.len); + xdata.len = SHA512_DIGEST_STRING_LENGTH - 1; + } else { + LM_ERR("unknown algorithm [%.*s]\n", alg->len, alg->s); + return -1; + } + + if(xdata.len + hdr->len + 6 >= pv_get_buffer_size()) { + LM_ERR("size of new header is too big for pv buffer\n"); + return -1; + } + + strncpy(xdata.s, hdr->s, hdr->len); + xdata.s[hdr->len] = ':'; + xdata.s[hdr->len+1] = ' '; + strncpy(xdata.s + hdr->len + 2, xout, xdata.len); + xdata.len += hdr->len + 2; + xdata.s[xdata.len] = '\r'; + xdata.s[xdata.len+1] = '\n'; + xdata.s[xdata.len+2] = '\0'; + xdata.len += 2; + + anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0); + if(anchor == 0) { + LM_ERR("can't get anchor\n"); + return -1; + } + if (insert_new_lump_before(anchor, xdata.s, xdata.len, 0) == 0) { + LM_ERR("cannot insert the new header [%.*s]\n", hdr->len, hdr->s); + return -1; + } + return 0; +} + +/** + * + */ +int auth_xkeys_check(sip_msg_t* msg, str *hdr, str *key, + str *alg, str *data) +{ + hdr_field_t *hf; + str xdata; + auth_xkey_t *itc; + char xout[SHA512_DIGEST_STRING_LENGTH]; + str hbody; + + if(_auth_xkeys_list==NULL || _auth_xkeys_list==NULL) { + LM_ERR("no stored keys\n"); + return -1; + } + if(parse_headers(msg, HDR_EOH_F, 0)<0) { + LM_ERR("error parsing headers\n"); + return -1; + } + + for (hf=msg->headers; hf; hf=hf->next) { + if (cmp_hdrname_str(&hf->name, hdr)==0) + break; + } + if(hf==NULL) { + LM_DBG("no header with name [%.*s]\n", hdr->len, hdr->s); + return -1; + } + if(hf->body.len<=0) { + LM_DBG("empty header with name [%.*s]\n", hdr->len, hdr->s); + return -1; + } + hbody = hf->body; + trim(&hbody); + if(hbody.len!=SHA256_DIGEST_STRING_LENGTH-1 + && hbody.len!=SHA384_DIGEST_STRING_LENGTH-1 + && hbody.len!=SHA512_DIGEST_STRING_LENGTH-1) { + LM_DBG("not maching digest size for [%.*s]\n", + hf->body.len, hf->body.s); + return -1; + } + + for(itc = *_auth_xkeys_list; itc; itc = itc->next_id) { + if(itc->kid.len==key->len + && strncasecmp(itc->kid.s, key->s, key->len)==0) + break; + } + if(itc==NULL) { + LM_DBG("no key chain id [%.*s]\n", key->len, key->s); + return -1; + } + xdata.s = pv_get_buffer(); + for(; itc; itc = itc->next) { + xdata.len = data->len + itc->kvalue.len + 1; + if(xdata.len + 1 >= pv_get_buffer_size()) { + LM_WARN("size of data and key is too big - ignoring\n"); + continue; + } + strncpy(xdata.s, itc->kvalue.s, itc->kvalue.len); + xdata.s[itc->kvalue.len] = ':'; + strncpy(xdata.s + itc->kvalue.len + 1, data->s, data->len); + if(alg->len==6 && strncasecmp(alg->s, "sha256", 6)==0) { + if(hbody.len!=SHA256_DIGEST_STRING_LENGTH-1) { + LM_DBG("not maching sha256 digest size for [%.*s]\n", + hf->body.len, hf->body.s); + return -1; + } + compute_sha256(xout, (u_int8_t*)xdata.s, xdata.len); + if(strncasecmp(xout, hbody.s, hbody.len)==0) { + LM_DBG("no digest sha256 matched for key [%.*s:%.*s]\n", + key->len, key->s, itc->kname.len, itc->kname.s); + return 0; + } + } else if(alg->len==6 && strncasecmp(alg->s, "sha384", 6)==0) { + if(hbody.len!=SHA384_DIGEST_STRING_LENGTH-1) { + LM_DBG("not maching sha384 digest size for [%.*s]\n", + hf->body.len, hf->body.s); + return -1; + } + compute_sha384(xout, (u_int8_t*)xdata.s, xdata.len); + if(strncasecmp(xout, hbody.s, hbody.len)==0) { + LM_DBG("no digest sha384 matched for key [%.*s:%.*s]\n", + key->len, key->s, itc->kname.len, itc->kname.s); + return 0; + } + } else if(alg->len==6 && strncasecmp(alg->s, "sha512", 6)==0) { + if(hbody.len!=SHA512_DIGEST_STRING_LENGTH-1) { + LM_DBG("not maching sha512 digest size for [%.*s]\n", + hf->body.len, hf->body.s); + return -1; + } + compute_sha512(xout, (u_int8_t*)xdata.s, xdata.len); + if(strncasecmp(xout, hbody.s, hbody.len)==0) { + LM_DBG("no digest sha512 matched for key [%.*s:%.*s]\n", + key->len, key->s, itc->kname.len, itc->kname.s); + return 0; + } + } else { + LM_ERR("unknown algorithm [%.*s]\n", alg->len, alg->s); + return -1; + } + } + + LM_DBG("no digest matched for key [%.*s]\n", key->len, key->s); + return -1; +} + diff --git a/modules/auth_xkeys/auth_xkeys.h b/modules/auth_xkeys/auth_xkeys.h new file mode 100644 index 00000000000..5bb7282fbab --- /dev/null +++ b/modules/auth_xkeys/auth_xkeys.h @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2015 Daniel-Constantin Mierla (asipto.com) + * + * This file is part of Kamailio, a free SIP server. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _AUTH_XKEYS_H_ +#define _AUTH_XKEYS_H_ + +#include "../../str.h" + +int authx_xkey_add_params(str *sparam); +int auth_xkeys_add(sip_msg_t* msg, str *hdr, str *key, + str *alg, str *data); +int auth_xkeys_check(sip_msg_t* msg, str *hdr, str *key, + str *alg, str *data); + +#endif diff --git a/modules/auth_xkeys/auth_xkeys_mod.c b/modules/auth_xkeys/auth_xkeys_mod.c new file mode 100644 index 00000000000..e36cc7a53cb --- /dev/null +++ b/modules/auth_xkeys/auth_xkeys_mod.c @@ -0,0 +1,207 @@ +/** + * Copyright (C) 2015 Daniel-Constantin Mierla (asipto.com) + * + * This file is part of Kamailio, a free SIP server. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "../../sr_module.h" +#include "../../dprint.h" +#include "../../ut.h" +#include "../../pvar.h" +#include "../../mod_fix.h" +#include "../../timer_proc.h" +#include "../../route_struct.h" + +#include "auth_xkeys.h" + +MODULE_VERSION + + +static int mod_init(void); +static int child_init(int); +static void mod_destroy(void); + +int authx_xkey_param(modparam_t type, void* val); + +static int w_auth_xkeys_add(sip_msg_t* msg, char* hdr, char* key, + char* alg, char* data); +static int fixup_auth_xkeys_add(void** param, int param_no); +static int w_auth_xkeys_check(sip_msg_t* msg, char* hdr, char* key, + char* alg, char* data); +static int fixup_auth_xkeys_check(void** param, int param_no); + +/* timer for cleaning up the expired keys */ +/* int auth_xkeys_timer_mode = 0; */ + + +static cmd_export_t cmds[]={ + {"auth_xkeys_add", (cmd_function)w_auth_xkeys_add, + 4, fixup_auth_xkeys_add, + 0, ANY_ROUTE}, + {"auth_xkeys_check", (cmd_function)w_auth_xkeys_check, + 4, fixup_auth_xkeys_check, + 0, ANY_ROUTE}, + {0, 0, 0, 0, 0, 0} +}; + +static param_export_t params[]={ + {"xkey", PARAM_STRING|USE_FUNC_PARAM, (void*)authx_xkey_param}, + /* {"timer_mode", PARAM_INT, &auth_xkeys_timer_mode}, */ + {0, 0, 0} +}; + +struct module_exports exports = { + "auth_xkeys", + DEFAULT_DLFLAGS, /* dlopen flags */ + cmds, + params, + 0, + 0, /* exported MI functions */ + 0, /* exported pseudo-variables */ + 0, /* extra processes */ + mod_init, /* module initialization function */ + 0, /* response function */ + mod_destroy, /* destroy function */ + child_init /* per child init function */ +}; + + + +/** + * init module function + */ +static int mod_init(void) +{ + return 0; +} + +/** + * @brief Initialize async module children + */ +static int child_init(int rank) +{ + return 0; +} +/** + * destroy module function + */ +static void mod_destroy(void) +{ +} + + +static int w_auth_xkeys_add(sip_msg_t* msg, char* hdr, char* key, + char* alg, char* data) +{ + str shdr; + str skey; + str salg; + str sdata; + + if(fixup_get_svalue(msg, (gparam_t*)hdr, &shdr)!=0) + { + LM_ERR("cannot get the header name\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)key, &skey)!=0) + { + LM_ERR("cannot get the key id\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)alg, &salg)!=0) + { + LM_ERR("cannot get the algorithm\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)data, &sdata)!=0) + { + LM_ERR("cannot get the hasing data\n"); + return -1; + } + + if(auth_xkeys_add(msg, &shdr, &skey, &salg, &sdata)<0) + return -1; + + return 1; +} + +static int w_auth_xkeys_check(sip_msg_t* msg, char* hdr, char* key, + char* alg, char* data) +{ + str shdr; + str skey; + str salg; + str sdata; + + if(fixup_get_svalue(msg, (gparam_t*)hdr, &shdr)!=0) + { + LM_ERR("cannot get the header name\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)key, &skey)!=0) + { + LM_ERR("cannot get the key id\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)alg, &salg)!=0) + { + LM_ERR("cannot get the algorithm\n"); + return -1; + } + if(fixup_get_svalue(msg, (gparam_t*)data, &sdata)!=0) + { + LM_ERR("cannot get the hasing data\n"); + return -1; + } + + if(auth_xkeys_check(msg, &shdr, &skey, &salg, &sdata)<0) + return -1; + + return 1; +} + +static int fixup_auth_xkeys_add(void** param, int param_no) +{ + if(fixup_spve_null(param, 1)<0) + return -1; + return 0; +} + +static int fixup_auth_xkeys_check(void** param, int param_no) +{ + if(fixup_spve_null(param, 1)<0) + return -1; + return 0; +} + +int authx_xkey_param(modparam_t type, void* val) +{ + str s; + + if(val==NULL) + return -1; + s.s = (char*)val; + s.len = strlen(s.s); + return authx_xkey_add_params(&s); +} diff --git a/modules/auth_xkeys/doc/Makefile b/modules/auth_xkeys/doc/Makefile new file mode 100644 index 00000000000..7efb7b95e94 --- /dev/null +++ b/modules/auth_xkeys/doc/Makefile @@ -0,0 +1,4 @@ +docs = auth_xkeys.xml + +docbook_dir = ../../../docbook +include $(docbook_dir)/Makefile.module diff --git a/modules/auth_xkeys/doc/auth_xkeys.xml b/modules/auth_xkeys/doc/auth_xkeys.xml new file mode 100644 index 00000000000..f77f913fc14 --- /dev/null +++ b/modules/auth_xkeys/doc/auth_xkeys.xml @@ -0,0 +1,36 @@ + + + +%docentities; + +]> + + + + AUTH_XKEYS Module + kamailio.org + + + Daniel-Constantin + Mierla + miconda@gmail.com + + + Daniel-Constantin + Mierla + miconda@gmail.com + + + + 2015 + asipto.com + + + + + + + diff --git a/modules/auth_xkeys/doc/auth_xkeys_admin.xml b/modules/auth_xkeys/doc/auth_xkeys_admin.xml new file mode 100644 index 00000000000..2b4667443cc --- /dev/null +++ b/modules/auth_xkeys/doc/auth_xkeys_admin.xml @@ -0,0 +1,207 @@ + + + +%docentities; + +]> + + + + + &adminguide; + +
+ Overview + + This module provides a custom mechanism to authenticate a SIP entity + using a list of shared keys. + + + It is similar to the API key based authentication used by many web + services. In short, the sender adds a particular header with a hash + token computed with the shared key and some values from the SIP + request (e.g., local IP, From/To/R-URI username, Call-ID, CSeq). The + receiver will check the hash value and decide whether the SIP message + is authenticated or not. The sender and receiver have to agree + beforehand on the name of the server, shared secret, algorithm to be + used and what data is going to be hashed. + + + The module is designed to work with many shared keys on the same + group, for more flexibility in adding/removing keys. The last added + key in the group is used to add the header, but older ones are used + for matching the hash value. That allows to change the active shared + key without affecting ongoing traffic. If one decides to use a new + share key, add it first to receiver (it will still authenticate with + older key) and then to the sender. Once both nodes are provisioned + with the new key, the older one can be removed. + + + For proper protection, it is recommended to use this + authentication mechanism over a secure channel (e.g., TLS, VPN, + private network). + + + The benefit is avoiding the extra traffic and processing required + by WWW-Digest authentication schema (no more 401/407 and a follow up + request with credentials). + + + Another goal is to provide more elasticity for scalability needs of + the core SIP network nodes. Most of the nodes in the core network or + the interconnecting peers trust each other based on IP address. But + adding a new node requires updates to the exiting ones to trust the + IP address of the new node. On large deployments, that can become + rather complex. For example, as a replacement for IP trust + relationships, the sender can hash the local IP with the secret + shared key, add it in the header and the receiver will check if the + source ip hased with the key results in the same value. + + + Not being a challenge-reply mechanism, this can be used to authenticate + SIP responses from trusted peers. + +
+ +
+ Dependencies +
+ &kamailio; Modules + + The following modules must be loaded before this module: + + + + none. + + + + +
+
+ External Libraries or Applications + + The following libraries or applications must be installed before running + &kamailio; with this module loaded: + + + + none + + + + +
+
+
+ Parameters +
+ <varname>xkey</varname> (str) + + Specify the attributes for a shared secret. The value is in + the format 'name1=value1;name2=value2;...'. The attributes can be: + + + + + id - the id of the group for keys + + + + + name - the name of the key within group + + + + + value - the value of the key + + + + + expires - expiration time (seconds) + + + + + + Default value is empty. + + + + Set <varname>xkey</varname> parameter + +... +modparam("auth_xkeys", "xkey", "id=abc;name=xyz;value=secret;expires=72000") +... + + +
+
+ +
+ Functions +
+ + <function moreinfo="none">auth_xkeys_add(hdr, kid, alg, data)</function> + + + Add a header computed with the first key in the group kid, hasing with + algorithm alg over the content of parameter data. The parameters can + include variables. + + + The algorithm can be: sha256, sha384, sha512. + + + This function can be used from ANY_ROUTE. + + + <function>auth_xkeys_add</function> usage + +... +auth_xkeys_add("X-My-Key", "abc", "sha256", "$Ri:$fu:$ru:$hdr(CSeq)"); +... + + +
+ +
+ + <function moreinfo="none">auth_xkeys_check(hdr, kid, alg, data)</function> + + + Check if the value of header hdr matches the value computed with the + first key in the group kid, hasing with algorithm alg over the content + of parameter data. The parameters can include variables. + + + The algorithm can be: sha256, sha384, sha512. + + + Note that the header is not removed by the function, it is recommended + to remove it if sending to untrusted destination. + + + This function can be used from ANY_ROUTE. + + + <function>auth_xkeys_check</function> usage + +... +if(!auth_xkeys_add("X-My-Key", "abc", "sha256", "$si:$fu:$ru:$hdr(CSeq)")) { + send_reply("403", "Forbidden"); + exit; +} +remove_hf("X-My-Key"); +... + + +
+ +
+
+ diff --git a/modules/cdp_avp/imsapp.h b/modules/cdp_avp/imsapp.h index 8ac14f096f4..1eabb711e7c 100644 --- a/modules/cdp_avp/imsapp.h +++ b/modules/cdp_avp/imsapp.h @@ -273,6 +273,8 @@ cdp_avp (Multiple_Registration_Indication,IMS_vendor_id_3GPP,0, Enumerat cdp_avp_add_ptr (Restoration_Info, IMS_vendor_id_3GPP,0, Grouped, AAA_AVP_LIST*) cdp_avp_get (Restoration_Info, IMS_vendor_id_3GPP,0, Grouped, AAA_AVP_LIST) +cdp_avp_ptr (Access_Network_Information, IMS_vendor_id_3GPP, 0, UTF8String, str) + /* * ETSI something, that probably does not exist anymore diff --git a/modules/ctl/ctl.c b/modules/ctl/ctl.c index 2a05435c8d1..f630f8a67c8 100644 --- a/modules/ctl/ctl.c +++ b/modules/ctl/ctl.c @@ -264,6 +264,9 @@ static int mod_init(void) goto error; } } + /* get the uid/gid from core if not set for the module */ + if(usock_uid==-1 && sock_uid!=-1) usock_uid = sock_uid; + if(usock_gid==-1 && sock_gid!=-1) usock_gid = sock_gid; /* open socket now, before suid */ if (init_ctrl_sockets(&ctrl_sock_lst, listen_lst, DEFAULT_CTL_PORT, usock_mode, usock_uid, usock_gid)<0){ diff --git a/modules/db_cluster/dbcl_api.c b/modules/db_cluster/dbcl_api.c index abb52d68031..c3386150d06 100644 --- a/modules/db_cluster/dbcl_api.c +++ b/modules/db_cluster/dbcl_api.c @@ -158,7 +158,7 @@ extern int dbcl_max_query_length; cls->name.len, cls->name.s, i, j);\ sec = get_ticks();\ dbh = cls->wlist[i].clist[j]->dbh;\ - if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\ + if(cls->wlist[i].clist[j]->dbf.qfunc==NULL) {\ LM_ERR("unsupported command by db connector\n");\ return -1;\ }\ @@ -189,7 +189,7 @@ extern int dbcl_max_query_length; cls->name.len, cls->name.s, i, j);\ sec = get_ticks();\ dbh = cls->wlist[i].clist[j]->dbh;\ - if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\ + if(cls->wlist[i].clist[j]->dbf.qfunc==NULL) {\ LM_ERR("unsupported command by db connector\n");\ return -1;\ }\ @@ -221,7 +221,7 @@ extern int dbcl_max_query_length; cls->name.len, cls->name.s, i, j);\ sec = get_ticks();\ dbh = cls->wlist[i].clist[j]->dbh;\ - if(cls->rlist[i].clist[j]->dbf.qfunc==NULL) {\ + if(cls->wlist[i].clist[j]->dbf.qfunc==NULL) {\ LM_ERR("unsupported command by db connector\n");\ return -1;\ }\ diff --git a/modules/db_mysql/km_db_mysql.c b/modules/db_mysql/km_db_mysql.c index d3606505633..201c0188223 100644 --- a/modules/db_mysql/km_db_mysql.c +++ b/modules/db_mysql/km_db_mysql.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module interface * * Copyright (C) 2001-2003 FhG Fokus @@ -22,12 +20,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * History: - * -------- - * 2003-03-11 updated to the new module exports interface (andrei) - * 2003-03-16 flags export parameter added (janakj) - */ /*! \file * \brief DB_MYSQL :: Core diff --git a/modules/db_mysql/km_db_mysql.h b/modules/db_mysql/km_db_mysql.h index cb51b555f81..80afd4a542c 100644 --- a/modules/db_mysql/km_db_mysql.h +++ b/modules/db_mysql/km_db_mysql.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module interface * * Copyright (C) 2001-2003 FhG Fokus @@ -22,10 +20,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2003-03-11 updated to the new module exports interface (andrei) - * 2003-03-16 flags export parameter added (janakj) */ /*! \file diff --git a/modules/db_mysql/km_dbase.c b/modules/db_mysql/km_dbase.c index a3a0e779fb9..b44ab555151 100644 --- a/modules/db_mysql/km_dbase.c +++ b/modules/db_mysql/km_dbase.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module core functions * * Copyright (C) 2001-2003 FhG Fokus diff --git a/modules/db_mysql/km_dbase.h b/modules/db_mysql/km_dbase.h index a37e85004f2..78964971ce0 100644 --- a/modules/db_mysql/km_dbase.h +++ b/modules/db_mysql/km_dbase.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module core functions * * Copyright (C) 2001-2003 FhG Fokus diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c index deadd76976c..5558d666898 100644 --- a/modules/db_mysql/km_my_con.c +++ b/modules/db_mysql/km_my_con.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2004 iptel.org * Copyright (C) 2008 1&1 Internet AG * diff --git a/modules/db_mysql/km_my_con.h b/modules/db_mysql/km_my_con.h index cd353dcbca2..45fed57d246 100644 --- a/modules/db_mysql/km_my_con.h +++ b/modules/db_mysql/km_my_con.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2008 1&1 Internet AG * diff --git a/modules/db_mysql/km_res.c b/modules/db_mysql/km_res.c index 35844b0a377..c7dbb9e5c48 100644 --- a/modules/db_mysql/km_res.c +++ b/modules/db_mysql/km_res.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module result related functions * * Copyright (C) 2001-2003 FhG Fokus diff --git a/modules/db_mysql/km_res.h b/modules/db_mysql/km_res.h index e7c8156c707..5c73bee9644 100644 --- a/modules/db_mysql/km_res.h +++ b/modules/db_mysql/km_res.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module result related functions * * Copyright (C) 2001-2003 FhG Fokus diff --git a/modules/db_mysql/km_row.c b/modules/db_mysql/km_row.c index f84a63c102f..4e6ab234471 100644 --- a/modules/db_mysql/km_row.c +++ b/modules/db_mysql/km_row.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module row related functions * * Copyright (C) 2001-2003 FhG Fokus diff --git a/modules/db_mysql/km_row.h b/modules/db_mysql/km_row.h index 99629753a97..231d26a2568 100644 --- a/modules/db_mysql/km_row.h +++ b/modules/db_mysql/km_row.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * MySQL module row related functions * * Copyright (C) 2001-2003 FhG Fokus diff --git a/modules/db_mysql/km_val.c b/modules/db_mysql/km_val.c index 4bc55cb936d..418bebc7151 100644 --- a/modules/db_mysql/km_val.c +++ b/modules/db_mysql/km_val.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2008 1&1 Internet AG * diff --git a/modules/db_mysql/km_val.h b/modules/db_mysql/km_val.h index dd8a85d0b35..345541b1b27 100644 --- a/modules/db_mysql/km_val.h +++ b/modules/db_mysql/km_val.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2008 1&1 Internet AG * diff --git a/modules/db_mysql/my_cmd.c b/modules/db_mysql/my_cmd.c index a482102c6f7..666692c2127 100644 --- a/modules/db_mysql/my_cmd.c +++ b/modules/db_mysql/my_cmd.c @@ -2,19 +2,14 @@ * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_cmd.h b/modules/db_mysql/my_cmd.h index 6b51d16cd5a..d8a3d6460e0 100644 --- a/modules/db_mysql/my_cmd.h +++ b/modules/db_mysql/my_cmd.h @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_con.c b/modules/db_mysql/my_con.c index 919f6fc1e1e..15a102704f1 100644 --- a/modules/db_mysql/my_con.c +++ b/modules/db_mysql/my_con.c @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2004 iptel.org * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_con.h b/modules/db_mysql/my_con.h index 667e35b856f..7194320ed58 100644 --- a/modules/db_mysql/my_con.h +++ b/modules/db_mysql/my_con.h @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_fld.c b/modules/db_mysql/my_fld.c index 0ef1168dd69..b5975d678d4 100644 --- a/modules/db_mysql/my_fld.c +++ b/modules/db_mysql/my_fld.c @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_fld.h b/modules/db_mysql/my_fld.h index b93387bfde0..0a024ce7c0b 100644 --- a/modules/db_mysql/my_fld.h +++ b/modules/db_mysql/my_fld.h @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_res.c b/modules/db_mysql/my_res.c index c9608c18a6a..0c93d40029c 100644 --- a/modules/db_mysql/my_res.c +++ b/modules/db_mysql/my_res.c @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_res.h b/modules/db_mysql/my_res.h index 8f1ee877782..5546aa74834 100644 --- a/modules/db_mysql/my_res.h +++ b/modules/db_mysql/my_res.h @@ -1,22 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_uri.c b/modules/db_mysql/my_uri.c index c1dc388fa63..10faa1309f4 100644 --- a/modules/db_mysql/my_uri.c +++ b/modules/db_mysql/my_uri.c @@ -1,24 +1,17 @@ /* - * $Id$ - * * MySQL module interface * * Copyright (C) 2001-2003 FhG FOKUS * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/my_uri.h b/modules/db_mysql/my_uri.h index 403333939af..704c134e2c9 100644 --- a/modules/db_mysql/my_uri.h +++ b/modules/db_mysql/my_uri.h @@ -1,24 +1,17 @@ /* - * $Id$ - * * MySQL module interface * * Copyright (C) 2001-2003 FhG FOKUS * Copyright (C) 2006-2007 iptelorg GmbH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/db_mysql/mysql_mod.c b/modules/db_mysql/mysql_mod.c index 664f25816d9..f537a6d5494 100644 --- a/modules/db_mysql/mysql_mod.c +++ b/modules/db_mysql/mysql_mod.c @@ -1,22 +1,15 @@ /* - * $Id$ - * * MySQL module interface * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the Kamailio software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -26,13 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * History: - * -------- - * 2003-03-11 updated to the new module exports interface (andrei) - * 2003-03-16 flags export parameter added (janakj) - * 2013-04-02 added transaction support (haakon.nessjoen@gmail.com) - */ /** @addtogroup mysql * @{ */ diff --git a/modules/db_mysql/mysql_mod.h b/modules/db_mysql/mysql_mod.h index 8e9095c27df..fd686d70328 100644 --- a/modules/db_mysql/mysql_mod.h +++ b/modules/db_mysql/mysql_mod.h @@ -1,23 +1,16 @@ /* - * $Id$ - * * MySQL module interface * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -26,12 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - * History: - * -------- - * 2003-03-11 updated to the new module exports interface (andrei) - * 2003-03-16 flags export parameter added (janakj) - */ #ifndef _MYSQL_MOD_H #define _MYSQL_MOD_H diff --git a/modules/dialog_ng/dialog.c b/modules/dialog_ng/dialog.c index 1724a60569c..412ef71dd89 100644 --- a/modules/dialog_ng/dialog.c +++ b/modules/dialog_ng/dialog.c @@ -126,7 +126,7 @@ static cmd_export_t cmds[] = { static param_export_t mod_params[] = { { "hash_size", INT_PARAM, &dlg_hash_size}, - { "rr_param", PARAM_STR, &rr_param}, + { "rr_param", PARAM_STRING, &rr_param}, { "dlg_flag", INT_PARAM, &dlg_flag}, { "timeout_avp", PARAM_STR, &timeout_spec}, { "default_timeout", INT_PARAM, &default_timeout}, @@ -140,8 +140,8 @@ static param_export_t mod_params[] = { { "db_fetch_rows", INT_PARAM, &db_fetch_rows } , { "detect_spirals", INT_PARAM, &detect_spirals }, - { "profiles_with_value",PARAM_STR, &profiles_wv_s }, - { "profiles_no_value", PARAM_STR, &profiles_nv_s }, + { "profiles_with_value",PARAM_STRING, &profiles_wv_s }, + { "profiles_no_value", PARAM_STRING, &profiles_nv_s }, { "bridge_controller", PARAM_STR, &dlg_bridge_controller }, { "ruri_pvar", PARAM_STR, &ruri_pvar_param }, diff --git a/modules/dialog_ng/dlg_cb.c b/modules/dialog_ng/dlg_cb.c index ebbf5d63d04..3365e7b4c31 100644 --- a/modules/dialog_ng/dlg_cb.c +++ b/modules/dialog_ng/dlg_cb.c @@ -235,7 +235,7 @@ void run_create_callbacks(struct dlg_cell *dlg, struct sip_msg *msg) { struct dlg_callback *cb; - if (create_cbs==NULL || create_cbs->first==NULL) + if (create_cbs==NULL || create_cbs==POINTER_CLOSED_MARKER || create_cbs->first==NULL) return; params.req = msg; diff --git a/modules/dialplan/dialplan.c b/modules/dialplan/dialplan.c index b72d25a28e4..9a7fe33714e 100644 --- a/modules/dialplan/dialplan.c +++ b/modules/dialplan/dialplan.c @@ -1,20 +1,18 @@ /* - * $Id$ - * * Copyright (C) 2007-2008 Voice Sistem SRL * * Copyright (C) 2008 Juha Heinanen * * Copyright (C) 2014 Olle E. Johansson, Edvina AB * - * This file is part of SIP-router, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SIP-router is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * SIP-router is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -23,21 +21,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-01 initial version (ancuta onofrei) - * 2008-10-09 module is now using pcre regexp lib (juha heinanen) - * 2015-11-25 added RPC command for listing dialplan */ /*! * \file - * \brief SIP-router dialplan :: Module interface + * \brief Kamailio dialplan :: Module interface * \ingroup dialplan * Module: \ref dialplan */ -/*! \defgroup dialplan SIP-router dialplan transformations module +/*! \defgroup dialplan Kamailio dialplan transformations module * */ diff --git a/modules/dialplan/dialplan.h b/modules/dialplan/dialplan.h index ea976aad788..d4047116309 100644 --- a/modules/dialplan/dialplan.h +++ b/modules/dialplan/dialplan.h @@ -1,17 +1,14 @@ - /* - * $Id$ - * * Copyright (C) 2007-2008 Voice Sistem SRL * - * This file is part of SIP-router, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SIP-router is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * SIP-router is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,14 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-01 initial version (ancuta onofrei) */ /*! * \file - * \brief SIP-router dialplan :: Module interface + * \brief Kamailio dialplan :: Module interface * \ingroup dialplan * Module: \ref dialplan */ diff --git a/modules/dialplan/dp_db.c b/modules/dialplan/dp_db.c index c1c421d4c1d..a61efb1357b 100644 --- a/modules/dialplan/dp_db.c +++ b/modules/dialplan/dp_db.c @@ -1,16 +1,14 @@ /* - * $Id$ - * * Copyright (C) 2007-2008 Voice Sistem SRL * - * This file is part of SIP-router, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SIP-router is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * SIP-router is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -19,15 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-01 initial version (ancuta onofrei) - * 2008-10-09 module is now using pcre regexp lib (juha heinanen) */ /*! * \file - * \brief SIP-router dialplan :: database interface + * \brief Kamailio dialplan :: database interface * \ingroup dialplan * Module: \ref dialplan */ diff --git a/modules/dialplan/dp_db.h b/modules/dialplan/dp_db.h index b511c85c5db..6eb0e1b819d 100644 --- a/modules/dialplan/dp_db.h +++ b/modules/dialplan/dp_db.h @@ -1,16 +1,14 @@ /* - * $Id$ - * * Copyright (C) 2007-2008 Voice Sistem SRL * - * This file is part of SIP-router, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SIP-router is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * SIP-router is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -19,14 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-01 initial version (ancuta onofrei) */ /*! * \file - * \brief SIP-router dialplan :: Database interface + * \brief Kamailio dialplan :: Database interface * \ingroup dialplan * Module: \ref dialplan */ diff --git a/modules/dialplan/dp_repl.c b/modules/dialplan/dp_repl.c index 1e96ecf3dec..12ba230dbbf 100644 --- a/modules/dialplan/dp_repl.c +++ b/modules/dialplan/dp_repl.c @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2007-2008 Voice Sistem SRL * * Copyright (C) 2008 Juha Heinanen * - * This file is part of SIP-router, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SIP-router is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * SIP-router is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -21,14 +19,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-01 initial version (ancuta onofrei) */ /*! * \file - * \brief SIP-router dialplan :: database interface - reply parsing + * \brief Kamailio dialplan :: database interface - reply parsing * \ingroup dialplan * Module: \ref dialplan */ diff --git a/modules/dmq/README b/modules/dmq/README index 8bc19e48e3b..28b7c1187c3 100644 --- a/modules/dmq/README +++ b/modules/dmq/README @@ -6,6 +6,10 @@ Charles Chance Sipcentric Ltd. +Olle E. Johansson + + Edvina AB + Edited by Marius Ovidiu Bucur @@ -14,9 +18,11 @@ Edited by Charles Chance - Copyright © 2011 Marius Bucur + Copyright © 2011 Marius Bucur - Copyright © 2013 Charles Chance, Sipcentric Ltd. + Copyright © 2013 Charles Chance, Sipcentric Ltd. + + Copyright © 2015 Olle E. Johansson, Edvina AB __________________________________________________________________ Table of Contents @@ -58,15 +64,16 @@ Charles Chance List of Examples - 1.1. Set server_address parameter - 1.2. Set notification_address parameter - 1.3. Set num_workers parameter - 1.4. Set ping_interval parameter - 1.5. dmq_handle_message usage - 1.6. dmq_send_message usage - 1.7. dmq_bcast_message usage - 1.8. dmq_t_replicate usage - 1.9. dmq_is_from_node usage + 1.1. Example of a KDMQ message + 1.2. Set server_address parameter + 1.3. Set notification_address parameter + 1.4. Set num_workers parameter + 1.5. Set ping_interval parameter + 1.6. dmq_handle_message usage + 1.7. dmq_send_message usage + 1.8. dmq_bcast_message usage + 1.9. dmq_t_replicate usage + 1.10. dmq_is_from_node usage 2.1. dmq_api_t structure 2.2. register_dmq_peer usage 2.3. bcast_message usage @@ -113,6 +120,29 @@ Chapter 1. Admin Guide grouping of peers can be compared to a topic in a typical pub/sub system. + DMQ sends SIP requests using the KDMQ request method, that is private + to Kamailio. + + Example 1.1. Example of a KDMQ message + + This message is for basic DMQ bus handling. Other messages are produced + by other modules, like the htable module. +KDMQ sip:notification_peer@192.168.40.15:5090 SIP/2.0 +Via: SIP/2.0/UDP 192.168.40.15;branch=z9hG4bK55e5.423d95110000 +To: +From: ;tag=2cdb7a33a7f21abb98fd3a44968 +e3ffd-5b01 +CSeq: 10 KDMQ +Call-ID: 1fe138e07b5d0a7a-50419@192.168.40.15 +Content-Length: 116 +User-Agent: kamailio (4.3.0 (x86_64/linneaus)) +Max-Forwards: 1 +Content-Type: text/plain + +sip:192.168.40.16:5060;status=active +sip:192.168.40.15:5060;status=disabled +sip:192.168.40.17:5060;status=active + 2. Dependencies 2.1. Kamailio Modules @@ -142,9 +172,9 @@ Chapter 1. Admin Guide The local server address. This is the interface over which the DMQ engine will send/receive messages. - Default value is “NULLâ€. + Default value is "NULL". - Example 1.1. Set server_address parameter + Example 1.2. Set server_address parameter ... modparam("dmq", "server_address", "sip:10.0.0.20:5060") ... @@ -154,9 +184,9 @@ modparam("dmq", "server_address", "sip:10.0.0.20:5060") The address of another DMQ node from which the local node should retrieve initial information about all other nodes. - Default value is “NULLâ€. + Default value is "NULL". - Example 1.2. Set notification_address parameter + Example 1.3. Set notification_address parameter ... modparam("dmq", "notification_address", "sip:10.0.0.21:5060") ... @@ -165,9 +195,9 @@ modparam("dmq", "notification_address", "sip:10.0.0.21:5060") The number of worker threads for sending/receiving messages. - Default value is “2â€. + Default value is "2". - Example 1.3. Set num_workers parameter + Example 1.4. Set num_workers parameter ... modparam("dmq", "num_threads", 4) ... @@ -177,9 +207,9 @@ modparam("dmq", "num_threads", 4) The number of seconds between node pings (for checking status of other nodes). - Minimum value is “60†(default). + Minimum value is "60" (default). - Example 1.4. Set ping_interval parameter + Example 1.5. Set ping_interval parameter ... modparam("dmq", "ping_interval", 90) ... @@ -192,14 +222,14 @@ modparam("dmq", "ping_interval", 90) 4.4. dmq_t_replicate([skip_loop_test]) 4.5. dmq_is_from_node() -4.1. dmq_handle_message() +4.1. dmq_handle_message() Handles a DMQ message by passing it to the appropriate local peer (module). The peer is identified by the user part of the To header. This function can be used from REQUEST_ROUTE. - Example 1.5. dmq_handle_message usage + Example 1.6. dmq_handle_message usage ... if(is_method("KDMQ")) { @@ -207,7 +237,7 @@ modparam("dmq", "ping_interval", 90) } ... -4.2. dmq_send_message(peer, node, body, content_type) +4.2. dmq_send_message(peer, node, body, content_type) Sends a DMQ message directly from config file to a single node. @@ -219,13 +249,13 @@ modparam("dmq", "ping_interval", 90) This function can be used from any route. - Example 1.6. dmq_send_message usage + Example 1.7. dmq_send_message usage ... dmq_send_message("peer_name", "sip:10.0.0.21:5060", "Message body...", " text/plain"); ... -4.3. dmq_bcast_message(peer, body, content_type) +4.3. dmq_bcast_message(peer, body, content_type) Broadcasts a DMQ message from config file to all active nodes (except self). @@ -237,12 +267,12 @@ text/plain"); This function can be used from any route. - Example 1.7. dmq_bcast_message usage + Example 1.8. dmq_bcast_message usage ... dmq_bcast_message("peer_name", "Message body...", "text/plain"); ... -4.4. dmq_t_replicate([skip_loop_test]) +4.4. dmq_t_replicate([skip_loop_test]) Replicates the current SIP message to all active nodes (except self). Useful for replicating REGISTER, PUBLISH etc. in a clustered @@ -259,19 +289,19 @@ text/plain"); This function can be used from REQUEST_ROUTE only. - Example 1.8. dmq_t_replicate usage + Example 1.9. dmq_t_replicate usage ... dmq_t_replicate(); ... -4.5. dmq_is_from_node() +4.5. dmq_is_from_node() Checks whether the current message has been sent by another DMQ node in the cluster. This function can be used from REQUEST_ROUTE only. - Example 1.9. dmq_is_from_node usage + Example 1.10. dmq_is_from_node usage ... # Example REGISTER block if (dmq_is_from_node()) { @@ -301,7 +331,7 @@ Chapter 2. Developer Guide The module provides the following functions that can be used in other Kamailio modules. -1. dmq_load_api(dmq_api_t* api) +1. dmq_load_api(dmq_api_t* api) This function binds the DMQ module and fills the structure with the exported functions below. @@ -315,7 +345,7 @@ typedef struct dmq_api { } dmq_api_t; ... -2. register_dmq_peer(dmq_peer_t* peer) +2. register_dmq_peer(dmq_peer_t* peer) Registers an entity as a DMQ peer which permits receiving/sending messages between nodes which support the same peer. @@ -325,7 +355,7 @@ typedef struct dmq_api { Example to follow. ... -3. bcast_message(dmq_peer_t* peer, str* body, dmq_node_t* except, +3. bcast_message(dmq_peer_t* peer, str* body, dmq_node_t* except, dmq_resp_cback_t* resp_cback, int max_forwards, str* content_type) Broadcast a DMQ message to all nodes in the DMQ bus excluding self, @@ -336,7 +366,7 @@ dmq_resp_cback_t* resp_cback, int max_forwards, str* content_type) Example to follow. ... -4. send_message(dmq_peer_t* peer, str* body, dmq_node_t* node, +4. send_message(dmq_peer_t* peer, str* body, dmq_node_t* node, dmq_resp_cback_t* resp_cback, int max_forwards, str* content_type) Send a DMQ message to a single node. diff --git a/modules/dmq/bind_dmq.c b/modules/dmq/bind_dmq.c index 5d80e12223e..04e7494d9c7 100644 --- a/modules/dmq/bind_dmq.c +++ b/modules/dmq/bind_dmq.c @@ -1,5 +1,4 @@ /** - * $Id$ * * dmq module - distributed message queue * diff --git a/modules/dmq/bind_dmq.h b/modules/dmq/bind_dmq.h index dc90fb46c76..57f983ff388 100644 --- a/modules/dmq/bind_dmq.h +++ b/modules/dmq/bind_dmq.h @@ -1,5 +1,4 @@ /** - * $Id$ * * dmq module - distributed message queue * diff --git a/modules/dmq/dmq.c b/modules/dmq/dmq.c index 7df28a371c7..fd0c30e334a 100644 --- a/modules/dmq/dmq.c +++ b/modules/dmq/dmq.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/dmq.h b/modules/dmq/dmq.h index 660a741aa99..ac119391f0e 100644 --- a/modules/dmq/dmq.h +++ b/modules/dmq/dmq.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/dmq_funcs.c b/modules/dmq/dmq_funcs.c index a3611e8724b..35c121bf3f8 100644 --- a/modules/dmq/dmq_funcs.c +++ b/modules/dmq/dmq_funcs.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/dmq_funcs.h b/modules/dmq/dmq_funcs.h index 55f67ac621b..02c0516bb05 100644 --- a/modules/dmq/dmq_funcs.h +++ b/modules/dmq/dmq_funcs.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/dmqnode.c b/modules/dmq/dmqnode.c index d4bde2af8b6..7b0bf639e27 100644 --- a/modules/dmq/dmqnode.c +++ b/modules/dmq/dmqnode.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/dmqnode.h b/modules/dmq/dmqnode.h index 0bfd9ba4f89..2ef7b5fe32b 100644 --- a/modules/dmq/dmqnode.h +++ b/modules/dmq/dmqnode.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/doc/dmq.xml b/modules/dmq/doc/dmq.xml index f64c11b3bd2..250a771ff48 100644 --- a/modules/dmq/doc/dmq.xml +++ b/modules/dmq/doc/dmq.xml @@ -26,6 +26,11 @@ Chance Sipcentric Ltd. + + Olle E. + Johansson + Edvina AB + Marius Ovidiu Bucur @@ -46,6 +51,10 @@ 2013 Charles Chance, Sipcentric Ltd. + + 2015 + Olle E. Johansson, Edvina AB + diff --git a/modules/dmq/doc/dmq_admin.xml b/modules/dmq/doc/dmq_admin.xml index 7eabc1af036..e91995b6427 100644 --- a/modules/dmq/doc/dmq_admin.xml +++ b/modules/dmq/doc/dmq_admin.xml @@ -26,6 +26,36 @@ Peers are grouped by name in order to ensure the correct messages are passed to the relevant peers. This grouping of peers can be compared to a topic in a typical pub/sub system. + + DMQ sends SIP requests using the KDMQ request method, that is private + to Kamailio. + + + Example of a KDMQ message + + This message is for basic DMQ bus handling. Other messages are produced + by other modules, like the htable module. + + + + +KDMQ sip:notification_peer@192.168.40.15:5090 SIP/2.0 +Via: SIP/2.0/UDP 192.168.40.15;branch=z9hG4bK55e5.423d95110000 +To: <sip:notification_peer@192.168.40.15:5090> +From: <sip:notification_peer@192.168.40.15:5060>;tag=2cdb7a33a7f21abb98fd3a44968e3ffd-5b01 +CSeq: 10 KDMQ +Call-ID: 1fe138e07b5d0a7a-50419@192.168.40.15 +Content-Length: 116 +User-Agent: kamailio (4.3.0 (x86_64/linneaus)) +Max-Forwards: 1 +Content-Type: text/plain + +sip:192.168.40.16:5060;status=active +sip:192.168.40.15:5060;status=disabled +sip:192.168.40.17:5060;status=active + + + diff --git a/modules/dmq/message.c b/modules/dmq/message.c index ca5bd66ac32..714442900c2 100644 --- a/modules/dmq/message.c +++ b/modules/dmq/message.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/message.h b/modules/dmq/message.h index f6bf9cc433d..f3d20465dfa 100644 --- a/modules/dmq/message.h +++ b/modules/dmq/message.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/notification_peer.c b/modules/dmq/notification_peer.c index ae92e826b3d..78180761452 100644 --- a/modules/dmq/notification_peer.c +++ b/modules/dmq/notification_peer.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/notification_peer.h b/modules/dmq/notification_peer.h index 99be3398c18..9248b394bf5 100644 --- a/modules/dmq/notification_peer.h +++ b/modules/dmq/notification_peer.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/peer.c b/modules/dmq/peer.c index f54a2c0333c..95293793261 100644 --- a/modules/dmq/peer.c +++ b/modules/dmq/peer.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/peer.h b/modules/dmq/peer.h index 8b6fc328099..7878f6e27da 100644 --- a/modules/dmq/peer.h +++ b/modules/dmq/peer.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/worker.c b/modules/dmq/worker.c index 1f4b37dd1e4..b47cdb7cae6 100644 --- a/modules/dmq/worker.c +++ b/modules/dmq/worker.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/dmq/worker.h b/modules/dmq/worker.h index 66ebdcb6c35..b8a5dd167c5 100644 --- a/modules/dmq/worker.h +++ b/modules/dmq/worker.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * dmq module - distributed message queue * * Copyright (C) 2011 Bucur Marius - Ovidiu diff --git a/modules/enum/README b/modules/enum/README index 2f10a2c427a..b1f0c0007d6 100644 --- a/modules/enum/README +++ b/modules/enum/README @@ -72,7 +72,7 @@ Chapter 1. Admin Guide based on the user part of the current Request-URI. These functions assume that the Request URI user part consists of an international phone number of the form +decimal-digits, where the number of digits is - at least 2 and at most 15. Out of this number enum_query forms a domain + at least 2 and at most 20. Out of this number enum_query forms a domain name, where the digits are in reverse order and separated by dots followed by domain suffix that by default is "e164.arpa.". For example, if the user part is +35831234567, the domain name will be diff --git a/modules/enum/doc/enum_admin.xml b/modules/enum/doc/enum_admin.xml index 939c5fc56b6..d5d34d2d79d 100644 --- a/modules/enum/doc/enum_admin.xml +++ b/modules/enum/doc/enum_admin.xml @@ -21,7 +21,7 @@ based on the user part of the current Request-URI. These functions assume that the Request URI user part consists of an international phone number of the form +decimal-digits, where the number of digits is at - least 2 and at most 15. Out of this number + least 2 and at most 20. Out of this number enum_query forms a domain name, where the digits are in reverse order and separated by dots followed by domain suffix that by default is e164.arpa.. For example, diff --git a/modules/geoip/README b/modules/geoip/README index a8ac4ccd76c..ed5644696be 100644 --- a/modules/geoip/README +++ b/modules/geoip/README @@ -68,7 +68,9 @@ Chapter 1. Admin Guide 1. Overview This module allows real-time queries against the Max Mind GeoIP - database to be performed from the config script. + database to be performed from the config script. It uses the old + version of API, still very common on OS distributions. For using the + new version of GeoIP API, see geoip2 module. The Max Mind GeoIP database is a map of IP network address assignments to geographical locales that can be useful -- though approximate -- in @@ -160,6 +162,7 @@ if(geoip_match("$si", "src")) + regc - region + regn - region name + metro - metro code + + contc - continent code Exported pseudo-variables are documented at - http://www.kamailio.org/dokuwiki/. + http://www.kamailio.org/wiki/. diff --git a/modules/geoip/doc/geoip_admin.xml b/modules/geoip/doc/geoip_admin.xml index 7bd64270bca..e4db7e7332f 100644 --- a/modules/geoip/doc/geoip_admin.xml +++ b/modules/geoip/doc/geoip_admin.xml @@ -18,7 +18,9 @@ Overview This module allows real-time queries against the Max Mind GeoIP - database to be performed from the config script. + database to be performed from the config script. It uses the old + version of API, still very common on OS distributions. For using + the new version of GeoIP API, see geoip2 module. The Max Mind GeoIP database is a map of IP network address assignments @@ -182,6 +184,9 @@ if(geoip_match("$si", "src")) metro - metro code + + contc - continent code + diff --git a/modules/geoip/geoip_pv.c b/modules/geoip/geoip_pv.c index 60f37cabe87..46c4dff4cdd 100644 --- a/modules/geoip/geoip_pv.c +++ b/modules/geoip/geoip_pv.c @@ -210,6 +210,8 @@ int pv_parse_geoip_name(pv_spec_p sp, str *in) case 5: if(strncmp(pvs.s, "metro", 5)==0) gpv->type = 12; + else if(strncmp(pvs.s, "contc", 5)==0) + gpv->type = 13; else goto error; break; default: @@ -349,6 +351,11 @@ int pv_get_geoip(struct sip_msg *msg, pv_param_t *param, return pv_get_null(msg, param, res); return pv_get_sintval(msg, param, res, gpv->item->r.record->metro_code); + case 13: /* contc */ + if(gpv->item->r.record==NULL) + return pv_get_null(msg, param, res); + return pv_geoip_get_strzval(msg, param, res, + gpv->item->r.record->continent_code); default: /* cc */ if(gpv->item->r.record==NULL) return pv_get_null(msg, param, res); diff --git a/modules/geoip2/README b/modules/geoip2/README index c9cb1edab3b..fd07cddec0a 100644 --- a/modules/geoip2/README +++ b/modules/geoip2/README @@ -141,6 +141,7 @@ if(geoip2_match("$si", "src")) + regc - region + regn - region name + metro - metro code + + contc - continent code Exported pseudo-variables are documented at http://www.kamailio.org/wiki/. diff --git a/modules/geoip2/doc/geoip2_admin.xml b/modules/geoip2/doc/geoip2_admin.xml index 244930dd733..b944bb3228f 100644 --- a/modules/geoip2/doc/geoip2_admin.xml +++ b/modules/geoip2/doc/geoip2_admin.xml @@ -163,6 +163,9 @@ if(geoip2_match("$si", "src")) metro - metro code + + contc - continent code + diff --git a/modules/geoip2/geoip2_pv.c b/modules/geoip2/geoip2_pv.c index f9f7dbba6a2..69bd7199eb2 100644 --- a/modules/geoip2/geoip2_pv.c +++ b/modules/geoip2/geoip2_pv.c @@ -41,6 +41,7 @@ typedef struct _sr_geoip2_record { str region_code; str region_name; str country; + str cont_code; char latitude[16]; char longitude[16]; char metro[16]; @@ -207,6 +208,8 @@ int pv_parse_geoip2_name(pv_spec_p sp, str *in) gpv->type = 12; else if(strncmp(pvs.s, "nmask", 5)==0) gpv->type = 13; + else if(strncmp(pvs.s, "contc", 5)==0) + gpv->type = 6; else goto error; break; default: @@ -311,6 +314,22 @@ int pv_get_geoip2(struct sip_msg *msg, pv_param_t *param, } return pv_geoip2_get_strzval(msg, param, res, gpv->item->r.longitude); + case 6: /* contc */ + if(gpv->item->r.cont_code.s==NULL) + { + if(gpv->item->r.flags&16) + return pv_get_null(msg, param, res); + if(MMDB_get_value(&gpv->item->r.record.entry, &entry_data, + "continent","code", NULL + ) != MMDB_SUCCESS) + return pv_get_null(msg, param, res); + if(entry_data.has_data && entry_data.type == MMDB_DATA_TYPE_UTF8_STRING) { + gpv->item->r.cont_code.s = (char *)entry_data.utf8_string; + gpv->item->r.cont_code.len = entry_data.data_size; + } + gpv->item->r.flags |= 16; + } + return pv_get_strval(msg, param, res, &gpv->item->r.cont_code); case 8: /* city */ if(gpv->item->r.city.s==NULL) { diff --git a/modules/htable/Makefile b/modules/htable/Makefile index 9811122650e..7adca5ddff4 100644 --- a/modules/htable/Makefile +++ b/modules/htable/Makefile @@ -1,5 +1,5 @@ # -# example module makefile +# htable module makefile # # # WARNING: do not run this directly, it should be run by the master Makefile diff --git a/modules/htable/api.c b/modules/htable/api.c index 34bfc6b9761..1116a0dcadf 100644 --- a/modules/htable/api.c +++ b/modules/htable/api.c @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/api.h b/modules/htable/api.h index 71502b2ba71..4f126748948 100644 --- a/modules/htable/api.h +++ b/modules/htable/api.h @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/ht_api.c b/modules/htable/ht_api.c index 90f8c96e222..690f9c75e4c 100644 --- a/modules/htable/ht_api.c +++ b/modules/htable/ht_api.c @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/ht_api.h b/modules/htable/ht_api.h index f760bc63fa6..e91db338a3d 100644 --- a/modules/htable/ht_api.h +++ b/modules/htable/ht_api.h @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/ht_db.c b/modules/htable/ht_db.c index 0231ece485d..06f3057e63a 100644 --- a/modules/htable/ht_db.c +++ b/modules/htable/ht_db.c @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/ht_db.h b/modules/htable/ht_db.h index 15518625e77..cffe5342098 100644 --- a/modules/htable/ht_db.h +++ b/modules/htable/ht_db.h @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/ht_var.c b/modules/htable/ht_var.c index 5ac76cb7df1..4bcc2b1c335 100644 --- a/modules/htable/ht_var.c +++ b/modules/htable/ht_var.c @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/htable/ht_var.h b/modules/htable/ht_var.h index 4ffe8c29c93..6c95e91eec3 100644 --- a/modules/htable/ht_var.h +++ b/modules/htable/ht_var.h @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2008 Elena-Ramona Modroiu (asipto.com) * diff --git a/modules/ims_charging/Ro_data.c b/modules/ims_charging/Ro_data.c index f53fec8e0c8..c15ba9f42a4 100644 --- a/modules/ims_charging/Ro_data.c +++ b/modules/ims_charging/Ro_data.c @@ -87,7 +87,7 @@ time_stamps_t * new_time_stamps(time_t *sip_request_timestamp, uint32_t *sip_req } ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t * time_stamps, str * user_session_id, str * outgoing_session_id, str * calling_party, - str * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *incoming_trunk_id, str *outgoing_trunk_id) { + str * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *incoming_trunk_id, str *outgoing_trunk_id, str* pani) { str_list_slot_t *sl = 0; ims_information_t *x = 0; @@ -123,6 +123,10 @@ ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t if (outgoing_trunk_id && outgoing_trunk_id->s) str_dup_ptr(x->outgoing_trunk_id, *outgoing_trunk_id, pkg); + + if (pani && pani->s) { + str_dup_ptr(x->access_network_info, *pani, pkg); + } //WL_FREE_ALL(&(x->called_asserted_identity),str_list_t,pkg); //str_free_ptr(x->requested_party_address,pkg); @@ -239,6 +243,7 @@ void ims_information_free(ims_information_t *x) { str_free_ptr(x->incoming_trunk_id, pkg); str_free_ptr(x->outgoing_trunk_id, pkg); + str_free_ptr(x->access_network_info, pkg); time_stamps_free(x->time_stamps); diff --git a/modules/ims_charging/Ro_data.h b/modules/ims_charging/Ro_data.h index e68d4b7ba0d..26dd0dc327f 100644 --- a/modules/ims_charging/Ro_data.h +++ b/modules/ims_charging/Ro_data.h @@ -271,7 +271,8 @@ typedef struct { str_list_t calling_party_address; str *called_party_address; str_list_t called_asserted_identity; - str * requested_party_address; + str *requested_party_address; + str *access_network_info; time_stamps_t *time_stamps; @@ -398,7 +399,8 @@ ims_information_t * new_ims_information(event_type_t * event_type, str * term_ioi, int node_role, str *incoming_trunk_id, - str *outgoing_trunk_id); + str *outgoing_trunk_id, + str *pani); void event_type_free(event_type_t *x); void time_stamps_free(time_stamps_t *x); diff --git a/modules/ims_charging/ccr.c b/modules/ims_charging/ccr.c index a315f872b6d..140d1c1d325 100644 --- a/modules/ims_charging/ccr.c +++ b/modules/ims_charging/ccr.c @@ -108,6 +108,10 @@ int Ro_write_ims_information_avps(AAA_AVP_LIST * avp_list, ims_information_t* x) cdp_avp->cdp->AAAFreeAVPList(&aList); aList.head = aList.tail = 0; } + + if (x->access_network_info) { + cdp_avp->imsapp.add_Access_Network_Information(&aList2, *(x->access_network_info), 0); + } for (sl = x->called_asserted_identity.head; sl; sl = sl->next) { if (!cdp_avp->epcapp.add_Called_Asserted_Identity(&aList2, sl->data, 0)) diff --git a/modules/ims_charging/ims_charging_stats.c b/modules/ims_charging/ims_charging_stats.c new file mode 100644 index 00000000000..c21ea611b04 --- /dev/null +++ b/modules/ims_charging/ims_charging_stats.c @@ -0,0 +1,66 @@ +#include "ims_charging_stats.h" + +struct ims_charging_counters_h ims_charging_cnts_h; +enum sctp_info_req { IMS_CHARGING_AVG_RSP, IMS_CHARGING_FAILED_INITIAL, IMS_CHARGING_FAILED_FINAL, IMS_CHARGING_FAILED_INTERIM }; + +static counter_val_t ims_charging_internal_stats(counter_handle_t h, void* what); + +counter_def_t ims_charging_cnt_defs[] = { + {&ims_charging_cnts_h.active_ro_sessions, "active_ro_sessions", 0, 0, 0, "number of currently active Ro sessions"}, + {&ims_charging_cnts_h.billed_secs, "billed_secs", 0, 0, 0, "total number of seconds billed since start or reset"}, + {&ims_charging_cnts_h.ccr_avg_response_time, "ccr_avg_response_time", 0, ims_charging_internal_stats, (void*) (long) IMS_CHARGING_AVG_RSP, "avg response time for CCRs"}, + {&ims_charging_cnts_h.ccr_response_time, "ccr_response_time", 0, 0, 0, "total number of seconds waiting for CCR responses"}, + {&ims_charging_cnts_h.ccr_timeouts, "ccr_timeouts", 0, 0, 0, "total number of CCR timeouts"}, + {&ims_charging_cnts_h.failed_final_ccrs, "failed_final_ccrs", 0, 0, 0, "total number of failed final CCRs"}, + {&ims_charging_cnts_h.failed_initial_ccrs, "failed_initial_ccrs", 0, 0, 0, "total number of failed initial CCRs"}, + {&ims_charging_cnts_h.failed_interim_ccr, "failed_interim_ccrs", 0, 0, 0, "total number of failed interim CCRs"}, + {&ims_charging_cnts_h.final_ccrs, "final_ccrs", 0, 0, 0, "total number of final (terminating) CCRs"}, + {&ims_charging_cnts_h.initial_ccrs, "initial_ccrs", 0, 0, 0, "total number of initial CCRs"}, + {&ims_charging_cnts_h.interim_ccrs, "interim_ccrs", 0, 0, 0, "total number of interim CCRs"}, + {&ims_charging_cnts_h.killed_calls, "killed_calls", 0, 0, 0, "total number of killed calls"}, + {&ims_charging_cnts_h.successful_final_ccrs, "successful_final_ccrs", 0, 0, 0, "total number of successful final CCRs"}, + {&ims_charging_cnts_h.successful_initial_ccrs, "successful_initial_ccrs", 0, 0, 0, "total number of successful initial CCRs"}, + {&ims_charging_cnts_h.successful_interim_ccrs, "successful_interim_ccrs", 0, 0, 0, "total number of successful interim CCRs"}, + {0, 0, 0, 0, 0, 0} +}; + +int ims_charging_init_counters() { + if (counter_register_array("ims_charging", ims_charging_cnt_defs) < 0) + goto error; + return 0; +error: + return -1; +} + +void ims_charging_destroy_counters() { + +} + +/** helper function for some stats (which are kept internally). + */ +static counter_val_t ims_charging_internal_stats(counter_handle_t h, void* what) { + enum sctp_info_req w; + + w = (int) (long) what; + switch (w) { + case IMS_CHARGING_AVG_RSP: + if ((counter_get_val(ims_charging_cnts_h.initial_ccrs) + counter_get_val(ims_charging_cnts_h.interim_ccrs) + counter_get_val(ims_charging_cnts_h.final_ccrs)) == 0) + return 0; + else + return counter_get_val(ims_charging_cnts_h.ccr_response_time)/ + (counter_get_val(ims_charging_cnts_h.initial_ccrs) + counter_get_val(ims_charging_cnts_h.interim_ccrs) + counter_get_val(ims_charging_cnts_h.final_ccrs)); + break; + case IMS_CHARGING_FAILED_INITIAL: + return (counter_get_val(ims_charging_cnts_h.initial_ccrs) - counter_get_val(ims_charging_cnts_h.successful_initial_ccrs)); + break; + case IMS_CHARGING_FAILED_INTERIM: + return (counter_get_val(ims_charging_cnts_h.interim_ccrs) - counter_get_val(ims_charging_cnts_h.successful_interim_ccrs)); + break; + case IMS_CHARGING_FAILED_FINAL: + return (counter_get_val(ims_charging_cnts_h.final_ccrs) - counter_get_val(ims_charging_cnts_h.successful_final_ccrs)); + break; + default: + return 0; + }; + return 0; +} diff --git a/modules/ims_charging/ims_charging_stats.h b/modules/ims_charging/ims_charging_stats.h new file mode 100644 index 00000000000..0e345be4dcf --- /dev/null +++ b/modules/ims_charging/ims_charging_stats.h @@ -0,0 +1,37 @@ +/* + * File: ims_charging_stats.h + * Author: jaybeepee + * + * Created on 24 February 2015, 11:15 AM + */ + +#ifndef IMS_CHARGING_STATS_H +#define IMS_CHARGING_STATS_H + +#include "../../counters.h" + +struct ims_charging_counters_h { + counter_handle_t billed_secs; + counter_handle_t ccr_avg_response_time; + counter_handle_t ccr_response_time; + counter_handle_t ccr_timeouts; + counter_handle_t failed_final_ccrs; + counter_handle_t failed_initial_ccrs; + counter_handle_t failed_interim_ccr; + counter_handle_t final_ccrs; + counter_handle_t initial_ccrs; + counter_handle_t interim_ccrs; + counter_handle_t killed_calls; + counter_handle_t successful_final_ccrs; + counter_handle_t successful_initial_ccrs; + counter_handle_t successful_interim_ccrs; + counter_handle_t active_ro_sessions; +}; + +int ims_charging_init_counters(); +void ims_charging_destroy_counters(); + +#endif /* IMS_CHARGING_STATS_H */ + + + diff --git a/modules/ims_charging/ims_ro.c b/modules/ims_charging/ims_ro.c index 142135f8e81..eb3516573ab 100644 --- a/modules/ims_charging/ims_ro.c +++ b/modules/ims_charging/ims_ro.c @@ -29,9 +29,9 @@ #include "ccr.h" #include "config.h" #include "ro_session_hash.h" -#include "stats.h" #include "ro_avp.h" #include "ro_db_handler.h" +#include "ims_charging_stats.h" extern struct tm_binds tmb; extern struct cdp_binds cdpb; @@ -40,13 +40,13 @@ extern struct dlg_binds dlgb; extern cdp_avp_bind_t *cdp_avp; extern str ro_forced_peer; extern int ro_db_mode; +extern struct ims_charging_counters_h ims_charging_cnts_h; struct session_setup_data { - struct ro_session *ro_session; - - cfg_action_t* action; - unsigned int tindex; - unsigned int tlabel; + struct ro_session *ro_session; + cfg_action_t* action; + unsigned int tindex; + unsigned int tlabel; }; struct dlg_binds* dlgb_p; @@ -66,17 +66,15 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c static int get_mac_avp_value(struct sip_msg *msg, str *value); void credit_control_session_callback(int event, void* session) { - switch (event) { - case AUTH_EV_SESSION_DROP: - LM_DBG("Received notification of CC App session drop - we must free the generic data\n"); - break; - default: - LM_DBG("Received unhandled event [%d] in credit control session callback from CDP\n", event); - } + switch (event) { + case AUTH_EV_SESSION_DROP: + LM_DBG("Received notification of CC App session drop - we must free the generic data\n"); + break; + default: + LM_DBG("Received unhandled event [%d] in credit control session callback from CDP\n", event); + } } - - /** * Retrieves the SIP request that generated a diameter transaction * @param hash - the tm hash value for this request @@ -87,8 +85,8 @@ struct sip_msg * trans_get_request_from_current_reply() { struct cell *t; t = tmb.t_gett(); if (!t || t == (void*) - 1) { - LM_ERR("trans_get_request_from_current_reply: Reply without transaction\n"); - return 0; + LM_ERR("trans_get_request_from_current_reply: Reply without transaction\n"); + return 0; } if (t) return t->uas.request; else return 0; @@ -107,24 +105,24 @@ struct sip_msg * trans_get_request_from_current_reply() { * @returns 1 on success or 0 on failure */ static inline int Ro_add_avp_list(AAA_AVP_LIST *list, char *d, int len, int avp_code, - int flags, int vendorid, int data_do, const char *func) { + int flags, int vendorid, int data_do, const char *func) { AAA_AVP *avp; if (vendorid != 0) flags |= AAA_AVP_FLAG_VENDOR_SPECIFIC; avp = cdpb.AAACreateAVP(avp_code, flags, vendorid, d, len, data_do); if (!avp) { - LM_ERR("%s: Failed creating avp\n", func); - return 0; + LM_ERR("%s: Failed creating avp\n", func); + return 0; } if (list->tail) { - avp->prev = list->tail; - avp->next = 0; - list->tail->next = avp; - list->tail = avp; + avp->prev = list->tail; + avp->next = 0; + list->tail->next = avp; + list->tail = avp; } else { - list->head = avp; - list->tail = avp; - avp->next = 0; - avp->prev = 0; + list->head = avp; + list->tail = avp; + avp->next = 0; + avp->prev = 0; } return 1; @@ -188,7 +186,7 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used char x[4]; //unsigned int service_id = 1000; //Removed these are now configurable config file params - + //unsigned int rating_group = 500; //Removed these are now configurable config file params used_list.head = 0; @@ -198,16 +196,16 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used /* if we must Used-Service-Unit */ if (used_unit >= 0) { - set_4bytes(x, used_unit); - Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); - used_group = cdpb.AAAGroupAVPS(used_list); - cdpb.AAAFreeAVPList(&used_list); - Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__); + set_4bytes(x, used_unit); + Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); + used_group = cdpb.AAAGroupAVPS(used_list); + cdpb.AAAFreeAVPList(&used_list); + Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__); } set_4bytes(x, active_service_identifier); Ro_add_avp_list(&mscc_list, x, 4, AVP_Service_Identifier, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); - + set_4bytes(x, active_rating_group); Ro_add_avp_list(&mscc_list, x, 4, AVP_Rating_Group, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); @@ -220,7 +218,7 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int requested_unit, int used_unit, int active_rating_group, int active_service_identifier) { AAA_AVP_LIST list, used_list, mscc_list; str group, used_group; - + char x[4]; list.head = 0; @@ -239,17 +237,17 @@ inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int set_4bytes(x, active_service_identifier); Ro_add_avp_list(&mscc_list, x, 4, AVP_Service_Identifier, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); - + set_4bytes(x, active_rating_group); Ro_add_avp_list(&mscc_list, x, 4, AVP_Rating_Group, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); /* if we must Used-Service-Unit */ if (used_unit >= 0) { - set_4bytes(x, used_unit); - Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); - used_group = cdpb.AAAGroupAVPS(used_list); - cdpb.AAAFreeAVPList(&used_list); - Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__); + set_4bytes(x, used_unit); + Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); + used_group = cdpb.AAAGroupAVPS(used_list); + cdpb.AAAFreeAVPList(&used_list); + Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__); } group = cdpb.AAAGroupAVPS(mscc_list); @@ -299,12 +297,12 @@ inline int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id, Ro_add_avp_list(&list, x, 4, AVP_Vendor_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); if (auth_id) { - set_4bytes(x, auth_id); - Ro_add_avp_list(&list, x, 4, AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); + set_4bytes(x, auth_id); + Ro_add_avp_list(&list, x, 4, AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); } if (acct_id) { - set_4bytes(x, acct_id); - Ro_add_avp_list(&list, x, 4, AVP_Acct_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); + set_4bytes(x, acct_id); + Ro_add_avp_list(&list, x, 4, AVP_Acct_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__); } group = cdpb.AAAGroupAVPS(list); @@ -315,41 +313,41 @@ inline int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id, } int get_sip_header_info(struct sip_msg * req, - struct sip_msg * reply, - int32_t * acc_record_type, - str * sip_method, - str * event, uint32_t * expires, - str * callid, str * asserted_id_uri, str * to_uri) { + struct sip_msg * reply, + int32_t * acc_record_type, + str * sip_method, + str * event, uint32_t * expires, + str * callid, str * asserted_id_uri, str * to_uri) { sip_method->s = req->first_line.u.request.method.s; sip_method->len = req->first_line.u.request.method.len; if (strncmp(sip_method->s, "INVITE", 6) == 0) - *acc_record_type = AAA_ACCT_START; + *acc_record_type = AAA_ACCT_START; else if (strncmp(sip_method->s, "BYE", 3) == 0) - *acc_record_type = AAA_ACCT_STOP; + *acc_record_type = AAA_ACCT_STOP; else - *acc_record_type = AAA_ACCT_EVENT; + *acc_record_type = AAA_ACCT_EVENT; *event = cscf_get_event(req); *expires = cscf_get_expires_hdr(req, 0); *callid = cscf_get_call_id(req, NULL); if ((*asserted_id_uri = cscf_get_asserted_identity(req, 0)).len == 0) { - LM_DBG("No P-Asserted-Identity hdr found. Using From hdr"); + LM_DBG("No P-Asserted-Identity hdr found. Using From hdr"); - if (!cscf_get_from_uri(req, asserted_id_uri)) { - LM_ERR("Error assigning P-Asserted-Identity using From hdr"); - goto error; - } + if (!cscf_get_from_uri(req, asserted_id_uri)) { + LM_ERR("Error assigning P-Asserted-Identity using From hdr"); + goto error; + } } - *to_uri = req->first_line.u.request.uri; + *to_uri = req->first_line.u.request.uri; LM_DBG("retrieved sip info : sip_method %.*s acc_record_type %i, event %.*s expires %u " - "call_id %.*s from_uri %.*s to_uri %.*s\n", - sip_method->len, sip_method->s, *acc_record_type, event->len, event->s, *expires, - callid->len, callid->s, asserted_id_uri->len, asserted_id_uri->s, to_uri->len, to_uri->s); + "call_id %.*s from_uri %.*s to_uri %.*s\n", + sip_method->len, sip_method->s, *acc_record_type, event->len, event->s, *expires, + callid->len, callid->s, asserted_id_uri->len, asserted_id_uri->s, to_uri->len, to_uri->s); return 1; error: @@ -360,9 +358,9 @@ int get_ims_charging_info(struct sip_msg *req, struct sip_msg * reply, str * ici LM_DBG("get ims charging info\n"); if (req) - cscf_get_p_charging_vector(req, icid, orig_ioi, term_ioi); + cscf_get_p_charging_vector(req, icid, orig_ioi, term_ioi); if (reply) - cscf_get_p_charging_vector(reply, icid, orig_ioi, term_ioi); + cscf_get_p_charging_vector(reply, icid, orig_ioi, term_ioi); return 1; } @@ -370,9 +368,9 @@ int get_ims_charging_info(struct sip_msg *req, struct sip_msg * reply, str * ici int get_timestamps(struct sip_msg * req, struct sip_msg * reply, time_t * req_timestamp, time_t * reply_timestamp) { if (reply) - *reply_timestamp = time(NULL); + *reply_timestamp = time(NULL); if (req) - *req_timestamp = time(NULL); + *req_timestamp = time(NULL); return 1; } @@ -381,8 +379,8 @@ int get_timestamps(struct sip_msg * req, struct sip_msg * reply, time_t * req_ti * */ -Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, AAASession ** authp, int dir, str asserted_identity, - str called_asserted_identity, str subscription_id, int subscription_id_type, str* incoming_trunk_id, str *outgoing_trunk_id) { +Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, AAASession ** authp, int dir, str asserted_identity, + str called_asserted_identity, str subscription_id, int subscription_id_type, str* incoming_trunk_id, str *outgoing_trunk_id, str* pani) { Ro_CCR_t * ro_ccr_data = 0; AAASession * auth = NULL; @@ -401,66 +399,66 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A *authp = 0; if (!get_sip_header_info(req, reply, &acc_record_type, &sip_method, &event, &expires, &callid, &from_uri, &to_uri)) - goto error; + goto error; user_name.s = subscription_id.s; user_name.len = subscription_id.len; - + /* if(!get_ims_charging_info(req, reply, &icid, &orig_ioi, &term_ioi)) - goto error; + goto error; */ LM_DBG("retrieved ims charging info icid:[%.*s] orig_ioi:[%.*s] term_ioi:[%.*s]\n", - icid.len, icid.s, orig_ioi.len, orig_ioi.s, term_ioi.len, term_ioi.s); + icid.len, icid.s, orig_ioi.len, orig_ioi.s, term_ioi.len, term_ioi.s); if (!get_timestamps(req, reply, &req_timestamp, &reply_timestamp)) - goto error; + goto error; if (!(event_type = new_event_type(&sip_method, &event, &expires))) - goto error; + goto error; if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, &reply_timestamp, NULL))) - goto error; + goto error; - if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid, - &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id))) - goto error; + if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid, + &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani))) + goto error; event_type = 0; time_stamps = 0; - + subscr.id.s = subscription_id.s; subscr.id.len = subscription_id.len; subscr.type = subscription_id_type; - + ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr); if (!ro_ccr_data) { - LM_ERR("dlg_create_ro_session: no memory left for generic\n"); - goto out_of_memory; + LM_ERR("dlg_create_ro_session: no memory left for generic\n"); + goto out_of_memory; } ims_info = 0; if (strncmp(req->first_line.u.request.method.s, "INVITE", 6) == 0) { - //create CDP CC Accounting session - auth = cdpb.AAACreateCCAccSession(credit_control_session_callback, 1/*is_session*/, NULL ); //must unlock session hash when done - LM_DBG("Created Ro Session with id Session ID [%.*s]\n", auth->id.len, auth->id.s); - //save_session = auth->id; + //create CDP CC Accounting session + auth = cdpb.AAACreateCCAccSession(credit_control_session_callback, 1/*is_session*/, NULL); //must unlock session hash when done + LM_DBG("Created Ro Session with id Session ID [%.*s]\n", auth->id.len, auth->id.s); + //save_session = auth->id; } /*if (strncmp(req->first_line.u.request.method.s, "BYE", 3) == 0) { - auth = cdp_avp->cdp->AAAGetAuthSession(save_session); + auth = cdp_avp->cdp->AAAGetAuthSession(save_session); }*/ if (!auth) { - LM_ERR("unable to create the Ro Session\n"); - goto error; + LM_ERR("unable to create the Ro Session\n"); + goto error; } *authp = auth; return ro_ccr_data; out_of_memory: -error : - time_stamps_free(time_stamps); + error : + time_stamps_free(time_stamps); event_type_free(event_type); ims_information_free(ims_info); Ro_free_CCR(ro_ccr_data); @@ -468,18 +466,18 @@ error : return NULL; } -int sip_create_ro_ccr_data(struct sip_msg * msg, int dir, Ro_CCR_t ** ro_ccr_data, AAASession ** auth, str asserted_identity, str called_asserted_identity, - str subscription_id, int subscription_id_type, str* incoming_trunk_id, str* outgoing_trunk_id) { +int sip_create_ro_ccr_data(struct sip_msg * msg, int dir, Ro_CCR_t ** ro_ccr_data, AAASession ** auth, str asserted_identity, str called_asserted_identity, + str subscription_id, int subscription_id_type, str* incoming_trunk_id, str* outgoing_trunk_id, str* pani) { if (msg->first_line.type == SIP_REQUEST) { - /*end of session*/ - if (strncmp(msg->first_line.u.request.method.s, "INVITE", 6) == 0) { - if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id, - subscription_id_type, incoming_trunk_id, outgoing_trunk_id))) - goto error; - } + /*end of session*/ + if (strncmp(msg->first_line.u.request.method.s, "INVITE", 6) == 0) { + if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id, + subscription_id_type, incoming_trunk_id, outgoing_trunk_id, pani))) + goto error; + } } else { - goto error; //We only support Request (INVITE) messages on this interface + goto error; //We only support Request (INVITE) messages on this interface } return 1; @@ -497,16 +495,16 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned int32_t acc_record_type; subscription_id_t subscr; time_stamps_t *time_stamps; - struct interim_ccr *i_req = shm_malloc(sizeof(struct interim_ccr)); - int ret = 0; + struct interim_ccr *i_req = shm_malloc(sizeof (struct interim_ccr)); + int ret = 0; event_type_t *event_type; - memset(i_req, 0, sizeof(sizeof(struct interim_ccr))); - i_req->ro_session = ro_session; + memset(i_req, 0, sizeof (sizeof (struct interim_ccr))); + i_req->ro_session = ro_session; str sip_method = str_init("dummy"); str sip_event = str_init("dummy"); - + str user_name = {0, 0}; time_t req_timestamp; @@ -514,45 +512,45 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned event_type = new_event_type(&sip_method, &sip_event, 0); LM_DBG("Sending interim CCR request for (usage:new) [%i:%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n", - used, - reserve, - ro_session->asserted_identity.len, ro_session->asserted_identity.s, - ro_session->ro_session_id.len, ro_session->ro_session_id.s, - ro_session->rating_group, ro_session->service_identifier, - ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s, - ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s); + used, + reserve, + ro_session->asserted_identity.len, ro_session->asserted_identity.s, + ro_session->ro_session_id.len, ro_session->ro_session_id.s, + ro_session->rating_group, ro_session->service_identifier, + ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s, + ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s); req_timestamp = time(0); if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, NULL, NULL))) - goto error; + goto error; - if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, - &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id))) - goto error; + if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, + &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id, &ro_session->pani))) + goto error; LM_DBG("Created IMS information\n"); event_type = 0; if (ro_session->direction == RO_ORIG_DIRECTION) { - subscr.id = ro_session->asserted_identity; - - - } else if (ro_session->direction == RO_TERM_DIRECTION){ - subscr.id = ro_session->called_asserted_identity; + subscr.id = ro_session->asserted_identity; + + + } else if (ro_session->direction == RO_TERM_DIRECTION) { + subscr.id = ro_session->called_asserted_identity; } else { - LM_CRIT("don't know what to do in unknown mode - should we even get here\n"); - goto error; + LM_CRIT("don't know what to do in unknown mode - should we even get here\n"); + goto error; } - + //getting subscription id type - if (strncasecmp(subscr.id.s,"tel:",4)==0) { + if (strncasecmp(subscr.id.s, "tel:", 4) == 0) { subscr.type = Subscription_Type_MSISDN; - }else{ + } else { subscr.type = Subscription_Type_IMPU; //default is END_USER_SIP_URI } - + user_name.s = subscr.id.s; user_name.len = subscr.id.len; @@ -560,53 +558,53 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr); if (!ro_ccr_data) { - LM_ERR("no memory left for generic\n"); - goto error; + LM_ERR("no memory left for generic\n"); + goto error; } ims_info = NULL; auth = cdpb.AAAGetCCAccSession(ro_session->ro_session_id); if (!auth) { - LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n"); - /* lets try and recreate this session */ - //TODO: make a CC App session auth = cdpb.AAASession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp - //BUG("Oh shit, session timed out and I don't know how to create a new one."); + LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n"); + /* lets try and recreate this session */ + //TODO: make a CC App session auth = cdpb.AAASession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp + //BUG("Oh shit, session timed out and I don't know how to create a new one."); - auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp - if (!auth) - goto error; + auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp + if (!auth) + goto error; } //don't send INTERIM record if session is not in OPEN state (it could already be waiting for a previous response, etc) if (auth->u.cc_acc.state != ACC_CC_ST_OPEN) { - LM_WARN("ignoring interim update on CC session not in correct state, currently in state [%d]\n", auth->u.cc_acc.state); - goto error; + LM_WARN("ignoring interim update on CC session not in correct state, currently in state [%d]\n", auth->u.cc_acc.state); + goto error; } if (!(ccr = Ro_new_ccr(auth, ro_ccr_data))) - goto error; + goto error; if (!Ro_add_vendor_specific_appid(ccr, IMS_vendor_id_3GPP, IMS_Ro, 0/*acct id*/)) { - LM_ERR("Problem adding Vendor specific ID\n"); + LM_ERR("Problem adding Vendor specific ID\n"); } ro_session->hop_by_hop += 1; if (!Ro_add_cc_request(ccr, RO_CC_INTERIM, ro_session->hop_by_hop)) { - LM_ERR("Problem adding CC-Request data\n"); + LM_ERR("Problem adding CC-Request data\n"); } if (!Ro_add_event_timestamp(ccr, time(NULL))) { - LM_ERR("Problem adding Event-Timestamp data\n"); + LM_ERR("Problem adding Event-Timestamp data\n"); } if (!Ro_add_user_equipment_info(ccr, AVP_EPC_User_Equipment_Info_Type_MAC, ro_session->avp_value.mac)) { - LM_ERR("Problem adding User-Equipment data\n"); + LM_ERR("Problem adding User-Equipment data\n"); } if (!Ro_add_subscription_id(ccr, subscr.type, &(subscr.id))) { - LM_ERR("Problem adding Subscription ID data\n"); + LM_ERR("Problem adding Subscription ID data\n"); } if (!Ro_add_multiple_service_credit_Control(ccr, interim_request_credits/*INTERIM_CREDIT_REQ_AMOUNT*/, used, ro_session->rating_group, ro_session->service_identifier)) { - LM_ERR("Problem adding Multiple Service Credit Control data\n"); + LM_ERR("Problem adding Multiple Service Credit Control data\n"); } LM_DBG("Sending CCR Diameter message.\n"); @@ -614,32 +612,32 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned cdpb.AAASessionsUnlock(auth->hash); if (ro_forced_peer.len > 0) { - ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_interim_ccr, (void *) i_req); + ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_interim_ccr, (void *) i_req); } else { - ret = cdpb.AAASendMessage(ccr, resume_on_interim_ccr, (void *) i_req); + ret = cdpb.AAASendMessage(ccr, resume_on_interim_ccr, (void *) i_req); } if (ret != 1) { - goto error; + goto error; } -// cdpb.AAASessionsUnlock(auth->hash); + // cdpb.AAASessionsUnlock(auth->hash); Ro_free_CCR(ro_ccr_data); - update_stat(interim_ccrs, 1); + counter_inc(ims_charging_cnts_h.interim_ccrs); return; error: - LM_ERR("error trying to reserve interim credit\n"); + LM_ERR("error trying to reserve interim credit\n"); - if (ro_ccr_data) - Ro_free_CCR(ro_ccr_data); + if (ro_ccr_data) + Ro_free_CCR(ro_ccr_data); - if (ccr) - cdpb.AAAFreeMessage(&ccr); + if (ccr) + cdpb.AAAFreeMessage(&ccr); if (auth) { - cdpb.AAASessionsUnlock(auth->hash); - cdpb.AAADropCCAccSession(auth); + cdpb.AAASessionsUnlock(auth->hash); + cdpb.AAADropCCAccSession(auth); } shm_free(i_req); @@ -649,76 +647,76 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned // struct ro_session_entry *ro_session_entry = &(ro_session_table->entries[ro_session->h_entry]); ro_session_lock(ro_session_table, ro_session_entry); - unref_ro_session_unsafe(ro_session, 1, ro_session_entry);//unref from the initial timer that fired this event. + unref_ro_session_unsafe(ro_session, 1, ro_session_entry); //unref from the initial timer that fired this event. ro_session_unlock(ro_session_table, ro_session_entry); return; } static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca, long elapsed_msecs) { - struct interim_ccr *i_req = (struct interim_ccr *) param; - Ro_CCA_t * ro_cca_data = NULL; + struct interim_ccr *i_req = (struct interim_ccr *) param; + Ro_CCA_t * ro_cca_data = NULL; if (is_timeout) { - update_stat(ccr_timeouts, 1); - LM_ERR("Transaction timeout - did not get CCA\n"); - goto error; + counter_inc(ims_charging_cnts_h.ccr_timeouts); + LM_ERR("Transaction timeout - did not get CCA\n"); + goto error; } - update_stat(ccr_responses_time, elapsed_msecs); + counter_add(ims_charging_cnts_h.ccr_response_time, elapsed_msecs); - if (!i_req) { - LM_ERR("This is so wrong: ro session is NULL\n"); - goto error; - } + if (!i_req) { + LM_ERR("This is so wrong: ro session is NULL\n"); + goto error; + } - if (cca == NULL) { - LM_ERR("Error reserving credit for CCA.\n"); - goto error; - } + if (cca == NULL) { + LM_ERR("Error reserving credit for CCA.\n"); + goto error; + } - ro_cca_data = Ro_parse_CCA_avps(cca); + ro_cca_data = Ro_parse_CCA_avps(cca); - if (ro_cca_data == NULL) { - LM_ERR("Could not parse CCA message response.\n"); - goto error; - } + if (ro_cca_data == NULL) { + LM_ERR("Could not parse CCA message response.\n"); + goto error; + } - if (ro_cca_data->resultcode != 2001) { - LM_ERR("Got bad CCA result code [%d] - reservation failed", ro_cca_data->resultcode); - goto error; - } else { - LM_DBG("Valid CCA response with time chunk of [%i] and validity [%i].\n", ro_cca_data->mscc->granted_service_unit->cc_time, ro_cca_data->mscc->validity_time); - } + if (ro_cca_data->resultcode != 2001) { + LM_ERR("Got bad CCA result code [%d] - reservation failed", ro_cca_data->resultcode); + goto error; + } else { + LM_DBG("Valid CCA response with time chunk of [%i] and validity [%i].\n", ro_cca_data->mscc->granted_service_unit->cc_time, ro_cca_data->mscc->validity_time); + } - i_req->new_credit = ro_cca_data->mscc->granted_service_unit->cc_time; - i_req->credit_valid_for = ro_cca_data->mscc->validity_time; - i_req->is_final_allocation = 0; + i_req->new_credit = ro_cca_data->mscc->granted_service_unit->cc_time; + i_req->credit_valid_for = ro_cca_data->mscc->validity_time; + i_req->is_final_allocation = 0; - if (ro_cca_data->mscc->final_unit_action && (ro_cca_data->mscc->final_unit_action->action == 0)) - i_req->is_final_allocation = 1; + if (ro_cca_data->mscc->final_unit_action && (ro_cca_data->mscc->final_unit_action->action == 0)) + i_req->is_final_allocation = 1; - Ro_free_CCA(ro_cca_data); - cdpb.AAAFreeMessage(&cca); + Ro_free_CCA(ro_cca_data); + cdpb.AAAFreeMessage(&cca); - update_stat(successful_interim_ccrs, 1); - goto success; + counter_inc(ims_charging_cnts_h.successful_interim_ccrs); + goto success; error: - if (ro_cca_data) - Ro_free_CCA(ro_cca_data); + if (ro_cca_data) + Ro_free_CCA(ro_cca_data); - if (!is_timeout && cca) { - cdpb.AAAFreeMessage(&cca); - } + if (!is_timeout && cca) { + cdpb.AAAFreeMessage(&cca); + } - if (i_req) { - i_req->credit_valid_for = 0; - i_req->new_credit = 0; - } + if (i_req) { + i_req->credit_valid_for = 0; + i_req->new_credit = 0; + } success: - resume_ro_session_ontimeout(i_req); + resume_ro_session_ontimeout(i_req); } void send_ccr_stop(struct ro_session *ro_session) { @@ -731,13 +729,13 @@ void send_ccr_stop(struct ro_session *ro_session) { time_stamps_t *time_stamps; unsigned int used = 0; str user_name = {0, 0}; - int ret = 0; - + int ret = 0; + if (ro_session->event_type != pending) { - used = time(0) - ro_session->last_event_timestamp; + used = time(0) - ro_session->last_event_timestamp; } - update_stat(billed_secs, used); + counter_add(ims_charging_cnts_h.billed_secs, used); event_type_t *event_type; @@ -747,54 +745,54 @@ void send_ccr_stop(struct ro_session *ro_session) { time_t req_timestamp; event_type = new_event_type(&sip_method, &sip_event, 0); - + LM_DBG("Sending stop CCR request for (usage) [%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n", - used, - ro_session->asserted_identity.len, ro_session->asserted_identity.s, - ro_session->ro_session_id.len, ro_session->ro_session_id.s, - ro_session->rating_group, ro_session->service_identifier, - ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s, - ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s); + used, + ro_session->asserted_identity.len, ro_session->asserted_identity.s, + ro_session->ro_session_id.len, ro_session->ro_session_id.s, + ro_session->rating_group, ro_session->service_identifier, + ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s, + ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s); req_timestamp = time(0); if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, NULL, NULL))) - goto error0; + goto error0; + + if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, + &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id, &ro_session->pani))) + goto error0; - if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, - &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id))) - goto error0; - event_type = 0; if (ro_session->direction == RO_ORIG_DIRECTION) { - subscr.id = ro_session->asserted_identity; - - - } else if (ro_session->direction == RO_TERM_DIRECTION){ - subscr.id = ro_session->called_asserted_identity; + subscr.id = ro_session->asserted_identity; + + + } else if (ro_session->direction == RO_TERM_DIRECTION) { + subscr.id = ro_session->called_asserted_identity; } else { - LM_CRIT("don't know what to do in unknown mode - should we even get here\n"); - goto error0; + LM_CRIT("don't know what to do in unknown mode - should we even get here\n"); + goto error0; } - + //getting subscription id type - if (strncasecmp(subscr.id.s,"tel:",4)==0) { + if (strncasecmp(subscr.id.s, "tel:", 4) == 0) { subscr.type = Subscription_Type_MSISDN; - }else{ + } else { subscr.type = Subscription_Type_IMPU; //default is END_USER_SIP_URI } - + user_name.s = subscr.id.s; user_name.len = subscr.id.len; - - + + acc_record_type = AAA_ACCT_STOP; ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr); if (!ro_ccr_data) { - LM_ERR("send_ccr_stop: no memory left for generic\n"); - goto error0; + LM_ERR("send_ccr_stop: no memory left for generic\n"); + goto error0; } ims_info = 0; @@ -803,63 +801,64 @@ void send_ccr_stop(struct ro_session *ro_session) { auth = cdpb.AAAGetCCAccSession(ro_session->ro_session_id); if (!auth) { - LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n"); - /* lets try and recreate this session */ - auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp - if (!auth) - goto error1; + LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n"); + /* lets try and recreate this session */ + auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp + if (!auth) + goto error1; } if (!(ccr = Ro_new_ccr(auth, ro_ccr_data))) - goto error1; + goto error1; LM_DBG("Created new CCR\n"); if (!Ro_add_vendor_specific_appid(ccr, IMS_vendor_id_3GPP, IMS_Ro, 0)) { - LM_ERR("Problem adding Vendor specific ID\n"); + LM_ERR("Problem adding Vendor specific ID\n"); } - + ro_session->hop_by_hop += 1; if (!Ro_add_cc_request(ccr, RO_CC_STOP, ro_session->hop_by_hop)) { - LM_ERR("Problem adding CC-Request data\n"); + LM_ERR("Problem adding CC-Request data\n"); } - + if (!Ro_add_event_timestamp(ccr, time(NULL))) { - LM_ERR("Problem adding Event-Timestamp data\n"); + LM_ERR("Problem adding Event-Timestamp data\n"); } if (!Ro_add_user_equipment_info(ccr, AVP_EPC_User_Equipment_Info_Type_MAC, ro_session->avp_value.mac)) { - LM_ERR("Problem adding User-Equipment data\n"); + LM_ERR("Problem adding User-Equipment data\n"); } - + if (!Ro_add_subscription_id(ccr, subscr.type, &subscr.id)) { - LM_ERR("Problem adding Subscription ID data\n"); + LM_ERR("Problem adding Subscription ID data\n"); } - + if (!Ro_add_multiple_service_credit_Control_stop(ccr, used, ro_session->rating_group, ro_session->service_identifier)) { - LM_ERR("Problem adding Multiple Service Credit Control data\n"); + LM_ERR("Problem adding Multiple Service Credit Control data\n"); } - + if (!Ro_add_termination_cause(ccr, TERM_CAUSE_LOGOUT)) { - LM_ERR("problem add Termination cause AVP to STOP record.\n"); + LM_ERR("problem add Termination cause AVP to STOP record.\n"); } cdpb.AAASessionsUnlock(auth->hash); if (ro_forced_peer.len > 0) { - ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_termination_ccr, NULL); + ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_termination_ccr, NULL); } else { - ret = cdpb.AAASendMessage(ccr, resume_on_termination_ccr, NULL); + ret = cdpb.AAASendMessage(ccr, resume_on_termination_ccr, NULL); } if (ret != 1) { - goto error1; + goto error1; } Ro_free_CCR(ro_ccr_data); - update_stat(final_ccrs, 1); + counter_inc(ims_charging_cnts_h.final_ccrs); + counter_add(ims_charging_cnts_h.active_ro_sessions, -1); return; error1: @@ -867,8 +866,8 @@ void send_ccr_stop(struct ro_session *ro_session) { Ro_free_CCR(ro_ccr_data); if (auth) { - cdpb.AAASessionsUnlock(auth->hash); - cdpb.AAADropCCAccSession(auth); + cdpb.AAASessionsUnlock(auth->hash); + cdpb.AAADropCCAccSession(auth); } error0: @@ -880,44 +879,41 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c Ro_CCA_t *ro_cca_data = NULL; if (is_timeout) { - update_stat(ccr_timeouts, 1); - LM_ERR("Transaction timeout - did not get CCA\n"); - goto error; + counter_inc(ims_charging_cnts_h.ccr_timeouts); + LM_ERR("Transaction timeout - did not get CCA\n"); + goto error; } - update_stat(ccr_responses_time, elapsed_msecs); + counter_add(ims_charging_cnts_h.ccr_response_time, elapsed_msecs); if (!cca) { - LM_ERR("Error in termination CCR.\n"); - return; + LM_ERR("Error in termination CCR.\n"); + return; } ro_cca_data = Ro_parse_CCA_avps(cca); if (ro_cca_data == NULL) { - LM_DBG("Could not parse CCA message response.\n"); - return; + LM_DBG("Could not parse CCA message response.\n"); + return; } if (ro_cca_data->resultcode != 2001) { - LM_ERR("Got bad CCA result code for STOP record - [%d]\n", ro_cca_data->resultcode); - goto error; - } - else { - LM_DBG("Valid CCA response for STOP record\n"); + LM_ERR("Got bad CCA result code for STOP record - [%d]\n", ro_cca_data->resultcode); + goto error; + } else { + LM_DBG("Valid CCA response for STOP record\n"); } - update_stat(successful_final_ccrs, 1); + counter_inc(ims_charging_cnts_h.successful_final_ccrs); error: - Ro_free_CCA(ro_cca_data); - if (!is_timeout && cca) { - cdpb.AAAFreeMessage(&cca); - } + Ro_free_CCA(ro_cca_data); + if (!is_timeout && cca) { + cdpb.AAAFreeMessage(&cca); + } } - - /** * Send a CCR to the OCS based on the SIP message (INVITE ONLY) * @param msg - SIP message @@ -930,11 +926,11 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c * @returns #CSCF_RETURN_BREAK if OK, #CSCF_RETURN_ERROR on error */ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservation_units, str* incoming_trunk_id, str* outgoing_trunk_id, - cfg_action_t* action, unsigned int tindex, unsigned int tlabel) { - str session_id = { 0, 0 }, - called_asserted_identity = {0 , 0 }, - subscription_id = {0 , 0 }, - asserted_identity = {0 , 0 }; + str* pani, cfg_action_t* action, unsigned int tindex, unsigned int tlabel) { + str session_id = {0, 0}, + called_asserted_identity = {0, 0}, + subscription_id = {0, 0}, + asserted_identity = {0, 0}; int subscription_id_type = AVP_EPC_Subscription_Id_Type_End_User_SIP_URI; AAASession* cc_acc_session = NULL; Ro_CCR_t * ro_ccr_data = 0; @@ -942,219 +938,219 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat struct ro_session *new_session = 0; struct session_setup_data *ssd; int ret = 0; - struct hdr_field *h=0; - - int cc_event_number = 0; //According to IOT tests this should start at 0 + struct hdr_field *h = 0; + + int cc_event_number = 0; //According to IOT tests this should start at 0 int cc_event_type = RO_CC_START; int free_called_asserted_identity = 0; - + sdp_session_cell_t* msg_sdp_session; sdp_stream_cell_t* msg_sdp_stream; - + int active_service_identifier; int active_rating_group; - + int sdp_stream_num = 0; LM_DBG("Sending initial CCR request for reservation_units [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n", - reservation_units, - incoming_trunk_id->len, incoming_trunk_id->s, - outgoing_trunk_id->len, outgoing_trunk_id->s); - - - - ssd = shm_malloc(sizeof(struct session_setup_data)); // lookup structure used to load session info from cdp callback on CCA + reservation_units, + incoming_trunk_id->len, incoming_trunk_id->s, + outgoing_trunk_id->len, outgoing_trunk_id->s); + + + + ssd = shm_malloc(sizeof (struct session_setup_data)); // lookup structure used to load session info from cdp callback on CCA if (!ssd) { - LM_ERR("no more shm mem\n"); - goto error; + LM_ERR("no more shm mem\n"); + goto error; } //getting asserted identity if ((asserted_identity = cscf_get_asserted_identity(msg, 0)).len == 0) { - LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity"); - asserted_identity = dlg->from_uri; + LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity"); + asserted_identity = dlg->from_uri; } - - + + //getting called asserted identity if ((called_asserted_identity = cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) { - LM_DBG("No P-Called-Identity hdr found. Using request URI for called_asserted_identity"); - called_asserted_identity = cscf_get_public_identity_from_requri(msg); - free_called_asserted_identity = 1; + LM_DBG("No P-Called-Identity hdr found. Using request URI for called_asserted_identity"); + called_asserted_identity = cscf_get_public_identity_from_requri(msg); + free_called_asserted_identity = 1; } - + if (dir == RO_ORIG_DIRECTION) { - subscription_id.s = asserted_identity.s; - subscription_id.len = asserted_identity.len; - - } else if (dir == RO_TERM_DIRECTION){ - subscription_id.s = called_asserted_identity.s; - subscription_id.len = called_asserted_identity.len; + subscription_id.s = asserted_identity.s; + subscription_id.len = asserted_identity.len; + + } else if (dir == RO_TERM_DIRECTION) { + subscription_id.s = called_asserted_identity.s; + subscription_id.len = called_asserted_identity.len; } else { - LM_CRIT("don't know what to do in unknown mode - should we even get here\n"); - goto error; + LM_CRIT("don't know what to do in unknown mode - should we even get here\n"); + goto error; } - + //getting subscription id type - if (strncasecmp(subscription_id.s,"tel:",4)==0) { + if (strncasecmp(subscription_id.s, "tel:", 4) == 0) { subscription_id_type = Subscription_Type_MSISDN; - }else{ + } else { subscription_id_type = Subscription_Type_IMPU; //default is END_USER_SIP_URI } - str mac = {0,0}; + str mac = {0, 0}; if (get_mac_avp_value(msg, &mac) != 0) - LM_DBG(RO_MAC_AVP_NAME" was not set. Using default."); - + LM_DBG(RO_MAC_AVP_NAME" was not set. Using default."); + //by default we use voice service id and rate group - //then we check SDP - if we find video then we use video service id and rate group - LM_DBG("Setting default SID to %d and RG to %d for voice", - voice_service_identifier, voice_rating_group); - active_service_identifier = voice_service_identifier; - active_rating_group = voice_rating_group; - - //check SDP - if there is video then set default to video, if not set it to audio - if (parse_sdp(msg) < 0) { - LM_ERR("Unable to parse req SDP\n"); - goto error; - } - - msg_sdp_session = get_sdp_session(msg, 0); - if (!msg_sdp_session ) { - LM_ERR("Missing SDP session information from rpl\n"); - } else { - for (;;) { - msg_sdp_stream = get_sdp_stream(msg, 0, sdp_stream_num); - if (!msg_sdp_stream) { - //LM_ERR("Missing SDP stream information\n"); - break; - } - - int intportA = atoi(msg_sdp_stream->port.s); - if(intportA != 0 && strncasecmp(msg_sdp_stream->media.s,"video",5)==0){ - LM_DBG("This SDP has a video component and src ports not equal to 0 - so we set default SID to %d and RG to %d for video", - video_service_identifier, video_rating_group); - active_service_identifier = video_service_identifier; - active_rating_group = video_rating_group; - break; - } - - sdp_stream_num++; + //then we check SDP - if we find video then we use video service id and rate group + LM_DBG("Setting default SID to %d and RG to %d for voice", + voice_service_identifier, voice_rating_group); + active_service_identifier = voice_service_identifier; + active_rating_group = voice_rating_group; + + //check SDP - if there is video then set default to video, if not set it to audio + if (parse_sdp(msg) < 0) { + LM_ERR("Unable to parse req SDP\n"); + goto error; + } + + msg_sdp_session = get_sdp_session(msg, 0); + if (!msg_sdp_session) { + LM_ERR("Missing SDP session information from rpl\n"); + } else { + for (;;) { + msg_sdp_stream = get_sdp_stream(msg, 0, sdp_stream_num); + if (!msg_sdp_stream) { + //LM_ERR("Missing SDP stream information\n"); + break; } - } - - free_sdp((sdp_info_t**) (void*) &msg->body); - //create a session object without auth and diameter session id - we will add this later. - new_session = build_new_ro_session(dir, 0, 0, &session_id, &dlg->callid, - &asserted_identity, &called_asserted_identity, &mac, dlg->h_entry, dlg->h_id, - reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id, outgoing_trunk_id); + int intportA = atoi(msg_sdp_stream->port.s); + if (intportA != 0 && strncasecmp(msg_sdp_stream->media.s, "video", 5) == 0) { + LM_DBG("This SDP has a video component and src ports not equal to 0 - so we set default SID to %d and RG to %d for video", + video_service_identifier, video_rating_group); + active_service_identifier = video_service_identifier; + active_rating_group = video_rating_group; + break; + } - if (!new_session) { - LM_ERR("Couldn't create new Ro Session - this is BAD!\n"); - goto error; + sdp_stream_num++; } + } + + free_sdp((sdp_info_t**) (void*) &msg->body); - ssd->action = action; - ssd->tindex = tindex; - ssd->tlabel = tlabel; - ssd->ro_session = new_session; + //create a session object without auth and diameter session id - we will add this later. + new_session = build_new_ro_session(dir, 0, 0, &session_id, &dlg->callid, + &asserted_identity, &called_asserted_identity, &mac, dlg->h_entry, dlg->h_id, + reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id, outgoing_trunk_id, pani); - if (!sip_create_ro_ccr_data(msg, dir, &ro_ccr_data, &cc_acc_session, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, incoming_trunk_id, outgoing_trunk_id)) - goto error; + if (!new_session) { + LM_ERR("Couldn't create new Ro Session - this is BAD!\n"); + goto error; + } + + ssd->action = action; + ssd->tindex = tindex; + ssd->tlabel = tlabel; + ssd->ro_session = new_session; + + if (!sip_create_ro_ccr_data(msg, dir, &ro_ccr_data, &cc_acc_session, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, incoming_trunk_id, outgoing_trunk_id, pani)) + goto error; if (!ro_ccr_data) - goto error; + goto error; if (!cc_acc_session) - goto error; - + goto error; + if (!(ccr = Ro_new_ccr(cc_acc_session, ro_ccr_data))) - goto error; + goto error; if (!Ro_add_vendor_specific_appid(ccr, IMS_vendor_id_3GPP, IMS_Ro, 0)) { - LM_ERR("Problem adding Vendor specific ID\n"); - goto error; + LM_ERR("Problem adding Vendor specific ID\n"); + goto error; } if (!Ro_add_cc_request(ccr, cc_event_type, cc_event_number)) { - LM_ERR("Problem adding CC-Request data\n"); - goto error; + LM_ERR("Problem adding CC-Request data\n"); + goto error; } if (!Ro_add_event_timestamp(ccr, time(NULL))) { - LM_ERR("Problem adding Event-Timestamp data\n"); - goto error; + LM_ERR("Problem adding Event-Timestamp data\n"); + goto error; } if (!Ro_add_user_equipment_info(ccr, AVP_EPC_User_Equipment_Info_Type_MAC, mac)) { - LM_ERR("Problem adding User-Equipment data\n"); - goto error; + LM_ERR("Problem adding User-Equipment data\n"); + goto error; } if (!Ro_add_subscription_id(ccr, subscription_id_type, &subscription_id)) { - LM_ERR("Problem adding Subscription ID data\n"); - goto error; + LM_ERR("Problem adding Subscription ID data\n"); + goto error; } if (!Ro_add_multiple_service_credit_Control(ccr, reservation_units, -1, active_rating_group, active_service_identifier)) { - LM_ERR("Problem adding Multiple Service Credit Control data\n"); - goto error; + LM_ERR("Problem adding Multiple Service Credit Control data\n"); + goto error; } - + /* before we send, update our session object with CC App session ID and data */ new_session->auth_appid = cc_acc_session->application_id; new_session->auth_session_type = cc_acc_session->type; new_session->ro_session_id.s = (char*) shm_malloc(cc_acc_session->id.len); new_session->ro_session_id.len = cc_acc_session->id.len; memcpy(new_session->ro_session_id.s, cc_acc_session->id.s, cc_acc_session->id.len); - + LM_DBG("new CC Ro Session ID: [%.*s]\n", cc_acc_session->id.len, cc_acc_session->id.s); LM_DBG("Sending CCR Diameter message.\n"); cdpb.AAASessionsUnlock(cc_acc_session->hash); if (ro_forced_peer.len > 0) { - LM_DBG("Sending message with Peer\n"); - ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_initial_ccr, (void *) ssd); + LM_DBG("Sending message with Peer\n"); + ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_initial_ccr, (void *) ssd); } else { - LM_DBG("Sending message without Peer and realm is [%.*s]\n", ccr->dest_realm->data.len, ccr->dest_realm->data.s); - ret = cdpb.AAASendMessage(ccr, resume_on_initial_ccr, (void *) ssd); + LM_DBG("Sending message without Peer and realm is [%.*s]\n", ccr->dest_realm->data.len, ccr->dest_realm->data.s); + ret = cdpb.AAASendMessage(ccr, resume_on_initial_ccr, (void *) ssd); } if (ret != 1) { - LM_ERR("Failed to send Diameter CCR\n"); - goto error; + LM_ERR("Failed to send Diameter CCR\n"); + goto error; } Ro_free_CCR(ro_ccr_data); //TODO: if the following fail, we should clean up the Ro session....... - if (dlgb.register_dlgcb(dlg, /* DLGCB_RESPONSE_FWDED */ DLGCB_CONFIRMED, dlg_reply, (void*)new_session ,NULL ) != 0) { - LM_CRIT("cannot register callback for dialog confirmation\n"); - goto error; + if (dlgb.register_dlgcb(dlg, /* DLGCB_RESPONSE_FWDED */ DLGCB_CONFIRMED, dlg_reply, (void*) new_session, NULL) != 0) { + LM_CRIT("cannot register callback for dialog confirmation\n"); + goto error; } if (dlgb.register_dlgcb(dlg, DLGCB_TERMINATED | DLGCB_FAILED | DLGCB_EXPIRED /*| DLGCB_DESTROY */ - , dlg_terminated, (void*)new_session, NULL ) != 0) { - LM_CRIT("cannot register callback for dialog termination\n"); - goto error; + , dlg_terminated, (void*) new_session, NULL) != 0) { + LM_CRIT("cannot register callback for dialog termination\n"); + goto error; } - update_stat(initial_ccrs, 1); + counter_inc(ims_charging_cnts_h.initial_ccrs); - if(free_called_asserted_identity) shm_free(called_asserted_identity.s);// shm_malloc in cscf_get_public_identity_from_requri + if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri return RO_RETURN_BREAK; error: - if(free_called_asserted_identity) shm_free(called_asserted_identity.s);// shm_malloc in cscf_get_public_identity_from_requri + if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri Ro_free_CCR(ro_ccr_data); if (cc_acc_session) { - cdpb.AAASessionsUnlock(cc_acc_session->hash); - cdpb.AAADropSession(cc_acc_session); + cdpb.AAASessionsUnlock(cc_acc_session->hash); + cdpb.AAADropSession(cc_acc_session); } if (ssd) - shm_free(ssd); + shm_free(ssd); LM_DBG("Trying to reserve credit on initial INVITE failed.\n"); return RO_RETURN_ERROR; @@ -1164,37 +1160,37 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca, Ro_CCA_t *ro_cca_data = NULL; struct cell *t = NULL; struct session_setup_data *ssd = (struct session_setup_data *) param; - int error_code = RO_RETURN_ERROR; + int error_code = RO_RETURN_ERROR; if (is_timeout) { - update_stat(ccr_timeouts, 1); - LM_ERR("Transaction timeout - did not get CCA\n"); - error_code = RO_RETURN_ERROR; - goto error0; + counter_inc(ims_charging_cnts_h.ccr_timeouts); + LM_ERR("Transaction timeout - did not get CCA\n"); + error_code = RO_RETURN_ERROR; + goto error0; } - update_stat(ccr_responses_time, elapsed_msecs); + counter_add(ims_charging_cnts_h.ccr_response_time, elapsed_msecs); if (!cca) { - LM_ERR("Error reserving credit for CCA.\n"); - error_code = RO_RETURN_ERROR; - goto error0; + LM_ERR("Error reserving credit for CCA.\n"); + error_code = RO_RETURN_ERROR; + goto error0; } if (!ssd) { - LM_ERR("Session lookup data is NULL.\n"); - error_code = RO_RETURN_ERROR; - goto error0; + LM_ERR("Session lookup data is NULL.\n"); + error_code = RO_RETURN_ERROR; + goto error0; } // we make sure the transaction exists - if (tmb.t_lookup_ident(&t, ssd->tindex, ssd->tlabel) < 0) { - LM_ERR("t_continue: transaction not found\n"); - error_code = RO_RETURN_ERROR; - goto error0; - } + if (tmb.t_lookup_ident(&t, ssd->tindex, ssd->tlabel) < 0) { + LM_ERR("t_continue: transaction not found\n"); + error_code = RO_RETURN_ERROR; + goto error0; + } - // we bring the list of AVPs of the transaction to the current context + // we bring the list of AVPs of the transaction to the current context set_avp_list(AVP_TRACK_FROM | AVP_CLASS_URI, &t->uri_avps_from); set_avp_list(AVP_TRACK_TO | AVP_CLASS_URI, &t->uri_avps_to); set_avp_list(AVP_TRACK_FROM | AVP_CLASS_USER, &t->user_avps_from); @@ -1205,20 +1201,20 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca, ro_cca_data = Ro_parse_CCA_avps(cca); if (!ro_cca_data) { - LM_ERR("Could not parse CCA message response.\n"); - error_code = RO_RETURN_ERROR; - goto error0; + LM_ERR("Could not parse CCA message response.\n"); + error_code = RO_RETURN_ERROR; + goto error0; } if (ro_cca_data->resultcode != 2001) { - LM_ERR("Got bad CCA result code - reservation failed"); - error_code = RO_RETURN_FALSE; - goto error1; + LM_ERR("Got bad CCA result code - reservation failed"); + error_code = RO_RETURN_FALSE; + goto error1; } LM_DBG("Valid CCA response with time chunk of [%i] and validity [%i]\n", - ro_cca_data->mscc->granted_service_unit->cc_time, - ro_cca_data->mscc->validity_time); + ro_cca_data->mscc->granted_service_unit->cc_time, + ro_cca_data->mscc->validity_time); ssd->ro_session->last_event_timestamp = time(0); ssd->ro_session->event_type = pending; @@ -1230,41 +1226,43 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca, LM_DBG("Freeing CCA message\n"); cdpb.AAAFreeMessage(&cca); - link_ro_session(ssd->ro_session, 1); /* create extra ref for the fact that dialog has a handle in the callbacks */ - + link_ro_session(ssd->ro_session, 1); /* create extra ref for the fact that dialog has a handle in the callbacks */ + if (ro_db_mode == DB_MODE_REALTIME) { ssd->ro_session->flags |= RO_SESSION_FLAG_NEW; if (update_ro_dbinfo(ssd->ro_session) != 0) { LM_ERR("Failed to update ro_session in database... continuing\n"); }; } - - unref_ro_session(ssd->ro_session, 1); /* release our reference */ - + + unref_ro_session(ssd->ro_session, 1); /* release our reference */ + create_cca_return_code(RO_RETURN_TRUE); if (t) - tmb.unref_cell(t); + tmb.unref_cell(t); tmb.t_continue(ssd->tindex, ssd->tlabel, ssd->action); shm_free(ssd); - update_stat(successful_initial_ccrs, 1); + counter_inc(ims_charging_cnts_h.successful_initial_ccrs); + counter_inc(ims_charging_cnts_h.active_ro_sessions); + return; error1: - Ro_free_CCA(ro_cca_data); + Ro_free_CCA(ro_cca_data); error0: LM_DBG("Trying to reserve credit on initial INVITE failed on cdp callback\n"); create_cca_return_code(error_code); if (!is_timeout && cca) { - cdpb.AAAFreeMessage(&cca); + cdpb.AAAFreeMessage(&cca); } if (t) - tmb.unref_cell(t); + tmb.unref_cell(t); tmb.t_continue(ssd->tindex, ssd->tlabel, ssd->action); shm_free(ssd); @@ -1274,23 +1272,23 @@ void remove_aaa_session(str *session_id) { AAASession *session; if ((session = cdpb.AAAGetCCAccSession(*session_id))) { - LM_DBG("Found AAA CC App Auth session to delete.\n"); - cdpb.AAASessionsUnlock(session->hash); - cdpb.AAADropCCAccSession(session); + LM_DBG("Found AAA CC App Auth session to delete.\n"); + cdpb.AAASessionsUnlock(session->hash); + cdpb.AAADropCCAccSession(session); } } int get_direction_as_int(str* direction) { - char* p = direction->s; - - if (direction->len > 0 && p) { - if (p[0]=='O' || p[0]=='o'){ - return RO_ORIG_DIRECTION; - } else if (p[0]=='T' || p[0]=='t') { - return RO_TERM_DIRECTION; - } + char* p = direction->s; + + if (direction->len > 0 && p) { + if (p[0] == 'O' || p[0] == 'o') { + return RO_ORIG_DIRECTION; + } else if (p[0] == 'T' || p[0] == 't') { + return RO_TERM_DIRECTION; } - return RO_UNKNOWN_DIRECTION; + } + return RO_UNKNOWN_DIRECTION; } static int create_cca_return_code(int result) { @@ -1300,50 +1298,50 @@ static int create_cca_return_code(int result) { avp_name.s.len = RO_AVP_CCA_RETURN_CODE_LENGTH; avp_val.n = result; - avp_val.s.s = RO_RETURN_TRUE_STR; //assume true + avp_val.s.s = RO_RETURN_TRUE_STR; //assume true avp_val.s.len = 1; - switch(result) { - case RO_RETURN_FALSE: - avp_val.s.s = RO_RETURN_FALSE_STR; - break; - case RO_RETURN_ERROR: - avp_val.s.s = RO_RETURN_ERROR_STR; - break; - default: - if (result >= 0) - break; + switch (result) { + case RO_RETURN_FALSE: + avp_val.s.s = RO_RETURN_FALSE_STR; + break; + case RO_RETURN_ERROR: + avp_val.s.s = RO_RETURN_ERROR_STR; + break; + default: + if (result >= 0) + break; - LM_ERR("Unknown result code: %d", result); - avp_val.s.s = "??"; + LM_ERR("Unknown result code: %d", result); + avp_val.s.s = "??"; } - if (result < 0) - avp_val.s.len = 2; + if (result < 0) + avp_val.s.len = 2; - rc = add_avp(AVP_NAME_STR|AVP_VAL_STR, avp_name, avp_val); + rc = add_avp(AVP_NAME_STR | AVP_VAL_STR, avp_name, avp_val); if (rc < 0) - LM_ERR("Couldn't create ["RO_AVP_CCA_RETURN_CODE"] AVP\n"); + LM_ERR("Couldn't create ["RO_AVP_CCA_RETURN_CODE"] AVP\n"); else - LM_DBG("Created AVP ["RO_AVP_CCA_RETURN_CODE"] successfully: value=[%d]\n", result); + LM_DBG("Created AVP ["RO_AVP_CCA_RETURN_CODE"] successfully: value=[%d]\n", result); return 1; } static int get_mac_avp_value(struct sip_msg *msg, str *value) { - str mac_avp_name_str = str_init(RO_MAC_AVP_NAME); - pv_spec_t avp_spec; - pv_value_t val; + str mac_avp_name_str = str_init(RO_MAC_AVP_NAME); + pv_spec_t avp_spec; + pv_value_t val; - pv_parse_spec2(&mac_avp_name_str, &avp_spec, 1); - if (pv_get_spec_value(msg, &avp_spec, &val) != 0 || val.rs.len == 0) { + pv_parse_spec2(&mac_avp_name_str, &avp_spec, 1); + if (pv_get_spec_value(msg, &avp_spec, &val) != 0 || val.rs.len == 0) { - value->s = "00:00:00:00:00:00"; - value->len = sizeof("00:00:00:00:00:00") - 1; - return -1; - } + value->s = "00:00:00:00:00:00"; + value->len = sizeof ("00:00:00:00:00:00") - 1; + return -1; + } - *value = val.rs; - return 0; + *value = val.rs; + return 0; } diff --git a/modules/ims_charging/ims_ro.h b/modules/ims_charging/ims_ro.h index b6087b8cac9..b18d0f8f93b 100644 --- a/modules/ims_charging/ims_ro.h +++ b/modules/ims_charging/ims_ro.h @@ -15,7 +15,7 @@ struct interim_ccr { void credit_control_session_callback(int event, void* session); void remove_aaa_session(str *session_id); int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservation_units, - str *incoming_trunk_id, str *outgoing_trunk_id, cfg_action_t* action, unsigned int tindex, unsigned int tlabel); + str *incoming_trunk_id, str *outgoing_trunk_id, str *enb_cell_id, cfg_action_t* action, unsigned int tindex, unsigned int tlabel); void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned int reserve); void send_ccr_stop(struct ro_session *ro_session); int get_direction_as_int(str* direction); diff --git a/modules/ims_charging/mod.c b/modules/ims_charging/mod.c index 0d323c84cc4..2b45f72e359 100644 --- a/modules/ims_charging/mod.c +++ b/modules/ims_charging/mod.c @@ -12,7 +12,6 @@ #include "../cdp/cdp_load.h" #include "../cdp_avp/mod_export.h" #include "../../parser/parse_to.h" -#include "stats.h" #include "ro_timer.h" #include "ro_session_hash.h" #include "ims_ro.h" @@ -21,6 +20,7 @@ #include "../ims_usrloc_scscf/usrloc.h" #include "../../lib/ims/ims_getters.h" #include "ro_db_handler.h" +#include "ims_charging_stats.h" MODULE_VERSION @@ -75,17 +75,6 @@ int cdp_event_threshold = 500; /*time in ms above which we should report slow pr int cdp_event_latency_loglevel = 0; /*log-level to use to report slow processing of CDP callback event - default ERROR*/ int single_ro_session_per_dialog = 0; /*whether to to have 1 ro_session per dialog or let user decide from config - default is an ro session every time Ro_CCR called from config file*/ -stat_var *initial_ccrs; -stat_var *interim_ccrs; -stat_var *final_ccrs; -stat_var *successful_initial_ccrs; -stat_var *successful_interim_ccrs; -stat_var *successful_final_ccrs; -stat_var *ccr_responses_time; -stat_var *billed_secs; -stat_var *killed_calls; -stat_var *ccr_timeouts; - /** module functions */ static int mod_init(void); static int mod_child_init(int); @@ -133,29 +122,11 @@ static param_export_t params[] = { { 0, 0, 0 } }; -stat_export_t charging_stats[] = { - {"initial_ccrs", STAT_NO_RESET, &initial_ccrs}, - {"interim_ccrs", STAT_NO_RESET, &interim_ccrs}, - {"final_ccrs", STAT_NO_RESET, &final_ccrs}, - {"successful_initial_ccrs", STAT_NO_RESET, &successful_initial_ccrs}, - {"successful_interim_ccr", STAT_NO_RESET, &successful_interim_ccrs}, - {"successful_final_ccrs", STAT_NO_RESET, &successful_final_ccrs}, - {"failed_initial_ccrs", STAT_IS_FUNC, (stat_var**) get_failed_initial_ccrs}, - {"failed_interim_ccr", STAT_IS_FUNC, (stat_var**) get_failed_interim_ccrs}, - {"failed_final_ccrs", STAT_IS_FUNC, (stat_var**) get_failed_final_ccrs}, - {"ccr_avg_response_time", STAT_IS_FUNC, (stat_var**) get_ccr_avg_response_time}, - {"ccr_responses_time", STAT_NO_RESET, &ccr_responses_time}, - {"billed_secs", STAT_NO_RESET, &billed_secs}, - {"killed_calls", STAT_NO_RESET, &killed_calls}, - {"ccr_timeouts", 0, &ccr_timeouts}, - {0, 0, 0} -}; - /** module exports */ struct module_exports exports = { MOD_NAME, DEFAULT_DLFLAGS, /* dlopen flags */ cmds, /* Exported functions */ params, /* Exported params */ - charging_stats, /* exported statistics */ + 0, /* exported statistics */ 0, /* exported MI functions */ 0, /* exported pseudo-variables */ 0, /* extra processes */ @@ -280,16 +251,10 @@ static int mod_init(void) { return -1; } - /* register statistics */ - if (register_module_stats(exports.name, charging_stats) != 0) { - LM_ERR("failed to register core statistics\n"); - return -1; + if (ims_charging_init_counters() != 0) { + LM_ERR("Failed to register counters for ims_charging module\n"); + return -1; } - - /*if (register_stat(MOD_NAME, "ccr_responses_time", &ccr_responses_time, 0)) { - LM_ERR("failed to register core statistics\n"); - return -1; - }*/ /* if a database should be used to store the dialogs' information */ ro_db_mode = ro_db_mode_param; @@ -360,6 +325,7 @@ static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, int ret = RO_RETURN_TRUE; int dir = 0; str identity = {0, 0}, + pani = {0,0}, contact = {0, 0}; struct hdr_field *h=0; @@ -428,6 +394,7 @@ static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, goto send_ccr; } + pani = cscf_get_access_network_info(msg, &h); } else if (dir == RO_TERM_DIRECTION){ //get callee IMPU from called part id - if not present then skip this if ((identity = cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) { @@ -538,7 +505,7 @@ static int w_ro_ccr(struct sip_msg *msg, char* c_route_name, char* c_direction, goto done; } - ret = Ro_Send_CCR(msg, dlg, dir, reservation_units, &s_incoming_trunk_id, &s_outgoing_trunk_id, cfg_action, tindex, tlabel); + ret = Ro_Send_CCR(msg, dlg, dir, reservation_units, &s_incoming_trunk_id, &s_outgoing_trunk_id, &pani, cfg_action, tindex, tlabel); if(ret < 0){ LM_ERR("Failed to send CCR\n"); diff --git a/modules/ims_charging/ro_session_hash.c b/modules/ims_charging/ro_session_hash.c index 543009bbcdc..b78d827f58a 100644 --- a/modules/ims_charging/ro_session_hash.c +++ b/modules/ims_charging/ro_session_hash.c @@ -177,10 +177,11 @@ void destroy_dlg_table(void) { struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_session_type, str *session_id, str *callid, str *asserted_identity, str* called_asserted_identity, str* mac, unsigned int dlg_h_entry, unsigned int dlg_h_id, unsigned int requested_secs, unsigned int validity_timeout, - int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id){ + int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id, str *pani){ LM_DBG("Building Ro Session **********"); char *p; - unsigned int len = session_id->len + callid->len + asserted_identity->len + called_asserted_identity->len + mac->len + incoming_trunk_id->len + outgoing_trunk_id->len + sizeof (struct ro_session); + unsigned int len = session_id->len + callid->len + asserted_identity->len + called_asserted_identity->len + mac->len + + incoming_trunk_id->len + outgoing_trunk_id->len + pani->len + sizeof (struct ro_session); struct ro_session *new_ro_session = (struct ro_session*) shm_malloc(len); if (!new_ro_session) { @@ -192,6 +193,11 @@ struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_ LM_DBG("New Ro Session given memory at address [%p]\n", new_ro_session); memset(new_ro_session, 0, len); + +// if (pani->len < MAX_PANI_LEN) { +// p = new_ro_session->pani; +// memcpy(p, pani->s, pani->len); +// } new_ro_session->direction = direction; new_ro_session->auth_appid = auth_appid; @@ -246,11 +252,15 @@ struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_ memcpy(p, outgoing_trunk_id->s, outgoing_trunk_id->len); p += outgoing_trunk_id->len; - new_ro_session->avp_value.mac.s = p; - new_ro_session->avp_value.mac.len = mac->len; + new_ro_session->avp_value.mac.s = p; + new_ro_session->avp_value.mac.len = mac->len; memcpy(p, mac->s, mac->len); - p += mac->len; + + new_ro_session->pani.s = p; + memcpy(p, pani->s, pani->len); + new_ro_session->pani.len = pani->len; + p += pani->len; if (p != (((char*) new_ro_session) + len)) { LM_ERR("buffer overflow\n"); diff --git a/modules/ims_charging/ro_session_hash.h b/modules/ims_charging/ro_session_hash.h index 3ba0e5ec015..4e7c9fe900f 100644 --- a/modules/ims_charging/ro_session_hash.h +++ b/modules/ims_charging/ro_session_hash.h @@ -20,6 +20,8 @@ #define RO_SESSION_FLAG_CHANGED (1<<2) /*!< ro session has been updated */ #define RO_SESSION_FLAG_DELETED (1<<3) /*!< ro session has been deleted */ +#define MAX_PANI_LEN 100 + enum ro_session_event_type { pending, answered, @@ -50,6 +52,7 @@ struct ro_session { str called_asserted_identity; str incoming_trunk_id; str outgoing_trunk_id; + str pani; unsigned int hop_by_hop; struct ro_tl ro_tl; unsigned int reserved_secs; @@ -191,7 +194,7 @@ void remove_aaa_session(str *session_id); struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_session_type, str *session_id, str *callid, str *asserted_identity, str* called_asserted_identity, str* mac, unsigned int dlg_h_entry, unsigned int dlg_h_id, unsigned int requested_secs, unsigned int validity_timeout, - int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id); + int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id, str *pani); /*! * \brief Refefence a ro_session with locking diff --git a/modules/ims_charging/ro_timer.c b/modules/ims_charging/ro_timer.c index 75f6eab4656..d1d036dd5fe 100644 --- a/modules/ims_charging/ro_timer.c +++ b/modules/ims_charging/ro_timer.c @@ -14,14 +14,16 @@ #include "ro_timer.h" #include "ro_session_hash.h" #include "ims_ro.h" -#include "stats.h" #include "ro_db_handler.h" #include "mod.h" +#include "ims_charging_stats.h" +#include "../../counters.h" extern int interim_request_credits; extern int ro_timer_buffer; extern int ro_db_mode; extern struct dlg_binds dlgb; +extern struct ims_charging_counters_h ims_charging_cnts_h; /*! global dialog timer */ struct ro_timer *roi_timer = 0; @@ -383,7 +385,6 @@ void ro_session_ontimeout(struct ro_tl *tl) { LM_DBG("We have a fired timer [p=%p] and tl=[%i].\n", tl, tl->timeout); /* find the session id for this timer*/ - struct ro_session_entry *ro_session_entry = NULL; struct ro_session* ro_session = ((struct ro_session*) ((char *) (tl) - (unsigned long) (&((struct ro_session*) 0)->ro_tl))); if (!ro_session) { @@ -391,8 +392,6 @@ void ro_session_ontimeout(struct ro_tl *tl) { return; } - ro_session_entry = &(ro_session_table->entries[ro_session->h_entry]); - LM_DBG("event-type=%d", ro_session->event_type); // if (!ro_session->active) { @@ -407,7 +406,7 @@ void ro_session_ontimeout(struct ro_tl *tl) { used_secs = now - ro_session->last_event_timestamp; call_time = now - ro_session->start_time; - update_stat(billed_secs, used_secs); + counter_add(ims_charging_cnts_h.billed_secs, used_secs); if (ro_session->callid.s != NULL && ro_session->dlg_h_entry >= 0 @@ -463,7 +462,7 @@ void ro_session_ontimeout(struct ro_tl *tl) { } - update_stat(killed_calls, 1); + counter_inc(ims_charging_cnts_h.killed_calls); //unref_ro_session_unsafe(ro_session, 1, ro_session_entry); //unref from the initial timer that fired this event. // ro_session_unlock(ro_session_table, ro_session_entry); diff --git a/modules/ims_charging/stats.c b/modules/ims_charging/stats.c deleted file mode 100644 index 93627d86b0a..00000000000 --- a/modules/ims_charging/stats.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * stats.c - * - * Created on: Sep 30, 2013 - * Author: carlos - */ - -#include "stats.h" - -unsigned long get_failed_initial_ccrs() { - - unsigned long success_number = get_stat_val(successful_initial_ccrs), - total_number = get_stat_val(initial_ccrs); - - return total_number - success_number; -} - -unsigned long get_failed_interim_ccrs() { - - unsigned long success_number = get_stat_val(successful_interim_ccrs), - total_number = get_stat_val(interim_ccrs); - - return total_number - success_number; -} - -unsigned long get_failed_final_ccrs() { - - unsigned long success_number = get_stat_val(successful_final_ccrs), - total_number = get_stat_val(final_ccrs); - - return total_number - success_number; -} - -unsigned long get_ccr_avg_response_time() { - - unsigned long responses_time = get_stat_val(ccr_responses_time), - ccrs = get_stat_val(initial_ccrs) - + get_stat_val(interim_ccrs) - + get_stat_val(final_ccrs); - - if (responses_time == 0 || ccrs == 0) - return 0; - - return responses_time / ccrs; -} diff --git a/modules/ims_charging/stats.h b/modules/ims_charging/stats.h deleted file mode 100644 index 9b0e3fc1cd4..00000000000 --- a/modules/ims_charging/stats.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * stats.h - * - * Created on: Sep 30, 2013 - * Author: carlos - */ - -#ifndef STATS_H_ -#define STATS_H_ - -#include "../../lib/kcore/statistics.h" - -extern stat_var *initial_ccrs; -extern stat_var *interim_ccrs; -extern stat_var *final_ccrs; -extern stat_var *successful_initial_ccrs; -extern stat_var *successful_interim_ccrs; -extern stat_var *successful_final_ccrs; -extern stat_var *ccr_responses_time; -extern stat_var *billed_secs; -extern stat_var *killed_calls; -extern stat_var *ccr_timeouts; - -unsigned long get_failed_initial_ccrs(); -unsigned long get_failed_interim_ccrs(); -unsigned long get_failed_final_ccrs(); -unsigned long get_ccr_avg_response_time(); - -#endif /* STATS_H_ */ diff --git a/modules/ims_qos/cdpeventprocessor.c b/modules/ims_qos/cdpeventprocessor.c index 42fcfa8a2dd..2b38050a6e4 100644 --- a/modules/ims_qos/cdpeventprocessor.c +++ b/modules/ims_qos/cdpeventprocessor.c @@ -51,6 +51,7 @@ #include "mod.h" #include "cdpeventprocessor.h" #include "rx_str.h" +#include "ims_qos_stats.h" cdp_cb_event_list_t *cdp_event_list = 0; extern usrloc_api_t ul; @@ -60,6 +61,8 @@ extern int cdp_event_threshold; extern int cdp_event_latency_loglevel; extern int cdp_event_list_size_threshold; +extern struct ims_qos_counters_h ims_qos_cnts_h; + int init_cdp_cb_event_list() { cdp_event_list = shm_malloc(sizeof (cdp_cb_event_list_t)); if (!cdp_event_list) { @@ -255,10 +258,12 @@ void cdp_cb_event_process() { ul.update_pcontact(domain, &ci, pcontact); } ul.unlock_udomain(domain, &p_session_data->registration_aor, &p_session_data->ip, p_session_data->recv_port); + counter_add(ims_qos_cnts_h.active_registration_rx_sessions, -1); } } else { LM_DBG("This is a media bearer session session"); - + + counter_add(ims_qos_cnts_h.active_media_rx_sessions, -1); //we only terminate the dialog if this was triggered from the transport plane or timeout - i.e. if must_terminate_dialog is set //if this was triggered from the signalling plane (i.e. someone hanging up) then we don'y need to terminate the dialog if (p_session_data->must_terminate_dialog) { diff --git a/modules/ims_qos/ims_qos_stats.c b/modules/ims_qos/ims_qos_stats.c new file mode 100644 index 00000000000..ea1eda8004d --- /dev/null +++ b/modules/ims_qos/ims_qos_stats.c @@ -0,0 +1,116 @@ +/* + * $Id$ + * + * Copyright (C) 2012 Smile Communications, jason.penton@smilecoms.com + * Copyright (C) 2012 Smile Communications, richard.good@smilecoms.com + * + * The initial version of this code was written by Dragos Vingarzan + * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the + * Fruanhofer Institute. It was and still is maintained in a separate + * branch of the original SER. We are therefore migrating it to + * Kamailio/SR and look forward to maintaining it from here on out. + * 2011/2012 Smile Communications, Pty. Ltd. + * ported/maintained/improved by + * Jason Penton (jason(dot)penton(at)smilecoms.com and + * Richard Good (richard(dot)good(at)smilecoms.com) as part of an + * effort to add full IMS support to Kamailio/SR using a new and + * improved architecture + * + * NB: Alot of this code was originally part of OpenIMSCore, + * FhG Fokus. + * Copyright (C) 2004-2006 FhG Fokus + * Thanks for great work! This is an effort to + * break apart the various CSCF functions into logically separate + * components. We hope this will drive wider use. We also feel + * that in this way the architecture is more complete and thereby easier + * to manage in the Kamailio/SR environment + * + * This file is part of Kamailio, a free SIP server. + * + * Kamailio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * Kamailio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * + * + * + * History: + * -------- + * 2011-02-02 initial version (jason.penton) + */ + + +#include "ims_qos_stats.h" + +struct ims_qos_counters_h ims_qos_cnts_h; +enum sctp_info_req { IMS_QOS_REGISTRATION_AAR_AVG_RSP, IMS_QOS_MEDIA_AAR_AVG_RSP }; + +static counter_val_t ims_qos_internal_stats(counter_handle_t h, void* what); + +counter_def_t ims_qos_cnt_defs[] = { + {&ims_qos_cnts_h.active_registration_rx_sessions, "active_registration_rx_sessions", 0, 0, 0, "number of currently active registration Rx sessions"}, + {&ims_qos_cnts_h.registration_aar_avg_response_time, "registration_aar_avg_response_time", 0, ims_qos_internal_stats, (void*) (long) IMS_QOS_REGISTRATION_AAR_AVG_RSP, "avg response time for registration AARs"}, + {&ims_qos_cnts_h.registration_aar_timeouts, "registration_aar_timeouts", 0, 0, 0, "total number of registration AAR timeouts"}, + {&ims_qos_cnts_h.failed_registration_aars, "failed_registration_aars", 0, 0, 0, "total number of failed registration AARs"}, + {&ims_qos_cnts_h.registration_aars, "registration_aars", 0, 0, 0, "total number of registration AARs"}, + {&ims_qos_cnts_h.asrs, "asrs", 0, 0, 0, "total number of registration ASRs"}, + {&ims_qos_cnts_h.successful_registration_aars, "successful_registration_aars", 0, 0, 0, "total number of successful registration AARs"}, + {&ims_qos_cnts_h.registration_aar_response_time, "registration_aar_response_time", 0, 0, 0, "total number of seconds waiting for registration AAR responses"}, + + {&ims_qos_cnts_h.active_media_rx_sessions, "active_media_rx_sessions", 0, 0, 0, "number of currently active media Rx sessions"}, + {&ims_qos_cnts_h.media_aar_avg_response_time, "media_aar_avg_response_time", 0, ims_qos_internal_stats, (void*) (long) IMS_QOS_MEDIA_AAR_AVG_RSP, "avg response time for media AARs"}, + {&ims_qos_cnts_h.media_aar_timeouts, "media_aar_timeouts", 0, 0, 0, "total number of media AAR timeouts"}, + {&ims_qos_cnts_h.failed_media_aars, "failed_media_aars", 0, 0, 0, "total number of failed media AARs"}, + {&ims_qos_cnts_h.media_aars, "media_aars", 0, 0, 0, "total number of media AARs"}, + {&ims_qos_cnts_h.successful_media_aars, "successful_media_aars", 0, 0, 0, "total number of successful media AARs"}, + {&ims_qos_cnts_h.media_aar_response_time, "media_aar_response_time", 0, 0, 0, "total number of seconds waiting for media AAR responses"}, + {0, 0, 0, 0, 0, 0} +}; + + +int ims_qos_init_counters() { + if (counter_register_array("ims_qos", ims_qos_cnt_defs) < 0) + goto error; + return 0; +error: + return -1; +} + +void ims_qos_destroy_counters() { + +} + +/** helper function for some stats (which are kept internally). + */ +static counter_val_t ims_qos_internal_stats(counter_handle_t h, void* what) { + enum sctp_info_req w; + + w = (int) (long) what; + switch (w) { + case IMS_QOS_REGISTRATION_AAR_AVG_RSP: + if (counter_get_val(ims_qos_cnts_h.registration_aars) == 0) + return 0; + else + return counter_get_val(ims_qos_cnts_h.registration_aar_response_time)/counter_get_val(ims_qos_cnts_h.registration_aars); + break; + case IMS_QOS_MEDIA_AAR_AVG_RSP: + if (counter_get_val(ims_qos_cnts_h.media_aars) == 0) + return 0; + else + return counter_get_val(ims_qos_cnts_h.media_aar_response_time)/counter_get_val(ims_qos_cnts_h.media_aars); + break; + default: + return 0; + }; + return 0; +} diff --git a/modules/ims_qos/ims_qos_stats.h b/modules/ims_qos/ims_qos_stats.h new file mode 100644 index 00000000000..a1d4d48ce75 --- /dev/null +++ b/modules/ims_qos/ims_qos_stats.h @@ -0,0 +1,37 @@ +/* + * File: ims_qos_stats.h + * Author: jaybeepee + * + * Created on 24 February 2015, 11:15 AM + */ + +#ifndef IMS_QOS_STATS_H +#define IMS_QOS_STATS_H + +#include "../../counters.h" + +struct ims_qos_counters_h { + counter_handle_t registration_aar_avg_response_time; + counter_handle_t registration_aar_response_time; + counter_handle_t registration_aar_timeouts; + counter_handle_t failed_registration_aars; + counter_handle_t registration_aars; + counter_handle_t asrs; + counter_handle_t successful_registration_aars; + counter_handle_t active_registration_rx_sessions; + counter_handle_t media_aar_avg_response_time; + counter_handle_t media_aar_response_time; + counter_handle_t media_aar_timeouts; + counter_handle_t failed_media_aars; + counter_handle_t media_aars; + counter_handle_t successful_media_aars; + counter_handle_t active_media_rx_sessions; +}; + +int ims_qos_init_counters(); +void ims_qos_destroy_counters(); + +#endif /* IMS_QOS_STATS_H */ + + + diff --git a/modules/ims_qos/mod.c b/modules/ims_qos/mod.c index acb35ae10e2..6d0486b7fe3 100644 --- a/modules/ims_qos/mod.c +++ b/modules/ims_qos/mod.c @@ -43,7 +43,6 @@ * */ -#include "stats.h" #include #include #include @@ -72,7 +71,7 @@ #include "../../parser/sdp/sdp.h" #include "../../lib/ims/useful_defs.h" - +#include "ims_qos_stats.h" MODULE_VERSION @@ -103,6 +102,13 @@ int video_default_bandwidth = 128; int cdp_event_list_size_threshold = 0; /**Threshold for size of cdp event list after which a warning is logged */ +stat_var *aars; +stat_var *strs; +stat_var *asrs; +stat_var *successful_aars; +stat_var *successful_strs; + + /** module functions */ static int mod_init(void); static int mod_child_init(int); @@ -142,11 +148,6 @@ static param_export_t params[] = { { 0, 0, 0} }; -stat_export_t mod_stats[] = { - {"aar_avg_response_time", STAT_IS_FUNC, (stat_var**) get_avg_aar_response_time}, - {"aar_timeouts", 0, (stat_var**) & stat_aar_timeouts}, - {0, 0, 0} -}; /** module exports */ struct module_exports exports = {"ims_qos", DEFAULT_DLFLAGS, /* dlopen flags */ @@ -162,18 +163,6 @@ struct module_exports exports = {"ims_qos", DEFAULT_DLFLAGS, /* dlopen flags */ * init module function */ static int mod_init(void) { -#ifdef STATISTICS - /* register statistics */ - if (register_module_stats(exports.name, mod_stats) != 0) { - LM_ERR("failed to register core statistics\n"); - goto error; - } - - if (!register_stats()) { - LM_ERR("Unable to register statistics\n"); - goto error; - } -#endif callback_singleton = shm_malloc(sizeof (int)); *callback_singleton = 0; @@ -226,6 +215,11 @@ static int mod_init(void) { LM_ERR("unable to initialise cdp callback event list\n"); return -1; } + + if (ims_qos_init_counters() != 0) { + LM_ERR("Failed to register counters for ims_qos module\n"); + return -1; + } return 0; error: diff --git a/modules/ims_qos/rx_aar.c b/modules/ims_qos/rx_aar.c index 500d0f2bd36..69e24790458 100644 --- a/modules/ims_qos/rx_aar.c +++ b/modules/ims_qos/rx_aar.c @@ -48,7 +48,6 @@ * 2011-02-02 initial version (jason.penton) */ -#include "stats.h" #include "../../mem/shm_mem.h" #include "../../parser/sdp/sdp.h" #include "../cdp_avp/mod_export.h" @@ -66,11 +65,16 @@ #include "mod.h" #include "../../lib/ims/useful_defs.h" +#include "ims_qos_stats.h" + + #define macro_name(_rc) #_rc //extern struct tm_binds tmb; usrloc_api_t ul; +extern struct ims_qos_counters_h ims_qos_cnts_h; + extern int authorize_video_flow; str IMS_Serv_AVP_val = {"IMS Services", 12}; @@ -116,7 +120,7 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps if (is_timeout != 0) { LM_ERR("Error timeout when sending AAR message via CDP\n"); - update_stat(stat_aar_timeouts, 1); + counter_inc(ims_qos_cnts_h.media_aar_timeouts); goto error; } if (!aaa) { @@ -124,8 +128,8 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps goto error; } - update_stat(aar_replies_received, 1); - update_stat(aar_replies_response_time, elapsed_msecs); + counter_inc(ims_qos_cnts_h.media_aars); + counter_add(ims_qos_cnts_h.media_aar_response_time, elapsed_msecs); /* Process the response to AAR, retrieving result code and associated Rx session ID */ if (rx_process_aaa(aaa, &cdp_result) < 0) { @@ -135,11 +139,14 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps if (cdp_result >= 2000 && cdp_result < 3000) { LM_DBG("Success, received code: [%i] from PCRF for AAR request\n", cdp_result); + counter_inc(ims_qos_cnts_h.successful_media_aars); LM_DBG("Auth session ID [%.*s]", aaa->sessionId->data.len, aaa->sessionId->data.s); if(!data->aar_update) { LM_DBG("This is an AAA response to an initial AAR"); + counter_inc(ims_qos_cnts_h.active_media_rx_sessions); + str * passed_rx_session_id = shm_malloc(sizeof (struct _str)); passed_rx_session_id->s = 0; passed_rx_session_id->len = 0; @@ -151,6 +158,7 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps result = CSCF_RETURN_TRUE; } else { LM_DBG("Received negative reply from PCRF for AAR Request\n"); + counter_inc(ims_qos_cnts_h.failed_media_aars); //we don't free rx_authdata_p here - it is free-ed when the CDP session expires goto error; // if its not a success then that means i want to reject this call! } @@ -223,7 +231,7 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e if (is_timeout != 0) { LM_ERR("Error timeout when sending AAR message via CDP\n"); - update_stat(stat_aar_timeouts, 1); + counter_inc(ims_qos_cnts_h.registration_aar_timeouts); goto error; } if (!aaa) { @@ -231,8 +239,8 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e goto error; } - update_stat(aar_replies_received, 1); - update_stat(aar_replies_response_time, elapsed_msecs); + counter_inc(ims_qos_cnts_h.registration_aars); + counter_add(ims_qos_cnts_h.registration_aar_response_time, elapsed_msecs); /* Process the response to AAR, retrieving result code and associated Rx session ID */ if (rx_process_aaa(aaa, &cdp_result) < 0) { @@ -241,7 +249,8 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e } if (cdp_result >= 2000 && cdp_result < 3000) { - if (is_rereg) { + counter_inc(ims_qos_cnts_h.successful_registration_aars); + if (is_rereg) { LM_DBG("this is a re-registration, therefore we don't need to do anything except know that the the subscription was successful\n"); result = CSCF_RETURN_TRUE; create_return_code(result); @@ -263,6 +272,8 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e goto error; } p_session_data->session_has_been_opened = 1; + counter_inc(ims_qos_cnts_h.active_registration_rx_sessions); + if (auth) cdpb.AAASessionsUnlock(auth->hash); @@ -300,6 +311,7 @@ void async_aar_reg_callback(int is_timeout, void *param, AAAMessage *aaa, long e result = CSCF_RETURN_TRUE; } else { LM_DBG("Received negative reply from PCRF for AAR Request\n"); + counter_inc(ims_qos_cnts_h.failed_registration_aars); result = CSCF_RETURN_FALSE; goto error; } diff --git a/modules/ims_qos/rx_asr.c b/modules/ims_qos/rx_asr.c index 523397b0f40..4f34ac2a8a2 100644 --- a/modules/ims_qos/rx_asr.c +++ b/modules/ims_qos/rx_asr.c @@ -60,6 +60,9 @@ #include "rx_asr.h" #include "rx_avp.h" #include "../../lib/ims/ims_getters.h" +#include "ims_qos_stats.h" + +extern struct ims_qos_counters_h ims_qos_cnts_h; /* * Called upon receipt of an ASR. Terminates the user session and returns the ASA. @@ -76,13 +79,15 @@ AAAMessage* rx_process_asr(AAAMessage *request) { if (!request || !request->sessionId) return 0; + counter_inc(ims_qos_cnts_h.asrs); + session = cdpb.AAAGetAuthSession(request->sessionId->data); if (!session) { LM_DBG("received an ASR but the session is already deleted\n"); return 0; } - + code = rx_get_abort_cause(request); LM_DBG("abort-cause code is %u\n", code); diff --git a/modules/jsonrpc-s/README b/modules/jsonrpc-s/README index bb92a7ae90a..02c3a520e9a 100644 --- a/modules/jsonrpc-s/README +++ b/modules/jsonrpc-s/README @@ -29,17 +29,36 @@ Daniel-Constantin Mierla 3. Parameters 3.1. pretty_format (int) + 3.2. transport (int) + 3.3. fifo_name (str) + 3.4. fifo_mode (int) + 3.5. fifo_group (int or str) + 3.6. fifo_user (int or str) + 3.7. fifo_reply_dir (str) 4. Functions 4.1. jsonrpc_dispatch() 4.2. jsonrpc_exec(cmd) + 5. JSONRPC Transports + + 5.1. JSONRPC Over HTTP + 5.2. JSONRPC Over FIFO + List of Examples 1.1. Set pretty_format parameter - 1.2. jsonrpc_dispatch usage - 1.3. jsonrpc_exec usage + 1.2. Set transport parameter + 1.3. Set fifo_name parameter + 1.4. Set fifo_mode parameter + 1.5. Set fifo_group parameter + 1.6. Set fifo_user parameter + 1.7. Set fifo_reply_dir parameter + 1.8. jsonrpc_dispatch usage + 1.9. jsonrpc_exec usage + 1.10. JSONRPC Over Fifo Command + 1.11. JSONRPC Over Fifo Command From Termina Chapter 1. Admin Guide @@ -57,21 +76,35 @@ Chapter 1. Admin Guide 3. Parameters 3.1. pretty_format (int) + 3.2. transport (int) + 3.3. fifo_name (str) + 3.4. fifo_mode (int) + 3.5. fifo_group (int or str) + 3.6. fifo_user (int or str) + 3.7. fifo_reply_dir (str) 4. Functions 4.1. jsonrpc_dispatch() 4.2. jsonrpc_exec(cmd) + 5. JSONRPC Transports + + 5.1. JSONRPC Over HTTP + 5.2. JSONRPC Over FIFO + 1. Overview 1.1. Limitations - This module provides a JSON-RPC server over HTTP implementation, + This module provides a JSON-RPC v2 server over HTTP implementation, tailored for the needs of Kamailio. It implements the Kamailio RPC interface over JSON-RPC. - The JSONRPC-S module uses the xHTTP module to handle HTTP requests. + The specification for JSON-RPC is available at: + http://www.jsonrpc.org/specification. + + The JSONRPC-S module uses the xHTTP module to handle HTTP/S requests. Read the documentation of the xHTTP module for more details. 1.1. Limitations @@ -102,6 +135,12 @@ Chapter 1. Admin Guide 3. Parameters 3.1. pretty_format (int) + 3.2. transport (int) + 3.3. fifo_name (str) + 3.4. fifo_mode (int) + 3.5. fifo_group (int or str) + 3.6. fifo_user (int or str) + 3.7. fifo_reply_dir (str) 3.1. pretty_format (int) @@ -114,6 +153,80 @@ Chapter 1. Admin Guide modparam("jsonrpc-s", "pretty_format", 1) ... +3.2. transport (int) + + Control what transports are enabled. The value can be: + * 0 - all transports that can be enabled. For http, the xhttp module + must be loaded. For FIFO, the fifo_name parameter must be set. + * 1 - only HTTP transport + * 2 - only FIFO transport + + Default value is '0'. + + Example 1.2. Set transport parameter +... +modparam("jsonrpc-s", "transport", 1) +... + +3.3. fifo_name (str) + + The name of the FIFO file to be created for listening and reading + external commands. + + Default value is NONE. + + Example 1.3. Set fifo_name parameter +... +modparam("jsonrpc-s", "fifo_name", "/tmp/kamailio_jsonrpc_fifo") +... + +3.4. fifo_mode (int) + + Permission to be used for creating the listening FIFO file. It follows + the UNIX conventions. + + Default value is 0660 (rw-rw----). + + Example 1.4. Set fifo_mode parameter +... +modparam("jsonrpc-s", "fifo_mode", 0600) +... + +3.5. fifo_group (int or str) + + System Group to be used for creating the listening FIFO file. + + Default value is the inherited one (process group). + + Example 1.5. Set fifo_group parameter +... +modparam("jsonrpc-s", "fifo_group", 0) +modparam("jsonrpc-s", "fifo_group", "root") +... + +3.6. fifo_user (int or str) + + System User to be used for creating the listening FIFO file. + + Default value is the inherited one (process user). + + Example 1.6. Set fifo_user parameter +... +modparam("jsonrpc-s", "fifo_user", 0) +modparam("jsonrpc-s", "fifo_user", "root") +... + +3.7. fifo_reply_dir (str) + + Directory to be used for creating the reply FIFO files. + + Default value is "/tmp/" + + Example 1.7. Set fifo_reply_dir parameter +... +modparam("jsonrpc-s", "fifo_reply_dir", "/home/kamailio/tmp/") +... + 4. Functions 4.1. jsonrpc_dispatch() @@ -123,7 +236,7 @@ modparam("jsonrpc-s", "pretty_format", 1) Handle the JSONRPC request and generate a response. - Example 1.2. jsonrpc_dispatch usage + Example 1.8. jsonrpc_dispatch usage ... #!KAMAILIO @@ -174,7 +287,62 @@ event_route[xhttp:request] { dynamic string with variables. The result of the command can be accessed via $jsonrpl(key) pseudo variables. - Example 1.3. jsonrpc_exec usage + Example 1.9. jsonrpc_exec usage ... jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}'); ... + +5. JSONRPC Transports + + 5.1. JSONRPC Over HTTP + 5.2. JSONRPC Over FIFO + + JSONRPC specifications do not enforce a specific transport to carry the + JSON documents. Very common is JSONRPC over HTTP or HTTPS, and they are + supported by Kamailio. In addition, Kamailio supports receiving JSON + documents via a local FIFO file. + +5.1. JSONRPC Over HTTP + + It requires that XHTTP module is loaded. HTTPS can be used if you + enable TLS for Kamailio. The JSONRPC requests have to be sent to the + TCP or TLS ports of Kamailio. + + The 'transport' parameter has to be 0 or 1. + + The format of the JSON document must follow the JSONRPC specifications. + +5.2. JSONRPC Over FIFO + + This module can retrive JSONRPC requests via a local FIFO file. To + enable this feature, 'fifo_name' parameter must be set and 'transport' + parameter has to be 0 or 2. + + The format of the JSON document must follow the JSONRPC specifications + plus an additional field named 'reply_name'. The value for this field + must be the name of the FIFO file were to write the JSONRPC response. + The reply FIFO file is created in the folder specified by + 'fifo_reply_dir'. Next is an example showing a JSONRPC command to be + sent via FIFO transport. + + Example 1.10. JSONRPC Over Fifo Command +... +{ + "jsonrpc": "2.0", + "method": "core.psx", + "reply_name": "kamailio_jsonrpc_reply_fifo", + "id": 1 +} +... + + Next is an example of how to test it from a terminal, assuming that the + parameter 'fifo_name' is set to '/tmp/kamailio_jsonrpc_fifo'. + + Example 1.11. JSONRPC Over Fifo Command From Termina +... +mkfifo /tmp/kamailio_jsonrpc_reply_fifo +cat /tmp/kamailio_jsonrpc_reply_fifo & +echo '{"jsonrpc": "2.0", "method": "core.psx", \ + "reply_name": "kamailio_jsonrpc_reply_fifo", "id": 1}' \ + > /tmp/kamailio_jsonrpc_fifo +rm /tmp/kamailio_jsonrpc_reply_fifo diff --git a/modules/jsonrpc-s/doc/jsonrpc-s_admin.xml b/modules/jsonrpc-s/doc/jsonrpc-s_admin.xml index a12b15342f2..34653016b84 100644 --- a/modules/jsonrpc-s/doc/jsonrpc-s_admin.xml +++ b/modules/jsonrpc-s/doc/jsonrpc-s_admin.xml @@ -16,12 +16,16 @@
Overview - This module provides a JSON-RPC server over HTTP implementation, + This module provides a JSON-RPC v2 server over HTTP implementation, tailored for the needs of &kamailio;. It implements the &kamailio; RPC interface over JSON-RPC. + + The specification for JSON-RPC is available at: + http://www.jsonrpc.org/specification. - The JSONRPC-S module uses the xHTTP module to handle HTTP requests. + + The JSONRPC-S module uses the xHTTP module to handle HTTP/S requests. Read the documentation of the xHTTP module for more details. @@ -78,7 +82,7 @@
Parameters -
+
<varname>pretty_format</varname> (int) Pretty format for JSON-RPC response document. @@ -97,6 +101,143 @@ modparam("jsonrpc-s", "pretty_format", 1)
+
+ <varname>transport</varname> (int) + + Control what transports are enabled. The value can be: + + + + 0 - all transports that can be enabled. + For http, the xhttp module must be loaded. For FIFO, the + fifo_name parameter must be set. + + + 1 - only HTTP transport + + + 2 - only FIFO transport + + + + + + Default value is '0'. + + + + Set <varname>transport</varname> parameter + +... +modparam("jsonrpc-s", "transport", 1) +... + + +
+
+ <varname>fifo_name</varname> (str) + + The name of the FIFO file to be created for listening and + reading external commands. + + + + Default value is NONE. + + + + Set <varname>fifo_name</varname> parameter + +... +modparam("jsonrpc-s", "fifo_name", "/tmp/kamailio_jsonrpc_fifo") +... + + +
+ +
+ <varname>fifo_mode</varname> (int) + + Permission to be used for creating the listening FIFO file. It + follows the UNIX conventions. + + + + Default value is 0660 (rw-rw----). + + + + Set <varname>fifo_mode</varname> parameter + +... +modparam("jsonrpc-s", "fifo_mode", 0600) +... + + +
+ +
+ <varname>fifo_group</varname> (int or str) + + System Group to be used for creating the listening FIFO file. + + + + Default value is the inherited one (process group). + + + + Set <varname>fifo_group</varname> parameter + +... +modparam("jsonrpc-s", "fifo_group", 0) +modparam("jsonrpc-s", "fifo_group", "root") +... + + +
+ +
+ <varname>fifo_user</varname> (int or str) + + System User to be used for creating the listening FIFO file. + + + + Default value is the inherited one (process user). + + + + Set <varname>fifo_user</varname> parameter + +... +modparam("jsonrpc-s", "fifo_user", 0) +modparam("jsonrpc-s", "fifo_user", "root") +... + + +
+ +
+ <varname>fifo_reply_dir</varname> (str) + + Directory to be used for creating the reply FIFO files. + + + + Default value is /tmp/ + + + + Set <varname>fifo_reply_dir</varname> parameter + +... +modparam("jsonrpc-s", "fifo_reply_dir", "/home/kamailio/tmp/") +... + + +
+
@@ -178,5 +319,77 @@ jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}');
+ +
+ JSONRPC Transports + + JSONRPC specifications do not enforce a specific transport to carry the + JSON documents. Very common is JSONRPC over HTTP or HTTPS, and they are + supported by &kamailio;. In addition, &kamailio; supports receiving JSON + documents via a local FIFO file. + +
+ JSONRPC Over HTTP + + It requires that XHTTP module is loaded. HTTPS can be used if + you enable TLS for &kamailio;. The JSONRPC requests have to be + sent to the TCP or TLS ports of &kamailio;. + + + The 'transport' parameter has to be 0 or 1. + + + The format of the JSON document must follow the JSONRPC + specifications. + +
+
+ JSONRPC Over FIFO + + This module can retrive JSONRPC requests via a local FIFO file. To + enable this feature, 'fifo_name' parameter must be set and + 'transport' parameter has to be 0 or 2. + + + The format of the JSON document must follow the JSONRPC + specifications plus an additional field named 'reply_name'. The + value for this field must be the name of the FIFO file were to + write the JSONRPC response. The reply FIFO file is created in the + folder specified by 'fifo_reply_dir'. Next is an example showing + a JSONRPC command to be sent via FIFO transport. + + + JSONRPC Over Fifo Command + +... +{ + "jsonrpc": "2.0", + "method": "core.psx", + "reply_name": "kamailio_jsonrpc_reply_fifo", + "id": 1 +} +... + + + + Next is an example of how to test it from a terminal, assuming that + the parameter 'fifo_name' is set to '/tmp/kamailio_jsonrpc_fifo'. + + + JSONRPC Over Fifo Command From Termina + +... +mkfifo /tmp/kamailio_jsonrpc_reply_fifo +cat /tmp/kamailio_jsonrpc_reply_fifo & +echo '{"jsonrpc": "2.0", "method": "core.psx", \ + "reply_name": "kamailio_jsonrpc_reply_fifo", "id": 1}' \ + > /tmp/kamailio_jsonrpc_fifo +rm /tmp/kamailio_jsonrpc_reply_fifo + + + +
+
+ diff --git a/modules/jsonrpc-s/jsonrpc-s_mod.c b/modules/jsonrpc-s/jsonrpc-s_mod.c index 2946288ebfa..eb84b628297 100644 --- a/modules/jsonrpc-s/jsonrpc-s_mod.c +++ b/modules/jsonrpc-s/jsonrpc-s_mod.c @@ -23,12 +23,19 @@ #include #include #include +#include +#include +#include +#include +#include #include "../../ver.h" #include "../../trim.h" +#include "../../pt.h" #include "../../sr_module.h" #include "../../mod_fix.h" #include "../../nonsip_hooks.h" +#include "../../cfg/cfg_struct.h" #include "../../modules/xhttp/api.h" #include "jsonrpc-s_mod.h" @@ -53,8 +60,19 @@ MODULE_VERSION #define jsonrpc_malloc pkg_malloc #define jsonrpc_free pkg_free -str JSONRPC_REASON_OK = str_init("OK"); -str JSONRPC_CONTENT_TYPE_HTML = str_init("application/json"); +static str JSONRPC_REASON_OK = str_init("OK"); +static str JSONRPC_CONTENT_TYPE_HTML = str_init("application/json"); + +/* FIFO server vars */ +static char *jsonrpc_fifo = NULL; /*!< FIFO file name */ +static char *jsonrpc_fifo_reply_dir = "/tmp/"; /*!< dir where reply fifos are allowed */ +static int jsonrpc_fifo_uid = -1; /*!< Fifo default UID */ +static char *jsonrpc_fifo_uid_s = 0; /*!< Fifo default User ID name */ +static int jsonrpc_fifo_gid = -1; /*!< Fifo default Group ID */ +static char *jsonrpc_fifo_gid_s = 0; /*!< Fifo default Group ID name */ +static int jsonrpc_fifo_mode = S_IRUSR| S_IWUSR| S_IRGRP| S_IWGRP; /* Default file mode rw-rw---- */ + +static int jsonrpc_transport = 0; /*!< 0 - all available; 1 - http; 2 - fifo */ static int jsonrpc_pretty_format = 0; @@ -62,9 +80,12 @@ static int jsonrpc_register_rpc(void); static int mod_init(void); static int child_init(int rank); +static void mod_destroy(void); static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2); static int jsonrpc_exec(sip_msg_t* msg, char* cmd, char* s2); +static int jsonrpc_init_fifo_file(void); +static void jsonrpc_fifo_process(int rank); /** The context of the jsonrpc request being processed. * @@ -95,7 +116,15 @@ static cmd_export_t cmds[] = { }; static param_export_t params[] = { - {"pretty_format", PARAM_INT, &jsonrpc_pretty_format}, + {"pretty_format", PARAM_INT, &jsonrpc_pretty_format}, + {"fifo_name", PARAM_STRING, &jsonrpc_fifo}, + {"fifo_mode", PARAM_INT, &jsonrpc_fifo_mode}, + {"fifo_group", PARAM_STRING, &jsonrpc_fifo_gid_s}, + {"fifo_group", PARAM_INT, &jsonrpc_fifo_gid}, + {"fifo_user", PARAM_STRING, &jsonrpc_fifo_uid_s}, + {"fifo_user", PARAM_INT, &jsonrpc_fifo_uid}, + {"fifo_reply_dir", PARAM_STRING, &jsonrpc_fifo_reply_dir}, + {"transport", PARAM_INT, &jsonrpc_transport}, {0, 0, 0} }; @@ -120,7 +149,7 @@ struct module_exports exports= { 0, /* extra processes */ mod_init, /* module initialization function */ 0, - 0, + mod_destroy,/* module destroy function */ child_init /* per-child init function */ }; @@ -317,6 +346,7 @@ static int jsonrpc_send(jsonrpc_ctx_t* ctx) } else { jsonrpc_set_plain_reply(ctx->http_code, &ctx->http_text, &rbuf, ctx->jrpl->free_fn); + rbuf.s=NULL; } } else { if(ctx->msg) { @@ -864,9 +894,25 @@ static void jsonrpc_clean_context(jsonrpc_ctx_t* ctx) static int mod_init(void) { /* bind the XHTTP API */ - if (xhttp_load_api(&xhttp_api) < 0) { - LM_ERR("cannot bind to XHTTP API\n"); - return -1; + if(jsonrpc_transport==0 || jsonrpc_transport==1) { + if (xhttp_load_api(&xhttp_api) < 0) { + if(jsonrpc_transport==1) { + LM_ERR("cannot bind to XHTTP API\n"); + return -1; + } else { + memset(&xhttp_api, 0, sizeof(xhttp_api_t)); + } + } + } + if(jsonrpc_transport==0 || jsonrpc_transport==2) { + if(jsonrpc_init_fifo_file()<0) { + if(jsonrpc_transport==2) { + LM_ERR("cannot initialize fifo transport\n"); + return -1; + } else { + jsonrpc_fifo = NULL; + } + } } memset(&func_param, 0, sizeof(func_param)); @@ -892,12 +938,61 @@ static int mod_init(void) static int child_init(int rank) { + int pid; + + if (rank==PROC_MAIN) { + if(jsonrpc_fifo != NULL) { + pid=fork_process(PROC_NOCHLDINIT, "JSONRPC-S FIFO", 1); + if (pid<0) + return -1; /* error */ + if(pid==0) { + /* child */ + + /* initialize the config framework */ + if (cfg_child_init()) + return -1; + + jsonrpc_fifo_process(1); + } + } + } + if(rank==PROC_MAIN || rank==PROC_TCP_MAIN) + { return 0; /* do nothing for the main process */ + } return 0; } +static void mod_destroy(void) +{ + int n; + struct stat filestat; + + if(jsonrpc_fifo==NULL) + return; + + /* destroying the fifo file */ + n=stat(jsonrpc_fifo, &filestat); + if (n==0){ + /* FIFO exist, delete it (safer) if not config check */ + if(config_check==0) { + if (unlink(jsonrpc_fifo)<0){ + LM_ERR("cannot delete the fifo (%s): %s\n", + jsonrpc_fifo, strerror(errno)); + goto error; + } + } + } else if (n<0 && errno!=ENOENT) { + LM_ERR("FIFO stat failed: %s\n", strerror(errno)); + goto error; + } + + return; +error: + return; +} static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2) { @@ -979,7 +1074,7 @@ static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2) } -static int jsonrpc_exec(sip_msg_t* msg, char* cmd, char* s2) +static int jsonrpc_exec_ex(str *cmd, str *rpath) { rpc_export_t* rpce; jsonrpc_ctx_t* ctx; @@ -988,10 +1083,7 @@ static int jsonrpc_exec(sip_msg_t* msg, char* cmd, char* s2) str val; str scmd; - if(fixup_get_svalue(msg, (gparam_t*)cmd, &scmd)<0 || scmd.len<=0) { - LM_ERR("cannot get the rpc command parameter\n"); - return -1; - } + scmd = *cmd; /* initialize jsonrpc context */ ctx = &_jsonrpc_ctx; @@ -1028,6 +1120,27 @@ static int jsonrpc_exec(sip_msg_t* msg, char* cmd, char* s2) LM_ERR("unsupported jsonrpc version [%.*s]\n", val.len, val.s); goto send_reply; } + /* reply name */ + if(rpath!=NULL) { + if(rpath->s==NULL || rpath->len<=0) { + LM_ERR("empty buffer to store the reply name\n"); + goto send_reply; + } + nj = srjson_GetObjectItem(ctx->jreq, ctx->jreq->root, "reply_name"); + if(nj==NULL) { + LM_ERR("missing reply_name field in request\n"); + goto send_reply; + } + val.s = nj->valuestring; + val.len = strlen(val.s); + if(val.len>=rpath->len) { + LM_ERR("no space to store reply_name field\n"); + goto send_reply; + } + strncpy(rpath->s, val.s, val.len); + rpath->s[val.len] = 0; + rpath->len = val.len; + } /* run jsonrpc command */ nj = srjson_GetObjectItem(ctx->jreq, ctx->jreq->root, "method"); if(nj==NULL) { @@ -1062,6 +1175,16 @@ static int jsonrpc_exec(sip_msg_t* msg, char* cmd, char* s2) return 1; } +static int jsonrpc_exec(sip_msg_t* msg, char* cmd, char* s2) +{ + str scmd; + + if(fixup_get_svalue(msg, (gparam_t*)cmd, &scmd)<0 || scmd.len<=0) { + LM_ERR("cannot get the rpc command parameter\n"); + return -1; + } + return jsonrpc_exec_ex(&scmd, NULL); +} /** * */ @@ -1153,3 +1276,446 @@ static int jsonrpc_pv_parse_jrpl_name(pv_spec_t *sp, str *in) } return 0; } + +/* FIFO TRANSPORT */ + +/*! \brief Initialize fifo transport */ +static int jsonrpc_init_fifo_file(void) +{ + int n; + struct stat filestat; + + /* checking the jsonrpc_fifo module param */ + if (jsonrpc_fifo==NULL || *jsonrpc_fifo == 0) { + jsonrpc_fifo=NULL; + LM_DBG("No fifo configured\n"); + return 0; + } + + LM_DBG("testing if fifo file exists ...\n"); + n=stat(jsonrpc_fifo, &filestat); + if (n==0) { + /* FIFO exist, delete it (safer) if no config check */ + if(config_check==0) { + if (unlink(jsonrpc_fifo)<0){ + LM_ERR("Cannot delete old fifo (%s): %s\n", + jsonrpc_fifo, strerror(errno)); + return -1; + } + } + } else if (n<0 && errno!=ENOENT){ + LM_ERR("MI FIFO stat failed: %s\n", strerror(errno)); + return -1; + } + + /* checking the fifo_reply_dir param */ + if(!jsonrpc_fifo_reply_dir || *jsonrpc_fifo_reply_dir == 0) { + LM_ERR("fifo_reply_dir parameter is empty\n"); + return -1; + } + + /* Check if the directory for the reply fifo exists */ + n = stat(jsonrpc_fifo_reply_dir, &filestat); + if(n < 0){ + LM_ERR("Directory stat for MI Fifo reply failed: %s\n", strerror(errno)); + return -1; + } + + if(S_ISDIR(filestat.st_mode) == 0){ + LM_ERR("fifo_reply_dir parameter is not a directory\n"); + return -1; + } + + /* check fifo_mode */ + if(!jsonrpc_fifo_mode){ + LM_WARN("cannot specify fifo_mode = 0, forcing it to rw-------\n"); + jsonrpc_fifo_mode = S_IRUSR | S_IWUSR; + } + + if (jsonrpc_fifo_uid_s){ + if (user2uid(&jsonrpc_fifo_uid, &jsonrpc_fifo_gid, jsonrpc_fifo_uid_s)<0){ + LM_ERR("Bad user name %s\n", jsonrpc_fifo_uid_s); + return -1; + } + } + + if (jsonrpc_fifo_gid_s){ + if (group2gid(&jsonrpc_fifo_gid, jsonrpc_fifo_gid_s)<0){ + LM_ERR("Bad group name %s\n", jsonrpc_fifo_gid_s); + return -1; + } + } + + /* add space for one extra process */ + register_procs(1); + + /* add child to update local config framework structures */ + cfg_register_child(1); + + return 0; +} + + +static int jsonrpc_fifo_read = 0; +static int jsonrpc_fifo_write = 0; +#define JSONRPC_MAX_FILENAME 128 +static char *jsonrpc_reply_fifo_s = NULL; +static int jsonrpc_reply_fifo_len = 0; + +/*! \brief Initialize Fifo server */ +FILE *jsonrpc_init_fifo_server(char *fifo_name, int fifo_mode, + int fifo_uid, int fifo_gid, char* fifo_reply_dir) +{ + FILE *fifo_stream; + long opt; + + /* create FIFO ... */ + if ((mkfifo(fifo_name, fifo_mode)<0)) { + LM_ERR("Can't create FIFO: %s (mode=%d)\n", strerror(errno), fifo_mode); + return 0; + } + + LM_DBG("FIFO created @ %s\n", fifo_name ); + + if ((chmod(fifo_name, fifo_mode)<0)) { + LM_ERR("Can't chmod FIFO: %s (mode=%d)\n", strerror(errno), fifo_mode); + return 0; + } + + if ((fifo_uid!=-1) || (fifo_gid!=-1)){ + if (chown(fifo_name, fifo_uid, fifo_gid)<0){ + LM_ERR("Failed to change the owner/group for %s to %d.%d; %s[%d]\n", + fifo_name, fifo_uid, fifo_gid, strerror(errno), errno); + return 0; + } + } + + LM_DBG("fifo %s opened, mode=%o\n", fifo_name, fifo_mode ); + + /* open it non-blocking or else wait here until someone + * opens it for writing */ + jsonrpc_fifo_read=open(fifo_name, O_RDONLY|O_NONBLOCK, 0); + if (jsonrpc_fifo_read<0) { + LM_ERR("Can't open fifo %s for reading - fifo_read did not open: %s\n", fifo_name, strerror(errno)); + return 0; + } + + fifo_stream = fdopen(jsonrpc_fifo_read, "r"); + if (fifo_stream==NULL) { + LM_ERR("fdopen failed on %s: %s\n", fifo_name, strerror(errno)); + return 0; + } + + /* make sure the read fifo will not close */ + jsonrpc_fifo_write=open(fifo_name, O_WRONLY|O_NONBLOCK, 0); + if (jsonrpc_fifo_write<0) { + LM_ERR("fifo_write did not open: %s\n", strerror(errno)); + return 0; + } + /* set read fifo blocking mode */ + if ((opt=fcntl(jsonrpc_fifo_read, F_GETFL))==-1){ + LM_ERR("fcntl(F_GETFL) failed: %s [%d]\n", strerror(errno), errno); + return 0; + } + if (fcntl(jsonrpc_fifo_read, F_SETFL, opt & (~O_NONBLOCK))==-1){ + LM_ERR("cntl(F_SETFL) failed: %s [%d]\n", strerror(errno), errno); + return 0; + } + + jsonrpc_reply_fifo_s = pkg_malloc(JSONRPC_MAX_FILENAME); + if (jsonrpc_reply_fifo_s==NULL) { + LM_ERR("no more private memory\n"); + return 0; + } + + /* init fifo reply dir buffer */ + jsonrpc_reply_fifo_len = strlen(fifo_reply_dir); + memcpy( jsonrpc_reply_fifo_s, jsonrpc_fifo_reply_dir, jsonrpc_reply_fifo_len); + + return fifo_stream; +} + +/*! \brief Read input on fifo */ +int jsonrpc_read_stream(char *b, int max, FILE *stream, int *lread) +{ + int retry_cnt; + int len; + char *p; + int sstate; + int pcount; + int pfound; + int stype; + + sstate = 0; + retry_cnt=0; + + *lread = 0; + p = b; + pcount = 0; + pfound = 0; + stype = 0; + + while(1) { + len = fread (p, 1, 1, stream); + if(len==0) { + LM_ERR("fifo server fread failed: %s\n", strerror(errno)); + /* on Linux, sometimes returns ESPIPE -- give + it few more chances + */ + if (errno==ESPIPE) { + retry_cnt++; + if (retry_cnt>4) + return -1; + continue; + } + /* interrupted by signal or ... */ + if ((errno==EINTR)||(errno==EAGAIN)) + continue; + return -1; + } + if(*p=='"' && (sstate==0 || stype==1)) { + if(*lread>0) { + if(*(p-1)!='\\') { + sstate = (sstate+1) % 2; + stype = 1; + } + } else { + sstate = (sstate+1) % 2; + stype = 1; + } + } else if(*p=='\'' && (sstate==0 || stype==2)) { + if(*lread>0) { + if(*(p-1)!='\\') { + sstate = (sstate+1) % 2; + stype = 2; + } + } else { + sstate = (sstate+1) % 2; + stype = 2; + } + } else if(*p=='{') { + if(sstate==0) { + pfound = 1; + pcount++; + } + } else if(*p=='}') { + if(sstate==0) + pcount--; + } + *lread = *lread + 1; + if(*lread>=max-1) { + LM_WARN("input data too large (%d)\n", *lread); + return -1; + } + p++; + if(pfound==1 && pcount==0) { + *p = 0; + return 0; + } + } + + return -1; +} + +/*! \brief reply fifo security checks: + * + * checks if fd is a fifo, is not hardlinked and it's not a softlink + * opened file descriptor + file name (for soft link check) + * \return 0 if ok, <0 if not */ +static int jsonrpc_fifo_check(int fd, char* fname) +{ + struct stat fst; + struct stat lst; + + if (fstat(fd, &fst)<0){ + LM_ERR("security: fstat on %s failed: %s\n", fname, strerror(errno)); + return -1; + } + /* check if fifo */ + if (!S_ISFIFO(fst.st_mode)){ + LM_ERR("security: %s is not a fifo\n", fname); + return -1; + } + /* check if hard-linked */ + if (fst.st_nlink>1){ + LM_ERR("security: fifo_check: %s is hard-linked %d times\n", fname, (unsigned)fst.st_nlink); + return -1; + } + + /* lstat to check for soft links */ + if (lstat(fname, &lst)<0){ + LM_ERR("security: lstat on %s failed: %s\n", fname, strerror(errno)); + return -1; + } + if (S_ISLNK(lst.st_mode)){ + LM_ERR("security: fifo_check: %s is a soft link\n", fname); + return -1; + } + /* if this is not a symbolic link, check to see if the inode didn't + * change to avoid possible sym.link, rm sym.link & replace w/ fifo race + */ + if ((lst.st_dev!=fst.st_dev)||(lst.st_ino!=fst.st_ino)){ + LM_ERR("security: fifo_check: inode/dev number differ: %d %d (%s)\n", + (int)fst.st_ino, (int)lst.st_ino, fname); + return -1; + } + /* success */ + return 0; +} + +#define JSONRPC_REPLY_RETRIES 4 +FILE *jsonrpc_open_reply_fifo(str *srpath) +{ + int retries=JSONRPC_REPLY_RETRIES; + int fifofd; + FILE *file_handle; + int flags; + + if ( memchr(srpath->s, '.', srpath->len) + || memchr(srpath->s, '/', srpath->len) + || memchr(srpath->s, '\\', srpath->len) ) { + LM_ERR("Forbidden reply fifo filename: %.*s\n", + srpath->len, srpath->s); + return 0; + } + + if (jsonrpc_reply_fifo_len + srpath->len + 1 > JSONRPC_MAX_FILENAME) { + LM_ERR("Reply fifo filename too long %d\n", + jsonrpc_reply_fifo_len + srpath->len); + return 0; + } + + memcpy(jsonrpc_reply_fifo_s + jsonrpc_reply_fifo_len, srpath->s, srpath->len); + jsonrpc_reply_fifo_s[jsonrpc_reply_fifo_len + srpath->len]=0; + + +tryagain: + /* open non-blocking to make sure that a broken client will not + * block the FIFO server forever */ + fifofd=open( jsonrpc_reply_fifo_s, O_WRONLY | O_NONBLOCK ); + if (fifofd==-1) { + /* retry several times if client is not yet ready for getting + feedback via a reply pipe + */ + if (errno==ENXIO) { + /* give up on the client - we can't afford server blocking */ + if (retries==0) { + LM_ERR("no client at %s\n", jsonrpc_reply_fifo_s ); + return 0; + } + /* don't be noisy on the very first try */ + if (retries != JSONRPC_REPLY_RETRIES) + LM_DBG("mi_fifo retry countdown: %d\n", retries ); + sleep_us( 80000 ); + retries--; + goto tryagain; + } + /* some other opening error */ + LM_ERR("open error (%s): %s\n", jsonrpc_reply_fifo_s, strerror(errno)); + return 0; + } + + /* security checks: is this really a fifo?, is + * it hardlinked? is it a soft link? */ + if (jsonrpc_fifo_check(fifofd, jsonrpc_reply_fifo_s)<0) + goto error; + + /* we want server blocking for big writes */ + if ( (flags=fcntl(fifofd, F_GETFL, 0))<0) { + LM_ERR("pipe (%s): getfl failed: %s\n", jsonrpc_reply_fifo_s, strerror(errno)); + goto error; + } + flags&=~O_NONBLOCK; + if (fcntl(fifofd, F_SETFL, flags)<0) { + LM_ERR("pipe (%s): setfl cntl failed: %s\n", jsonrpc_reply_fifo_s, strerror(errno)); + goto error; + } + + /* create an I/O stream */ + file_handle=fdopen( fifofd, "w"); + if (file_handle==NULL) { + LM_ERR("open error (%s): %s\n", + jsonrpc_reply_fifo_s, strerror(errno)); + goto error; + } + return file_handle; +error: + close(fifofd); + return 0; +} + +#define JSONRPC_BUF_IN_SIZE 4096 +static void jsonrpc_run_fifo_server(FILE *fifo_stream) +{ + FILE *reply_stream; + char buf_in[JSONRPC_BUF_IN_SIZE]; + char buf_rpath[128]; + int lread; + str scmd; + str srpath; + int nw; + + while(1) { + /* update the local config framework structures */ + cfg_update(); + + reply_stream = NULL; + lread = 0; + if(jsonrpc_read_stream(buf_in, JSONRPC_BUF_IN_SIZE, + fifo_stream, &lread)<0 || lread<=0) { + LM_DBG("failed to get the json document from fifo stream\n"); + continue; + } + scmd.s = buf_in; + scmd.len = lread; + trim(&scmd); + LM_DBG("preparing to execute fifo jsonrpc [%.*s]\n", scmd.len, scmd.s); + srpath.s = buf_rpath; + srpath.len = 128; + if(jsonrpc_exec_ex(&scmd, &srpath)<0) { + LM_ERR("failed to execute the json document from fifo stream\n"); + continue; + } + + LM_DBG("command executed - result: [%.*s] [%d] [%p] [%.*s]\n", + srpath.len, srpath.s, + _jsonrpc_plain_reply.rcode, + _jsonrpc_plain_reply.rbody.s, + _jsonrpc_plain_reply.rbody.len, _jsonrpc_plain_reply.rbody.s); + if(srpath.len>0) { + reply_stream = jsonrpc_open_reply_fifo(&srpath); + if (reply_stream==NULL) { + LM_ERR("cannot open reply fifo: %.*s\n", srpath.len, srpath.s); + continue; + } + nw = fwrite(_jsonrpc_plain_reply.rbody.s, 1, + _jsonrpc_plain_reply.rbody.len, reply_stream); + if(nw < _jsonrpc_plain_reply.rbody.len) { + LM_ERR("failed to write the reply to fifo: %d out of %d\n", + nw, _jsonrpc_plain_reply.rbody.len); + } + fclose(reply_stream); + + } + } + return; +} + +static void jsonrpc_fifo_process(int rank) +{ + FILE *fifo_stream; + + LM_DBG("new process with pid = %d created\n",getpid()); + + fifo_stream = jsonrpc_init_fifo_server( jsonrpc_fifo, jsonrpc_fifo_mode, + jsonrpc_fifo_uid, jsonrpc_fifo_gid, jsonrpc_fifo_reply_dir); + if ( fifo_stream==NULL ) { + LM_CRIT("The function jsonrpc_init_fifo_server returned with error!!!\n"); + exit(-1); + } + + jsonrpc_run_fifo_server( fifo_stream ); + + LM_CRIT("the function jsonroc_fifo_server returned with error!!!\n"); + exit(-1); +} diff --git a/modules/kazoo/defs.h b/modules/kazoo/defs.h index 01d9af40477..e7f991de8bb 100644 --- a/modules/kazoo/defs.h +++ b/modules/kazoo/defs.h @@ -69,14 +69,17 @@ #define DIALOGINFO_EMPTY_BODY "\ \ -\ +\ terminated\ \ " +#define LOCAL_TAG "local-tag=\"%.*s\"" +#define REMOTE_TAG "remote-tag=\"%.*s\"" + #define DIALOGINFO_BODY "\ \ -\ +\ %.*s\ \ %.*s\ @@ -91,7 +94,7 @@ #define DIALOGINFO_BODY_2 "\ \ -\ +\ %.*s\ \ %.*s\ diff --git a/modules/kazoo/kazoo.c b/modules/kazoo/kazoo.c index 89484d1ab3e..e8b674943e8 100644 --- a/modules/kazoo/kazoo.c +++ b/modules/kazoo/kazoo.c @@ -320,18 +320,18 @@ static int mod_child_init(int rank) if (rank==PROC_MAIN) { - pid=fork_process(1, "AMQP Publisher", 1); + pid=fork_process(2, "AMQP Consumer", 1); if (pid<0) return -1; /* error */ if(pid==0){ - kz_amqp_publisher_proc(0); + kz_amqp_consumer_proc(1); } else { - pid=fork_process(2, "AMQP Consumer", 1); + pid=fork_process(1, "AMQP Publisher", 1); if (pid<0) return -1; /* error */ if(pid==0){ - kz_amqp_consumer_proc(1); + kz_amqp_publisher_proc(0); } else { pid=fork_process(3, "AMQP Timer", 1); diff --git a/modules/kazoo/kz_amqp.c b/modules/kazoo/kz_amqp.c index f1534d8bdf4..9664cfd5e44 100644 --- a/modules/kazoo/kz_amqp.c +++ b/modules/kazoo/kz_amqp.c @@ -283,6 +283,42 @@ void kz_amqp_init_connection_pool() { } } +int kz_amqp_bind_init_targeted_channel(int idx ) +{ + kz_amqp_bind_ptr bind = NULL; + str rpl_exch = str_init("targeted"); + str rpl_exch_type = str_init("direct"); + int ret = -1; + char serverid[512]; + + bind = (kz_amqp_bind_ptr)shm_malloc(sizeof(kz_amqp_bind)); + if(bind == NULL) { + LM_ERR("error allocation memory for reply\n"); + goto error; + } + memset(bind, 0, sizeof(kz_amqp_bind)); + + bind->exchange = kz_amqp_bytes_dup_from_str(&rpl_exch); + bind->exchange_type = kz_amqp_bytes_dup_from_str(&rpl_exch_type); + + sprintf(serverid, "kamailio@%.*s-<%d-%d>", dbk_node_hostname.len, dbk_node_hostname.s, my_pid(), idx); + bind->queue = kz_amqp_bytes_dup_from_string(serverid); + + sprintf(serverid, "kamailio@%.*s-<%d>-targeted-%d", dbk_node_hostname.len, dbk_node_hostname.s, my_pid(), idx); + bind->routing_key = kz_amqp_bytes_dup_from_string(serverid); + + if (bind->exchange.bytes == NULL || bind->routing_key.bytes == NULL || bind->queue.bytes == NULL) { + LM_ERR("Out of memory allocating for exchange/routing_key\n"); + goto error; + } + + channels[idx].targeted = bind; + return 0; + error: + kz_amqp_free_bind(bind); + return ret; +} + int kz_amqp_init() { int i; kz_amqp_init_connection_pool(); @@ -294,11 +330,15 @@ int kz_amqp_init() { channels = shm_malloc(dbk_channels * sizeof(kz_amqp_channel)); memset(channels, 0, dbk_channels * sizeof(kz_amqp_channel)); for(i=0; i < dbk_channels; i++) { + channels[i].channel = i+1; if(lock_init(&channels[i].lock)==NULL) { LM_ERR("could not initialize locks for channels\n"); return 0; } - channels[i].channel = i+1; + if(kz_amqp_bind_init_targeted_channel(i)) { + LM_ERR("could not initialize targeted channels\n"); + return 0; + } } } return 1; @@ -541,10 +581,12 @@ kz_amqp_conn_ptr kz_amqp_get_next_connection() { int kz_amqp_open_next_connection(kz_amqp_conn_ptr ptr) { if(ptr == NULL) { + LM_ERR("OPEN CONNECTION PTR == NULL\n"); return -1; } if(kz_pool == NULL) { + LM_ERR("OPEN CONNECTION POOL == NULL\n"); return -2; } @@ -1216,7 +1258,43 @@ int get_channel_index() { return get_channel_index(); } -int kz_amqp_bind_targeted_channel(kz_amqp_conn_ptr kz_conn, int loopcount, int idx ) +int kz_amqp_bind_targeted_channel(kz_amqp_conn_ptr kz_conn, int idx ) +{ + kz_amqp_bind_ptr bind = channels[idx].targeted; + amqp_queue_declare_ok_t *r = NULL; + int ret = -1; + + r = amqp_queue_declare(kz_conn->conn, channels[idx].channel, bind->queue, 0, 0, 1, 1, kz_amqp_empty_table); + if (kz_amqp_error("Declaring queue", amqp_get_rpc_reply(kz_conn->conn))) + { + goto error; + } + + amqp_exchange_declare(kz_conn->conn, channels[idx].channel, bind->exchange, bind->exchange_type, 0, 0, kz_amqp_empty_table); + if (kz_amqp_error("Declaring exchange", amqp_get_rpc_reply(kz_conn->conn))) + { + ret = -RET_AMQP_ERROR; + goto error; + } + + if (amqp_queue_bind(kz_conn->conn, channels[idx].channel, bind->queue, bind->exchange, bind->routing_key, kz_amqp_empty_table) < 0 + || kz_amqp_error("Binding queue", amqp_get_rpc_reply(kz_conn->conn))) + { + goto error; + } + + if (amqp_basic_consume(kz_conn->conn, channels[idx].channel, bind->queue, kz_amqp_empty_bytes, 0, 1, 1, kz_amqp_empty_table) < 0 + || kz_amqp_error("Consuming", amqp_get_rpc_reply(kz_conn->conn))) + { + goto error; + } + + return 0; + error: + return ret; +} + +int kz_amqp_bind_targeted_channel_ex(kz_amqp_conn_ptr kz_conn, int loopcount, int idx ) { kz_amqp_bind_ptr bind = NULL; amqp_queue_declare_ok_t *r = NULL; @@ -1283,7 +1361,7 @@ int kz_amqp_bind_targeted_channels(kz_amqp_conn_ptr kz_conn , int loopcount) { int i, ret; for(i = 0; i < dbk_channels; i++) { - ret = kz_amqp_bind_targeted_channel(kz_conn, loopcount, i); + ret = kz_amqp_bind_targeted_channel_ex(kz_conn, loopcount, i); if(ret != 0) return ret; } @@ -1704,7 +1782,7 @@ void kz_amqp_manager_loop(int child_no) /* end cleanup */ channel_res = kz_amqp_channel_open(kzconn, channels[i].channel); if(channel_res == 0) { - kz_amqp_bind_targeted_channel(kzconn, loopcount, i); + kz_amqp_bind_targeted_channel_ex(kzconn, loopcount, i); channels[i].state = KZ_AMQP_FREE; } } @@ -1934,9 +2012,10 @@ void kz_amqp_timeout_proc(int child_no) void kz_amqp_publisher_proc(int child_no) { - LM_DBG("starting manager %d\n", child_no); + LM_DBG("starting publisher %d\n", child_no); close(kz_pipe_fds[child_no*2+1]); int data_pipe = kz_pipe_fds[child_no*2]; + LM_DBG("publisher started %d\n", child_no); fd_set fdset; int idx, i; int selret; @@ -1946,11 +2025,20 @@ void kz_amqp_publisher_proc(int child_no) int channel_res; kzconn = (kz_amqp_conn_ptr)pkg_malloc(sizeof(kz_amqp_conn)); + if(kzconn == NULL) + { + LM_ERR("NO MORE PACKAGE MEMORY\n"); + return; + } memset(kzconn, 0, sizeof(kz_amqp_conn)); while(1) { OK = 1; - kz_amqp_open_next_connection(kzconn); + if(kz_amqp_open_next_connection(kzconn)) { + LM_ERR("Error opening connection\n"); + sleep(3); + continue; + } kz_amqp_fire_connection_event("open", kzconn->info->info.host); for(i=0,channel_res=0; i < dbk_channels && channel_res == 0; i++) { @@ -1971,6 +2059,7 @@ void kz_amqp_publisher_proc(int child_no) } } + while(OK) { FD_ZERO(&fdset); FD_SET(data_pipe, &fdset); @@ -1992,17 +2081,17 @@ void kz_amqp_publisher_proc(int child_no) OK = 0; LM_ERR("ERROR SENDING PUBLISH"); } - channels[idx].state = KZ_AMQP_FREE; channels[idx].cmd = NULL; lock_release(&cmd->lock); + channels[idx].state = KZ_AMQP_FREE; break; case KZ_AMQP_CALL: idx = kz_amqp_send_receive(kzconn, cmd); if(idx < 0) { - channels[idx].state = KZ_AMQP_FREE; channels[idx].cmd = NULL; cmd->return_code = -1; lock_release(&cmd->lock); + channels[idx].state = KZ_AMQP_FREE; LM_ERR("ERROR SENDING QUERY"); OK = 0; } @@ -2031,15 +2120,29 @@ void kz_amqp_consumer_proc(int child_no) kz_amqp_channel_ptr consumer_channels = NULL; kzconn = (kz_amqp_conn_ptr)pkg_malloc(sizeof(kz_amqp_conn)); + if(kzconn == NULL) + { + LM_ERR("NO MORE PACKAGE MEMORY\n"); + return; + } memset(kzconn, 0, sizeof(kz_amqp_conn)); consumer_channels = (kz_amqp_channel_ptr)pkg_malloc(sizeof(kz_amqp_channel)*bindings_count); + if(consumer_channels == NULL) + { + LM_ERR("NO MORE PACKAGE MEMORY\n"); + return; + } for(i=0; i < bindings_count; i++) consumer_channels[i].channel = dbk_channels + i + 1; while(1) { OK = 1; - kz_amqp_open_next_connection(kzconn); + if(kz_amqp_open_next_connection(kzconn)) { + LM_ERR("Error opening connection\n"); + sleep(3); + continue; + } kz_amqp_fire_connection_event("open", kzconn->info->info.host); /* reset channels */ @@ -2047,16 +2150,20 @@ void kz_amqp_consumer_proc(int child_no) for(i=0,channel_res=0; i < dbk_channels && channel_res == 0; i++) { /* start cleanup */ channels[i].consumer = NULL; + + /* if(channels[i].targeted != NULL) { kz_amqp_free_bind(channels[i].targeted); channels[i].targeted = NULL; } + */ + /* end cleanup */ /* bind targeted channels */ channel_res = kz_amqp_channel_open(kzconn, channels[i].channel); if(channel_res == 0) { - kz_amqp_bind_targeted_channel(kzconn, 0, i); + kz_amqp_bind_targeted_channel(kzconn, i); } } @@ -2080,6 +2187,8 @@ void kz_amqp_consumer_proc(int child_no) } } + LM_DBG("CONSUMER INIT DONE\n"); + while(OK) { payload = NULL; amqp_envelope_t envelope; diff --git a/modules/kazoo/kz_pua.c b/modules/kazoo/kz_pua.c index 562a0606e2d..d9757a7b478 100644 --- a/modules/kazoo/kz_pua.c +++ b/modules/kazoo/kz_pua.c @@ -320,6 +320,8 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) { int expires = 0; str event = str_init("dialog"); int reset = 0; + char to_tag_buffer[100]; + char from_tag_buffer[100]; char *body = (char *)pkg_malloc(DIALOGINFO_BODY_BUFFER_SIZE); if(body == NULL) { @@ -375,6 +377,16 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) { if(!to_uri.len) to_uri = to; + if(fromtag.len > 0) { + fromtag.len = sprintf(from_tag_buffer, LOCAL_TAG, fromtag.len, fromtag.s); + fromtag.s = from_tag_buffer; + } + + if(totag.len > 0) { + totag.len = sprintf(to_tag_buffer, REMOTE_TAG, totag.len, totag.s); + totag.s = to_tag_buffer; + } + if(callid.len) { if(dbk_include_entity) { diff --git a/modules/ldap/ldap_connect.c b/modules/ldap/ldap_connect.c index 4ffff282dc1..c21e4459bdc 100644 --- a/modules/ldap/ldap_connect.c +++ b/modules/ldap/ldap_connect.c @@ -36,7 +36,7 @@ #include "../../mem/mem.h" #include "../../ut.h" -int ldap_connect(char* _ld_name) +int ldap_connect_ex(char* _ld_name, int llevel) { int rc; int ldap_bind_result_code; @@ -221,13 +221,18 @@ int ldap_connect(char* _ld_name) /* ldap_msgfree(result); */ - LM_DBG( "[%s]: LDAP bind successful (ldap_host [%s])\n", + LOG(llevel, "[%s]: LDAP bind successful (ldap_host [%s])\n", _ld_name, lds->host_name); return 0; } +int ldap_connect(char* _ld_name) +{ + return ldap_connect_ex(_ld_name, L_DBG); +} + int ldap_disconnect(char* _ld_name) { struct ld_session* lds; @@ -262,14 +267,14 @@ int ldap_reconnect(char* _ld_name) return -1; } - if ((rc = ldap_connect(_ld_name)) != 0) + if ((rc = ldap_connect_ex(_ld_name, L_INFO)) != 0) { LM_ERR("[%s]: reconnect failed\n", _ld_name); } else { - LM_ERR("[%s]: LDAP reconnect successful\n", + LM_NOTICE("[%s]: LDAP reconnect successful\n", _ld_name); } return rc; diff --git a/modules/msrp/msrp_cmap.c b/modules/msrp/msrp_cmap.c index 557d1a4cf42..6583e5a2024 100644 --- a/modules/msrp/msrp_cmap.c +++ b/modules/msrp/msrp_cmap.c @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2013 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_cmap.h b/modules/msrp/msrp_cmap.h index acb77fd40f3..81dca079975 100644 --- a/modules/msrp/msrp_cmap.h +++ b/modules/msrp/msrp_cmap.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2013 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_env.c b/modules/msrp/msrp_env.c index 5fdf36db5c5..e2ccf471150 100644 --- a/modules/msrp/msrp_env.c +++ b/modules/msrp/msrp_env.c @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_env.h b/modules/msrp/msrp_env.h index 17035b7b77d..133950c417a 100644 --- a/modules/msrp/msrp_env.h +++ b/modules/msrp/msrp_env.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_mod.c b/modules/msrp/msrp_mod.c index e068e32a663..4e168ced625 100644 --- a/modules/msrp/msrp_mod.c +++ b/modules/msrp/msrp_mod.c @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_netio.c b/modules/msrp/msrp_netio.c index 114ba64a2a5..1a169a7540b 100644 --- a/modules/msrp/msrp_netio.c +++ b/modules/msrp/msrp_netio.c @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_netio.h b/modules/msrp/msrp_netio.h index a593675a55c..00df67a4177 100644 --- a/modules/msrp/msrp_netio.h +++ b/modules/msrp/msrp_netio.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_parser.c b/modules/msrp/msrp_parser.c index 0a6492cbab6..e9cb11f2ab6 100644 --- a/modules/msrp/msrp_parser.c +++ b/modules/msrp/msrp_parser.c @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_parser.h b/modules/msrp/msrp_parser.h index 5977dc2d229..1ee99835af9 100644 --- a/modules/msrp/msrp_parser.h +++ b/modules/msrp/msrp_parser.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_vars.c b/modules/msrp/msrp_vars.c index 088e39987ee..98452fe5eca 100644 --- a/modules/msrp/msrp_vars.c +++ b/modules/msrp/msrp_vars.c @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/msrp/msrp_vars.h b/modules/msrp/msrp_vars.h index 566d1c70371..34ca3317519 100644 --- a/modules/msrp/msrp_vars.h +++ b/modules/msrp/msrp_vars.h @@ -1,6 +1,4 @@ /** - * $Id$ - * * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/ndb_redis/redis_client.c b/modules/ndb_redis/redis_client.c index 23cb2cbcc53..0476ed2d275 100644 --- a/modules/ndb_redis/redis_client.c +++ b/modules/ndb_redis/redis_client.c @@ -249,7 +249,7 @@ redisc_server_t *redisc_get_server(str *name) */ int redisc_reconnect_server(redisc_server_t *rsrv) { - char *addr, *unix_sock_path = NULL; + char *addr, *pass, *unix_sock_path = NULL; unsigned int port, db; param_t *pit = NULL; struct timeval tv; @@ -259,6 +259,7 @@ int redisc_reconnect_server(redisc_server_t *rsrv) addr = "127.0.0.1"; port = 6379; db = 0; + pass = NULL; for (pit = rsrv->attrs; pit; pit=pit->next) { if(pit->name.len==4 && strncmp(pit->name.s, "unix", 4)==0) { @@ -273,6 +274,9 @@ int redisc_reconnect_server(redisc_server_t *rsrv) } else if(pit->name.len==2 && strncmp(pit->name.s, "db", 2)==0) { if(str2int(&pit->body, &db) < 0) db = 0; + } else if(pit->name.len==4 && strncmp(pit->name.s, "pass", 4)==0) { + pass = pit->body.s; + pass[pit->body.len] = '\0'; } } if(rsrv->ctxRedis!=NULL) { @@ -289,6 +293,8 @@ int redisc_reconnect_server(redisc_server_t *rsrv) goto err; if (rsrv->ctxRedis->err) goto err2; + if ((pass != NULL) && redisc_check_auth(rsrv, pass)) + goto err2; if (redisCommandNR(rsrv->ctxRedis, "PING")) goto err2; if (redisCommandNR(rsrv->ctxRedis, "SELECT %i", db)) diff --git a/modules/presence/bind_presence.c b/modules/presence/bind_presence.c index 5cbcfc16ffe..98645bd68b9 100644 --- a/modules/presence/bind_presence.c +++ b/modules/presence/bind_presence.c @@ -1,5 +1,4 @@ /* - * $Id: bind_presence.c 1979 2007-04-06 13:24:12Z anca_vamanu $ * * presence module - presence server implementation * @@ -21,13 +20,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-04-17 initial version (Anca Vamanu) */ /*! \file - * \brief SIP-Router Presence :: Kamailio generic presence module + * \brief Kamailio Presence :: Kamailio generic presence module * * This is the core presence module, used in combination with other modules. * diff --git a/modules/presence/bind_presence.h b/modules/presence/bind_presence.h index d96f4007a92..2c512cb12e0 100644 --- a/modules/presence/bind_presence.h +++ b/modules/presence/bind_presence.h @@ -1,6 +1,4 @@ /* - * $Id: bind_presence.h 1979 2007-04-06 13:24:12Z anca_vamanu $ - * * presence module - presence server implementation * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,12 +19,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-04-17 initial version (Anca Vamanu) */ /*! \file - * \brief SIP-Router Presence :: Kamailio generic presence module + * \brief Kamailio Presence :: Kamailio generic presence module * * \ingroup presence */ diff --git a/modules/presence/event_list.c b/modules/presence/event_list.c index 238eebad3c9..e814db357aa 100644 --- a/modules/presence/event_list.c +++ b/modules/presence/event_list.c @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-04-04 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/event_list.h b/modules/presence/event_list.h index 29511cbc89b..640e6d553f4 100644 --- a/modules/presence/event_list.h +++ b/modules/presence/event_list.h @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-04-05 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/hash.c b/modules/presence/hash.c index 11d9e3e3182..5e46fd4af28 100644 --- a/modules/presence/hash.c +++ b/modules/presence/hash.c @@ -1,6 +1,4 @@ /* - * $Id: hash.c 2583 2007-08-08 11:33:25Z anca_vamanu $ - * * presence module - presence server implementation * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-20 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/hash.h b/modules/presence/hash.h index 065fd205ed3..87e01afc3f1 100644 --- a/modules/presence/hash.h +++ b/modules/presence/hash.h @@ -1,6 +1,4 @@ /* - * $Id: hash.h 2583 2007-08-08 11:33:25Z anca_vamanu $ - * * presence module - presence server implementation * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-08-20 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/notify.c b/modules/presence/notify.c index 1511587e697..94082aa7019 100644 --- a/modules/presence/notify.c +++ b/modules/presence/notify.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * presence module- presence server implementation * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/notify.h b/modules/presence/notify.h index 1ce747b49a5..d83a81cf67d 100644 --- a/modules/presence/notify.h +++ b/modules/presence/notify.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * presence module -presence server implementation * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/presence.c b/modules/presence/presence.c index 1a5284949d5..828ff462d86 100644 --- a/modules/presence/presence.c +++ b/modules/presence/presence.c @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/presence.h b/modules/presence/presence.h index b725bad5779..5dc529a8386 100644 --- a/modules/presence/presence.h +++ b/modules/presence/presence.h @@ -17,10 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * - * History: - * --------- - * 2006-10-09 first version (Anca Vamanu) */ /*! diff --git a/modules/presence/presentity.c b/modules/presence/presentity.c index 52515baa9c9..58d56cdc373 100644 --- a/modules/presence/presentity.c +++ b/modules/presence/presentity.c @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/presentity.h b/modules/presence/presentity.h index 55e433a273b..ca719e3649d 100644 --- a/modules/presence/presentity.h +++ b/modules/presence/presentity.h @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/publish.c b/modules/presence/publish.c index 4ca9afba1fa..1b380bb7236 100644 --- a/modules/presence/publish.c +++ b/modules/presence/publish.c @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/publish.h b/modules/presence/publish.h index 6c2e9d8d085..09be0fc7462 100644 --- a/modules/presence/publish.h +++ b/modules/presence/publish.h @@ -17,9 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! diff --git a/modules/presence/subscribe.c b/modules/presence/subscribe.c index 48938fce725..0363e3a915e 100644 --- a/modules/presence/subscribe.c +++ b/modules/presence/subscribe.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * presence module - presence server implementation * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/subscribe.h b/modules/presence/subscribe.h index 776d8dadd89..955e46a03af 100644 --- a/modules/presence/subscribe.h +++ b/modules/presence/subscribe.h @@ -19,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/utils_func.c b/modules/presence/utils_func.c index 64d0527ccb2..c56c6cb9505 100644 --- a/modules/presence/utils_func.c +++ b/modules/presence/utils_func.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * presence module - presence server implementation * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence/utils_func.h b/modules/presence/utils_func.h index cf7c030b7b6..866df1be6df 100644 --- a/modules/presence/utils_func.h +++ b/modules/presence/utils_func.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * presence module - presence server implementation * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-08-15 initial version (Anca Vamanu) */ /*! \file diff --git a/modules/presence_dialoginfo/notify_body.c b/modules/presence_dialoginfo/notify_body.c index bd2097bdd47..508b9f8304b 100644 --- a/modules/presence_dialoginfo/notify_body.c +++ b/modules/presence_dialoginfo/notify_body.c @@ -68,7 +68,7 @@ void free_xml_body(char* body) } #define DIALOGINFO_EMPTY_BODY "\ -\ +\ terminated\ \ " diff --git a/modules/pua/add_events.c b/modules/pua/add_events.c index f8ef09cee82..5446745924b 100644 --- a/modules/pua/add_events.c +++ b/modules/pua/add_events.c @@ -1,6 +1,4 @@ /* - * $Id: add_events.c 2007-05-03 15:05:20Z anca_vamanu $ - * * pua module - presence user agent module * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,7 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * initial version 2007-05-03 (anca) */ #include #include diff --git a/modules/pua/add_events.h b/modules/pua/add_events.h index 4d1b226f3e5..b802d67ef2c 100644 --- a/modules/pua/add_events.h +++ b/modules/pua/add_events.h @@ -1,6 +1,4 @@ /* - * $Id: add_events.h 2007-05-03 15:05:20Z anca_vamanu $ - * * pua module - presence user agent module * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,7 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * initial version 2007-05-03 (anca) */ #ifndef _PUA_ADD_EV_H_ #define _PUA_ADD_EV_H_ diff --git a/modules/pua/event_list.c b/modules/pua/event_list.c index 91a513b8786..1bdf52e3173 100644 --- a/modules/pua/event_list.c +++ b/modules/pua/event_list.c @@ -1,6 +1,4 @@ /* - * $Id: event_list.c 2007-05-03 15:05:20Z anca_vamanu $ - * * pua module - presence user agent module * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,7 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * initial version 2007-05-03 (anca) */ #include #include diff --git a/modules/pua/event_list.h b/modules/pua/event_list.h index 6670e164e9c..6df5df3988c 100644 --- a/modules/pua/event_list.h +++ b/modules/pua/event_list.h @@ -1,6 +1,4 @@ /* - * $Id: event_list.h 2007-05-03 15:05:20Z anca_vamanu $ - * * pua module - presence user agent module * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,7 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * initial version 2007-05-03 (anca) */ #ifndef _PUA_EVLIST_H_ diff --git a/modules/pua/hash.c b/modules/pua/hash.c index 93b9a898849..2af436f2898 100644 --- a/modules/pua/hash.c +++ b/modules/pua/hash.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/hash.h b/modules/pua/hash.h index 161939b1103..3da08944ae5 100644 --- a/modules/pua/hash.h +++ b/modules/pua/hash.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/pidf.c b/modules/pua/pidf.c index 83b337a4915..6c3c2883969 100644 --- a/modules/pua/pidf.c +++ b/modules/pua/pidf.c @@ -1,6 +1,4 @@ /* - * $Id: pidf.c 1953 2007-04-04 08:50:33Z anca_vamanu $ - * * pua module * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-07-03 initial version (anca) */ #include diff --git a/modules/pua/pidf.h b/modules/pua/pidf.h index 54bdd80465c..63ccf352ba7 100644 --- a/modules/pua/pidf.h +++ b/modules/pua/pidf.h @@ -1,6 +1,4 @@ /* - * $Id: pidf.h 1401 2006-12-14 11:12:42Z anca_vamanu $ - * * pua module * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-07-03 initial version (anca) */ #ifndef PUA_PIDF_H diff --git a/modules/pua/pua.c b/modules/pua/pua.c index 89b0a4906b7..06b3077e716 100644 --- a/modules/pua/pua.c +++ b/modules/pua/pua.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-11-29 initial version (anca) */ diff --git a/modules/pua/pua.h b/modules/pua/pua.h index 695f3fd2c5f..2295c29ece8 100644 --- a/modules/pua/pua.h +++ b/modules/pua/pua.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/pua_bind.c b/modules/pua/pua_bind.c index e8f80ef1580..80d5c9c60ab 100644 --- a/modules/pua/pua_bind.c +++ b/modules/pua/pua_bind.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/pua_bind.h b/modules/pua/pua_bind.h index ea8933f2e9b..35c208e05b5 100644 --- a/modules/pua/pua_bind.h +++ b/modules/pua/pua_bind.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/pua_callback.c b/modules/pua/pua_callback.c index 9741270b86b..c231c1da43c 100644 --- a/modules/pua/pua_callback.c +++ b/modules/pua/pua_callback.c @@ -1,6 +1,4 @@ /* - * $Id: pua_callback.c,v 1.2 2007/02/20 13:40:09 anca_vamanu Exp $ - * * pua module - presence user agent module * * Copyright (C) 2007 Voice Sistem S.R.L. diff --git a/modules/pua/pua_callback.h b/modules/pua/pua_callback.h index 4b885982653..68ee36f6768 100644 --- a/modules/pua/pua_callback.h +++ b/modules/pua/pua_callback.h @@ -1,6 +1,4 @@ /* - * $Id: pua_callback.c,v 1.2 2007/02/20 13:40:09 anca_vamanu Exp $ - * * pua module - presence user agent module * * Copyright (C) 2007 Voice Sistem S.R.L. diff --git a/modules/pua/pua_db.c b/modules/pua/pua_db.c index 4a10fff1ee9..7297d4a8165 100644 --- a/modules/pua/pua_db.c +++ b/modules/pua/pua_db.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua db - presence user agent database support * * Copyright (C) 2011 Crocodile RCS Ltd diff --git a/modules/pua/pua_db.h b/modules/pua/pua_db.h index 02f0a10ed9d..c5e7a0b383b 100644 --- a/modules/pua/pua_db.h +++ b/modules/pua/pua_db.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua_db headers - presence user agent db headers * * Copyright (C) 2011 Crocodile RCS Ltd diff --git a/modules/pua/send_publish.c b/modules/pua/send_publish.c index 8cd553b0374..a7bb09ef984 100644 --- a/modules/pua/send_publish.c +++ b/modules/pua/send_publish.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2006-11-29 initial version (anca) */ diff --git a/modules/pua/send_publish.h b/modules/pua/send_publish.h index 667d7aa480b..426c6d78068 100644 --- a/modules/pua/send_publish.h +++ b/modules/pua/send_publish.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/send_subscribe.c b/modules/pua/send_subscribe.c index 67aa9d2b75d..48acbd5ef58 100644 --- a/modules/pua/send_subscribe.c +++ b/modules/pua/send_subscribe.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/pua/send_subscribe.h b/modules/pua/send_subscribe.h index 6c7e721b863..2cd8e28e0b6 100644 --- a/modules/pua/send_subscribe.h +++ b/modules/pua/send_subscribe.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * pua module - presence user agent module * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/registrar/README b/modules/registrar/README index a35aa622114..f305a69a211 100644 --- a/modules/registrar/README +++ b/modules/registrar/README @@ -1068,6 +1068,7 @@ event_route[usrloc:contact-expired] { * ruid - record unique ID * reg-id - reg-id value * instance - instance value + * conid - TCP socket internal connection ID ($null if UDP) The pseudo-variable accepts positive index value to access a specific contact record. diff --git a/modules/registrar/doc/registrar_admin.xml b/modules/registrar/doc/registrar_admin.xml index f1c9dc51a47..53693ef9e98 100644 --- a/modules/registrar/doc/registrar_admin.xml +++ b/modules/registrar/doc/registrar_admin.xml @@ -1455,6 +1455,10 @@ event_route[usrloc:contact-expired] { instance - instance value + + conid - TCP socket internal connection ID ($null if UDP) + + The pseudo-variable accepts positive index value to access diff --git a/modules/registrar/regpv.c b/modules/registrar/regpv.c index 719bec3ff0c..8574e924ae9 100644 --- a/modules/registrar/regpv.c +++ b/modules/registrar/regpv.c @@ -192,7 +192,7 @@ int pv_get_ulc(struct sip_msg *msg, pv_param_t *param, /* get contact */ i = 0; c = rpp->contacts; - while(rpp) + while(c) { if(i == idx) break; @@ -269,6 +269,10 @@ int pv_get_ulc(struct sip_msg *msg, pv_param_t *param, if(c->instance.len>0) return pv_get_strval(msg, param, res, &c->instance); break; + case 21: /* conid */ + if (c->sock && (c->sock->proto == PROTO_TCP || c->sock->proto == PROTO_TLS || c->sock->proto == PROTO_WS || c->sock->proto == PROTO_WSS)) + return pv_get_sintval(msg, param, res, c->tcpconn_id); + break; } return pv_get_null(msg, param, res); @@ -363,6 +367,8 @@ int pv_parse_ulc_name(pv_spec_p sp, str *in) rp->attr = 17; else if(strncmp(pa.s, "regid", 5)==0) rp->attr = 19; + else if(strncmp(pa.s, "conid", 5)==0) + rp->attr = 21; else goto error; break; case 6: @@ -538,6 +544,10 @@ int pv_fetch_contacts(struct sip_msg* msg, char* table, char* uri, c0->instance.len = ptr->instance.len; p += c0->instance.len; } + if (ptr->sock->proto == PROTO_TCP || ptr->sock->proto == PROTO_TLS || ptr->sock->proto == PROTO_WS || ptr->sock->proto == PROTO_WSS) + { + c0->tcpconn_id = ptr->tcpconn_id; + } if(ptr0==NULL) { diff --git a/modules/rls/notify.c b/modules/rls/notify.c index fb9d7f3e83a..cda3da1c7eb 100644 --- a/modules/rls/notify.c +++ b/modules/rls/notify.c @@ -1,6 +1,4 @@ /* - * $Id: notify.c 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #include diff --git a/modules/rls/notify.h b/modules/rls/notify.h index 5223887c0d7..bb18e104245 100644 --- a/modules/rls/notify.h +++ b/modules/rls/notify.h @@ -1,6 +1,4 @@ /* - * $Id: notify.c 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,10 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) - * */ #ifndef _RLS_NOTIFY_H diff --git a/modules/rls/resource_notify.c b/modules/rls/resource_notify.c index 01c8dd8b47d..d17445c9506 100644 --- a/modules/rls/resource_notify.c +++ b/modules/rls/resource_notify.c @@ -1,6 +1,4 @@ /* - * $Id: resource_notify.c 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #include diff --git a/modules/rls/resource_notify.h b/modules/rls/resource_notify.h index 86f65f6986d..72fa7f4a68f 100644 --- a/modules/rls/resource_notify.h +++ b/modules/rls/resource_notify.h @@ -1,6 +1,4 @@ /* - * $Id: resource_notify.h 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #ifndef RLS_RES_NOT_H diff --git a/modules/rls/rls.c b/modules/rls/rls.c index c87e91e1348..23c6a7cd11c 100644 --- a/modules/rls/rls.c +++ b/modules/rls/rls.c @@ -1,6 +1,4 @@ /* - * $Id: rls.c 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #include diff --git a/modules/rls/rls.h b/modules/rls/rls.h index 8b55cf9af5c..ac11efa962b 100644 --- a/modules/rls/rls.h +++ b/modules/rls/rls.h @@ -1,6 +1,4 @@ /* - * $Id: rls.h 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #ifndef _RLS_H_ diff --git a/modules/rls/rls_db.c b/modules/rls/rls_db.c index 463b5bc67a2..5dbbca999fb 100644 --- a/modules/rls/rls_db.c +++ b/modules/rls/rls_db.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * rls db - RLS database support * * Copyright (C) 2011 Crocodile RCS Ltd diff --git a/modules/rls/subscribe.c b/modules/rls/subscribe.c index 801d5e4d3f8..09d988b8fdc 100644 --- a/modules/rls/subscribe.c +++ b/modules/rls/subscribe.c @@ -1,6 +1,4 @@ /* - * $Id: subscribe.c 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #include #include diff --git a/modules/rls/subscribe.h b/modules/rls/subscribe.h index c82df7426a2..04fc117f43d 100644 --- a/modules/rls/subscribe.h +++ b/modules/rls/subscribe.h @@ -1,6 +1,4 @@ /* - * $Id: subscribe.c 2230 2007-06-06 07:13:20Z anca_vamanu $ - * * rls module - resource list server * * Copyright (C) 2007 Voice Sistem S.R.L. @@ -21,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * -------- - * 2007-09-11 initial version (anca) */ #ifndef RLS_SUBSCRIBE_H diff --git a/modules/rr/api.c b/modules/rr/api.c index a4bd9492035..1b7c420ccf4 100644 --- a/modules/rr/api.c +++ b/modules/rr/api.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2005 Voice Sistem SRL * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/api.h b/modules/rr/api.h index abe50de1a74..e2b73402093 100644 --- a/modules/rr/api.h +++ b/modules/rr/api.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2005 Voice Sistem SRL * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/loose.c b/modules/rr/loose.c index f537a8d906c..de06bb3ab5d 100644 --- a/modules/rr/loose.c +++ b/modules/rr/loose.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2004 FhG Fokus * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/loose.h b/modules/rr/loose.h index a4f4252e167..9064a6f8ed0 100644 --- a/modules/rr/loose.h +++ b/modules/rr/loose.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/record.c b/modules/rr/record.c index a521092e1eb..d3357483cbd 100644 --- a/modules/rr/record.c +++ b/modules/rr/record.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/record.h b/modules/rr/record.h index 5cf02722031..8e30fb1ef8f 100644 --- a/modules/rr/record.h +++ b/modules/rr/record.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/rr_cb.c b/modules/rr/rr_cb.c index cebb0a4258e..d9c31498cfe 100644 --- a/modules/rr/rr_cb.c +++ b/modules/rr/rr_cb.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2005 Voice Sistem SRL * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/rr_cb.h b/modules/rr/rr_cb.h index 63acc1d8ffd..6224f883aca 100644 --- a/modules/rr/rr_cb.h +++ b/modules/rr/rr_cb.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2005 Voice Sistem SRL * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rr/rr_mod.c b/modules/rr/rr_mod.c index 34aa0a68c56..06aec935bef 100644 --- a/modules/rr/rr_mod.c +++ b/modules/rr/rr_mod.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * Copyright (C) 2011 Carsten Bock, carsten@ng-voice.com * @@ -40,6 +38,8 @@ #include "../../mem/mem.h" #include "../../mod_fix.h" #include "../../parser/parse_rr.h" +#include "../../parser/parse_from.h" +#include "../../parser/parse_to.h" #include "../outbound/api.h" #include "loose.h" #include "record.h" @@ -79,6 +79,13 @@ static int w_is_direction(struct sip_msg *,char *, char *); static int remove_record_route(sip_msg_t*, char*, char*); /* PV functions */ static int pv_get_route_uri_f(struct sip_msg *, pv_param_t *, pv_value_t *); +static int pv_get_from_tag_initial(sip_msg_t *msg, pv_param_t *param, + pv_value_t *res); +static int pv_get_to_tag_initial(sip_msg_t *msg, pv_param_t *param, + pv_value_t *res); +static int pv_get_rdir(sip_msg_t *msg, pv_param_t *param, pv_value_t *res); +static int pv_parse_rdir_name(pv_spec_p sp, str *in); + /*! * \brief Exported functions */ @@ -129,7 +136,14 @@ static param_export_t params[] ={ */ static pv_export_t mod_pvs[] = { {{"route_uri", (sizeof("route_uri")-1)}, /* URI of the first Route-Header */ - PVT_OTHER, pv_get_route_uri_f, 0, 0, 0, 0, 0}, + PVT_OTHER, pv_get_route_uri_f, 0, 0, 0, 0, 0}, + {{"fti", (sizeof("fti")-1)}, /* From-Tag as for initial request */ + PVT_OTHER, pv_get_from_tag_initial, 0, 0, 0, 0, 0}, + {{"tti", (sizeof("tti")-1)}, /* To-Tag as for response to initial request */ + PVT_OTHER, pv_get_to_tag_initial, 0, 0, 0, 0, 0}, + { {"rdir", (sizeof("rdir")-1)}, PVT_OTHER, pv_get_rdir, 0, + pv_parse_rdir_name, 0, 0, 0 }, + {{0, 0}, 0, 0, 0, 0, 0, 0, 0} }; @@ -480,3 +494,141 @@ static int remove_record_route(sip_msg_t* _m, char* _s1, char* _s2) free_rr_lump(&(_m->add_rm)); return 1; } + +/** + * + */ +static int pv_get_to_tag_initial(sip_msg_t *msg, pv_param_t *param, + pv_value_t *res) +{ + struct to_body *xto; + if(msg==NULL) + return -1; + + if(msg->to==NULL && parse_headers(msg, HDR_TO_F, 0)==-1) { + LM_ERR("cannot parse To header\n"); + return pv_get_null(msg, param, res); + } + if(msg->to==NULL || get_to(msg)==NULL) { + LM_DBG("no To header\n"); + return pv_get_null(msg, param, res); + } + xto = get_to(msg); + + if(is_direction(msg, RR_FLOW_UPSTREAM)==0) { + if(parse_from_header(msg)<0) { + LM_ERR("cannot parse From header\n"); + return pv_get_null(msg, param, res); + } + if(msg->from==NULL || get_from(msg)==NULL) { + LM_DBG("no From header\n"); + return pv_get_null(msg, param, res); + } + xto = get_from(msg); + } + + if (xto->tag_value.s==NULL || xto->tag_value.len<=0) { + LM_DBG("no Tag parameter\n"); + return pv_get_null(msg, param, res); + } + return pv_get_strval(msg, param, res, &xto->tag_value); +} + +/** + * + */ +static int pv_get_from_tag_initial(sip_msg_t *msg, pv_param_t *param, + pv_value_t *res) +{ + struct to_body *xto; + if(msg==NULL) + return -1; + + if(parse_from_header(msg)<0) { + LM_ERR("cannot parse From header\n"); + return pv_get_null(msg, param, res); + } + if(msg->from==NULL || get_from(msg)==NULL) { + LM_DBG("no From header\n"); + return pv_get_null(msg, param, res); + } + xto = get_from(msg); + + if(is_direction(msg, RR_FLOW_UPSTREAM)==0) { + if(msg->to==NULL && parse_headers(msg, HDR_TO_F, 0)==-1) { + LM_ERR("cannot parse To header\n"); + return pv_get_null(msg, param, res); + } + if(msg->to==NULL || get_to(msg)==NULL) { + LM_DBG("no To header\n"); + return pv_get_null(msg, param, res); + } + xto = get_to(msg); + } + + if (xto->tag_value.s==NULL || xto->tag_value.len<=0) { + LM_DBG("no Tag parameter\n"); + return pv_get_null(msg, param, res); + } + return pv_get_strval(msg, param, res, &xto->tag_value); +} + +/** + * + */ +static int pv_parse_rdir_name(pv_spec_p sp, str *in) +{ + if(sp==NULL || in==NULL || in->len<=0) + return -1; + + switch(in->len) + { + case 2: + if(strncmp(in->s, "id", 2)==0) + sp->pvp.pvn.u.isname.name.n = 0; + else goto error; + break; + case 4: + if(strncmp(in->s, "name", 4)==0) + sp->pvp.pvn.u.isname.name.n = 1; + else goto error; + break; + default: + goto error; + } + sp->pvp.pvn.type = PV_NAME_INTSTR; + sp->pvp.pvn.u.isname.type = 0; + + return 0; + +error: + LM_ERR("unknown PV af key: %.*s\n", in->len, in->s); + return -1; +} + +static str pv_rr_flow_list[] = { + { "downstream", 10 }, + { "upstream", 8 }, + { 0, 0 } + }; + +/** + * + */ +static int pv_get_rdir(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) +{ + if(msg==NULL || param==NULL) + return -1; + + switch(param->pvn.u.isname.name.n) + { + case 1: + if(is_direction(msg, RR_FLOW_UPSTREAM)==0) + return pv_get_strval(msg, param, res, &pv_rr_flow_list[1]); + return pv_get_strval(msg, param, res, &pv_rr_flow_list[0]); + default: + if(is_direction(msg, RR_FLOW_UPSTREAM)==0) + return pv_get_uintval(msg, param, res, RR_FLOW_UPSTREAM); + return pv_get_uintval(msg, param, res, RR_FLOW_DOWNSTREAM); + } +} diff --git a/modules/rr/rr_mod.h b/modules/rr/rr_mod.h index 2b5500331cb..566f280f3bf 100644 --- a/modules/rr/rr_mod.h +++ b/modules/rr/rr_mod.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * * This file is part of Kamailio, a free SIP server. diff --git a/modules/rtpengine/doc/rtpengine_admin.xml b/modules/rtpengine/doc/rtpengine_admin.xml index 576dd80772a..c03bc7dda9a 100644 --- a/modules/rtpengine/doc/rtpengine_admin.xml +++ b/modules/rtpengine/doc/rtpengine_admin.xml @@ -797,7 +797,9 @@ $ &ctltool; fifo nh_enable_rtpp udp:192.168.2.133:8081 0 <function moreinfo="none">nh_show_rtpp</function> Displays all the &rtp; proxies and their information: set and - status (disabled or not, weight and recheck_ticks). + status (disabled or not, weight and recheck_ticks). If a RTP proxy has been disabled by a mi command + a "(permanent)" quote will appear when printing the disabled status. This is to differentiate from + a temporary disable due to the proxy being not found responsive by kamailio. No parameter. diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c index 8b2a5b3ee0f..63fdba56240 100644 --- a/modules/rtpengine/rtpengine.c +++ b/modules/rtpengine/rtpengine.c @@ -109,6 +109,8 @@ MODULE_VERSION #define MI_RTP_PROXY_NOT_FOUND_LEN (sizeof(MI_RTP_PROXY_NOT_FOUND)-1) #define MI_PING_DISABLED "NATping disabled from script" #define MI_PING_DISABLED_LEN (sizeof(MI_PING_DISABLED)-1) +#define MI_DISABLED_PERMANENT "1 (permanent)" +#define MI_DISABLED_PERMANENT_LEN (sizeof(MI_DISABLED_PERMANENT)-1) #define MI_SET "set" #define MI_SET_LEN (sizeof(MI_SET)-1) #define MI_INDEX "index" @@ -760,8 +762,19 @@ static struct mi_root* mi_show_rtpproxies(struct mi_root* cmd_tree, add_rtpp_node_int_info(crt_node, MI_INDEX, MI_INDEX_LEN, crt_rtpp->idx, child, len,string,error); - add_rtpp_node_int_info(crt_node, MI_DISABLED, MI_DISABLED_LEN, - crt_rtpp->rn_disabled, child, len,string,error); + + if (( 1 == crt_rtpp->rn_disabled ) && ( crt_rtpp->rn_recheck_ticks == MI_MAX_RECHECK_TICKS)) { + if( !(child = add_mi_node_child(crt_node, MI_DUP_VALUE, MI_DISABLED, MI_DISABLED_LEN, + MI_DISABLED_PERMANENT, MI_DISABLED_PERMANENT_LEN))) { + LM_ERR("cannot add disabled (permanent) message\n"); + goto error; + } + } + else { + add_rtpp_node_int_info(crt_node, MI_DISABLED, MI_DISABLED_LEN, + crt_rtpp->rn_disabled, child, len,string,error); + } + add_rtpp_node_int_info(crt_node, MI_WEIGHT, MI_WEIGHT_LEN, crt_rtpp->rn_weight, child, len, string,error); add_rtpp_node_int_info(crt_node, MI_RECHECK_TICKS,MI_RECHECK_T_LEN, diff --git a/modules/sanity/api.h b/modules/sanity/api.h index c7ddb18f6b7..01666b52f66 100644 --- a/modules/sanity/api.h +++ b/modules/sanity/api.h @@ -1,23 +1,16 @@ /* - * $Id$ - * * Sanity Checks Module * * Copyright (C) 2006 iptelorg GbmH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/sanity/mod_sanity.c b/modules/sanity/mod_sanity.c index 310be093b68..1e10189908b 100644 --- a/modules/sanity/mod_sanity.c +++ b/modules/sanity/mod_sanity.c @@ -1,23 +1,16 @@ /* - * $Id$ - * * Sanity Checks Module * * Copyright (C) 2006 iptelorg GbmH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/sanity/mod_sanity.h b/modules/sanity/mod_sanity.h index fb27b408eda..f946a01be55 100644 --- a/modules/sanity/mod_sanity.h +++ b/modules/sanity/mod_sanity.h @@ -1,23 +1,16 @@ /* - * $Id$ - * * Sanity Checks Module * * Copyright (C) 2006 iptelorg GbmH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/sanity/sanity.c b/modules/sanity/sanity.c index 58522d4f319..7e1842ee653 100644 --- a/modules/sanity/sanity.c +++ b/modules/sanity/sanity.c @@ -1,23 +1,16 @@ /* - * $Id$ - * * Sanity Checks Module * * Copyright (C) 2006 iptelorg GbmH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/sanity/sanity.h b/modules/sanity/sanity.h index 8ea9d78b6b8..934acb53fc8 100644 --- a/modules/sanity/sanity.h +++ b/modules/sanity/sanity.h @@ -1,23 +1,16 @@ /* - * $Id$ - * * Sanity Checks Module * * Copyright (C) 2006 iptelorg GbmH * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/modules/siptrace/siptrace.c b/modules/siptrace/siptrace.c index 643eb2fdf52..07e3a1adae1 100644 --- a/modules/siptrace/siptrace.c +++ b/modules/siptrace/siptrace.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * siptrace module - helper module to trace sip messages * * Copyright (C) 2006 Voice Sistem S.R.L. diff --git a/modules/sqlops/sql_api.c b/modules/sqlops/sql_api.c index 6ef90e22de0..4b19f3363cd 100644 --- a/modules/sqlops/sql_api.c +++ b/modules/sqlops/sql_api.c @@ -259,7 +259,8 @@ int sql_do_query(sql_con_t *con, str *query, sql_result_t *res) } if(con->dbf.raw_query(con->dbh, query, &db_res)!=0) { - LM_ERR("cannot do the query\n"); + LM_ERR("cannot do the query [%.*s]\n", + (query->len>32)?32:query->len, query->s); return -1; } diff --git a/modules/tcpops/README b/modules/tcpops/README index 4d12a632160..d05b80008fa 100644 --- a/modules/tcpops/README +++ b/modules/tcpops/README @@ -74,11 +74,12 @@ Chapter 1. Admin Guide request_route { if (is_method("INVITE")) { $avp(caller_conid) = $conid; + t_on_reply("foo"); } ... } -onreply_route { +onreply_route[foo] { if (is_method("INVITE") && status == 200) { # enable on callee's connection tcp_keepalive_enable("60", "5", "5"); @@ -105,11 +106,12 @@ request_route { ... if (is_method("BYE")) { $avp(bye_conid) = $conid; + t_on_reply("foo"); } ... } -onreply_route { +onreply_route[foo] { ... if (is_method("BYE") && status == 200) { tcp_keepalive_disable(); diff --git a/modules/tcpops/doc/functions.xml b/modules/tcpops/doc/functions.xml index 1a668a9283d..16f1b869a53 100644 --- a/modules/tcpops/doc/functions.xml +++ b/modules/tcpops/doc/functions.xml @@ -47,11 +47,12 @@ request_route { if (is_method("INVITE")) { $avp(caller_conid) = $conid; + t_on_reply("foo"); } ... } -onreply_route { +onreply_route[foo] { if (is_method("INVITE") && status == 200) { # enable on callee's connection tcp_keepalive_enable("60", "5", "5"); @@ -89,11 +90,12 @@ request_route { ... if (is_method("BYE")) { $avp(bye_conid) = $conid; + t_on_reply("foo"); } ... } -onreply_route { +onreply_route[foo] { ... if (is_method("BYE") && status == 200) { tcp_keepalive_disable(); diff --git a/modules/textops/textops.c b/modules/textops/textops.c index f8b6e419b0b..a677cba03b6 100644 --- a/modules/textops/textops.c +++ b/modules/textops/textops.c @@ -2874,6 +2874,9 @@ static int subst_hf_f(struct sip_msg *msg, char *str_hf, char *subst, char *flag } else { hfl = hf; } + /* if flags set for first header, then all done */ + if(flags!=NULL && *flags=='f') + return ret; } if(hfl!=NULL) { diff --git a/modules/tls/doc/certs_howto.xml b/modules/tls/doc/certs_howto.xml index 651491f15a6..b3272e9ab72 100644 --- a/modules/tls/doc/certs_howto.xml +++ b/modules/tls/doc/certs_howto.xml @@ -68,7 +68,7 @@ Creating CA certificate cd ca 2. create ca directory structure and files (see ca(1)) - mkdir demoCA #default CA name, edit /etc/ss/openssl.cnf + mkdir demoCA #default CA name, edit /etc/ssl/openssl.cnf mkdir demoCA/private mkdir demoCA/newcerts touch demoCA/index.txt diff --git a/modules/tls/tls_server.c b/modules/tls/tls_server.c index 26872c9f11d..1d861405357 100644 --- a/modules/tls/tls_server.c +++ b/modules/tls/tls_server.c @@ -591,6 +591,7 @@ int tls_h_tcpconn_init(struct tcp_connection *c, int sock) c->type = PROTO_TLS; c->rcv.proto = PROTO_TLS; c->timeout = get_ticks_raw() + cfg_get(tls, tls_cfg, con_lifetime); + c->lifetime = cfg_get(tls, tls_cfg, con_lifetime); c->extra_data = 0; return 0; } diff --git a/modules/uac/uac_reg.c b/modules/uac/uac_reg.c index fdcc92ef697..07081d45d33 100644 --- a/modules/uac/uac_reg.c +++ b/modules/uac/uac_reg.c @@ -1035,9 +1035,9 @@ void uac_reg_timer(unsigned int ticks) (char*)(RES_ROWS(db_res)[i].values[pos].val.string_val); \ reg.attr.len = strlen(reg.attr.s); \ if(reg.attr.len == 0) { \ - LM_ERR("empty value not allowed for column[%d]=%.*s\n", \ + LM_ERR("empty value not allowed for column[%d]='%.*s' - ignoring record\n", \ pos, db_cols[pos]->len, db_cols[pos]->s); \ - goto error; \ + continue; \ } \ } \ } while(0); diff --git a/modules/usrloc/doc/usrloc_admin.xml b/modules/usrloc/doc/usrloc_admin.xml index 0f996812248..a25ed185b90 100644 --- a/modules/usrloc/doc/usrloc_admin.xml +++ b/modules/usrloc/doc/usrloc_admin.xml @@ -896,6 +896,27 @@ modparam("usrloc", "handle_lost_tcp", 1) +
+ <varname>close_expired_tcp</varname> (int) + + If set to 1, Kamailio will close the TCP connection when a contact + has expired, if the corresponding transport is TCP/TLS/WS/WSS. + + + + Default value is 0. + + + + Set <varname>close_expired_tcp</varname> parameter + +... +modparam("usrloc", "close_expired_tcp", 1) +... + + +
+
<varname>expires_type</varname> (int) diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c index 737da0399f8..89b94dc23a2 100644 --- a/modules/usrloc/ucontact.c +++ b/modules/usrloc/ucontact.c @@ -76,6 +76,8 @@ void ucontact_xavp_store(ucontact_t *_c) } #endif +int uldb_delete_attrs_ruid(str* _dname, str *_ruid); + /*! * \brief Create a new contact structure * \param _dom domain @@ -1451,6 +1453,8 @@ int db_delete_ucontact_ruid(ucontact_t* _c) vals[n].val.str_val = _c->ruid; n++; + uldb_delete_attrs_ruid(_c->domain, &_c->ruid); + if (ul_dbf.use_table(ul_dbh, _c->domain) < 0) { LM_ERR("sql use_table failed\n"); return -1; @@ -1611,6 +1615,9 @@ int uldb_delete_attrs(str* _dname, str *_user, str *_domain, str *_ruid) db_key_t keys[3]; db_val_t vals[3]; + if(ul_db_ops_ruid==1) + return uldb_delete_attrs_ruid(_dname, _ruid); + LM_DBG("trying to delete location attributes\n"); if(ul_xavp_contact_name.s==NULL) { @@ -1659,6 +1666,56 @@ int uldb_delete_attrs(str* _dname, str *_user, str *_domain, str *_ruid) return 0; } +/*! + * \brief Delete all location attributes from a udomain by ruid + * + * \param _dname loaded domain name + * \param _ruid usrloc record unique id + * \return 0 on success, -1 on failure + */ +int uldb_delete_attrs_ruid(str* _dname, str *_ruid) +{ + char tname_buf[64]; + str tname; + db_key_t keys[1]; + db_val_t vals[1]; + + LM_DBG("trying to delete location attributes\n"); + + if(ul_xavp_contact_name.s==NULL) { + /* feature disabled by mod param */ + return 0; + } + + if(_dname->len+6>=64) { + LM_ERR("attributes table name is too big\n"); + return -1; + } + strncpy(tname_buf, _dname->s, _dname->len); + tname_buf[_dname->len] = '\0'; + strcat(tname_buf, "_attrs"); + tname.s = tname_buf; + tname.len = _dname->len + 6; + + keys[0] = &ulattrs_ruid_col; + + vals[0].type = DB1_STR; + vals[0].nul = 0; + vals[0].val.str_val = *_ruid; + + if (ul_dbf.use_table(ul_dbh, &tname) < 0) { + LM_ERR("sql use_table failed\n"); + return -1; + } + + if (ul_dbf.delete(ul_dbh, keys, 0, vals, 1) < 0) { + LM_ERR("deleting from database failed\n"); + return -1; + } + + return 0; +} + /*! * \brief Insert contact attributes into the database * \param _dname loaded domain name diff --git a/modules/usrloc/ul_mod.c b/modules/usrloc/ul_mod.c index 9e2b6110087..160f7d23406 100644 --- a/modules/usrloc/ul_mod.c +++ b/modules/usrloc/ul_mod.c @@ -152,6 +152,7 @@ int db_mode = 0; /*!< Database sync scheme: 0-no db, 1-write through, int use_domain = 0; /*!< Whether usrloc should use domain part of aor */ int desc_time_order = 0; /*!< By default do not enable timestamp ordering */ int handle_lost_tcp = 0; /*!< By default do not remove contacts before expiration time */ +int close_expired_tcp = 0; /*!< By default do not close TCP connections for expired contacts */ int ul_fetch_rows = 2000; /*!< number of rows to fetch from result */ int ul_hash_size = 10; @@ -207,6 +208,7 @@ static param_export_t params[] = { {"hash_size", INT_PARAM, &ul_hash_size }, {"nat_bflag", INT_PARAM, &nat_bflag }, {"handle_lost_tcp", INT_PARAM, &handle_lost_tcp }, + {"close_expired_tcp", INT_PARAM, &close_expired_tcp }, {"preload", PARAM_STRING|USE_FUNC_PARAM, (void*)ul_preload_param}, {"db_update_as_insert", INT_PARAM, &ul_db_update_as_insert}, {"timer_procs", INT_PARAM, &ul_timer_procs}, diff --git a/modules/usrloc/ul_mod.h b/modules/usrloc/ul_mod.h index 60f631689f2..cceef24497d 100644 --- a/modules/usrloc/ul_mod.h +++ b/modules/usrloc/ul_mod.h @@ -81,6 +81,8 @@ extern int ul_db_update_as_insert; extern int ul_db_check_update; extern int ul_keepalive_timeout; extern int handle_lost_tcp; +extern int close_expired_tcp; + /*! nat branch flag */ extern unsigned int nat_bflag; diff --git a/modules/usrloc/urecord.c b/modules/usrloc/urecord.c index df3029399ae..9e0bff354fe 100644 --- a/modules/usrloc/urecord.c +++ b/modules/usrloc/urecord.c @@ -34,6 +34,7 @@ #include "../../ut.h" #include "../../hashes.h" #include "../../tcp_conn.h" +#include "../../pass_fd.h" #include "ul_mod.h" #include "usrloc.h" #include "utime.h" @@ -236,6 +237,31 @@ static inline int is_tcp_alive(ucontact_t *c) return rc; } +/*! + * \brief Close a TCP connection + * + * Requests the TCP main process to close the specified TCP connection + * \param conid the internal connection ID + */ +static inline int close_connection(int conid) { + struct tcp_connection *con; + long msg[2]; + int n; + if ((con = tcpconn_get(conid, 0, 0, 0, 0))) { + msg[0] = (long)con; + msg[1] = CONN_EOF; + + n = send_all(unix_tcp_sock, msg, sizeof(msg)); + tcpconn_put(con); + if (unlikely(n <= 0)){ + LM_ERR("failed to send close request: %s (%d)\n", strerror(errno), errno); + return 0; + } + return 1; + } + return 0; +} + /*! * \brief Expires timer for NO_DB db_mode * @@ -247,6 +273,7 @@ static inline void nodb_timer(urecord_t* _r) { ucontact_t* ptr, *t; + ptr = _r->contacts; while(ptr) { @@ -264,6 +291,10 @@ static inline void nodb_timer(urecord_t* _r) ptr->aor->len, ZSW(ptr->aor->s), ptr->c.len, ZSW(ptr->c.s)); + if (close_expired_tcp && is_valid_tcpconn(ptr)) { + close_connection(ptr->tcpconn_id); + } + t = ptr; ptr = ptr->next; @@ -301,6 +332,10 @@ static inline void wt_timer(urecord_t* _r) ptr->aor->len, ZSW(ptr->aor->s), ptr->c.len, ZSW(ptr->c.s)); + if (close_expired_tcp && is_valid_tcpconn(ptr)) { + close_connection(ptr->tcpconn_id); + } + t = ptr; ptr = ptr->next; @@ -350,6 +385,10 @@ static inline void wb_timer(urecord_t* _r) ptr->c.len, ZSW(ptr->c.s)); update_stat( _r->slot->d->expires, 1); + if (close_expired_tcp && is_valid_tcpconn(ptr)) { + close_connection(ptr->tcpconn_id); + } + t = ptr; ptr = ptr->next; diff --git a/modules/xhttp/api.h b/modules/xhttp/api.h index b62f9012f43..674f4539cd4 100644 --- a/modules/xhttp/api.h +++ b/modules/xhttp/api.h @@ -1,5 +1,4 @@ /** - * $Id$ * * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com) * diff --git a/modules/xhttp/xhttp_mod.c b/modules/xhttp/xhttp_mod.c index 9085af3fd66..912d75c109e 100644 --- a/modules/xhttp/xhttp_mod.c +++ b/modules/xhttp/xhttp_mod.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. diff --git a/modules/xhttp/xhttp_trans.c b/modules/xhttp/xhttp_trans.c index 6b207d95aa9..03e4ea8e172 100644 --- a/modules/xhttp/xhttp_trans.c +++ b/modules/xhttp/xhttp_trans.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2013 Crocodile RCS Ltd * * This file is part of Kamailio, a free SIP server. @@ -19,6 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include "../../pvar.h" #include "../../str.h" #include "../../trim.h" diff --git a/modules/xhttp/xhttp_trans.h b/modules/xhttp/xhttp_trans.h index cb4ca61b76e..18e19c8c92a 100644 --- a/modules/xhttp/xhttp_trans.h +++ b/modules/xhttp/xhttp_trans.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2013 Crocodile RCS Ltd * * This file is part of Kamailio, a free SIP server. @@ -19,6 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #ifndef XHTTP_TRANS_H_ #define XHTTP_TRANS_H_ diff --git a/modules/xhttp_rpc/xhttp_rpc.c b/modules/xhttp_rpc/xhttp_rpc.c index 4e0bef2e241..7f6f791cfd5 100644 --- a/modules/xhttp_rpc/xhttp_rpc.c +++ b/modules/xhttp_rpc/xhttp_rpc.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2011 VoIP Embedded, Inc. * * This file is part of Kamailio, a free SIP server. @@ -19,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * 2011-11-11 initial version (osas) */ #include diff --git a/modules/xhttp_rpc/xhttp_rpc.h b/modules/xhttp_rpc/xhttp_rpc.h index 2cb423c0e88..74662dea31f 100644 --- a/modules/xhttp_rpc/xhttp_rpc.h +++ b/modules/xhttp_rpc/xhttp_rpc.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2011 VoIP Embedded, Inc. * * This file is part of Kamailio, a free SIP server. @@ -19,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * 2011-11-11 initial version (osas) */ diff --git a/modules/xhttp_rpc/xhttp_rpc_fnc.c b/modules/xhttp_rpc/xhttp_rpc_fnc.c index da4c0c95400..6975d1fb5d4 100644 --- a/modules/xhttp_rpc/xhttp_rpc_fnc.c +++ b/modules/xhttp_rpc/xhttp_rpc_fnc.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2011 VoIP Embedded, Inc. * * This file is part of Kamailio, a free SIP server. @@ -19,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * 2011-11-11 initial version (osas) */ #include diff --git a/modules/xhttp_rpc/xhttp_rpc_fnc.h b/modules/xhttp_rpc/xhttp_rpc_fnc.h index db1ba792a74..980fa4a12cf 100644 --- a/modules/xhttp_rpc/xhttp_rpc_fnc.h +++ b/modules/xhttp_rpc/xhttp_rpc_fnc.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2011 VoIP Embedded, Inc. * * This file is part of Kamailio, a free SIP server. @@ -19,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * 2011-11-11 initial version (osas) */ diff --git a/modules/xmlrpc/doc/xmlrpc.xml b/modules/xmlrpc/doc/xmlrpc.xml index c9751283ed1..1e2dce13e87 100644 --- a/modules/xmlrpc/doc/xmlrpc.xml +++ b/modules/xmlrpc/doc/xmlrpc.xml @@ -31,7 +31,7 @@
Design Goals - + @@ -99,7 +99,7 @@ User-Agent: Radio UserLand/7.1b7 (WinNT) Host: time.xmlrpc.com Content-Type: text/xml Content-length: 131 - + currentTime.getCurrentTime @@ -307,7 +307,7 @@ if (method == "POST" || method == "GET") { dispatch_rpc scans through the list of all exported RPC functions searching for the statistics function of the usrloc module. The - + &kamailio; RPC Module API describes in detail how modules export RPC functions. @@ -367,7 +367,7 @@ Warning: 392 127.0.0.1:5060 "Noisy feedback tells: pid=9975 req_src_ip=127.0.0 HTTP requests from one SIP server to another and use standard SIP routing mechanisms to decide which SIP server should process the request. There is no need to have multiple SIP - servers in simple setups, because one SIP server can both add + servers in simple setups, because one SIP server can both add fake Via header field and process the RPC at the same time. Modified configuration file snipped could then look like this: @@ -659,8 +659,8 @@ Content-Length: 276
Interoperability Problems - Due to a bug in Python xmlrpclib there is an interoperability - problem with basic clients using it: by default an xmlrpclib client + Due to a bug in Python xmlrpclib there is an interoperability + problem with basic clients using it: by default an xmlrpclib client expects the server to immediately close the connection after answering and if the server does not close the connections the xmlrpclib client will wait forever. @@ -671,7 +671,7 @@ Content-Length: 276 make ser close the tcp connection after each request. - The + The examples/xmlrpc_test.py provides a very simple example of using xmlrpclib with a Transport class that works. @@ -683,7 +683,7 @@ Content-Length: 276 set_reply_no_connect() is also recommended (avoid trying to open tcp connection to xmlrpc clients that closed it). Alternatively ending the XMLRPC route with return -1, exit -1 or - drop -1 can also be used, but note that this will not work for + drop -1 can also be used, but note that this will not work for async rpcs (it will close the connection immeidately and not on the async response). @@ -716,37 +716,44 @@ route[XMLRPC]{
Client Examples - + examples/xmlrpc_test.pl (basic perl application that builds and sends an XMLRPC request from its commandline parameters). - + examples/xmlrpc_test.py (basic python application that builds and sends an XMLRPC request from its commandline parameters). + + + examples/xmlrpc_test2.py + (basic python application that builds and sends an + XMLRPC request from its commandline + parameters). + ser_ctl - (complex python application that + (complex python application that uses the XML-RPC interface implemented by the xmlrpc module). @@ -755,7 +762,7 @@ route[XMLRPC]{ serweb (php application that can use - the XML-RPC interface to call ser + the XML-RPC interface to call ser functions). diff --git a/modules/xmlrpc/examples/xmlrpc_test2.py b/modules/xmlrpc/examples/xmlrpc_test2.py index 0fdee1eec87..b6c02fd82ca 100644 --- a/modules/xmlrpc/examples/xmlrpc_test2.py +++ b/modules/xmlrpc/examples/xmlrpc_test2.py @@ -1,10 +1,11 @@ -import xmlrpclib, httplib, sys +import sys +import xmlrpclib # Usage: python xmlrpc_test2.py command [params...] # # python script for sending an xmlrpc command to ser's xmlrpc module. # This script uses python xmlrpclib directly and expects the remote side to -# immediately close the connection after answering (broken xmlrpclib +# immediately close the connection after answering (broken xmlrpclib # behaviour). # There are 2 way to make it work with ser xmlrpc module: define a # better transport class (that's what the xmlrpc_test.py script is doing) or @@ -23,7 +24,15 @@ if len(sys.argv) < 2: - sys.exit("Usage: "+sys.argv[0]+" rpc_command [args...]"); -c=xmlrpclib.ServerProxy("http://" + XMLRPC_SERVER+ ":" + str(XMLRPC_PORT)) -res=getattr(c, sys.argv[1])(*sys.argv[2:]) -print res; + sys.exit("Usage: " + sys.argv[0] + " rpc_command [args...]") + +client = xmlrpclib.ServerProxy( + "http://{0}:{1}".format(XMLRPC_SERVER, XMLRPC_PORT)) +res = getattr(client, sys.argv[1])(*sys.argv[2:]) +print res + +##### +# You can use this simple way. +#client =xmlrpclib.ServerProxy("http://127.0.0.1:5060") +#res = client.htable.listTables() +#print res diff --git a/modules/xmlrpc/http.c b/modules/xmlrpc/http.c index b15b0f50ab2..760b70a062f 100644 --- a/modules/xmlrpc/http.c +++ b/modules/xmlrpc/http.c @@ -1,21 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2005 iptelorg GmbH * Written by Jan Janak * - * This file is part of SER, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SER is free software; you can redistribute it and/or modify it under the + * Kamailio is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version * - * For a license to use the SER software under conditions other than those - * described here, or to purchase support for this software, please contact - * iptel.org by e-mail at the following addresses: info@iptel.org - * - * SER is distributed in the hope that it will be useful, but WITHOUT ANY + * Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. diff --git a/modules/xmlrpc/http.h b/modules/xmlrpc/http.h index 6bc6276e4ec..5a4ae84733c 100644 --- a/modules/xmlrpc/http.h +++ b/modules/xmlrpc/http.h @@ -1,21 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2005 iptelorg GmbH * Written by Jan Janak * - * This file is part of SER, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SER is free software; you can redistribute it and/or modify it under the + * Kamailio is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version * - * For a license to use the SER software under conditions other than those - * described here, or to purchase support for this software, please contact - * iptel.org by e-mail at the following addresses: info@iptel.org - * - * SER is distributed in the hope that it will be useful, but WITHOUT ANY + * Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. diff --git a/modules/xmlrpc/xmlrpc.c b/modules/xmlrpc/xmlrpc.c index e97a3f3aaee..8761c02f41d 100644 --- a/modules/xmlrpc/xmlrpc.c +++ b/modules/xmlrpc/xmlrpc.c @@ -2,18 +2,14 @@ * Copyright (C) 2005 iptelorg GmbH * Written by Jan Janak * - * This file is part of SER, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * SER is free software; you can redistribute it and/or modify it under the + * Kamailio is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version * - * For a license to use the SER software under conditions other than those - * described here, or to purchase support for this software, please contact - * iptel.org by e-mail at the following addresses: info@iptel.org - * - * SER is distributed in the hope that it will be useful, but WITHOUT ANY + * Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. diff --git a/modules/xmlrpc/xmlrpc.h b/modules/xmlrpc/xmlrpc.h index 1b6cb171a80..cb92e429935 100644 --- a/modules/xmlrpc/xmlrpc.h +++ b/modules/xmlrpc/xmlrpc.h @@ -1,21 +1,15 @@ /* - * $Id$ - * * Copyright (C) 2005 iptelorg GmbH * Written by Jan Janak * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify it under the + * Kamailio is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version * - * For a license to use the ser software under conditions other than those - * described here, or to purchase support for this software, please contact - * iptel.org by e-mail at the following addresses: info@iptel.org - * - * ser is distributed in the hope that it will be useful, but WITHOUT ANY + * Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. diff --git a/pkg/kamailio/deb/debian/changelog b/pkg/kamailio/deb/debian/changelog index 98757cd4802..757240cbdd1 100644 --- a/pkg/kamailio/deb/debian/changelog +++ b/pkg/kamailio/deb/debian/changelog @@ -1,3 +1,9 @@ +kamailio (4.3.0~dev5) unstable; urgency=medium + + * update version to 4.3.0~dev5 + + -- Victor Seva Thu, 12 Mar 2015 15:20:01 +0100 + kamailio (4.3.0~dev4) unstable; urgency=medium * update version to 4.3.0~dev4 diff --git a/pkg/kamailio/deb/debian/rules b/pkg/kamailio/deb/debian/rules index c0691a81ed9..b4d1983a838 100755 --- a/pkg/kamailio/deb/debian/rules +++ b/pkg/kamailio/deb/debian/rules @@ -172,7 +172,7 @@ binary-common: dh_testroot dh_installdebconf dh_installdocs - dh_installexamples -Xobsoleted + dh_installexamples -Xobsoleted -Xsr dh_installmenu dh_installinit -pkamailio -- defaults 23 dh_installcron diff --git a/pkg/kamailio/deb/jessie/changelog b/pkg/kamailio/deb/jessie/changelog index 98757cd4802..757240cbdd1 100644 --- a/pkg/kamailio/deb/jessie/changelog +++ b/pkg/kamailio/deb/jessie/changelog @@ -1,3 +1,9 @@ +kamailio (4.3.0~dev5) unstable; urgency=medium + + * update version to 4.3.0~dev5 + + -- Victor Seva Thu, 12 Mar 2015 15:20:01 +0100 + kamailio (4.3.0~dev4) unstable; urgency=medium * update version to 4.3.0~dev4 diff --git a/pkg/kamailio/deb/precise/changelog b/pkg/kamailio/deb/precise/changelog index 98757cd4802..757240cbdd1 100644 --- a/pkg/kamailio/deb/precise/changelog +++ b/pkg/kamailio/deb/precise/changelog @@ -1,3 +1,9 @@ +kamailio (4.3.0~dev5) unstable; urgency=medium + + * update version to 4.3.0~dev5 + + -- Victor Seva Thu, 12 Mar 2015 15:20:01 +0100 + kamailio (4.3.0~dev4) unstable; urgency=medium * update version to 4.3.0~dev4 diff --git a/pkg/kamailio/deb/squeeze/changelog b/pkg/kamailio/deb/squeeze/changelog index 98757cd4802..757240cbdd1 100644 --- a/pkg/kamailio/deb/squeeze/changelog +++ b/pkg/kamailio/deb/squeeze/changelog @@ -1,3 +1,9 @@ +kamailio (4.3.0~dev5) unstable; urgency=medium + + * update version to 4.3.0~dev5 + + -- Victor Seva Thu, 12 Mar 2015 15:20:01 +0100 + kamailio (4.3.0~dev4) unstable; urgency=medium * update version to 4.3.0~dev4 diff --git a/pkg/kamailio/deb/trusty/changelog b/pkg/kamailio/deb/trusty/changelog index 98757cd4802..757240cbdd1 100644 --- a/pkg/kamailio/deb/trusty/changelog +++ b/pkg/kamailio/deb/trusty/changelog @@ -1,3 +1,9 @@ +kamailio (4.3.0~dev5) unstable; urgency=medium + + * update version to 4.3.0~dev5 + + -- Victor Seva Thu, 12 Mar 2015 15:20:01 +0100 + kamailio (4.3.0~dev4) unstable; urgency=medium * update version to 4.3.0~dev4 diff --git a/pkg/kamailio/deb/wheezy/changelog b/pkg/kamailio/deb/wheezy/changelog index 98757cd4802..757240cbdd1 100644 --- a/pkg/kamailio/deb/wheezy/changelog +++ b/pkg/kamailio/deb/wheezy/changelog @@ -1,3 +1,9 @@ +kamailio (4.3.0~dev5) unstable; urgency=medium + + * update version to 4.3.0~dev5 + + -- Victor Seva Thu, 12 Mar 2015 15:20:01 +0100 + kamailio (4.3.0~dev4) unstable; urgency=medium * update version to 4.3.0~dev4 diff --git a/tcp_main.c b/tcp_main.c index f8a7c6dd3ef..555392107c6 100644 --- a/tcp_main.c +++ b/tcp_main.c @@ -3770,17 +3770,17 @@ inline static int send2child(struct tcp_connection* tcpconn) if(tcpconn->rcv.bind_address->workers>0) { wfirst = tcpconn->rcv.bind_address->workers_tcpidx; wlast = wfirst + tcpconn->rcv.bind_address->workers; - LM_DBG("===== checking per-socket specific workers (%d/%d..%d/%d) [%s]\n", + LM_DBG("checking per-socket specific workers (%d/%d..%d/%d) [%s]\n", tcp_children[wfirst].pid, tcp_children[wfirst].proc_no, tcp_children[wlast-1].pid, tcp_children[wlast-1].proc_no, - tcpconn->rcv.bind_address->sock_str.s); + (tcpconn->rcv.bind_address)?tcpconn->rcv.bind_address->sock_str.s:""); } else { wfirst = 0; wlast = tcp_sockets_gworkers - 1; - LM_DBG("+++++ checking per-socket generic workers (%d/%d..%d/%d) [%s]\n", + LM_DBG("checking per-socket generic workers (%d/%d..%d/%d) [%s]\n", tcp_children[wfirst].pid, tcp_children[wfirst].proc_no, tcp_children[wlast-1].pid, tcp_children[wlast-1].proc_no, - tcpconn->rcv.bind_address->sock_str.s); + (tcpconn->rcv.bind_address)?tcpconn->rcv.bind_address->sock_str.s:""); } idx = wfirst; min_busy = tcp_children[idx].busy; @@ -3807,7 +3807,8 @@ inline static int send2child(struct tcp_connection* tcpconn) } LM_DBG("selected tcp worker %d %d(%ld) for activity on [%s], %p\n", idx, tcp_children[idx].proc_no, (long)tcp_children[idx].pid, - tcpconn->rcv.bind_address->sock_str.s, tcpconn); + (tcpconn->rcv.bind_address)?tcpconn->rcv.bind_address->sock_str.s:"", + tcpconn); /* first make sure this child doesn't have pending request for * tcp_main (to avoid a possible deadlock: e.g. child wants to * send a release command, but the master fills its socket buffer diff --git a/test/acc-test.cfg b/test/acc-test.cfg index fa56e72df98..ad7c1853a61 100644 --- a/test/acc-test.cfg +++ b/test/acc-test.cfg @@ -1,6 +1,4 @@ # -# $Id$ -# # iptel.org real world configuration # diff --git a/test/auto.c b/test/auto.c index 00541895f1f..b7bcdd4f558 100644 --- a/test/auto.c +++ b/test/auto.c @@ -4,19 +4,14 @@ * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/basex.c b/test/basex.c index 25df09e8119..3033a8bc195 100644 --- a/test/basex.c +++ b/test/basex.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Tests for basex.h * * Copyright (C) 2008 iptelorg GmbH diff --git a/test/bit_scan_test.c b/test/bit_scan_test.c index 206a7220c87..0d858799309 100644 --- a/test/bit_scan_test.c +++ b/test/bit_scan_test.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * test bit_scan operations from bit_scan.h * (both for correctness and speed) * diff --git a/test/dns_query.c b/test/dns_query.c index 907c707db0f..e3d727a9ba2 100644 --- a/test/dns_query.c +++ b/test/dns_query.c @@ -1,28 +1,22 @@ /* - * $Id$ * * tests for ../resolver.c * * Compile with: * gcc -o dns_query2 dns_query.c ../resolve.o ../dprint.o ../mem/ *.o -lresolv - * (and first compile ser with qm_malloc) + * (and first compile Kamailio with qm_malloc) * * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/echo.cfg b/test/echo.cfg index 650c8caec73..1e2cdba0b9d 100644 --- a/test/echo.cfg +++ b/test/echo.cfg @@ -1,7 +1,4 @@ # -# -# $Id$ -# # echo: rewrite userpart or r-uri to value from From header field # diff --git a/test/endian_test.c b/test/endian_test.c index a157034f2d7..7c2ca111620 100644 --- a/test/endian_test.c +++ b/test/endian_test.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2008 iptelorg GmbH * * Permission to use, copy, modify, and distribute this software for any diff --git a/test/flood.cfg b/test/flood.cfg index 9c3753ae510..5d3498350d7 100644 --- a/test/flood.cfg +++ b/test/flood.cfg @@ -1,7 +1,6 @@ # # configuration for Stress testing # -# $ID: $ # diff --git a/test/gen.cfg b/test/gen.cfg index 3ce9941e909..e99afc48177 100644 --- a/test/gen.cfg +++ b/test/gen.cfg @@ -1,8 +1,6 @@ # # configuration for Stress testing # -# $ID: $ -# debug=9 # debug level (cmd line: -dddddddddd) diff --git a/test/gethostbyaddr.c b/test/gethostbyaddr.c index 42a964868c8..2393680842b 100644 --- a/test/gethostbyaddr.c +++ b/test/gethostbyaddr.c @@ -1,22 +1,14 @@ /* - * $Id$ - * - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/gethostbyname.c b/test/gethostbyname.c index 93a28916bd5..2d5791744de 100644 --- a/test/gethostbyname.c +++ b/test/gethostbyname.c @@ -1,22 +1,14 @@ /* - * $Id$ - * - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/ifls.c b/test/ifls.c index df5460369f3..25a1aa5c559 100644 --- a/test/ifls.c +++ b/test/ifls.c @@ -1,23 +1,16 @@ -/* $Id$ - * - * +/* * test programs, list all interfaces and their ip address * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/lock_test.c b/test/lock_test.c index 0e09c8e7c1f..22c8c348bce 100644 --- a/test/lock_test.c +++ b/test/lock_test.c @@ -1,6 +1,5 @@ /* - * $Id$ - * + * * simple locking test program * (no paralles stuff) * diff --git a/test/nc.cfg b/test/nc.cfg index f8e6246f2e6..4047bc31785 100644 --- a/test/nc.cfg +++ b/test/nc.cfg @@ -1,6 +1,4 @@ /* - * $Id$ - * * test along with nmr.sip * */ diff --git a/test/profile.h b/test/profile.h index a0ca4739f53..d543191ba01 100644 --- a/test/profile.h +++ b/test/profile.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2007 iptelorg GmbH * * Permission to use, copy, modify, and distribute this software for any diff --git a/test/re_test.c b/test/re_test.c index 1f06d5ae285..0c5a17589aa 100644 --- a/test/re_test.c +++ b/test/re_test.c @@ -1,22 +1,14 @@ - -/* $Id$ */ /* - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -28,9 +20,6 @@ /* * regexec test program (good to find re lib. bugs) * uses the same flags as ser/textops for re-matching - * History: - * -------- - * created by andrei */ diff --git a/test/resolver_test.c b/test/resolver_test.c index 66355406c07..a824aa50b7f 100644 --- a/test/resolver_test.c +++ b/test/resolver_test.c @@ -1,21 +1,15 @@ -/* $Id$ */ /* * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/sf.cfg b/test/sf.cfg index ac62afefd0f..61c3bb25771 100644 --- a/test/sf.cfg +++ b/test/sf.cfg @@ -1,6 +1,4 @@ # -# $Id$ -# # iptel.org real world configuration # diff --git a/test/sock_conn.c b/test/sock_conn.c index c10777461f6..b060be1c167 100644 --- a/test/sock_conn.c +++ b/test/sock_conn.c @@ -1,21 +1,14 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/sock_disc.c b/test/sock_disc.c index 7655b595250..a9a0966198a 100644 --- a/test/sock_disc.c +++ b/test/sock_disc.c @@ -1,21 +1,14 @@ /* - * $Id$ - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/stateless.cfg b/test/stateless.cfg index 4dbd1cbee0c..19718335fec 100644 --- a/test/stateless.cfg +++ b/test/stateless.cfg @@ -1,7 +1,6 @@ # # configuration for stress testing # -# $ID: $ # diff --git a/test/stress.cfg b/test/stress.cfg index 500130eec6d..855b795ddb7 100644 --- a/test/stress.cfg +++ b/test/stress.cfg @@ -1,5 +1,4 @@ # -# $Id$ # # iptel.org real world configuration # diff --git a/test/struas.cfg b/test/struas.cfg index 619f6eb3d14..9efcc187fef 100644 --- a/test/struas.cfg +++ b/test/struas.cfg @@ -1,6 +1,4 @@ # -# $Id$ -# # iptel.org real world configuration # diff --git a/test/tcp.cfg b/test/tcp.cfg index b41c0d3be60..4d83498bb9d 100644 --- a/test/tcp.cfg +++ b/test/tcp.cfg @@ -1,8 +1,6 @@ # # configuration for stress testing # -# $ID: $ -# #debug=9 # debug level (cmd line: -dddddddddd) diff --git a/test/tcp_tunnel1.cfg b/test/tcp_tunnel1.cfg index 3743de290c8..b5c11a08411 100644 --- a/test/tcp_tunnel1.cfg +++ b/test/tcp_tunnel1.cfg @@ -1,7 +1,6 @@ # # configuration for stress testing # -# $ID: $ # diff --git a/test/tcp_tunnel2.cfg b/test/tcp_tunnel2.cfg index 1dd1b558fea..8b79e018e2b 100644 --- a/test/tcp_tunnel2.cfg +++ b/test/tcp_tunnel2.cfg @@ -1,7 +1,6 @@ # # configuration for stress testing # -# $ID: $ # diff --git a/test/test.c b/test/test.c index bb999350bbd..e52f9c77b03 100644 --- a/test/test.c +++ b/test/test.c @@ -1,22 +1,14 @@ /* - * $Id$ - * - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/test.cfg b/test/test.cfg index 6612730d4b8..4092dc9a8b4 100644 --- a/test/test.cfg +++ b/test/test.cfg @@ -1,7 +1,6 @@ # # configuration for stress testing # -# $ID: $ # diff --git a/test/th-uri-2.cfg b/test/th-uri-2.cfg index 0079279effc..05b27b640a8 100644 --- a/test/th-uri-2.cfg +++ b/test/th-uri-2.cfg @@ -2,7 +2,6 @@ # tm test configuration, please don't touch # - andrei # -# $Id$ # # diff --git a/test/th-uri-8.cfg b/test/th-uri-8.cfg index c105bd744c5..87dd5ae9b7a 100644 --- a/test/th-uri-8.cfg +++ b/test/th-uri-8.cfg @@ -1,7 +1,6 @@ # # configuration for Stress testing # -# $Id$ # diff --git a/test/th-uri-fast.cfg b/test/th-uri-fast.cfg index 6095d271a9c..a7da60c849b 100644 --- a/test/th-uri-fast.cfg +++ b/test/th-uri-fast.cfg @@ -1,7 +1,6 @@ # # configuration for stress testing # -# $Id$ # diff --git a/test/tx.cfg b/test/tx.cfg index e25f19a2304..a2ac8193b01 100644 --- a/test/tx.cfg +++ b/test/tx.cfg @@ -1,7 +1,6 @@ # # configuration for stress testing # -# $ID: $ # debug=3 # debug level (cmd line: -dddddddddd) diff --git a/test/udp.c b/test/udp.c index 980ed972500..9c33322cf24 100644 --- a/test/udp.c +++ b/test/udp.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2002-2003 FhG Fokus * * This file is sipsak, a free sip testing tool. @@ -17,19 +15,14 @@ * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/udp_flood_disc.c b/test/udp_flood_disc.c index 8483715d50d..ea132755138 100644 --- a/test/udp_flood_disc.c +++ b/test/udp_flood_disc.c @@ -1,21 +1,14 @@ -/* $Id$ */ /* - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/udp_test_proxy.c b/test/udp_test_proxy.c index 426878012ff..23a65fe628f 100644 --- a/test/udp_test_proxy.c +++ b/test/udp_test_proxy.c @@ -1,22 +1,14 @@ /* - * $Id$ - * - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/use_jab.cfg b/test/use_jab.cfg index aa0bba25d38..2b7a18644a6 100644 --- a/test/use_jab.cfg +++ b/test/use_jab.cfg @@ -1,7 +1,6 @@ # # configuration for Jabber module testing # -# $ID: daniel $ # diff --git a/test/via_parse.c b/test/via_parse.c index 2ec90e45154..0493c025726 100644 --- a/test/via_parse.c +++ b/test/via_parse.c @@ -1,22 +1,16 @@ /* test program -> via parse */ /* - * * Copyright (C) 2001-2003 FhG Fokus * - * This file is part of ser, a free SIP server. + * This file is part of Kamailio, a free SIP server. * - * ser is free software; you can redistribute it and/or modify + * Kamailio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version * - * For a license to use the ser software under conditions - * other than those described here, or to purchase support for this - * software, please contact iptel.org by e-mail at the following addresses: - * info@iptel.org - * - * ser is distributed in the hope that it will be useful, + * Kamailio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. diff --git a/test/xx.cfg b/test/xx.cfg index b4e87ca45e3..7013c7247dd 100644 --- a/test/xx.cfg +++ b/test/xx.cfg @@ -1,6 +1,5 @@ # forwarding to Cisco phone # -# $Id$ # diff --git a/test/xy.cfg b/test/xy.cfg index b6899ae362f..c6a77f42d77 100644 --- a/test/xy.cfg +++ b/test/xy.cfg @@ -1,6 +1,5 @@ # forwarding to a fixed non-responding destination # -# $Id$ # debug=9 # debug level (cmd line: -dddddddddd) diff --git a/utils/kamctl/mysql/dialog_ng-create.sql b/utils/kamctl/mysql/dialog_ng-create.sql new file mode 100644 index 00000000000..8a8cbde2a60 --- /dev/null +++ b/utils/kamctl/mysql/dialog_ng-create.sql @@ -0,0 +1,52 @@ +INSERT INTO version (table_name, table_version) values ('dialog_in', 7), ('dialog_out', 7), ('dialog_vars', 7); + +CREATE TABLE `dialog_in` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `hash_entry` int(10) unsigned NOT NULL, + `hash_id` int(10) unsigned NOT NULL, + `did` varchar(45) NOT NULL, + `callid` varchar(255) NOT NULL, + `from_uri` varchar(128) NOT NULL, + `from_tag` varchar(64) NOT NULL, + `caller_original_cseq` varchar(20) NOT NULL, + `req_uri` varchar(128) NOT NULL, + `caller_route_set` varchar(512) DEFAULT NULL, + `caller_contact` varchar(128) NOT NULL, + `caller_sock` varchar(64) NOT NULL, + `state` int(10) unsigned NOT NULL, + `start_time` int(10) unsigned NOT NULL, + `timeout` int(10) unsigned NOT NULL DEFAULT '0', + `sflags` int(10) unsigned NOT NULL DEFAULT '0', + `toroute_name` varchar(32) DEFAULT NULL, + `toroute_index` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `hash_idx` (`hash_entry`,`hash_id`) +); + +CREATE TABLE `dialog_out` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `hash_entry` int(11) NOT NULL, + `hash_id` int(11) NOT NULL, + `did` varchar(45) NOT NULL, + `to_uri` varchar(128) NOT NULL, + `to_tag` varchar(64) NOT NULL, + `caller_cseq` varchar(20) NOT NULL, + `callee_cseq` varchar(20) NOT NULL, + `callee_contact` varchar(128) NOT NULL, + `callee_route_set` varchar(512) DEFAULT NULL, + `callee_sock` varchar(64) NOT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE `dialog_vars` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `hash_entry` int(10) unsigned NOT NULL, + `hash_id` int(10) unsigned NOT NULL, + `dialog_key` varchar(128) NOT NULL, + `dialog_value` varchar(512) NOT NULL, + PRIMARY KEY (`id`), + KEY `hash_idx` (`hash_entry`,`hash_id`) +); + + +