Quellcode durchsuchen

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.
pd vor 14 Jahren
Ursprung
Commit
1265533a48

+ 1 - 1
modules_k/xcap_client/xcap_callbacks.h

@@ -38,7 +38,7 @@
 #define XCAP_CAPS          1<<5
 #define XCAP_CAPS          1<<5
 #define USER_PROFILE       1<<6
 #define USER_PROFILE       1<<6
 #define PRES_CONTENT       1<<7
 #define PRES_CONTENT       1<<7
-
+#define SEARCH             1<<8
 
 
 /* callback function prototype */
 /* callback function prototype */
 typedef int (xcap_cb)(int doc_type, str xid, char* doc);
 typedef int (xcap_cb)(int doc_type, str xid, char* doc);

+ 2 - 1
modules_k/xcap_server/README

@@ -263,7 +263,8 @@ event_route[xhttp:request] {
 5. Exported pseudo-variables
 5. Exported pseudo-variables
 
 
      * $xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key
      * $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
    Exported pseudo-variables are documented at
    http://www.kamailio.org/dokuwiki/.
    http://www.kamailio.org/dokuwiki/.

+ 1 - 1
modules_k/xcap_server/doc/xcap_server_admin.xml

@@ -307,7 +307,7 @@ event_route[xhttp:request] {
 			<listitem><para>
 			<listitem><para>
 				<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
 				<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
 				to idenitfy the XCAP uri; key can be: data, uri, root, auid,
 				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>
 			</para></listitem>
 		</itemizedlist>
 		</itemizedlist>
 		<para>
 		<para>

+ 50 - 0
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");
 		LM_DBG("matched oma pres-content\n");
 		xuri->type = PRES_CONTENT;
 		xuri->type = PRES_CONTENT;
 		xuri->auid.len = 35;
 		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 {
 	} else {
 		LM_ERR("unsupported auid in [%.*s]\n", xuri->uri.len,
 		LM_ERR("unsupported auid in [%.*s]\n", xuri->uri.len,
 				xuri->uri.s);
 				xuri->uri.s);
@@ -707,6 +743,10 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)
 		pxs->ktype = 7;
 		pxs->ktype = 7;
 	} else if(pxs->key.len==4 && strncmp(pxs->key.s, "node", 4)==0) {
 	} else if(pxs->key.len==4 && strncmp(pxs->key.s, "node", 4)==0) {
 		pxs->ktype = 8;
 		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 {
 	} else {
 		LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
 		LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
 		goto error;
 		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)
 			if(pxs->xus->xuri.node.len>0)
 				return pv_get_strval(msg, param, res, &pxs->xus->xuri.node);
 				return pv_get_strval(msg, param, res, &pxs->xus->xuri.node);
 		break;
 		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:
 		default:
 			return pv_get_null(msg, param, res);
 			return pv_get_null(msg, param, res);
 	}
 	}

+ 2 - 0
modules_k/xcap_server/xcap_misc.h

@@ -46,6 +46,8 @@ typedef struct xcap_uri {
 	str rdoc;
 	str rdoc;
 	char *nss;
 	char *nss;
 	str node;
 	str node;
+	str target;
+	str domain;
 } xcap_uri_t;
 } xcap_uri_t;
 
 
 int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);
 int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);

+ 18 - 10
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};
 static str xcaps_str_appxcxml   = {"application/xcap-caps+xml", 25};
 #endif
 #endif
 static str xcaps_str_appapxml   = {"application/auth-policy+xml", 27};
 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_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;
 		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;
 		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;
 		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;
 		goto done;
 	}
 	}