Module: sip-router Branch: master Commit: fecefaf10f6fc4d9bfd6cf7fec4312ea8c8479ec URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fecefaf1...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Wed Feb 8 10:19:00 2012 +0100
parser/uri: support for URN
- uri parser has support for URNs (e.g. urn:service:sos.fire) - t_relay does not break on RURI with URNs - PVs are set as follows: $ru= "urn:service:sos.fire" $rz= "urn" $rU= "service" $rd= "sos.fire" - refer to http://tools.ietf.org/html/draft-ietf-ecrit-framework-13#page-29 for SIP signaling requirements for SIP proxy servers. - patch by Wolfgang Kampichler, closes FS#201
---
parser/msg_parser.h | 2 +- parser/parse_uri.c | 19 +++++++++++++++++-- parser/parse_uri.h | 3 +-- 3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/parser/msg_parser.h b/parser/msg_parser.h index eee2948..44f5adb 100644 --- a/parser/msg_parser.h +++ b/parser/msg_parser.h @@ -174,7 +174,7 @@ if ( (*tmp==(firstchar) || *tmp==((firstchar) | 32)) && \ (((m)->new_uri.s && (m)->new_uri.len) ? (&(m)->new_uri) : (&(m)->first_line.u.request.uri))
-enum _uri_type{ERROR_URI_T=0, SIP_URI_T, SIPS_URI_T, TEL_URI_T, TELS_URI_T}; +enum _uri_type{ERROR_URI_T=0, SIP_URI_T, SIPS_URI_T, TEL_URI_T, TELS_URI_T, URN_URI_T}; typedef enum _uri_type uri_type; enum _uri_flags{ URI_USER_NORMALIZE=1, diff --git a/parser/parse_uri.c b/parser/parse_uri.c index affe44f..e6cedcf 100644 --- a/parser/parse_uri.c +++ b/parser/parse_uri.c @@ -132,6 +132,7 @@ int parse_uri(char* buf, int len, struct sip_uri* uri) #define SIP_SCH 0x3a706973 #define SIPS_SCH 0x73706973 #define TEL_SCH 0x3a6c6574 +#define URN_SCH 0x3a6e7275 #define case_port( ch, var) \ case ch: \ @@ -381,7 +382,7 @@ int parse_uri(char* buf, int len, struct sip_uri* uri) port_no=0; state=URI_INIT; memset(uri, 0, sizeof(struct sip_uri)); /* zero it all, just to be sure*/ - /*look for sip:, sips: or tel:*/ + /*look for sip:, sips: ,tel: or urn:*/ if (len<5) goto error_too_short; scheme=buf[0]+(buf[1]<<8)+(buf[2]<<16)+(buf[3]<<24); scheme|=0x20202020; @@ -392,6 +393,8 @@ int parse_uri(char* buf, int len, struct sip_uri* uri) else goto error_bad_uri; }else if (scheme==TEL_SCH){ uri->type=TEL_URI_T; + }else if (scheme==URN_SCH){ + uri->type=URN_URI_T; }else goto error_bad_uri; s=p; @@ -955,8 +958,13 @@ int parse_uri(char* buf, int len, struct sip_uri* uri) uri->user.len=0; break; case URI_PASSWORD_ALPHA: + /* it might be an urn, check scheme and set host */ + if (scheme==URN_SCH){ + uri->host.s=s; + uri->host.len=p-s; + DBG("parsed urn scheme...\n"); /* this is the port, it can't be the passwd */ - goto error_bad_port; + }else goto error_bad_port; case URI_HOST_P: case URI_HOST6_END: uri->host.s=s; @@ -1140,6 +1148,9 @@ int parse_uri(char* buf, int len, struct sip_uri* uri) uri->host.s=""; uri->host.len=0; break; + /* urn: do nothing */ + case URN_URI_T: + break; case ERROR_URI_T: LOG(L_ERR, "ERROR: parse_uri unexpected error (BUG?)\n"); goto error_bad_uri; @@ -1302,6 +1313,7 @@ str s_sip = STR_STATIC_INIT("sip"); str s_sips = STR_STATIC_INIT("sips"); str s_tel = STR_STATIC_INIT("tel"); str s_tels = STR_STATIC_INIT("tels"); +str s_urn = STR_STATIC_INIT("urn"); static str s_null = STR_STATIC_INIT("");
inline void uri_type_to_str(uri_type type, str *s) { @@ -1318,6 +1330,9 @@ inline void uri_type_to_str(uri_type type, str *s) { case TELS_URI_T: *s = s_tels; break; + case URN_URI_T: + *s = s_urn; + break; default: *s = s_null; } diff --git a/parser/parse_uri.h b/parser/parse_uri.h index b949966..0dbc4c7 100644 --- a/parser/parse_uri.h +++ b/parser/parse_uri.h @@ -37,8 +37,7 @@ #include "../str.h" #include "../parser/msg_parser.h"
- -extern str s_sip, s_sips, s_tel, s_tels; +extern str s_sip, s_sips, s_tel, s_tels, s_urn;
/* buf= pointer to begining of uri (sip:x@foo.bar:5060;a=b?h=i) * len= len of uri