[sr-dev] git:master: xcap_server(k): Added support for the org.openmobilealliance. search auid.

Peter Dunkley peter.dunkley at crocodile-rcs.com
Thu Jul 21 16:34:19 CEST 2011


Module: sip-router
Branch: master
Commit: 1265533a48ac444e950626702f8b6c3e5e29951e
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1265533a48ac444e950626702f8b6c3e5e29951e

Author: pd <peter.dunkley at crocodile-rcs.com>
Committer: pd <peter.dunkley at crocodile-rcs.com>
Date:   Thu Jul 21 15:28:42 2011 +0100

xcap_server(k): Added support for the org.openmobilealliance.search auid.

- This update does not perform searches, it just modifies XCAP so that it
  recognises and decodes the search auid correctly and doesn't report an
  error when one arrives.

  The mandatory target and optional domains parameters are decoded into new
  keys within the xcapuri pseudo-variable.

  Unlike other XCAP requests the org.openmobilealliance.search auid is only
  used within HTTP POSTs - so if using this kamailio.cfg should be updated to
  handle these.

---

 modules_k/xcap_client/xcap_callbacks.h          |    2 +-
 modules_k/xcap_server/README                    |    3 +-
 modules_k/xcap_server/doc/xcap_server_admin.xml |    2 +-
 modules_k/xcap_server/xcap_misc.c               |   50 +++++++++++++++++++++++
 modules_k/xcap_server/xcap_misc.h               |    2 +
 modules_k/xcap_server/xcap_server.c             |   28 ++++++++-----
 6 files changed, 74 insertions(+), 13 deletions(-)

diff --git a/modules_k/xcap_client/xcap_callbacks.h b/modules_k/xcap_client/xcap_callbacks.h
index 13b5a8f..5052869 100644
--- a/modules_k/xcap_client/xcap_callbacks.h
+++ b/modules_k/xcap_client/xcap_callbacks.h
@@ -38,7 +38,7 @@
 #define XCAP_CAPS          1<<5
 #define USER_PROFILE       1<<6
 #define PRES_CONTENT       1<<7
-
+#define SEARCH             1<<8
 
 /* callback function prototype */
 typedef int (xcap_cb)(int doc_type, str xid, char* doc);
diff --git a/modules_k/xcap_server/README b/modules_k/xcap_server/README
index 6c24bd1..aca4a04 100644
--- a/modules_k/xcap_server/README
+++ b/modules_k/xcap_server/README
@@ -263,7 +263,8 @@ event_route[xhttp:request] {
 5. Exported pseudo-variables
 
      * $xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key
-       can be: data, uri, root, auid, type, tree, xuid, file, node.
+       can be: data, uri, root, auid, type, tree, xuid, file, node,
+       target, domain.
 
    Exported pseudo-variables are documented at
    http://www.kamailio.org/dokuwiki/.
diff --git a/modules_k/xcap_server/doc/xcap_server_admin.xml b/modules_k/xcap_server/doc/xcap_server_admin.xml
index 3e677df..c690557 100644
--- a/modules_k/xcap_server/doc/xcap_server_admin.xml
+++ b/modules_k/xcap_server/doc/xcap_server_admin.xml
@@ -307,7 +307,7 @@ event_route[xhttp:request] {
 			<listitem><para>
 				<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
 				to idenitfy the XCAP uri; key can be: data, uri, root, auid,
-				type, tree, xuid, file, node.
+				type, tree, xuid, file, node, target, domain.
 			</para></listitem>
 		</itemizedlist>
 		<para>
diff --git a/modules_k/xcap_server/xcap_misc.c b/modules_k/xcap_server/xcap_misc.c
index 82b0171..57abf3f 100644
--- a/modules_k/xcap_server/xcap_misc.c
+++ b/modules_k/xcap_server/xcap_misc.c
@@ -161,6 +161,42 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri)
 		LM_DBG("matched oma pres-content\n");
 		xuri->type = PRES_CONTENT;
 		xuri->auid.len = 35;
+	} else if(s.len> 30 && strncmp(s.s, "org.openmobilealliance.search?", 30)==0) {
+		LM_DBG("matched oma search\n");
+		xuri->type = SEARCH;
+		xuri->auid.len = 29;
+
+		s.s   += xuri->auid.len + 1;
+		s.len -= xuri->auid.len + 1;
+
+		/* target */
+		if (s.len>7 && strncmp(s.s, "target=", 7)==0) {
+			LM_DBG("matched target=\n");
+			s.s   += 7;
+			s.len -= 7;
+			xuri->target.s = s.s;
+			p = strchr(s.s, '&');
+			if (p==NULL) {
+				xuri->target.len = s.len;
+			} else {
+				xuri->target.len = p - xuri->target.s;
+			}
+			s.s   += xuri->target.len + 1;
+			s.len -= xuri->target.len+1;
+			LM_DBG("target=%.*s\n", xuri->target.len, xuri->target.s);
+		}
+
+		/* domain */
+		if (s.len>7 && strncmp(s.s, "domain=", 7)==0) {
+			LM_DBG("matched domain=\n");
+			s.s   += 7;
+			s.len -= 7;
+			xuri->domain.s = s.s;
+			xuri->domain.len = s.len;
+			LM_DBG("domain=%.*s\n", xuri->domain.len, xuri->domain.s);
+		}
+
+		return 0;
 	} else {
 		LM_ERR("unsupported auid in [%.*s]\n", xuri->uri.len,
 				xuri->uri.s);
@@ -707,6 +743,10 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)
 		pxs->ktype = 7;
 	} else if(pxs->key.len==4 && strncmp(pxs->key.s, "node", 4)==0) {
 		pxs->ktype = 8;
+	} else if(pxs->key.len==6 && strncmp(pxs->key.s, "target", 6)==0) {
+		pxs->ktype = 9;
+	} else if(pxs->key.len==6 && strncmp(pxs->key.s, "domain", 6)==0) {
+		pxs->ktype = 10;
 	} else {
 		LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
 		goto error;
@@ -801,6 +841,16 @@ int pv_get_xcap_uri(struct sip_msg *msg,  pv_param_t *param,
 			if(pxs->xus->xuri.node.len>0)
 				return pv_get_strval(msg, param, res, &pxs->xus->xuri.node);
 		break;
+		case 9:
+			/* get target */
+			if(pxs->xus->xuri.target.len>0)
+				return pv_get_strval(msg, param, res, &pxs->xus->xuri.target);
+		break;
+		case 10:
+			/* get domain */
+			if(pxs->xus->xuri.domain.len>0)
+				return pv_get_strval(msg, param, res, &pxs->xus->xuri.domain);
+		break;
 		default:
 			return pv_get_null(msg, param, res);
 	}
diff --git a/modules_k/xcap_server/xcap_misc.h b/modules_k/xcap_server/xcap_misc.h
index 78c92a0..ab7ed0f 100644
--- a/modules_k/xcap_server/xcap_misc.h
+++ b/modules_k/xcap_server/xcap_misc.h
@@ -46,6 +46,8 @@ typedef struct xcap_uri {
 	str rdoc;
 	char *nss;
 	str node;
+	str target;
+	str domain;
 } xcap_uri_t;
 
 int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);
