[sr-dev] git:master:deb0e811: kazoo: only create tags if not empty

Luis Azedo luis at 2600hz.com
Mon Mar 9 13:47:49 CET 2015


Module: kamailio
Branch: master
Commit: deb0e811cddd71c45ebb36db7b41faa8d9e9ca5e
URL: https://github.com/kamailio/kamailio/commit/deb0e811cddd71c45ebb36db7b41faa8d9e9ca5e

Author: Luis Azedo <luis at 2600hz.com>
Committer: Luis Azedo <luis at 2600hz.com>
Date: 2015-03-09T12:47:31Z

kazoo: only create tags if not empty

to-tag and from-tag are created empty if not supplied in amp payload
this patch formats the dialog message to include the tags only if they are supplied in amp payload

---

Modified: modules/kazoo/defs.h
Modified: modules/kazoo/kz_pua.c

---

Diff:  https://github.com/kamailio/kamailio/commit/deb0e811cddd71c45ebb36db7b41faa8d9e9ca5e.diff
Patch: https://github.com/kamailio/kamailio/commit/deb0e811cddd71c45ebb36db7b41faa8d9e9ca5e.patch

---

diff --git a/modules/kazoo/defs.h b/modules/kazoo/defs.h
index 01d9af4..e7f991d 100644
--- a/modules/kazoo/defs.h
+++ b/modules/kazoo/defs.h
@@ -69,14 +69,17 @@
 
 #define DIALOGINFO_EMPTY_BODY "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
 <dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"1\" state=\"full\" entity=\"%.*s\"> \
-<dialog direction=\"initiator\">\
+<dialog call-id=\"76001e23e09704ea9e1257ebea85e1f3\" direction=\"initiator\">\
 <state>terminated</state>\
 </dialog>\
 </dialog-info>"
 
+#define LOCAL_TAG "local-tag=\"%.*s\""
+#define REMOTE_TAG "remote-tag=\"%.*s\""
+
 #define DIALOGINFO_BODY "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
 <dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"1\" state=\"full\" entity=\"%.*s\">\
-<dialog id=\"%.*s\" call-id=\"%.*s\" local-tag=\"%.*s\" remote-tag=\"%.*s\" direction=\"%.*s\">\
+<dialog id=\"%.*s\" call-id=\"%.*s\" %.*s %.*s direction=\"%.*s\">\
 <state>%.*s</state>\
 <local>\
 <identity display=\"%.*s\">%.*s</identity>\
@@ -91,7 +94,7 @@
 
 #define DIALOGINFO_BODY_2 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
 <dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"1\" state=\"full\" entity=\"%.*s\">\
-<dialog id=\"%.*s\" call-id=\"%.*s\" local-tag=\"%.*s\" remote-tag=\"%.*s\" direction=\"%.*s\">\
+<dialog id=\"%.*s\" call-id=\"%.*s\" %.*s %.*s direction=\"%.*s\">\
 <state>%.*s</state>\
 <local>\
 <identity display=\"%.*s\">%.*s</identity>\
diff --git a/modules/kazoo/kz_pua.c b/modules/kazoo/kz_pua.c
index 562a060..d9757a7 100644
--- a/modules/kazoo/kz_pua.c
+++ b/modules/kazoo/kz_pua.c
@@ -320,6 +320,8 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     int expires = 0;
     str event = str_init("dialog");
     int reset = 0;
+    char to_tag_buffer[100];
+    char from_tag_buffer[100];
 
     char *body = (char *)pkg_malloc(DIALOGINFO_BODY_BUFFER_SIZE);
     if(body == NULL) {
@@ -375,6 +377,16 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     if(!to_uri.len)
     	to_uri = to;
 
+    if(fromtag.len > 0) {
+    	fromtag.len = sprintf(from_tag_buffer, LOCAL_TAG, fromtag.len, fromtag.s);
+    	fromtag.s = from_tag_buffer;
+    }
+
+    if(totag.len > 0) {
+    	totag.len = sprintf(to_tag_buffer, REMOTE_TAG, totag.len, totag.s);
+    	totag.s = to_tag_buffer;
+    }
+
     if(callid.len) {
 
     	if(dbk_include_entity) {




More information about the sr-dev mailing list