Module: sip-router
Branch: tirpi/cfg_framework_multivalue
Commit: b2efa6a116ebc89c8c6198a49fff176df745a2f5
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b2efa6a…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Fri Sep 3 14:48:27 2010 +0200
cfg framework: group meta-data introduced
A new structure for meta-data is added to the variable block
before each group. This stucture will be a placeholder for the
multiple values of the same variable.
The meta-data indicates how many instances the group has excluding
the default instance, and will store the pointer to the array of
these instances.
---
cfg/cfg_ctx.c | 6 +++---
cfg/cfg_script.c | 8 ++++++++
cfg/cfg_struct.c | 40 +++++++++++++++++++++++++++++++++-------
cfg/cfg_struct.h | 30 +++++++++++++++++++++++++++---
4 files changed, 71 insertions(+), 13 deletions(-)
diff --git a/cfg/cfg_ctx.c b/cfg/cfg_ctx.c
index 677a070..d2ea621 100644
--- a/cfg/cfg_ctx.c
+++ b/cfg/cfg_ctx.c
@@ -328,13 +328,13 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
if (var->def->type & CFG_ATOMIC) {
/* atomic change is allowed, we can rewrite the value
directly in the global config */
- p = (*cfg_global)->vars+group->offset+var->offset;
+ p = (*cfg_global)->vars+group->var_offset+var->offset;
} else {
/* clone the memory block, and prepare the modification */
if (!(block = cfg_clone_global())) goto error;
- p = block->vars+group->offset+var->offset;
+ p = block->vars+group->var_offset+var->offset;
}
} else {
/* we are allowed to rewrite the value on-the-fly
@@ -786,7 +786,7 @@ int cfg_commit(cfg_ctx_t *ctx)
changed = changed->next
) {
p = block->vars
- + changed->group->offset
+ + changed->group->var_offset
+ changed->var->offset;
if ((CFG_VAR_TYPE(changed->var) == CFG_VAR_STRING)
diff --git a/cfg/cfg_script.c b/cfg/cfg_script.c
index a4ef236..e57fa2d 100644
--- a/cfg/cfg_script.c
+++ b/cfg/cfg_script.c
@@ -103,7 +103,15 @@ cfg_script_var_t *new_cfg_script_var(char *gname, char *vname, unsigned int type
LOG(L_ERR, "ERROR: new_cfg_script_var(): unsupported variable type\n");
return NULL;
}
+
group->num++;
+ if (group->num > CFG_MAX_VAR_NUM) {
+ LOG(L_ERR, "ERROR: new_cfg_script_var(): too many variables (%d) within a single group,"
+ " the limit is %d. Increase CFG_MAX_VAR_NUM, or split the group into multiple"
+ " definitions.\n",
+ group->num, CFG_MAX_VAR_NUM);
+ return NULL;
+ }
var = (cfg_script_var_t *)pkg_malloc(sizeof(cfg_script_var_t));
if (!var) goto error;
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index f2f5bfe..18a8aca 100644
--- a/cfg/cfg_struct.c
+++ b/cfg/cfg_struct.c
@@ -42,7 +42,7 @@ cfg_block_t **cfg_global = NULL; /* pointer to the active cfg block */
cfg_block_t *cfg_local = NULL; /* per-process pointer to the active cfg block.
Updated only when the child process
finishes working on the SIP message */
-static int cfg_block_size = 0; /* size of the cfg block (constant) */
+static int cfg_block_size = 0; /* size of the cfg block including the meta-data (constant) */
gen_lock_t *cfg_global_lock = 0; /* protects *cfg_global */
gen_lock_t *cfg_writer_lock = 0; /* This lock makes sure that two processes do not
try to clone *cfg_global at the same time.
@@ -68,6 +68,14 @@ cfg_group_t *cfg_new_group(char *name, int name_len,
return NULL;
}
+ if (num > CFG_MAX_VAR_NUM) {
+ LOG(L_ERR, "ERROR: cfg_new_group(): too many variables (%d) within a single group,"
+ " the limit is %d. Increase CFG_MAX_VAR_NUM, or split the group into multiple"
+ " definitions.\n",
+ num, CFG_MAX_VAR_NUM);
+ return NULL;
+ }
+
group = (cfg_group_t *)pkg_malloc(sizeof(cfg_group_t)+name_len-1);
if (!group) {
LOG(L_ERR, "ERROR: cfg_new_group(): not enough memory\n");
@@ -162,13 +170,31 @@ int cfg_shmize(void)
if (!cfg_group) return 0;
/* Let us allocate one memory block that
- will contain all the variables */
+ * will contain all the variables + meta-data
+ * in the following form:
+ * |-----------|
+ * | meta-data | <- group A: meta_offset
+ * | variables | <- group A: var_offset
+ * |-----------|
+ * | meta-data | <- group B: meta_offset
+ * | variables | <- group B: var_offset
+ * |-----------|
+ * | ... |
+ * |-----------|
+ *
+ * The additional array for the multiple values
+ * of the same variable is linked to the meta-data.
+ */
for ( size=0, group = cfg_group;
group;
group=group->next
) {
size = ROUND_POINTER(size);
- group->offset = size;
+ group->meta_offset = size;
+ size += sizeof(cfg_group_meta_t);
+
+ size = ROUND_POINTER(size);
+ group->var_offset = size;
size += group->size;
}
@@ -190,19 +216,19 @@ int cfg_shmize(void)
if (cfg_shmize_strings(group)) goto error;
/* copy the values to the new block */
- memcpy(block->vars+group->offset, group->vars, group->size);
+ memcpy(block->vars+group->var_offset, group->vars, group->size);
} else {
/* The group was declared with NULL values,
* we have to fix it up.
* The fixup function takes care about the values,
* it fills up the block */
- if (cfg_script_fixup(group, block->vars+group->offset)) goto error;
+ if (cfg_script_fixup(group, block->vars+group->var_offset)) goto error;
/* Notify the drivers about the new config definition.
* Temporary set the group handle so that the drivers have a chance to
* overwrite the default values. The handle must be reset after this
* because the main process does not have a local configuration. */
- *(group->handle) = block->vars+group->offset;
+ *(group->handle) = block->vars+group->var_offset;
cfg_notify_drivers(group->name, group->name_len,
group->mapping->def);
*(group->handle) = NULL;
@@ -243,7 +269,7 @@ static void cfg_destory_groups(unsigned char *block)
(CFG_VAR_TYPE(&mapping[i]) == CFG_VAR_STR)) &&
mapping[i].flag & cfg_var_shmized) {
- old_string = *(char **)(block + group->offset + mapping[i].offset);
+ old_string = *(char **)(block + group->var_offset + mapping[i].offset);
if (old_string) shm_free(old_string);
}
diff --git a/cfg/cfg_struct.h b/cfg/cfg_struct.h
index c72573b..456e32b 100644
--- a/cfg/cfg_struct.h
+++ b/cfg/cfg_struct.h
@@ -36,6 +36,9 @@
#include "../compiler_opt.h"
#include "cfg.h"
+/*! \brief Maximum number of variables within a configuration group. */
+#define CFG_MAX_VAR_NUM 256
+
/*! \brief indicates that the variable has been already shmized */
#define cfg_var_shmized 1U
@@ -59,8 +62,10 @@ typedef struct _cfg_group {
shmized. */
int size; /*!< size of the memory block that has to be
allocated to store the values */
- int offset; /*!< offset of the group within the
- shmized memory block */
+ int meta_offset; /*!< offset of the group within the
+ shmized memory block for the meta_data */
+ int var_offset; /*!< offset of the group within the
+ shmized memory block for the variables */
void **handle; /*!< per-process handle that can be used
by the modules to access the variables.
It is registered when the group is created,
@@ -73,6 +78,25 @@ typedef struct _cfg_group {
char name[1];
} cfg_group_t;
+/*! \brief One instance of the cfg group variables which stores
+ * the additional values. These values can overwrite the default values. */
+typedef struct _cfg_group_inst {
+ unsigned int set[CFG_MAX_VAR_NUM/(sizeof(int)*8)];
+ /*!< Bitmap indicating whether or not a value is explicitely set
+ within this instance. If the value is not set,
+ then the default value is used, and copied into this instance. */
+ unsigned char vars[1]; /*!< block for the values */
+} cfg_group_inst_t;
+
+/*! \bried Meta-data which is stored before each variable group
+ * within the blob. This structure is used to handle the multivalue
+ * instances of the variables, i.e. manages the array for the
+ * additional values. */
+typedef struct _cfg_group_meta {
+ int num; /*!< Number of items in the array */
+ cfg_group_inst_t *array; /*!< Array of cfg groups with num number of items */
+} cfg_group_meta_t;
+
/*! \brief single memoy block that contains all the cfg values */
typedef struct _cfg_block {
atomic_t refcnt; /*!< reference counter,
@@ -242,7 +266,7 @@ static inline void cfg_update_local(int no_cbs)
group;
group = group->next
)
- *(group->handle) = cfg_local->vars + group->offset;
+ *(group->handle) = cfg_local->vars + group->var_offset;
if (unlikely(cfg_child_cb==CFG_NO_CHILD_CBS || no_cbs))
return;
Module: sip-router
Branch: master
Commit: 61b81832cb4eacc82b0c711c686f85c09e62be7c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=61b8183…
Author: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Date: Tue Sep 14 11:42:42 2010 +0300
Modules_k:usrloc Fixed syntax errors on documentation of modules.
---
modules_k/usrloc/README | 36 +++++++++++++++++---------------
modules_k/usrloc/doc/usrloc_admin.xml | 36 ++++++++++++++++----------------
2 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/modules_k/usrloc/README b/modules_k/usrloc/README
index d6df0ea..f6fd5f7 100644
--- a/modules_k/usrloc/README
+++ b/modules_k/usrloc/README
@@ -199,26 +199,28 @@ Chapter 1. Admin Guide
1.1. Contact matching
How the contacts are matched (dor same AOR - Address of Record) is an
- important aspect of the usrloc modules, especialy in the context of NAT
- traversal - this raise mre problems since contacts from different
- phones of same users may overlap (if behind NATs with same
- configuration) or the re-register contact of same phone may be seen as
- a new one (due different binding via NAT).
+ important aspect of the usrloc module, especially in the context of NAT
+ traversal - this raises more problems since contacts from different
+ phones of the same user may overlap (if behind NATs with same
+ configuration) or the re-register contact of the same phone may be seen
+ as a new one (due different binding via NAT).
The SIP RFC 3261 publishes a matching algorithm based only on the
contact string with callid and cseq number extra checking (if callid is
- the same, it must have a higher cseq number, otherwise invalid). But as
- argumented above, this is not enough in NAT traversal context, so the
- Kamailio implementation of contact machting offers more algorithms:
- * contact based only - it strict RFC 3261 compiancy - the contact is
- matched as string and extra checked via callid and cseg (if callid
- is the same, it must have a higher cseq number, otherwise invalid).
- * contact and callid based - it an extension of the first case - the
- contact and callid must matched as string; the cseg must be higher
- than the previous one - so be careful how you deal with REGISTER
- retransmissions in this case.
- * contact and path based - it an extension of the first case - the
- contact and path must matched as string; the cseg must be higher
+ the same, it must have a higher cseq number, otherwise it is invalid).
+ But as argumented above, this is not enough in NAT traversal context,
+ so the Kamailio implementation of contact matching offers more
+ algorithms:
+ * contact based only - it is strict RFC 3261 compliancy - the contact
+ is matched as string and extra checked via callid and cseq (if
+ callid is the same, it must have a higher cseq number, otherwise it
+ is invalid).
+ * contact and callid based - it is an extension of the first case -
+ the contact and callid must be matched as string; the cseq must be
+ higher than the previous one - so be careful how you deal with
+ REGISTER retransmissions in this case.
+ * contact and path based - it is an extension of the first case - the
+ contact and path must be matched as string; the cseq must be higher
than the previous one - so be careful how you deal with REGISTER
retransmissions in this case.
diff --git a/modules_k/usrloc/doc/usrloc_admin.xml b/modules_k/usrloc/doc/usrloc_admin.xml
index 2b6d307..0b03fe2 100644
--- a/modules_k/usrloc/doc/usrloc_admin.xml
+++ b/modules_k/usrloc/doc/usrloc_admin.xml
@@ -24,43 +24,43 @@
<title>Contact matching</title>
<para>
How the contacts are matched (dor same AOR - Address of Record) is an
- important aspect of the usrloc modules, especialy in the context of NAT
- traversal - this raise mre problems since contacts from different
- phones of same users may overlap (if behind NATs with same
- configuration) or the re-register contact of same phone may be
+ important aspect of the usrloc module, especially in the context of NAT
+ traversal - this raises more problems since contacts from different
+ phones of the same user may overlap (if behind NATs with same
+ configuration) or the re-register contact of the same phone may be
seen as a new one (due different binding via NAT).
</para>
<para>
The SIP RFC 3261 publishes a matching algorithm based only on the
contact string with callid and cseq number extra checking (if callid
- is the same, it must have a higher cseq number, otherwise invalid).
+ is the same, it must have a higher cseq number, otherwise it is invalid).
But as argumented above, this is not enough in NAT traversal context,
- so the &kamailio; implementation of contact machting offers more algorithms:
+ so the &kamailio; implementation of contact matching offers more algorithms:
</para>
<itemizedlist>
<listitem>
<para>
- <emphasis>contact based only</emphasis> - it strict RFC 3261
- compiancy - the contact is matched as string and extra checked
- via callid and cseg (if callid is the same, it must have a
- higher cseq number, otherwise invalid).
+ <emphasis>contact based only</emphasis> - it is strict RFC 3261
+ compliancy - the contact is matched as string and extra checked
+ via callid and cseq (if callid is the same, it must have a
+ higher cseq number, otherwise it is invalid).
</para>
</listitem>
<listitem>
<para>
- <emphasis>contact and callid based</emphasis> - it an extension
- of the first case - the contact and callid must matched as
- string; the cseg must be higher than the previous one - so be
- careful how you deal with REGISTER retransmissions in this
+ <emphasis>contact and callid based</emphasis> - it is an extension
+ of the first case - the contact and callid must be matched as
+ string; the cseq must be higher than the previous one - so be
+ careful how you deal with REGISTER retransmissions in this
case.
</para>
</listitem>
<listitem>
<para>
- <emphasis>contact and path based</emphasis> - it an extension
- of the first case - the contact and path must matched as
- string; the cseg must be higher than the previous one - so be
- careful how you deal with REGISTER retransmissions in this
+ <emphasis>contact and path based</emphasis> - it is an extension
+ of the first case - the contact and path must be matched as
+ string; the cseq must be higher than the previous one - so be
+ careful how you deal with REGISTER retransmissions in this
case.
</para>
</listitem>
Module: sip-router
Branch: master
Commit: e017bd9c00a021c1f2fe0b69bb5382d69afd5e7d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e017bd9…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Mon Sep 13 15:03:57 2010 -0400
modules_k/rtpproxy: fix crash related to SDP without ssession IP
- when the IP address is provided only in the SDP stream description
and not in the SDP session description, the rtpproxy module was crashing
due to wrong check of the IP address length.
- thanks to Daniel Constantin Mierla for reporting and investigating this.
---
modules_k/rtpproxy/rtpproxy.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules_k/rtpproxy/rtpproxy.c b/modules_k/rtpproxy/rtpproxy.c
index f526581..daee003 100644
--- a/modules_k/rtpproxy/rtpproxy.c
+++ b/modules_k/rtpproxy/rtpproxy.c
@@ -2074,7 +2074,7 @@ force_rtp_proxy(struct sip_msg* msg, char* str1, char* str2, int offer)
sdp_stream = get_sdp_stream(msg, sdp_session_num, sdp_stream_num);
if(!sdp_stream) break;
- if (sdp_stream->ip_addr.s && !sdp_stream->ip_addr.len) {
+ if (sdp_stream->ip_addr.s && sdp_stream->ip_addr.len>0) {
oldip = sdp_stream->ip_addr;
pf = sdp_stream->pf;
} else {
Module: sip-router
Branch: master
Commit: c02995c63b7fd908893ad2fc3c48c86dbf0b4002
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c02995c…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Sep 13 18:41:50 2010 +0200
pdbt: script for finish carrier IDs, from Mikko Lehto, mikko dot lehto at setera dot fi
---
utils/pdbt/scripts/get_carrier_names_finland.sh | 26 +++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/utils/pdbt/scripts/get_carrier_names_finland.sh b/utils/pdbt/scripts/get_carrier_names_finland.sh
new file mode 100755
index 0000000..2576475
--- /dev/null
+++ b/utils/pdbt/scripts/get_carrier_names_finland.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Mikko Lehto, mikko dot lehto at setera dot fi
+#
+# This file is part of sip-router, a free SIP server.
+#
+# sip-router 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,
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Small helper script for Finland:
+# Download the directory of finish carrier names and the respective IDs from
+# the regulation authorities and convert this into the format which the pdbt tool
+# understands.
+
+wget -O - "http://www2.ficora.fi/numerointi/nure_numbering.asp?nums=tot&lang=en" | awk '/<tbody>/, /<\/tbody>/' | awk -F"</td" -v RS="</tr" '{ gsub(/.*>/,"",$1) gsub(/.*>/,"",$2); gsub(/ä/,"ä",$2); gsub(/Å/,"Å",$2); gsub(/ö/,"ö",$2); if ( $2 != "") { printf "D%.3d %s\n",$1,$2 } }'
Module: sip-router
Branch: master
Commit: 1cf291af15d10160ca2bacedbb3d51817ed4286c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1cf291a…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Sep 13 18:37:38 2010 +0200
pdbt: fix wrong help output and comment, reported from Mikko Lehto, mikko dot lehto at setera dot fi
---
utils/pdbt/pdbt.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/utils/pdbt/pdbt.c b/utils/pdbt/pdbt.c
index 973e9d2..5cc5689 100644
--- a/utils/pdbt/pdbt.c
+++ b/utils/pdbt/pdbt.c
@@ -66,7 +66,7 @@ void print_usage(char *program) {
LINFO(" -s <file>: Specifies the csv list.\n");
LINFO(" Use '-' as filename to read from stdin.\n");
LINFO(" Line format: <number prefix>;<carrier id>\n");
- LINFO(" Format of carrier id: D[0-9][0-9][0-9]\n");
+ LINFO(" Format of carrier id: [0-9][0-9][0-9]\n");
LINFO(" -m <file>: Specifies the mmap image.\n");
LINFO(" -f <file>: Specifies the query file.\n");
LINFO(" Use '-' as filename to read from stdin.\n");
@@ -159,7 +159,7 @@ int file_query(char *filename, query_func_t query_func, void *data) {
/*
Read a csv list from the given file and build a dtree structure.
Format of lines in csv file: "<number prefix>;<carrier id>".
- Format of carrier id: "D[0-9][0-9][0-9]".
+ Format of carrier id: "[0-9][0-9][0-9]".
Returns the number of lines imported or -1 on error.
*/
int import_csv(struct dt_node_t *root, char *filename) {
sip-router writes:
> Since GIT#99cff51099 one doesn't not have to specify any fixup for string or any type of variable type arguments. Everything will be converted to string by the core (but note that vars will not be auto-converted if quoted, if you need that you probably need one of the
> fixup_var_str_12() or fixup_var_pve_str_12()).
> E.g.: f($a, "$a = " + $a) will work automatically.
> For ints, either convert the string argument to int by hand, or use
> fixup_var_int_12() as fixup and then access the args with
> get_int_fparam().
andrei,
can you give an example, how cmd_export_t entry would look like for a
function that has three arguments: a pvar argument and two string
arguments that can contain pseudo variables, and how the argument values
are referenced in the code?
-- juha