diff --git a/modules_k/xcap_server/xcap_server.c b/modules_k/xcap_server/xcap_server.c
index d961224..1a041e3 100644
--- a/modules_k/xcap_server/xcap_server.c
+++ b/modules_k/xcap_server/xcap_server.c
@@ -410,8 +410,9 @@ static str xcaps_str_nocontent  = {"No content", 10};
 static str xcaps_str_appxcxml   = {"application/xcap-caps+xml", 25};
 #endif
 static str xcaps_str_appapxml   = {"application/auth-policy+xml", 27};
-static str xcaps_str_appupxml	= {"application/vnd.oma.user-profile+xml", 36};
+static str xcaps_str_appupxml	= {"application/vnd.oma.user-profile+xml", 36}; 
 static str xcaps_str_apppcxml	= {"application/vnd.oma.pres-content+xml", 36};
+static str xcaps_str_appsexml	= {"application/vnd.oma.search+xml", 30};
 
 
 /**
@@ -1045,24 +1046,31 @@ int xcaps_path_get_auid_type(str *path)
 		goto done;
 	}
 
-	if(s.len>11 && strstr(s.s, "/xcap-caps/")!=NULL)
+        if(s.len>11 && strstr(s.s, "/xcap-caps/")!=NULL)
 	{
-		LM_DBG("matched xcap-caps\n");
-		ret = XCAP_CAPS;
+                LM_DBG("matched xcap-caps\n");
+                ret = XCAP_CAPS;
 		goto done;
 	}
 
-	if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.user-profile/")!=NULL)
+        if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.user-profile/")!=NULL)
 	{
-		LM_DBG("matched oma user-profile\n");
-		ret = USER_PROFILE;
+                LM_DBG("matched oma user-profile\n");
+                ret = USER_PROFILE;
 		goto done;
 	}
 
-	if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.pres-content/")!=NULL)
+        if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.pres-content/")!=NULL)
 	{
-		LM_DBG("matched oma pres-content\n");
-		ret = PRES_CONTENT;
+                LM_DBG("matched oma pres-content\n");
+                ret = PRES_CONTENT;
+		goto done;
+	}
+
+	if(s.len>31 && strstr(s.s, "/org.openmobilealliance.search?")!=NULL)
+	{
+                LM_DBG("matched oma search\n");
+                ret = SEARCH;
 		goto done;
 	}
 




More information about the sr-dev mailing list