On Tuesday 03 March 2009, Henning Westerholt wrote:
> [..]
> I'll provide the slides and eventual some notes after the talk as usual.
Hi all,
the event went pretty well. It was not a typical "free software conference"
like for example the FOSDEM, as most of the audience were system or
network administrators. The talks i visited were informative, in the evening
they organised a really nice social event.
My presentation is available at:
http://www.kamailio.org/events/2009-FFG/presentation.pdf
Cheers,
Henning
Hi,
attached patch removes the VQ_MALLOC memory manager from the sip-router core.
As discussed some time ago, this memory manager don't provide a realloc
implementation, and is thus not really usable for the modules, as some of
them needs this. We removed this in kamailio in the last year, so far nobody
missed it. Removing this memory manager is in my opinion a good cleanup, and
also make the synchronisation of this MM implementations with the ones in the
kamailio core easier.
Cheers,
Henning
Module: sip-router
Branch: master
Commit: e430fa027b632c289cd440a228f102f385d29087
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e430fa0…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 16 18:49:27 2009 +0100
Teach sip-router how to recognized Path header field name.
---
parser/case_path.h | 41 +++++++++++++++++++++++++++++++++++++++++
parser/hf.c | 1 +
parser/hf.h | 2 ++
parser/keys.h | 1 +
parser/msg_parser.c | 5 +++++
parser/msg_parser.h | 1 +
parser/parse_hname2.c | 2 ++
7 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/parser/case_path.h b/parser/case_path.h
new file mode 100644
index 0000000..5b065fc
--- /dev/null
+++ b/parser/case_path.h
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * Path Header Field Name Parsing Macros
+ *
+ * Copyright (C) 2009 iptelorg GmbH
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser 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(a)iptel.org
+ *
+ * ser 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
+ */
+
+
+#ifndef CASE_PATH_H
+#define CASE_PATH_H
+
+
+#define path_CASE \
+ hdr->type = HDR_PATH_T; \
+ p += 4; \
+ goto dc_end
+
+
+#endif /* CASE_PATH_H */
diff --git a/parser/hf.c b/parser/hf.c
index 594a27f..c5f7ba3 100644
--- a/parser/hf.c
+++ b/parser/hf.c
@@ -211,6 +211,7 @@ void clean_hdr_field(struct hdr_field* hf)
case HDR_REQUESTDISPOSITION_T:
case HDR_WWW_AUTHENTICATE_T:
case HDR_PROXY_AUTHENTICATE_T:
+ case HDR_PATH_T:
break;
default:
LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
diff --git a/parser/hf.h b/parser/hf.h
index 7196833..bddf0a2 100644
--- a/parser/hf.h
+++ b/parser/hf.h
@@ -109,6 +109,7 @@ enum _hdr_types_t {
HDR_RETRY_AFTER_T /* Retry-After header field */,
HDR_PPI_T /**< P-Preferred-Identity header field */,
HDR_PAI_T /**< P-Asserted-Identity header field */,
+ HDR_PATH_T /**< Path header field */,
HDR_EOH_T /* End of message header */
};
@@ -178,6 +179,7 @@ typedef unsigned long long hdr_flags_t;
#define HDR_RETRY_AFTER_F HDR_F_DEF(RETRY_AFTER)
#define HDR_PPI_F HDR_F_DEF(PPI)
#define HDR_PAI_F HDR_F_DEF(PAI)
+#define HDR_PATH_F HDR_F_DEF(PATH)
#define HDR_OTHER_F HDR_F_DEF(OTHER)
diff --git a/parser/keys.h b/parser/keys.h
index 92c60ce..bf17058 100644
--- a/parser/keys.h
+++ b/parser/keys.h
@@ -108,6 +108,7 @@
#define _iden_ 0x6e656469 /* "iden" */
#define _tity_ 0x79746974 /* "tity" */
#define _info_ 0x6f666e69 /* "info" */
+#define _path_ 0x68746170 /* "path" */
#define _pt_l_ 0x6c2d7470 /* "pt-l" */
#define _angu_ 0x75676e61 /* "angu" */
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index 5cfbd7c..cad8028 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -241,6 +241,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
case HDR_REQUESTDISPOSITION_T:
case HDR_WWW_AUTHENTICATE_T:
case HDR_PROXY_AUTHENTICATE_T:
+ case HDR_PATH_T:
case HDR_OTHER_T:
/* just skip over it */
hdr->body.s=tmp;
@@ -516,6 +517,10 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
if (msg->identity_info==0) msg->identity_info=hf;
msg->parsed_flag|=HDR_IDENTITY_INFO_F;
break;
+ case HDR_PATH_T:
+ if (msg->path==0) msg->path=hf;
+ msg->parsed_flag|=HDR_PATH_F;
+ break;
default:
LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
hf->type);
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 4b18ed5..48790c9 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -257,6 +257,7 @@ typedef struct sip_msg {
struct hdr_field* identity_info;
struct hdr_field* pai;
struct hdr_field* ppi;
+ struct hdr_field* path;
char* eoh; /* pointer to the end of header (if found) or null */
char* unparsed; /* here we stopped parsing*/
diff --git a/parser/parse_hname2.c b/parser/parse_hname2.c
index 6b8e159..a222d5e 100644
--- a/parser/parse_hname2.c
+++ b/parser/parse_hname2.c
@@ -98,6 +98,7 @@ static inline char* skip_ws(char* p, unsigned int size)
#include "case_date.h" /* Date */
#include "case_iden.h" /* Identity, Identity-info */
#include "case_retr.h" /* Retry-After */
+#include "case_path.h" /* Path */
#define READ(val) \
@@ -143,6 +144,7 @@ static inline char* skip_ws(char* p, unsigned int size)
case _date_: date_CASE; \
case _iden_: iden_CASE; \
case _retr_: retr_CASE; \
+ case _path_: path_CASE;
Module: sip-router
Branch: master
Commit: feef2d2e0bdbc5232138e0308e8e1cd9daf0a4ab
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=feef2d2…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 16 16:54:44 2009 +0100
Include dlfcn.h for RTLD_NOW and friends.
There is a test in sr_module.h which tests whether the macro RTLD_NOW is
defined and defines it to DL_LAZY if not. The header file did not include
dlfcn.h which defines the macro RTLD_NOW, so as a result it was always
re-defined to DL_LAZY.
---
sr_module.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/sr_module.h b/sr_module.h
index 0078f25..bdf64de 100644
--- a/sr_module.h
+++ b/sr_module.h
@@ -58,6 +58,8 @@
#ifndef sr_module_h
#define sr_module_h
+#include <dlfcn.h>
+
#include "parser/msg_parser.h" /* for sip_msg */
#include "version.h"
#include "rpc.h"
Module: sip-router
Branch: janakj/kcore
Commit: 301e4abff0ac546969eaa6b26b97574883fcba08
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=301e4ab…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 16 15:23:26 2009 +0100
Adding files regexp.[ch] from kamailio core
---
lib/kcore/regexp.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/kcore/regexp.h | 41 +++++++++++++++++
2 files changed, 163 insertions(+), 0 deletions(-)
diff --git a/lib/kcore/regexp.c b/lib/kcore/regexp.c
new file mode 100644
index 0000000..da724ca
--- /dev/null
+++ b/lib/kcore/regexp.c
@@ -0,0 +1,122 @@
+/*
+ * $Id$
+ *
+ * Regular expression functions
+ *
+ * Copyright (C) 2003 Juha Heinanen
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/*!
+ * \file
+ * \brief Regular Expression functions
+ */
+
+#include <sys/types.h>
+#include <string.h>
+#include <regex.h>
+#include <ctype.h>
+#include "regexp.h"
+#include "dprint.h"
+
+/*! \brief Replace in replacement tokens \\d with substrings of string pointed by
+ * pmatch.
+ */
+int replace(regmatch_t* pmatch, char* string, char* replacement, str* result)
+{
+ int len, i, j, digit, size;
+
+ len = strlen(replacement);
+ j = 0;
+
+ for (i = 0; i < len; i++) {
+ if (replacement[i] == '\\') {
+ if (i < len - 1) {
+ if (isdigit((unsigned char)replacement[i+1])) {
+ digit = replacement[i+1] - '0';
+ if (pmatch[digit].rm_so != -1) {
+ size = pmatch[digit].rm_eo - pmatch[digit].rm_so;
+ if (j + size < result->len) {
+ memcpy(&(result->s[j]), string+pmatch[digit].rm_so, size);
+ j = j + size;
+ } else {
+ return -1;
+ }
+ } else {
+ return -2;
+ }
+ i = i + 1;
+ continue;
+ } else {
+ i = i + 1;
+ }
+ } else {
+ return -3;
+ }
+ }
+ if (j + 1 < result->len) {
+ result->s[j] = replacement[i];
+ j = j + 1;
+ } else {
+ return -4;
+ }
+ }
+ result->len = j;
+ return 1;
+}
+
+
+/*! \brief Match pattern against string and store result in pmatch */
+int reg_match(char *pattern, char *string, regmatch_t *pmatch)
+{
+ regex_t preg;
+
+ if (regcomp(&preg, pattern, REG_EXTENDED | REG_NEWLINE)) {
+ return -1;
+ }
+ if (preg.re_nsub > MAX_MATCH) {
+ regfree(&preg);
+ return -2;
+ }
+ if (regexec(&preg, string, MAX_MATCH, pmatch, 0)) {
+ regfree(&preg);
+ return -3;
+ }
+ regfree(&preg);
+ return 0;
+}
+
+
+/*! \brief Match pattern against string and, if match succeeds, and replace string
+ * with replacement substituting tokens \\d with matched substrings.
+ */
+int reg_replace(char *pattern, char *replacement, char *string, str *result)
+{
+ regmatch_t pmatch[MAX_MATCH];
+
+ LM_DBG("pattern: '%s', replacement: '%s', string: '%s'\n",
+ pattern, replacement, string);
+
+ if (reg_match(pattern, string, &(pmatch[0]))) {
+ return -1;
+ }
+
+ return replace(&pmatch[0], string, replacement, result);
+
+}
diff --git a/lib/kcore/regexp.h b/lib/kcore/regexp.h
new file mode 100644
index 0000000..e63ed60
--- /dev/null
+++ b/lib/kcore/regexp.h
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * Regular expression definitions
+ *
+ * Copyright (C) 2003 Juha Heinanen
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/*!
+ * \file
+ * \brief Regular expression definitions
+ */
+
+
+#ifndef REGEXP_H
+#define REGEXP_H
+
+#include "str.h"
+
+#define MAX_MATCH 6
+
+extern int reg_replace(char *pattern, char *replacement, char *string, str *result);
+
+#endif