Browse code

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 authored on 21/07/2011 14:28:42
Showing 6 changed files
... ...
@@ -38,7 +38,7 @@
38 38
 #define XCAP_CAPS          1<<5
39 39
 #define USER_PROFILE       1<<6
40 40
 #define PRES_CONTENT       1<<7
41
-
41
+#define SEARCH             1<<8
42 42
 
43 43
 /* callback function prototype */
44 44
 typedef int (xcap_cb)(int doc_type, str xid, char* doc);
... ...
@@ -263,7 +263,8 @@ event_route[xhttp:request] {
263 263
 5. Exported pseudo-variables
264 264
 
265 265
      * $xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key
266
-       can be: data, uri, root, auid, type, tree, xuid, file, node.
266
+       can be: data, uri, root, auid, type, tree, xuid, file, node,
267
+       target, domain.
267 268
 
268 269
    Exported pseudo-variables are documented at
269 270
    http://www.kamailio.org/dokuwiki/.
... ...
@@ -307,7 +307,7 @@ event_route[xhttp:request] {
307 307
 			<listitem><para>
308 308
 				<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
309 309
 				to idenitfy the XCAP uri; key can be: data, uri, root, auid,
310
-				type, tree, xuid, file, node.
310
+				type, tree, xuid, file, node, target, domain.
311 311
 			</para></listitem>
312 312
 		</itemizedlist>
313 313
 		<para>
... ...
@@ -161,6 +161,42 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri)
161 161
 		LM_DBG("matched oma pres-content\n");
162 162
 		xuri->type = PRES_CONTENT;
163 163
 		xuri->auid.len = 35;
164
+	} else if(s.len> 30 && strncmp(s.s, "org.openmobilealliance.search?", 30)==0) {
165
+		LM_DBG("matched oma search\n");
166
+		xuri->type = SEARCH;
167
+		xuri->auid.len = 29;
168
+
169
+		s.s   += xuri->auid.len + 1;
170
+		s.len -= xuri->auid.len + 1;
171
+
172
+		/* target */
173
+		if (s.len>7 && strncmp(s.s, "target=", 7)==0) {
174
+			LM_DBG("matched target=\n");
175
+			s.s   += 7;
176
+			s.len -= 7;
177
+			xuri->target.s = s.s;
178
+			p = strchr(s.s, '&');
179
+			if (p==NULL) {
180
+				xuri->target.len = s.len;
181
+			} else {
182
+				xuri->target.len = p - xuri->target.s;
183
+			}
184
+			s.s   += xuri->target.len + 1;
185
+			s.len -= xuri->target.len+1;
186
+			LM_DBG("target=%.*s\n", xuri->target.len, xuri->target.s);
187
+		}
188
+
189
+		/* domain */
190
+		if (s.len>7 && strncmp(s.s, "domain=", 7)==0) {
191
+			LM_DBG("matched domain=\n");
192
+			s.s   += 7;
193
+			s.len -= 7;
194
+			xuri->domain.s = s.s;
195
+			xuri->domain.len = s.len;
196
+			LM_DBG("domain=%.*s\n", xuri->domain.len, xuri->domain.s);
197
+		}
198
+
199
+		return 0;
164 200
 	} else {
165 201
 		LM_ERR("unsupported auid in [%.*s]\n", xuri->uri.len,
166 202
 				xuri->uri.s);
... ...
@@ -707,6 +743,10 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)
707 707
 		pxs->ktype = 7;
