kamailio.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
List overview
Download
sr-dev
September 2010
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
sr-dev@lists.kamailio.org
25 participants
222 discussions
Start a n
N
ew thread
git:master: xcap_server: components of xcap uri available in cfg
by Daniel-Constantin Mierla
Module: sip-router Branch: master Commit: 1ae80a64d1d488ed581a70085c61480ca3ae7c79 URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1ae80a6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Committer: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: Wed Sep 1 12:49:01 2010 +0200 xcap_server: components of xcap uri available in cfg - the user id is embedded in xcap uri and is needed to decide what is the sip uri associated with it - $xcapuri(name=>key) PV exported to config --- modules_k/xcap_server/xcap_misc.c | 247 ++++++++++++++++++++++++++++++++++- modules_k/xcap_server/xcap_misc.h | 8 + modules_k/xcap_server/xcap_server.c | 10 +- 3 files changed, 260 insertions(+), 5 deletions(-) diff --git a/modules_k/xcap_server/xcap_misc.c b/modules_k/xcap_server/xcap_misc.c index 70a7d1f..1c844e7 100644 --- a/modules_k/xcap_server/xcap_misc.c +++ b/modules_k/xcap_server/xcap_misc.c @@ -30,15 +30,19 @@ #include <libxml/xpathInternals.h> #include "../../dprint.h" -#include "../../sr_module.h" #include "../../mem/mem.h" #include "../../parser/parse_param.h" #include "../../modules_k/xcap_client/xcap_callbacks.h" #include "xcap_misc.h" +extern str xcaps_root; + static param_t *_xcaps_xpath_ns_root = NULL; +/** + * parse xcap uri + */ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri) { str s; @@ -213,6 +217,7 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri) xuri->node.len = xuri->uri.s + xuri->uri.len - xuri->node.s; } +#if 0 LM_DBG("----- uri: [%.*s]\n", xuri->uri.len, xuri->uri.s); LM_DBG("----- root: [%.*s]\n", xuri->root.len, xuri->root.s); LM_DBG("----- auid: [%.*s] (%d)\n", xuri->auid.len, xuri->auid.s, @@ -225,9 +230,13 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri) LM_DBG("----- rdoc: [%.*s]\n", xuri->rdoc.len, xuri->rdoc.s); if(xuri->nss!=NULL) LM_DBG("----- node: [%.*s]\n", xuri->node.len, xuri->node.s); +#endif return 0; } +/** + * get content of xpath pointer + */ int xcaps_xpath_get(str *inbuf, str *xpaths, str *outbuf) { xmlDocPtr doc = NULL; @@ -357,7 +366,9 @@ error: return -1; } - +/** + * set content of xpath pointer + */ int xcaps_xpath_set(str *inbuf, str *xpaths, str *val, str *outbuf) { xmlDocPtr doc = NULL; @@ -499,7 +510,9 @@ error: return -1; } - +/** + * register extra xml name spaces + */ void xcaps_xpath_register_ns(xmlXPathContextPtr xpathCtx) { param_t *ns; @@ -511,6 +524,9 @@ void xcaps_xpath_register_ns(xmlXPathContextPtr xpathCtx) } } +/** + * parse xml ns parameter + */ int xcaps_xpath_ns_param(modparam_t type, void *val) { char *p; @@ -549,3 +565,228 @@ error: } +/** + * xcapuri PV export + */ +typedef struct _pv_xcap_uri { + str name; + unsigned int id; + xcap_uri_t xuri; + struct _pv_xcap_uri *next; +} pv_xcap_uri_t; + +typedef struct _pv_xcap_uri_spec { + str name; + str key; + int ktype; + pv_xcap_uri_t *xus; +} pv_xcap_uri_spec_t; + + +pv_xcap_uri_t *_pv_xcap_uri_root = NULL; + +/** + * + */ +pv_xcap_uri_t *pv_xcap_uri_get_struct(str *name) +{ + unsigned int id; + pv_xcap_uri_t *it; + + id = get_hash1_raw(name->s, name->len); + it = _pv_xcap_uri_root; + + while(it!=NULL) + { + if(id == it->id && name->len==it->name.len + && strncmp(name->s, it->name.s, name->len)==0) + { + LM_DBG("uri found [%.*s]\n", name->len, name->s); + return it; + } + it = it->next; + } + + it = (pv_xcap_uri_t*)pkg_malloc(sizeof(pv_xcap_uri_t)); + if(it==NULL) + { + LM_ERR("no more pkg\n"); + return NULL; + } + memset(it, 0, sizeof(pv_xcap_uri_t)); + + it->id = id; + it->name = *name; + + it->next = _pv_xcap_uri_root; + _pv_xcap_uri_root = it; + return it; +} + + +/** + * + */ +int pv_parse_xcap_uri_name(pv_spec_p sp, str *in) +{ + pv_xcap_uri_spec_t *pxs = NULL; + char *p; + + if(in->s==NULL || in->len<=0) + return -1; + + pxs = (pv_xcap_uri_spec_t*)pkg_malloc(sizeof(pv_xcap_uri_spec_t)); + if(pxs==NULL) + return -1; + + memset(pxs, 0, sizeof(pv_xcap_uri_spec_t)); + + p = in->s; + + while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r')) + p++; + if(p>in->s+in->len || *p=='\0') + goto error; + pxs->name.s = p; + while(p < in->s + in->len) + { + if(*p=='=' || *p==' ' || *p=='\t' || *p=='\n' || *p=='\r') + break; + p++; + } + if(p>in->s+in->len || *p=='\0') + goto error; + pxs->name.len = p - pxs->name.s; + if(*p!='=') + { + while(p<in->s+in->len && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r')) + p++; + if(p>in->s+in->len || *p=='\0' || *p!='=') + goto error; + } + p++; + if(*p!='>') + goto error; + p++; + + pxs->key.len = in->len - (int)(p - in->s); + pxs->key.s = p; + LM_DBG("uri name [%.*s] - key [%.*s]\n", pxs->name.len, pxs->name.s, + pxs->key.len, pxs->key.s); + if(pxs->key.len==4 && strncmp(pxs->key.s, "data", 4)==0) { + pxs->ktype = 0; + } else if(pxs->key.len==3 && strncmp(pxs->key.s, "uri", 4)==0) { + pxs->ktype = 1; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "root", 4)==0) { + pxs->ktype = 2; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "auid", 4)==0) { + pxs->ktype = 3; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "type", 4)==0) { + pxs->ktype = 4; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "tree", 4)==0) { + pxs->ktype = 5; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "xuid", 4)==0) { + pxs->ktype = 6; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "file", 4)==0) { + pxs->ktype = 7; + } else if(pxs->key.len==4 && strncmp(pxs->key.s, "node", 4)==0) { + pxs->ktype = 8; + } else { + LM_ERR("unknown key type [%.*s]\n", in->len, in->s); + goto error; + } + pxs->xus = pv_xcap_uri_get_struct(&pxs->name); + sp->pvp.pvn.u.dname = (void*)pxs; + sp->pvp.pvn.type = PV_NAME_OTHER; + return 0; + +error: + if(pxs!=NULL) + pkg_free(pxs); + return -1; +} + +/** + * + */ +int pv_set_xcap_uri(struct sip_msg* msg, pv_param_t *param, + int op, pv_value_t *val) +{ + pv_xcap_uri_spec_t *pxs = NULL; + + pxs = (pv_xcap_uri_spec_t*)param->pvn.u.dname; + if(pxs->xus==NULL) + return -1; + if(!(val->flags&PV_VAL_STR)) + return -1; + if(pxs->ktype!=0) + return -1; + /* set uri data */ + if(xcap_parse_uri(&val->rs, &xcaps_root, &pxs->xus->xuri)<0) + { + LM_ERR("error setting xcap uri data [%.*s]\n", + val->rs.len, val->rs.s); + return -1; + } + + return 0; +} + +/** + * + */ +int pv_get_xcap_uri(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res) +{ + pv_xcap_uri_spec_t *pxs = NULL; + + pxs = (pv_xcap_uri_spec_t*)param->pvn.u.dname; + if(pxs->xus==NULL) + return -1; + + switch(pxs->ktype) { + case 0: + case 1: + /* get uri */ + if(pxs->xus->xuri.uri.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.uri); + break; + case 2: + /* get root */ + if(pxs->xus->xuri.root.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.root); + break; + case 3: + /* get auid */ + if(pxs->xus->xuri.auid.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.auid); + break; + case 4: + /* get type */ + return pv_get_sintval(msg, param, res, pxs->xus->xuri.type); + break; + case 5: + /* get tree */ + if(pxs->xus->xuri.tree.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.tree); + break; + case 6: + /* get xuid */ + if(pxs->xus->xuri.xuid.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.xuid); + break; + case 7: + /* get file */ + if(pxs->xus->xuri.file.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.file); + break; + case 8: + /* get node */ + if(pxs->xus->xuri.node.len>0) + return pv_get_strval(msg, param, res, &pxs->xus->xuri.node); + break; + default: + return pv_get_null(msg, param, res); + } + return pv_get_null(msg, param, res); +} diff --git a/modules_k/xcap_server/xcap_misc.h b/modules_k/xcap_server/xcap_misc.h index 83564e9..78c92a0 100644 --- a/modules_k/xcap_server/xcap_misc.h +++ b/modules_k/xcap_server/xcap_misc.h @@ -26,6 +26,8 @@ #define _XCAP_MISC_H_ #include "../../str.h" +#include "../../sr_module.h" +#include "../../pvar.h" #define XCAP_MAX_URI_SIZE 127 /* Node Selector Separator */ @@ -50,4 +52,10 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri); int xcaps_xpath_set(str *inbuf, str *xpaths, str *val, str *outbuf); int xcaps_xpath_get(str *inbuf, str *xpaths, str *outbuf); +int pv_get_xcap_uri(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res); +int pv_set_xcap_uri(struct sip_msg* msg, pv_param_t *param, + int op, pv_value_t *val); +int pv_parse_xcap_uri_name(pv_spec_p sp, str *in); + #endif diff --git a/modules_k/xcap_server/xcap_server.c b/modules_k/xcap_server/xcap_server.c index e71bee4..4f5d5c0 100644 --- a/modules_k/xcap_server/xcap_server.c +++ b/modules_k/xcap_server/xcap_server.c @@ -75,9 +75,9 @@ int xcaps_generate_etag_hdr(str *etag); static str xcaps_db_table = str_init("xcap"); static str xcaps_db_url = str_init(DEFAULT_DB_URL); -static str xcaps_root = str_init("/xcap-root/"); static int xcaps_init_time = 0; static int xcaps_etag_counter = 1; +str xcaps_root = str_init("/xcap-root/"); static str xcaps_buf = {0, 8192}; #define XCAPS_ETAG_SIZE 128 @@ -100,6 +100,12 @@ db_func_t xcaps_dbf; /** SL API structure */ sl_api_t slb; +static pv_export_t mod_pvs[] = { + { {"xcapuri", sizeof("xcapuri")-1}, PVT_OTHER, pv_get_xcap_uri, + pv_set_xcap_uri, pv_parse_xcap_uri_name, 0, 0, 0 }, + { {0, 0}, 0, 0, 0, 0, 0, 0, 0 } +}; + static param_export_t params[] = { { "db_url", STR_PARAM, &xcaps_db_url.s }, { "xcap_table", STR_PARAM, &xcaps_db_table.s }, @@ -128,7 +134,7 @@ struct module_exports exports= { params, /* exported parameters */ 0, /* exported statistics */ 0, /* exported MI functions */ - 0, /* exported pseudo-variables */ + mod_pvs, /* exported pseudo-variables */ 0, /* extra processes */ mod_init, /* module initialization function */ 0, /* response handling function */
14 years, 4 months
1
0
0
0
ratelimit module migration from (k) to generic
by Ovidiu Sas
Hello all, The (k) ratelimit module is an enhanced version of the original (s) ratelimit module. Are there any objections in moving the ratelimit module from (k) to generic and purging the (s) version? Regards, Ovidiu Sas
14 years, 4 months
2
3
0
0
← Newer
1
...
20
21
22
23
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Results per page:
10
25
50
100
200