Module: sip-router
Branch: janakj/kcore
Commit: 8f3676cf2f6d3b20ae67294817bd49514a061d3a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8f3676c…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Thu Mar 5 23:56:19 2009 +0100
Merge branch 'sr' into kcore
* sr:
Include parse_to.h explicitly where needed.
Add parsed_uri structure to the to_body structure.
Kamailo compatiblity macros was_canceled and no_new_branches
fix compiler warning about uninitialized variable
integrate sip-router compatiblity patches from Jan Janak
Define fixup_spve_null
Alias LM_NOTICE to NOTICE
Function load_tm_api added
A comment warning about flag FL_REQ_UPSTREAM.
Replace explicit flag values with bit shifts for better readability
---
Module: sip-router
Branch: janakj/kcore
Commit: 66b8eec6fd1123e10b805d11d8d78cfb50c7a33e
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=66b8eec…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Thu Mar 5 23:57:38 2009 +0100
Parser helper functions not present in sip-router.
That include parse_to_uri and parse_from_uri. Also adding errinfo.[ch]
which is required by the parser helpers.
---
lib/kcore/errinfo.c | 75 ++++++++++++++++++++++++++++++++++++++++++++
lib/kcore/errinfo.h | 59 ++++++++++++++++++++++++++++++++++
lib/kcore/parser_helpers.c | 65 ++++++++++++++++++++++++++++++++++++++
lib/kcore/parser_helpers.h | 11 ++++++
4 files changed, 210 insertions(+), 0 deletions(-)
diff --git a/lib/kcore/errinfo.c b/lib/kcore/errinfo.c
new file mode 100644
index 0000000..799549f
--- /dev/null
+++ b/lib/kcore/errinfo.c
@@ -0,0 +1,75 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2006 Voice Sistem SRL
+ *
+ * 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 errinfo.c
+ * \brief Kamailio Error info functions
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../dprint.h"
+#include "errinfo.h"
+
+/*! global error info */
+err_info_t _oser_err_info;
+
+/*! \brief Get global error state
+ */
+err_info_t* get_err_info(void) { return &_oser_err_info; }
+
+/*! \brief Initialize global error state
+ */
+void init_err_info(void)
+{
+ memset(&_oser_err_info, 0, sizeof(err_info_t));
+}
+
+/*! \brief Set suggested error info message
+ */
+void set_err_info(int ec, int el, char *info)
+{
+ LM_DBG("ec: %d, el: %d, ei: '%s'\n", ec, el,
+ (info)?info:"");
+ _oser_err_info.eclass = ec;
+ _oser_err_info.level = el;
+ if(info)
+ {
+ _oser_err_info.info.s = info;
+ _oser_err_info.info.len = strlen(info);
+ }
+}
+
+/*! \brief Set suggested error reply
+ */
+void set_err_reply(int rc, char *rr)
+{
+ _oser_err_info.rcode = rc;
+ if(rr)
+ {
+ _oser_err_info.rreason.s = rr;
+ _oser_err_info.rreason.len = strlen(rr);
+ }
+}
+
diff --git a/lib/kcore/errinfo.h b/lib/kcore/errinfo.h
new file mode 100644
index 0000000..fb4bf6b
--- /dev/null
+++ b/lib/kcore/errinfo.h
@@ -0,0 +1,59 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2006 Voice Sistem SRL
+ *
+ * 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 errinfo.h
+ * \brief Error handling
+ */
+
+
+#ifndef _errinfo_h_
+#define _errinfo_h_
+
+#include "../../str.h"
+
+/*! \name ErrorClasses error clases */
+#define OSER_EC_PARSER 1 /*!< parse error */
+#define OSER_EC_PMEMORY 2 /*!< private memory error */
+#define OSER_EC_SMEMORY 3 /*!< share memory error */
+
+#define OSER_EL_CRITIC 1
+#define OSER_EL_HIGH 2
+#define OSER_EL_MEDIUM 3 /*!< severity level normal - used by parsing errors */
+#define OSER_EL_NORMAL 4
+#define OSER_EL_LOW 5
+
+typedef struct err_info_
+{
+ int eclass; /*!< error class */
+ int level; /*!< severity level (lower is higher) */
+ str info; /*!< error details */
+ int rcode; /*!< recommended reply code */
+ str rreason; /*!< recommended reply reason phrase */
+} err_info_t;
+
+void init_err_info(void);
+void set_err_info(int ec, int el, char *info);
+void set_err_reply(int rc, char *rr);
+err_info_t* get_err_info(void);
+
+#endif
diff --git a/lib/kcore/parser_helpers.c b/lib/kcore/parser_helpers.c
new file mode 100644
index 0000000..15c48c6
--- /dev/null
+++ b/lib/kcore/parser_helpers.c
@@ -0,0 +1,65 @@
+#include "parser_helpers.h"
+#include "errinfo.h"
+#include "../../parser/parse_to.h"
+#include "../../parser/parse_from.h"
+#include "../../dprint.h"
+
+#include <string.h>
+
+struct sip_uri *parse_to_uri(struct sip_msg *msg)
+{
+ struct to_body *tb = NULL;
+
+ if(msg==NULL || msg->to==NULL || msg->to->parsed==NULL)
+ return NULL;
+
+ tb = get_to(msg);
+
+ if(tb->parsed_uri.user.s!=NULL || tb->parsed_uri.host.s!=NULL)
+ return &tb->parsed_uri;
+
+ if (parse_uri(tb->uri.s, tb->uri.len , &tb->parsed_uri)<0)
+ {
+ LM_ERR("failed to parse To uri\n");
+ memset(&tb->parsed_uri, 0, sizeof(struct sip_uri));
+ set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM, "error parsing To uri");
+ set_err_reply(400, "bad To uri");
+ return NULL;
+ }
+
+ return &tb->parsed_uri;
+}
+
+
+struct sip_uri *parse_from_uri(struct sip_msg *msg)
+{
+ struct to_body *tb = NULL;
+
+ if(msg==NULL)
+ return NULL;
+
+ if(parse_from_header(msg)<0)
+ {
+ LM_ERR("cannot parse FROM header\n");
+ return NULL;
+ }
+
+ if(msg->from==NULL || get_from(msg)==NULL)
+ return NULL;
+
+ tb = get_from(msg);
+
+ if(tb->parsed_uri.user.s!=NULL || tb->parsed_uri.host.s!=NULL)
+ return &tb->parsed_uri;
+
+ if (parse_uri(tb->uri.s, tb->uri.len , &tb->parsed_uri)<0)
+ {
+ LM_ERR("failed to parse From uri\n");
+ memset(&tb->parsed_uri, 0, sizeof(struct sip_uri));
+ set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM, "error parsing From uri");
+ set_err_reply(400, "bad From uri");
+ return NULL;
+ }
+ return &tb->parsed_uri;
+}
+
diff --git a/lib/kcore/parser_helpers.h b/lib/kcore/parser_helpers.h
new file mode 100644
index 0000000..58e8764
--- /dev/null
+++ b/lib/kcore/parser_helpers.h
@@ -0,0 +1,11 @@
+#ifndef _PARSER_HELPERS_H
+#define _PARSER_HELPERS_H
+
+#include "../../parser/msg_parser.h"
+#include "../../parser/parse_uri.h"
+
+struct sip_uri* parse_to_uri(struct sip_msg* msg);
+
+struct sip_uri* parse_from_uri(struct sip_msg* msg);
+
+#endif /* _PARSER_HELPERS_H */
Module: sip-router
Branch: master
Commit: 3bc6281523b9a85a9781fa8f8d21b04ac7529d71
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3bc6281…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Fri Mar 6 00:41:57 2009 +0100
Merge branch 'master' of ssh://janakj@git.sip-router.org/sip-router into sr
* 'master' of ssh://janakj@git.sip-router.org/sip-router:
tcp: config option to disable active connects
tcp: async mode on by default
tcp: enable runtime changing for most of the cfg vars
tcp: use dynamic config framework, part 2
tcp: use dynamic config framework, part 1
test: updated parse uri test program
sctp: rpc info command
sctp: connection reuse & connection tracking
sctp: empty sctp_handle_assoc_change added
regfree() function call is added to free the memory allocated by regcomp().
---
Module: sip-router
Branch: master
Commit: 0873991755f732a3a57cfeb8d0d9437f4fd306bb
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0873991…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Thu Mar 5 23:47:02 2009 +0100
Add parsed_uri structure to the to_body structure.
This is a compatiblity change inspired by kamailio changes. It makes
it possible to store already parsed to and from URIs in the sip
message structure and there is no need to reparse such URIs later.
To and From headers are often parsed repeatedly in modules.
As a side effect I had to avoid a nasty cyclic dependency in parser
headers. I removed parse_to from msg_parser.h, the header does not have
to be included there because nothing in msg_parser.h uses stuff from
parse_to. In addition to that many files that previously included only
msg_parser.h, and assumed that the header would pull parse_to.h as well,
needed to be modified to include parse_to.h explicitly.
---
msg_translator.c | 1 +
parser/msg_parser.c | 1 +
parser/msg_parser.h | 1 -
parser/parse_from.h | 1 +
parser/parse_to.h | 2 ++
5 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/msg_translator.c b/msg_translator.c
index ae52878..3df42d4 100644
--- a/msg_translator.c
+++ b/msg_translator.c
@@ -139,6 +139,7 @@
#include "ut.h"
#include "pt.h"
#include "cfg/cfg.h"
+#include "parser/parse_to.h"
#include "forward.h"
diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index a7df061..e50d3ff 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -58,6 +58,7 @@
#include "parse_hname2.h"
#include "parse_uri.h"
#include "parse_content.h"
+#include "parse_to.h"
#include "../compiler_opt.h"
#ifdef DEBUG_DMALLOC
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index b1541b7..86855e8 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -59,7 +59,6 @@
#include "../config.h"
#include "parse_def.h"
#include "parse_cseq.h"
-#include "parse_to.h"
#include "parse_via.h"
#include "parse_fline.h"
#include "parse_retry_after.h"
diff --git a/parser/parse_from.h b/parser/parse_from.h
index f9e149a..1618627 100644
--- a/parser/parse_from.h
+++ b/parser/parse_from.h
@@ -29,6 +29,7 @@
#ifndef _PARSE_FROM_H
#define _PARSE_FROM_H
+#include "parse_to.h"
#include "msg_parser.h"
diff --git a/parser/parse_to.h b/parser/parse_to.h
index c032cb1..08e4fc4 100644
--- a/parser/parse_to.h
+++ b/parser/parse_to.h
@@ -30,6 +30,7 @@
#define PARSE_TO
#include "../str.h"
+#include "msg_parser.h"
enum {
TAG_PARAM = 400, GENERAL_PARAM
@@ -49,6 +50,7 @@ struct to_body{
str uri; /* URI */
str display; /* Display Name */
str tag_value; /* Value of tag */
+ struct sip_uri parsed_uri;
struct to_param *param_lst; /* Linked list of parameters */
struct to_param *last_param; /* Last parameter in the list */
};