708 708
 	} else if(pxs->key.len==4 && strncmp(pxs->key.s, "node", 4)==0) {
709 709
 		pxs->ktype = 8;
710
+	} else if(pxs->key.len==6 && strncmp(pxs->key.s, "target", 6)==0) {
711
+		pxs->ktype = 9;
712
+	} else if(pxs->key.len==6 && strncmp(pxs->key.s, "domain", 6)==0) {
713
+		pxs->ktype = 10;
710 714
 	} else {
711 715
 		LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
712 716
 		goto error;
... ...
@@ -801,6 +841,16 @@ int pv_get_xcap_uri(struct sip_msg *msg,  pv_param_t *param,
801 801
 			if(pxs->xus->xuri.node.len>0)
802 802
 				return pv_get_strval(msg, param, res, &pxs->xus->xuri.node);
803 803
 		break;
804
+		case 9:
805
+			/* get target */
806
+			if(pxs->xus->xuri.target.len>0)
807
+				return pv_get_strval(msg, param, res, &pxs->xus->xuri.target);
808
+		break;
809
+		case 10:
810
+			/* get domain */
811
+			if(pxs->xus->xuri.domain.len>0)
812
+				return pv_get_strval(msg, param, res, &pxs->xus->xuri.domain);
813
+		break;
804 814
 		default:
805 815
 			return pv_get_null(msg, param, res);
806 816
 	}
... ...
@@ -46,6 +46,8 @@ typedef struct xcap_uri {
46 46
 	str rdoc;
47 47
 	char *nss;
48 48
 	str node;
49
+	str target;
50
+	str domain;
49 51
 } xcap_uri_t;
50 52
 
51 53
 int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);
... ...
@@ -410,8 +410,9 @@ static str xcaps_str_nocontent  = {"No content", 10};
410 410
 static str xcaps_str_appxcxml   = {"application/xcap-caps+xml", 25};
411 411
 #endif
412 412
 static str xcaps_str_appapxml   = {"application/auth-policy+xml", 27};
413
-static str xcaps_str_appupxml	= {"application/vnd.oma.user-profile+xml", 36};
413
+static str xcaps_str_appupxml	= {"application/vnd.oma.user-profile+xml", 36}; 
414 414
 static str xcaps_str_apppcxml	= {"application/vnd.oma.pres-content+xml", 36};
415
+static str xcaps_str_appsexml	= {"application/vnd.oma.search+xml", 30};
415 416
 
416 417
 
417 418
 /**
... ...
@@ -1045,24 +1046,31 @@ int xcaps_path_get_auid_type(str *path)
1045 1045
 		goto done;
1046 1046
 	}
1047 1047
 
1048
-	if(s.len>11 && strstr(s.s, "/xcap-caps/")!=NULL)
1048
+        if(s.len>11 && strstr(s.s, "/xcap-caps/")!=NULL)
1049 1049
 	{
1050
-		LM_DBG("matched xcap-caps\n");
1051
-		ret = XCAP_CAPS;
1050
+                LM_DBG("matched xcap-caps\n");
1051
+                ret = XCAP_CAPS;
1052 1052
 		goto done;
1053 1053
 	}
1054 1054
 
1055
-	if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.user-profile/")!=NULL)
1055
+        if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.user-profile/")!=NULL)
1056 1056
 	{
1057
-		LM_DBG("matched oma user-profile\n");
1058
-		ret = USER_PROFILE;
1057
+                LM_DBG("matched oma user-profile\n");
1058
+                ret = USER_PROFILE;
1059 1059
 		goto done;
1060 1060
 	}
1061 1061
 
1062
-	if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.pres-content/")!=NULL)
1062
+        if(s.len> 37 && strstr(s.s, "/org.openmobilealliance.pres-content/")!=NULL)
1063 1063
 	{
1064
-		LM_DBG("matched oma pres-content\n");
1065
-		ret = PRES_CONTENT;
1064
+                LM_DBG("matched oma pres-content\n");
1065
+                ret = PRES_CONTENT;
1066
+		goto done;
1067
+	}
1068
+
1069
+	if(s.len>31 && strstr(s.s, "/org.openmobilealliance.search?")!=NULL)
1070
+	{
1071
+                LM_DBG("matched oma search\n");
1072
+                ret = SEARCH;
1066 1073
 		goto done;
1067 1074
 	}
1068 1075