Module: sip-router
Branch: master
Commit: a075952dd0970b3ab5f7e403c88f954c2743ce80
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a075952…
Author: Richard Fuchs <rfuchs(a)sipwise.com>
Committer: Andreas Granig <agranig(a)sipwise.com>
Date: Thu Apr 19 17:38:29 2012 +0200
core: Move parse_via_header to correct place.
- Move parse_via_header(...) from select_core to parser
to avoid compiler warnings when accessing it from modules.
---
parser/parse_via.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
parser/parse_via.h | 8 +++++++
select_core.c | 54 --------------------------------------------------
3 files changed, 64 insertions(+), 54 deletions(-)
diff --git a/parser/parse_via.c b/parser/parse_via.c
index 5c54e09..1ed1004 100644
--- a/parser/parse_via.c
+++ b/parser/parse_via.c
@@ -68,6 +68,7 @@
#include "../ip_addr.h"
#include "parse_via.h"
#include "parse_def.h"
+#include "msg_parser.h"
@@ -2662,3 +2663,58 @@ void free_via_list(struct via_body* vb)
pkg_free(foo);
}
}
+
+int parse_via_header( struct sip_msg *msg, int n, struct via_body** q)
+{
+ struct hdr_field *p;
+ struct via_body *pp = NULL;
+ int i;
+
+ switch (n) {
+ case 1:
+ case 2:
+ if (!msg->h_via1 && (parse_headers(msg,HDR_VIA_F,0)==-1 || !msg->h_via1))
{
+ DBG("bad msg or missing VIA1 header \n");
+ return -1;
+ }
+ pp = msg->h_via1->parsed;
+ if (n==1) break;
+ pp = pp->next;
+ if (pp) break;
+
+ if (!msg->h_via2 && (parse_headers(msg,HDR_VIA2_F,0)==-1 ||
!msg->h_via2)) {
+ DBG("bad msg or missing VIA2 header \n");
+ return -1;
+ }
+ pp = msg->h_via2->parsed;
+ break;
+ default:
+ if (!msg->eoh && (parse_headers(msg,HDR_EOH_F,0)==-1 ||
!msg->eoh)) {
+ ERR("bad msg while parsing to EOH \n");
+ return -1;
+ }
+ p = msg->h_via1;
+ i = n;
+ while (i && p) {
+ if (p->type == HDR_VIA_T) {
+ i--;
+ pp = p->parsed;
+ while (i && (pp->next)) {
+ i--;
+ pp = pp->next;
+ }
+ }
+ p = p->next;
+ }
+ if (i > 0) {
+ DBG("missing VIA[%d] header\n", n);
+ return -1;
+ }
+ }
+ if (pp) {
+ *q = pp;
+ return 0;
+ } else
+ return -1;
+}
+
diff --git a/parser/parse_via.h b/parser/parse_via.h
index 9f899a0..5c7f3c1 100644
--- a/parser/parse_via.h
+++ b/parser/parse_via.h
@@ -48,6 +48,8 @@
#include "../str.h"
+struct sip_msg;
+
/* via param types
* WARNING: keep in sync with parse_via.c FIN_HIDDEN...
* and with tm/sip_msg.c via_body_cloner
@@ -124,4 +126,10 @@ char* parse_via(char* buffer, char* end, struct via_body *vb);
void free_via_list(struct via_body *vb);
+/*
+ * Get one Via header
+ */
+int parse_via_header( struct sip_msg *msg, int n, struct via_body** q);
+
+
#endif /* PARSE_VIA_H */
diff --git a/select_core.c b/select_core.c
index ea9d5a1..94fa162 100644
--- a/select_core.c
+++ b/select_core.c
@@ -332,60 +332,6 @@ int select_contact_params(str* res, select_t* s, struct sip_msg*
msg)
return 1;
}
-int parse_via_header( struct sip_msg *msg, int n, struct via_body** q)
-{
- struct hdr_field *p;
- struct via_body *pp = NULL;
- int i;
-
- switch (n) {
- case 1:
- case 2:
- if (!msg->h_via1 && (parse_headers(msg,HDR_VIA_F,0)==-1 || !msg->h_via1))
{
- DBG("bad msg or missing VIA1 header \n");
- return -1;
- }
- pp = msg->h_via1->parsed;
- if (n==1) break;
- pp = pp->next;
- if (pp) break;
-
- if (!msg->h_via2 && (parse_headers(msg,HDR_VIA2_F,0)==-1 ||
!msg->h_via2)) {
- DBG("bad msg or missing VIA2 header \n");
- return -1;
- }
- pp = msg->h_via2->parsed;
- break;
- default:
- if (!msg->eoh && (parse_headers(msg,HDR_EOH_F,0)==-1 ||
!msg->eoh)) {
- ERR("bad msg while parsing to EOH \n");
- return -1;
- }
- p = msg->h_via1;
- i = n;
- while (i && p) {
- if (p->type == HDR_VIA_T) {
- i--;
- pp = p->parsed;
- while (i && (pp->next)) {
- i--;
- pp = pp->next;
- }
- }
- p = p->next;
- }
- if (i > 0) {
- DBG("missing VIA[%d] header\n", n);
- return -1;
- }
- }
- if (pp) {
- *q = pp;
- return 0;
- } else
- return -1;
-}
-
int select_via(str* res, select_t* s, struct sip_msg* msg)
{
struct via_body *p = NULL;