Module: sip-router
Branch: master
Commit: cf4651db94cc88b6523918faed6d89e8497da2c6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cf4651d…
Author: Iñaki Baz Castillo <ibc(a)aliax.net>
Committer: Iñaki Baz Castillo <ibc(a)aliax.net>
Date: Tue Sep 13 23:59:25 2011 +0200
core: Via parser now allows any token as Via transport field.
---
ip_addr.c | 2 +
ip_addr.h | 4 +-
parser/parse_via.c | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 267 insertions(+), 4 deletions(-)
diff --git a/ip_addr.c b/ip_addr.c
index 331bfaa..502b4ea 100644
--- a/ip_addr.c
+++ b/ip_addr.c
@@ -350,6 +350,8 @@ char* proto2a(enum sip_protos proto)
return "tls";
case PROTO_SCTP:
return "sctp";
+ case PROTO_OTHER:
+ return "other";
}
return "unknown";
}
diff --git a/ip_addr.h b/ip_addr.h
index d9cbf02..86c2502 100644
--- a/ip_addr.h
+++ b/ip_addr.h
@@ -52,8 +52,8 @@
#include "dprint.h"
-enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS, PROTO_SCTP };
-#define PROTO_LAST PROTO_SCTP
+enum sip_protos { PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS, PROTO_SCTP, PROTO_OTHER
};
+#define PROTO_LAST PROTO_OTHER
#ifdef USE_COMP
enum comp_methods { COMP_NONE, COMP_SIGCOMP, COMP_SERGZ };
diff --git a/parser/parse_via.c b/parser/parse_via.c
index d17df8d..5a50673 100644
--- a/parser/parse_via.c
+++ b/parser/parse_via.c
@@ -96,6 +96,7 @@ enum {
TCP_TLS1, TCP2, FIN_TCP,
TLS2, FIN_TLS,
SCTP1, SCTP2, SCTP3, FIN_SCTP,
+ OTHER_PROTO,
L_PROTO, F_PROTO
};
@@ -1371,6 +1372,25 @@ parse_again:
vb->proto=PROTO_SCTP;
state=F_HOST; /* start looking for host*/
goto main_via;
+ case OTHER_PROTO:
+ /* finished proto parsing */
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_OTHER;
+ state=F_HOST; /* start looking for host*/
+ goto main_via;
+ case UDP1:
+ case UDP2:
+ case TCP_TLS1:
+ case TCP2:
+ case TLS2:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ /* finished proto parsing */
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_OTHER;
+ state=F_HOST; /* start looking for host*/
+ goto main_via;
case FIN_SIP:
vb->name.len=tmp-vb->name.s;
state=L_VER;
@@ -1418,6 +1438,33 @@ parse_again:
state=F_LF;
saved_state=F_HOST; /* start looking for host*/
goto main_via;
+ case FIN_SCTP:
+ /* finished proto parsing */
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_SCTP;
+ state=F_LF;
+ saved_state=F_HOST; /* start looking for host*/
+ goto main_via;
+ case OTHER_PROTO:
+ /* finished proto parsing */
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_OTHER;
+ state=F_LF;
+ saved_state=F_HOST; /* start looking for host*/
+ goto main_via;
+ case UDP1:
+ case UDP2:
+ case TCP_TLS1:
+ case TCP2:
+ case TLS2:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ /* finished proto parsing */
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_OTHER;
+ state=F_HOST; /* start looking for host*/
+ goto main_via;
case FIN_SIP:
vb->name.len=tmp-vb->name.s;
state=F_LF;
@@ -1469,6 +1516,31 @@ parse_again:
state=F_CR;
saved_state=F_HOST;
goto main_via;
+ case FIN_SCTP:
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_SCTP;
+ state=F_CR;
+ saved_state=F_HOST;
+ goto main_via;
+ case OTHER_PROTO:
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_OTHER;
+ state=F_CR;
+ saved_state=F_HOST;
+ goto main_via;
+ case UDP1:
+ case UDP2:
+ case TCP_TLS1:
+ case TCP2:
+ case TLS2:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ /* finished proto parsing */
+ vb->transport.len=tmp-vb->transport.s;
+ vb->proto=PROTO_OTHER;
+ state=F_HOST; /* start looking for host*/
+ goto main_via;
case FIN_SIP:
vb->name.len=tmp-vb->name.s;
state=F_CR;
@@ -1528,6 +1600,21 @@ parse_again:
state=SCTP1;
vb->transport.s=tmp;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1540,6 +1627,22 @@ parse_again:
case SIP1:
state=SIP2;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1562,6 +1665,19 @@ parse_again:
case SCTP3:
state=FIN_SCTP;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1575,6 +1691,22 @@ parse_again:
state=UDP1;
vb->transport.s=tmp;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1587,6 +1719,21 @@ parse_again:
case UDP1:
state=UDP2;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1603,6 +1750,21 @@ parse_again:
case SCTP2:
state=SCTP3;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1618,6 +1780,20 @@ parse_again:
case SCTP1:
state=SCTP2;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1630,6 +1806,21 @@ parse_again:
case TCP_TLS1:
state=TLS2;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1643,6 +1834,22 @@ parse_again:
state=VER1;
vb->version.s=tmp;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1654,6 +1861,22 @@ parse_again:
case VER1:
state=VER2;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
@@ -1665,17 +1888,55 @@ parse_again:
case VER2:
state=FIN_VER;
break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
" state %d\n", *tmp, state);
goto error;
}
break;
-
default:
+ switch(state){
+ case F_PROTO:
+ state=OTHER_PROTO;
+ vb->transport.s=tmp;
+ break;
+ case OTHER_PROTO:
+ break;
+ case UDP1:
+ case UDP2:
+ case FIN_UDP:
+ case TCP_TLS1:
+ case TCP2:
+ case FIN_TCP:
+ case TLS2:
+ case FIN_TLS:
+ case SCTP1:
+ case SCTP2:
+ case SCTP3:
+ case FIN_SCTP:
+ state=OTHER_PROTO;
+ break;
+ default:
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
- " state %d\n", *tmp, state);
+ " state %d\n", *tmp, state);
goto error;
+ }
break;
}
} /* for tmp*/