Skip to content

Commit

Permalink
Add support for urn:nena:service URI scheme
Browse files Browse the repository at this point in the history
Thanks go to Carl Lemieux from Comtechtel for providing the patch for
this
  • Loading branch information
razvancrainea committed Jan 8, 2020
1 parent 6862850 commit a1689c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion parser/msg_parser.h
Expand Up @@ -158,7 +158,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, URN_SERVICE_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, URN_NENA_SERVICE_URI_T};
typedef enum _uri_type uri_type;

struct sip_uri {
Expand Down
20 changes: 17 additions & 3 deletions parser/parse_uri.c
Expand Up @@ -43,13 +43,14 @@
#include "../core_stats.h"
#include "../strcommon.h"

static const str uri_type_names[6] = {
static const str uri_type_names[7] = {
{NULL, 0}, /*This is the error type*/
str_init("sip"),
str_init("sips"),
str_init("tel"),
str_init("tels"),
str_init("urn:service")
str_init("urn:service"),
str_init("urn:nena:service")
};

char* uri_type2str(const uri_type type, char *result)
Expand Down Expand Up @@ -84,6 +85,9 @@ uri_type str2uri_type(char * buf)
if (memcmp(buf+3,URN_SERVICE_STR,URN_SERVICE_STR_LEN) == 0) {
type=URN_SERVICE_URI_T;
}
else if (memcmp(buf+3,URN_NENA_SERVICE_STR,URN_NENA_SERVICE_STR_LEN) == 0) {
type=URN_NENA_SERVICE_URI_T;
}
}
return type;
}
Expand Down Expand Up @@ -623,7 +627,11 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
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 if (memcmp(buf+3,URN_NENA_SERVICE_STR,URN_NENA_SERVICE_STR_LEN) == 0) {
p+= URN_NENA_SERVICE_STR_LEN-1;
uri->type=URN_NENA_SERVICE_URI_T;
}else goto error_bad_uri;
}else goto error_bad_uri;

s=p;
Expand Down Expand Up @@ -1353,6 +1361,12 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
case URN_SERVICE_URI_T:
/* nothing to do for these URIs */
break;
case URN_NENA_SERVICE_URI_T:
uri->user.s=0;
uri->user.len=0;
uri->host.s="";
uri->host.len=0;
break;
case ERROR_URI_T:
LM_ERR("unexpected error (BUG?)\n");
goto error_bad_uri;
Expand Down
2 changes: 2 additions & 0 deletions parser/parse_uri.h
Expand Up @@ -38,6 +38,8 @@
#define URN_SERVICE_SCH 0x3a6e7275
#define URN_SERVICE_STR ":service:"
#define URN_SERVICE_STR_LEN (sizeof(URN_SERVICE_STR) - 1)
#define URN_NENA_SERVICE_STR ":nena:service:"
#define URN_NENA_SERVICE_STR_LEN (sizeof(URN_NENA_SERVICE_STR) - 1)

/* buf= pointer to beginning of uri (sip:x@foo.bar:5060;a=b?h=i)
* len= len of uri
Expand Down

0 comments on commit a1689c6

Please sign in to comment.