Skip to content

Commit

Permalink
Added support for RFC 5031 urn:service type URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
vladpaiu committed Apr 2, 2014
1 parent 6606d15 commit edef0fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion parser/msg_parser.h
Expand Up @@ -143,7 +143,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_SERVICE_URI_T};
typedef enum _uri_type uri_type;

struct sip_uri {
Expand Down
17 changes: 14 additions & 3 deletions parser/parse_uri.c
Expand Up @@ -210,9 +210,12 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
int i;
#endif

#define SIP_SCH 0x3a706973
#define SIPS_SCH 0x73706973
#define TEL_SCH 0x3a6c6574
#define SIP_SCH 0x3a706973
#define SIPS_SCH 0x73706973
#define TEL_SCH 0x3a6c6574
#define URN_SERVICE_SCH 0x3a6e7275
#define URN_SERVICE_STR ":service:"
#define URN_SERVICE_STR_LEN (sizeof(URN_SERVICE_STR) - 1)

#define case_port( ch, var) \
case ch: \
Expand Down Expand Up @@ -480,6 +483,11 @@ 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_SERVICE_SCH){
if (memcmp(buf+3,URN_SERVICE_STR,URN_SERVICE_STR_LEN) == 0) {
p+= URN_SERVICE_STR_LEN-1;
uri->type=URN_SERVICE_URI_T;
} else goto error_bad_uri;
}else goto error_bad_uri;

s=p;
Expand Down Expand Up @@ -1198,6 +1206,9 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
uri->host.s="";
uri->host.len=0;
break;
case URN_SERVICE_URI_T:
/* leave the actual service name in the URI domain part */
break;
case ERROR_URI_T:
LM_ERR("unexpected error (BUG?)\n");
goto error_bad_uri;
Expand Down

0 comments on commit edef0fd

Please sign in to comment.