Module: sip-router
Branch: master
Commit: 7b878801737e7f368a22b1adcc1f2c05b9e8585a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7b87880…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Jan Janak <jan(a)iptel.org>
Date: Fri Mar 20 16:42:26 2009 +0100
New functions that can be used to search for a header with given type
This patch adds two new functions to the sip-router core. Function
get_hdr can be used to find the first occurrence of header with a given
type in a sip message if the particular header type does not have its
own hook in the sip_msg data structure.
The second function next_sibling_hdr can be used to find the next
occurence of header with the same type as the header in parameter
in the sip message.
Signed-off-by: Jan Janak <jan(a)iptel.org>
---
parser/msg_parser.c | 22 ++++++++++++++++++++++
parser/msg_parser.h | 3 +++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index cad8028..74f91f5 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -743,3 +743,25 @@ void reset_dst_uri(struct sip_msg* msg)
msg->dst_uri.s = 0;
msg->dst_uri.len = 0;
}
+
+
+struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht)
+{
+ struct hdr_field *hdr;
+
+ for(hdr = msg->headers; hdr; hdr = hdr->next) {
+ if(hdr->type == ht) return hdr;
+ }
+ return NULL;
+}
+
+
+struct hdr_field* next_sibling_hdr(struct hdr_field *hf)
+{
+ struct hdr_field *hdr;
+
+ for(hdr = hf->next; hdr; hdr = hdr->next) {
+ if(hdr->type == hf->type) return hdr;
+ }
+ return NULL;
+}
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 48790c9..624c2ab 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -411,4 +411,7 @@ int set_dst_uri(struct sip_msg* msg, str* uri);
/* If the dst_uri is set to an URI then reset it */
void reset_dst_uri(struct sip_msg* msg);
+struct hdr_field* get_hdr(struct sip_msg *msg, enum _hdr_types_t ht);
+struct hdr_field* next_sibling_hdr(struct hdr_field *hf);
+
#endif
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0051630…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 20 19:59:14 2009 +0000
tcp: minor optimization
- tcp_req complete & has_content_len transformed into flags
(4 bytes saved per connection)
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e2c4ed6…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 20 17:27:15 2009 +0000
sercmd: minor makefile fix
- clear C_DEFS, since we don't need ser common DEFS for building sercmd
(minor compile warning that appeared after the recend DEFS->C_DEFS changes
in the main Makefiles)
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ffc72fc…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 20 17:26:51 2009 +0000
tcp internal: send timeout is now kept only in ticks
- removed send_timeout_s and wq_timeout and replaced them with send_timeout,
which is now kept only in ticks. This fixes the cfg.set_delayed_int problem
reported by Miklos.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3165726…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 20 16:10:37 2009 +0000
core: typo fix
- ';' after if() (again). Fortunately it didn't have any impact
since right now nobody returns NONSIP_MSG_ACCEPT from a
nonsip_msg callback.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=575a0b4…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Mar 19 17:59:14 2009 +0000
tcp: typo & minor optimization
- fixed ';' after if() on tcp connection free (luckily that code path was
not very common and it was even more improbable to have a ref'ed connection
at that point).
- changed unlikely() into likely() when checking connect() return in async
mode (it's much more probable to get an EINPROGRESS).
Reported-by: Libor Chocholaty <libor(a)iptel.org>
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b4fb73d…
Author: Jan Janak <jan(a)iptel.org>
Date: Thu Mar 19 15:15:51 2009 +0000
Rename Contact parameter select 'method' to 'methods'
According RFC3840 the correct name of the parameter is 'methods',
not 'method'.
Reported by Daniel-Constantin Mierla
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=524b467…
Author: Jan Janak <jan(a)iptel.org>
Date: Thu Mar 19 15:15:04 2009 +0000
Rename Contact parameter 'method' to 'methods'
According RFC3840 the correct name of the parameter is 'methods',
not 'method'.
Reported by Daniel-Constantin Mierla
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b5b92e0…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Mar 19 14:32:36 2009 +0000
make install: avoid re-linking lib dependent modules
- install doesn't try first to build everything, it will build as
it installs. This will avoid re-linking ser-lib dependent
modules (the normal "make all" would use a local rpath, while "make
install" would change rpath to the install destination dir => the
module needs to be relinked with a different rpath or on Darwin
the lib has to be rebuilt)
- avoid an extra make call on lib install
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f072585…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Mar 19 13:42:09 2009 +0000
build system: avoid libraries re-compiling
- ignore module DEFS when deciding whether or not to recompile a
library: DEFS split into C_DEFS (for common DEFS which are taken
into account when deciding whether or not to recompile a lib)
and DEFS, which are now visible only inside the module or lib
that uses them. Same for INCLUDES and C_INCLUDES.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d88602c…
Author: Pavel Kasparek <pavel(a)iptel.org>
Date: Mon Mar 16 10:35:10 2009 +0000
fixing missing $ in ser_mysql.sh script
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4914d97…
Author: Pavel Kasparek <pavel(a)iptel.org>
Date: Mon Mar 16 10:08:44 2009 +0000
Debian packaging - fixing path to mysql sql files in my_create.sh script
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=33bfeb9…
Author: Miklos Tirpak <miklos(a)iptel.org>
Date: Fri Mar 13 13:59:28 2009 +0000
The fixup function prototypes of the config variables have been
extended with the group name.
All the fixup functions have been updated.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=536065b…
Author: Miklos Tirpak <miklos(a)iptel.org>
Date: Tue Mar 10 16:26:35 2009 +0000
Strip, prefix, rewriteuser, ... all the SET_* actions preserve the
original URI scheme unless the host name is rewritten. If the host name
is set, then tel: and tels: URIs are converted to sip: or sips:, and the
user=phone parameter is added.
A script function, userphone(), is introduced: It adds the "user=phone"
parameter to a sip: or sips: RURI if the param is not yet present.
(Does not change tel: and tels: URIs).
(Patch has been created with cooperation with Michal Matyska.)
Fixes SER-435.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=77932db…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Mar 9 13:47:48 2009 +0000
core: check & fix Content-Length when sending on tcp
- automatically check & fix wrong Content-Length before forwarding
on tcp or tls
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e655392…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Mar 9 13:45:49 2009 +0000
tcp: config option for the async write block size
- the block size used for the async writes can now be configured
both from ser.cfg (tcp_wq_blk_size) and at runtime. This value
has only a little performance impact and only when writes are
delayed. Small values are safer (big values on proxies that
open thousands of connections over slow links would eat up a
lot of memory). For now it's main use is debugging.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=827cd3b…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Mar 9 13:45:28 2009 +0000
tcp: config option for the read buffer size
- the read buffer size can now be configured both at runtime and
from ser.cfg (tcp_rd_buf_size). A high value will help
performance for tcp connections with lots of traffic, however it
will increase the memory consumption. As a rule of thumb use
high values(e.g. 32768, 65536) on servers which open only a few
tcp connections and have very heavy traffic on them and a low
value (e.g. 4096, 2048) on servers that are expected to have
lots of open connections (50k - 100k+). Note also that this
value will also limit the maximum sip datagram size that can be
received on tcp. The default value is 4096.
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9a74e06…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Mar 9 13:39:10 2009 +0000
tcp: dyn. config fix for tcp_con_lifetime
- cfg.set_delayed_int didn't work (fixup tried to modify another
config variable which doesn't work with cfg.set_delayed*)
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=efc23dc…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 6 16:54:10 2009 +0000
tcp: diff. connect timeout for async & states cleanup
- async mode will now honour tcp_connect_timeout (up to now it
used tcp_send_timeout also for connects)
- internal states cleanup (dropped S_CONN_PENDING, fixed
S_CONN_ACCEPT->S_CONN_OK transition a.s.o)
Hi,
is there any equivalent to the "exlude_modules" parameter in Makefiles.defs in
the sr tree? For some modules that are contained in the 'all' branch
of 'kamailio-3.0' i don't have dependencies installed, and i would like to
skip them on 'make all'.
Cheers,
Henning
Module: sip-router
Branch: master
Commit: d240dd18e0f2a51b1add374353dda34621d8c542
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d240dd1…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 20 21:47:32 2009 +0100
Merge commit 'origin/ser_core_cvs'
* commit 'origin/ser_core_cvs':
tcp: minor optimization
sercmd: minor makefile fix
tcp internal: send timeout is now kept only in ticks
core: typo fix
tcp: typo & minor optimization
Rename Contact parameter select 'method' to 'methods'
Rename Contact parameter 'method' to 'methods'
make install: avoid re-linking lib dependent modules
build system: avoid libraries re-compiling
fixing missing $ in ser_mysql.sh script
Debian packaging - fixing path to mysql sql files in my_create.sh script
The fixup function prototypes of the config variables have been
Strip, prefix, rewriteuser, ... all the SET_* actions preserve the
core: check & fix Content-Length when sending on tcp
tcp: config option for the async write block size
tcp: config option for the read buffer size
tcp: dyn. config fix for tcp_con_lifetime
tcp: diff. connect timeout for async & states cleanup
Conflicts:
Makefile.rules
action.c
cfg.lex
cfg.y
route_struct.h
---
Hello,
I have seen stun related code in sip-router core. Is there stun server,
client or both implementations? Any special purpose for it?
Cheers,
Daniel
--
Daniel-Constantin Mierla
SIP Router Masterclass - Kamailio (OpenSER) Training
http://www.asipto.com/index.php/sip-router-masterclass/
Module: sip-router
Branch: master
Commit: 1ee365faf8047d7a921da5a0bf5cc7d20f766a27
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1ee365f…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Tue Mar 17 17:41:19 2009 +0100
Refurbished event header field parser.
This is a new refurbished version of the Event header parser which adds
support for extra event packages and parameters needed by kamailio
presence modules, however both the implementation and the parser API
are different. It turned out that the original k. event parser (which
is an extended version of the same parser in ser) did not parse dialog
event packages correctly. The parser relies on the recently added
extensions to the generic parameter parser.
First off, the event structure contains different fields now, field
text has been renamed to name and field parsed has been renamed to type.
In addition that that there is a new structure dialog which contains
the linked list of all parsed parameters in variable list and pointers
to well known dialog event package parameters in structure dialog.
The test for the presence of the sla dialog event parameter would then
look like this:
if (e->type == EVENT_DIALOG && e->params.dialog.sla) ...
Support for new event types can be easily added by extending the global
variable events in parse_event.c, previously it was necessary to modify
the parser function, in the refurbished version it is sufficient just
to add a new element in the array and define a new event type in
parse_event.h
The original k. version handled "dialog;sla" and "dialog" as different
event types. This is no more so, in both cases event->type will be set
to EVENT_DIALOG and the caller can descriminate them by testing for
the presence of the sla parameter as described in the text above.
Function free_event has been modified to free the linked list of parsed
parameters in event->params.list.
---
parser/parse_event.c | 101 ++++++++++++++++++++++++++++++-------------------
parser/parse_event.h | 42 +++++++++++++--------
2 files changed, 88 insertions(+), 55 deletions(-)
diff --git a/parser/parse_event.c b/parser/parse_event.c
index 75b7017..98ca5e5 100644
--- a/parser/parse_event.c
+++ b/parser/parse_event.c
@@ -44,18 +44,19 @@
#include <stdio.h> /* printf */
#include "../ut.h"
-
-#define PRES_STR "presence"
-#define PRES_STR_LEN 8
-
-#define PRES_WINFO_STR "presence.winfo"
-#define PRES_WINFO_STR_LEN 14
-
-#define PRES_XCAP_CHANGE_STR "xcap-change"
-#define PRES_XCAP_CHANGE_STR_LEN 11
-
-#define PRES_SIP_PROFILE_STR "sip-profile"
-#define PRES_SIP_PROFILE_STR_LEN 11
+static struct {
+ str name;
+ int type;
+} events[] = {
+ {STR_STATIC_INIT("presence"), EVENT_PRESENCE},
+ {STR_STATIC_INIT("presence.winfo"), EVENT_PRESENCE_WINFO},
+ {STR_STATIC_INIT("xcap-change"), EVENT_XCAP_CHANGE},
+ {STR_STATIC_INIT("sip-profile"), EVENT_SIP_PROFILE},
+ {STR_STATIC_INIT("message-summary"), EVENT_MESSAGE_SUMMARY},
+ {STR_STATIC_INIT("dialog"), EVENT_DIALOG},
+ /* The following must be the last element in the array */
+ {STR_NULL, EVENT_OTHER}
+};
static inline char* skip_token(char* _b, int _l)
@@ -77,41 +78,58 @@ static inline char* skip_token(char* _b, int _l)
}
-static inline int event_parser(char* _s, int _l, event_t* _e)
+int event_parser(char* s, int len, event_t* e)
{
+ int i;
str tmp;
char* end;
+ param_hooks_t* phooks = NULL;
+ enum pclass pclass = CLASS_ANY;
- tmp.s = _s;
- tmp.len = _l;
+ if (e == NULL) {
+ ERR("event_parser: Invalid parameter value\n");
+ return -1;
+ }
+ tmp.s = s;
+ tmp.len = len;
trim_leading(&tmp);
if (tmp.len == 0) {
- LOG(L_ERR, "event_parser(): Empty body\n");
+ LOG(L_ERR, "event_parser: Empty body\n");
return -1;
}
- _e->text.s = tmp.s;
-
+ e->name.s = tmp.s;
end = skip_token(tmp.s, tmp.len);
+ e->name.len = end - tmp.s;
+
+ e->type = EVENT_OTHER;
+ for(i = 0; events[i].name.len; i++) {
+ if (e->name.len == events[i].name.len &&
+ !strncasecmp(e->name.s, events[i].name.s, e->name.len)) {
+ e->type = events[i].type;
+ break;
+ }
+ }
+
+ tmp.len -= end - tmp.s;
+ tmp.s = end;
+ trim_leading(&tmp);
+
+ if (tmp.s[0] == ';') {
+ /* We have parameters to parse */
+ if (e->type == EVENT_DIALOG) {
+ pclass = CLASS_EVENT_DIALOG;
+ phooks = (param_hooks_t*)&e->params.dialog;
+ }
- _e->text.len = end - tmp.s;
-
- if ((_e->text.len == PRES_STR_LEN) &&
- !strncasecmp(PRES_STR, tmp.s, _e->text.len)) {
- _e->parsed = EVENT_PRESENCE;
- } else if ((_e->text.len == PRES_XCAP_CHANGE_STR_LEN) &&
- !strncasecmp(PRES_XCAP_CHANGE_STR, tmp.s, _e->text.len)) {
- _e->parsed = EVENT_XCAP_CHANGE;
- } else if ((_e->text.len == PRES_WINFO_STR_LEN) &&
- !strncasecmp(PRES_WINFO_STR, tmp.s, _e->text.len)) {
- _e->parsed = EVENT_PRESENCE_WINFO;
- } else if ((_e->text.len == PRES_SIP_PROFILE_STR_LEN) &&
- !strncasecmp(PRES_SIP_PROFILE_STR, tmp.s, _e->text.len)) {
- _e->parsed = EVENT_SIP_PROFILE;
+ if (parse_params(&tmp, pclass, phooks, &e->params.list) < 0) {
+ ERR("event_parser: Error while parsing parameters parameters\n");
+ return -1;
+ }
} else {
- _e->parsed = EVENT_OTHER;
+ e->params.list = NULL;
}
return 0;
@@ -153,19 +171,24 @@ int parse_event(struct hdr_field* _h)
*/
void free_event(event_t** _e)
{
- if (*_e) pkg_free(*_e);
- *_e = 0;
+ if (*_e) {
+ if ((*_e)->params.list) free_params((*_e)->params.list);
+ pkg_free(*_e);
+ *_e = NULL;
+ }
}
/*
* Print structure, for debugging only
*/
-void print_event(event_t* _e)
+void print_event(event_t* e)
{
printf("===Event===\n");
- printf("text : \'%.*s\'\n", _e->text.len, ZSW(_e->text.s));
- printf("parsed: %s\n",
- (_e->parsed == EVENT_PRESENCE) ? ("EVENT_PRESENCE") : ("EVENT_OTHER"));
+ printf("name : \'%.*s\'\n", STR_FMT(&e->name));
+ printf("type: %d\n", e->type);
+ if (e->params.list) {
+ print_params(stdout, e->params.list);
+ }
printf("===/Event===\n");
}
diff --git a/parser/parse_event.h b/parser/parse_event.h
index 03feb5e..4e90a52 100644
--- a/parser/parse_event.h
+++ b/parser/parse_event.h
@@ -1,12 +1,6 @@
/*
* $Id$
*
- * Event header field body parser
- * This parser was written for Presence Agent module only.
- * it recognizes presence package only, no subpackages, no parameters
- * It should be replaced by a more generic parser if subpackages or
- * parameters should be parsed too.
- *
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
@@ -37,35 +31,51 @@
#include "../str.h"
#include "hf.h"
+#include "parse_param.h"
+
+/* Recognized event types */
+enum event_type {
+ EVENT_OTHER = 0,
+ EVENT_PRESENCE,
+ EVENT_PRESENCE_WINFO,
+ EVENT_SIP_PROFILE,
+ EVENT_XCAP_CHANGE,
+ EVENT_DIALOG,
+ EVENT_MESSAGE_SUMMARY
+};
+
+
+struct event_params {
+ struct event_dialog_hooks dialog; /* Well known dialog package params */
+ param_t* list; /* Linked list of all parsed parameters */
+};
-#define EVENT_OTHER 0
-#define EVENT_PRESENCE 1
-#define EVENT_PRESENCE_WINFO 2
-#define EVENT_SIP_PROFILE 3
-#define EVENT_XCAP_CHANGE 4
typedef struct event {
- str text; /* Original string representation */
- int parsed; /* Parsed variant */
+ enum event_type type; /* Parsed variant */
+ str name; /* Original string representation */
+ struct event_params params;
} event_t;
/*
* Parse Event HF body
*/
-int parse_event(struct hdr_field* _h);
+int parse_event(struct hdr_field* hf);
/*
* Release memory
*/
-void free_event(event_t** _e);
+void free_event(event_t** e);
/*
* Print structure, for debugging only
*/
-void print_event(event_t* _e);
+void print_event(event_t* e);
+
+int event_parser(char* s, int l, event_t* e);
#endif /* PARSE_EVENT_H */
Hi, two days ago I added a parameter to Kamailio TM module to drop replies
matching no transaction instead of forward them stateless (by insptecting
Via):
http://kamailio.org/docs/modules/devel/tm.html#id2530689
Which is the default behaviour of SR TM module in this subject?
--
Iñaki Baz Castillo
Hi Jan,
the param was added initial in Kamailio tm, but since the next release
will be based on sip-router core & tm part, I've ported the patch to
sip-router tm to keep the feature after the merge.
Patch is attached please review and commit
thanks and regards,
Andreas
Hi,
comparing the memory manager in sip-router and kamilio i wondered what is the
purpose of this mem/memdbg.h definitions. Both F_MALLOC and Q_MALLOC use
them, but also use the LOG(memlog,..) style of output informations.
What is the difference between the memlog parameter (which we also have), and
the memdbg parameter? Google tells me that the first is the mem statistics
log level, and the former the mem debug level. Is this correct?
Thanks,
Henning