diff --git a/src/modules/siputils/contact_ops.c b/src/modules/siputils/contact_ops.c index 5183f40ab65..bc48a8771bc 100644 --- a/src/modules/siputils/contact_ops.c +++ b/src/modules/siputils/contact_ops.c @@ -44,7 +44,7 @@ #include -int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip) +int ki_encode_contact (sip_msg_t *msg, str *eprefix, str *eaddr) { contact_body_t *cb; contact_t *c; @@ -85,7 +85,7 @@ int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip) /* we visit each contact */ if(c != NULL) { uri = c->uri; - res = encode_uri(uri, encoding_prefix, public_ip, separator, &newUri); + res = encode_uri(uri, eprefix->s, eaddr->s, separator, &newUri); if(res != 0) { LM_ERR("failed encoding contact.Code %d\n", res); @@ -103,8 +103,7 @@ int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip) c = c->next; uri = c->uri; - res = encode_uri( - uri, encoding_prefix, public_ip, separator, &newUri); + res = encode_uri(uri, eprefix->s, eaddr->s, separator, &newUri); if(res != 0) { LM_ERR("failed encode_uri.Code %d\n", res); #ifdef STRICT_CHECK @@ -121,8 +120,20 @@ int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip) return 1; } - int -decode_contact (struct sip_msg *msg,char *unused1,char *unused2) +int encode_contact(sip_msg_t *msg, char *encoding_prefix, char *public_ip) +{ + str eprefix = STR_NULL; + str eaddr = STR_NULL; + + eprefix.s = encoding_prefix; + eprefix.len = strlen(eprefix.s); + eaddr.s = public_ip; + eaddr.len = strlen(eaddr.s); + + return ki_encode_contact(msg, &eprefix, &eaddr); +} + +int ki_decode_contact(sip_msg_t *msg) { str uri; @@ -177,8 +188,12 @@ decode_contact (struct sip_msg *msg,char *unused1,char *unused2) return 1; } - int -decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2) +int decode_contact(sip_msg_t *msg, char *unused1, char *unused2) +{ + return ki_decode_contact(msg); +} + +int ki_decode_contact_header(sip_msg_t *msg) { contact_body_t *cb; @@ -255,6 +270,10 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2) } +int decode_contact_header(sip_msg_t *msg, char *unused1, char *unused2) +{ + return ki_decode_contact_header(msg); +} int diff --git a/src/modules/siputils/contact_ops.h b/src/modules/siputils/contact_ops.h index ef925c761bf..939b80ac6c1 100644 --- a/src/modules/siputils/contact_ops.h +++ b/src/modules/siputils/contact_ops.h @@ -64,6 +64,9 @@ struct uri_format typedef struct uri_format contact_fields_t; +int ki_encode_contact (sip_msg_t *msg, str *eprefix, str *eaddr); +int ki_decode_contact(sip_msg_t *msg); +int ki_decode_contact_header(sip_msg_t *msg); int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip); int decode_contact (struct sip_msg *msg, char *unused1,char *unused2); diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c index aa847ae9c4b..e9593da3b40 100644 --- a/src/modules/siputils/siputils.c +++ b/src/modules/siputils/siputils.c @@ -546,6 +546,21 @@ static sr_kemi_t sr_kemi_siputils_exports[] = { { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init("siputils"), str_init("encode_contact"), + SR_KEMIP_INT, ki_encode_contact, + { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("siputils"), str_init("decode_contact"), + SR_KEMIP_INT, ki_decode_contact, + { SR_KEMIP_NULL, SR_KEMIP_NULL, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("siputils"), str_init("decode_contact_header"), + SR_KEMIP_INT, ki_decode_contact_header, + { SR_KEMIP_NULL, SR_KEMIP_NULL, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } };