Lines Matching +full:wi +full:- +full:fi

2  * Hotspot 2.0 - OMA DM client
3 * Copyright (c) 2013-2014, Qualcomm Atheros, Inc.
13 #include "xml-utils.h"
14 #include "http-utils.h"
23 /* OMA-TS-SyncML-RepPro-V1_2_2 - 10. Response Status Codes */
53 "org.wi-fi.hotspot2dot0.SubscriptionCreation"
55 "org.wi-fi.hotspot2dot0.SubscriptionProvisioning"
57 "org.wi-fi.hotspot2dot0.SubscriptionRemediation"
59 "org.wi-fi.hotspot2dot0.PolicyUpdate"
61 #define DM_URI_PPS "./Wi-Fi/org.wi-fi/PerProviderSubscription"
63 "./DevDetail/Ext/org.wi-fi/Wi-Fi/Ops/launchBrowserToURI"
84 locuri = get_node(ctx->xml, node, "Item/Target/LocURI"); in oma_dm_get_target_locuri()
88 uri = xml_node_get_text(ctx->xml, locuri); in oma_dm_get_target_locuri()
91 xml_node_get_text_free(ctx->xml, uri); in oma_dm_get_target_locuri()
101 node = xml_node_create(ctx->xml, parent, NULL, element); in oma_dm_add_locuri()
104 xml_node_create_text(ctx->xml, node, NULL, "LocURI", uri); in oma_dm_add_locuri()
114 if (!ctx->devid) { in oma_dm_build_hdr()
116 "DevId from devinfo.xml is not available - cannot use OMA DM"); in oma_dm_build_hdr()
120 syncml = xml_node_create_root(ctx->xml, "SYNCML:SYNCML1.2", NULL, &ns, in oma_dm_build_hdr()
123 synchdr = xml_node_create(ctx->xml, syncml, NULL, "SyncHdr"); in oma_dm_build_hdr()
124 xml_node_create_text(ctx->xml, synchdr, NULL, "VerDTD", "1.2"); in oma_dm_build_hdr()
125 xml_node_create_text(ctx->xml, synchdr, NULL, "VerProto", "DM/1.2"); in oma_dm_build_hdr()
126 xml_node_create_text(ctx->xml, synchdr, NULL, "SessionID", "1"); in oma_dm_build_hdr()
127 xml_node_create_text(ctx->xml, synchdr, NULL, "MsgID", int2str(msgid)); in oma_dm_build_hdr()
130 oma_dm_add_locuri(ctx, synchdr, "Source", ctx->devid); in oma_dm_build_hdr()
139 xml_node_create_text(ctx->xml, parent, NULL, "CmdID", int2str(cmdid)); in oma_dm_add_cmdid()
148 node = xml_node_create(ctx->xml, parent, NULL, "Alert"); in add_alert()
152 xml_node_create_text(ctx->xml, node, NULL, "Data", int2str(data)); in add_alert()
164 node = xml_node_create(ctx->xml, parent, NULL, "Status"); in add_status()
168 xml_node_create_text(ctx->xml, node, NULL, "MsgRef", int2str(msgref)); in add_status()
170 xml_node_create_text(ctx->xml, node, NULL, "CmdRef", in add_status()
172 xml_node_create_text(ctx->xml, node, NULL, "Cmd", cmd); in add_status()
173 xml_node_create_text(ctx->xml, node, NULL, "Data", int2str(data)); in add_status()
175 xml_node_create_text(ctx->xml, node, NULL, "TargetRef", in add_status()
189 node = xml_node_create(ctx->xml, parent, NULL, "Results"); in add_results()
194 xml_node_create_text(ctx->xml, node, NULL, "MsgRef", int2str(msgref)); in add_results()
195 xml_node_create_text(ctx->xml, node, NULL, "CmdRef", int2str(cmdref)); in add_results()
208 fnode = node_from_file(ctx->xml, fname); in mo_str()
211 tnds = mo_to_tnds(ctx->xml, fnode, 0, urn, "syncml:dmddf1.2"); in mo_str()
212 xml_node_free(ctx->xml, fnode); in mo_str()
216 str = xml_node_to_str(ctx->xml, tnds); in mo_str()
217 xml_node_free(ctx->xml, tnds); in mo_str()
231 item = xml_node_create(ctx->xml, parent, NULL, "Item"); in add_item()
233 node = xml_node_create(ctx->xml, item, NULL, "Meta"); in add_item()
234 xml_node_create_text_ns(ctx->xml, node, "syncml:metinf", "Format", in add_item()
236 xml_node_create_text_ns(ctx->xml, node, "syncml:metinf", "Type", in add_item()
238 xml_node_create_text(ctx->xml, item, NULL, "Data", data); in add_item()
249 info = node_from_file(ctx->xml, "devinfo.xml"); in add_replace_devinfo()
255 replace = xml_node_create(ctx->xml, parent, NULL, "Replace"); in add_replace_devinfo()
257 xml_node_free(ctx->xml, info); in add_replace_devinfo()
262 xml_node_for_each_child(ctx->xml, child, info) { in add_replace_devinfo()
263 xml_node_for_each_check(ctx->xml, child); in add_replace_devinfo()
264 name = xml_node_get_localname(ctx->xml, child); in add_replace_devinfo()
266 txt = xml_node_get_text(ctx->xml, child); in add_replace_devinfo()
269 xml_node_get_text_free(ctx->xml, txt); in add_replace_devinfo()
273 xml_node_free(ctx->xml, info); in add_replace_devinfo()
287 item = xml_node_create(ctx->xml, node, NULL, "Item"); in oma_dm_add_hs20_generic_alert()
289 node = xml_node_create(ctx->xml, item, NULL, "Meta"); in oma_dm_add_hs20_generic_alert()
290 snprintf(buf, sizeof(buf), "Reversed-Domain-Name: %s", oper); in oma_dm_add_hs20_generic_alert()
291 xml_node_create_text_ns(ctx->xml, node, "syncml:metinf", "Type", buf); in oma_dm_add_hs20_generic_alert()
292 xml_node_create_text_ns(ctx->xml, node, "syncml:metinf", "Format", in oma_dm_add_hs20_generic_alert()
294 xml_node_create_text(ctx->xml, item, NULL, "Data", data); in oma_dm_add_hs20_generic_alert()
309 syncbody = xml_node_create(ctx->xml, syncml, NULL, "SyncBody"); in build_oma_dm_1()
311 xml_node_free(ctx->xml, syncml); in build_oma_dm_1()
320 xml_node_free(ctx->xml, syncml); in build_oma_dm_1()
330 xml_node_create(ctx->xml, syncbody, NULL, "Final"); in build_oma_dm_1()
343 debug_dump_node(ctx, "OMA-DM Package 1 (sub reg)", syncml); in build_oma_dm_1_sub_reg()
357 debug_dump_node(ctx, "OMA-DM Package 1 (sub prov)", syncml); in build_oma_dm_1_sub_prov()
370 debug_dump_node(ctx, "OMA-DM Package 1 (pol upd)", syncml); in build_oma_dm_1_pol_upd()
384 debug_dump_node(ctx, "OMA-DM Package 1 (sub rem)", syncml); in build_oma_dm_1_sub_rem()
396 node = get_node(ctx->xml, exec, "Item/Data"); in oma_dm_exec_browser()
402 data = xml_node_get_text(ctx->xml, node); in oma_dm_exec_browser()
411 xml_node_get_text_free(ctx->xml, data); in oma_dm_exec_browser()
434 node = get_node(ctx->xml, exec, "Item/Data"); in oma_dm_exec_get_cert()
440 data = xml_node_get_text(ctx->xml, node); in oma_dm_exec_get_cert()
446 getcert = xml_node_from_buf(ctx->xml, data); in oma_dm_exec_get_cert()
447 xml_node_get_text_free(ctx->xml, data); in oma_dm_exec_get_cert()
454 debug_dump_node(ctx, "OMA-DM getCertificate", getcert); in oma_dm_exec_get_cert()
456 name = xml_node_get_localname(ctx->xml, getcert); in oma_dm_exec_get_cert()
465 xml_node_free(ctx->xml, getcert); in oma_dm_exec_get_cert()
484 if (os_strcasecmp(locuri, "./DevDetail/Ext/org.wi-fi/Wi-Fi/Ops/" in oma_dm_exec()
487 } else if (os_strcasecmp(locuri, "./DevDetail/Ext/org.wi-fi/Wi-Fi/Ops/" in oma_dm_exec()
513 if (os_strncasecmp(locuri, "./Wi-Fi/", 8) != 0) { in oma_dm_run_add()
514 wpa_printf(MSG_INFO, "Do not allow Add outside ./Wi-Fi"); in oma_dm_run_add()
519 if (ctx->fqdn == NULL) in oma_dm_run_add()
521 fqdn_len = os_strlen(ctx->fqdn); in oma_dm_run_add()
522 if (os_strncasecmp(pos, ctx->fqdn, fqdn_len) != 0 || in oma_dm_run_add()
524 wpa_printf(MSG_INFO, "Do not allow Add outside ./Wi-Fi/%s", in oma_dm_run_add()
525 ctx->fqdn); in oma_dm_run_add()
532 "Do not allow Add outside ./Wi-Fi/%s/PerProviderSubscription", in oma_dm_run_add()
533 ctx->fqdn); in oma_dm_run_add()
540 pps_node = get_node(ctx->xml, pps, pos); in oma_dm_run_add()
554 pps_node = get_node(ctx->xml, pps, uri); in oma_dm_run_add()
579 pps_node = xml_node_create(ctx->xml, pps_node, NULL, upos); in oma_dm_run_add()
589 node = get_node(ctx->xml, add, "Item/Meta/Type"); in oma_dm_run_add()
592 type = xml_node_get_text(ctx->xml, node); in oma_dm_run_add()
602 node = get_node(ctx->xml, add, "Item/Data"); in oma_dm_run_add()
609 data = xml_node_get_text(ctx->xml, node); in oma_dm_run_add()
619 tnds = xml_node_from_buf(ctx->xml, data); in oma_dm_run_add()
620 xml_node_get_text_free(ctx->xml, data); in oma_dm_run_add()
628 unode = tnds_to_mo(ctx->xml, tnds); in oma_dm_run_add()
629 xml_node_free(ctx->xml, tnds); in oma_dm_run_add()
638 xml_node_add_child(ctx->xml, pps_node, unode); in oma_dm_run_add()
650 ctx->pps_updated = 1; in oma_dm_run_add()
664 node = get_node(ctx->xml, add, "Item/Target/LocURI"); in oma_dm_add()
669 locuri = xml_node_get_text(ctx->xml, node); in oma_dm_add()
675 if (os_strncasecmp(locuri, "./Wi-Fi/", 8) != 0) { in oma_dm_add()
677 xml_node_get_text_free(ctx->xml, locuri); in oma_dm_add()
681 node = get_node(ctx->xml, add, "Item/Data"); in oma_dm_add()
684 xml_node_get_text_free(ctx->xml, locuri); in oma_dm_add()
691 xml_node_get_text_free(ctx->xml, locuri); in oma_dm_add()
698 xml_node_get_text_free(ctx->xml, locuri); in oma_dm_add()
700 return ret == -2 ? DM_RESP_ALREADY_EXISTS : in oma_dm_add()
703 if (ctx->no_reconnect == 2) { in oma_dm_add()
704 os_snprintf(ctx->pps_fname, sizeof(ctx->pps_fname), "%s", in oma_dm_add()
706 ctx->pps_cred_set = 1; in oma_dm_add()
713 if (ctx->no_reconnect) in oma_dm_add()
717 if (wpa_command(ctx->ifname, "INTERWORKING_SELECT auto") < 0) in oma_dm_add()
738 if (os_strncasecmp(locuri, "./Wi-Fi/", 8) != 0) { in oma_dm_replace()
739 wpa_printf(MSG_INFO, "Do not allow Replace outside ./Wi-Fi"); in oma_dm_replace()
745 if (ctx->fqdn == NULL) { in oma_dm_replace()
749 fqdn_len = os_strlen(ctx->fqdn); in oma_dm_replace()
750 if (os_strncasecmp(pos, ctx->fqdn, fqdn_len) != 0 || in oma_dm_replace()
752 wpa_printf(MSG_INFO, "Do not allow Replace outside ./Wi-Fi/%s", in oma_dm_replace()
753 ctx->fqdn); in oma_dm_replace()
761 "Do not allow Replace outside ./Wi-Fi/%s/PerProviderSubscription", in oma_dm_replace()
762 ctx->fqdn); in oma_dm_replace()
770 pps_node = get_node(ctx->xml, pps, pos); in oma_dm_replace()
777 node = get_node(ctx->xml, replace, "Item/Meta/Type"); in oma_dm_replace()
780 type = xml_node_get_text(ctx->xml, node); in oma_dm_replace()
790 node = get_node(ctx->xml, replace, "Item/Data"); in oma_dm_replace()
797 data = xml_node_get_text(ctx->xml, node); in oma_dm_replace()
807 tnds = xml_node_from_buf(ctx->xml, data); in oma_dm_replace()
808 xml_node_get_text_free(ctx->xml, data); in oma_dm_replace()
816 unode = tnds_to_mo(ctx->xml, tnds); in oma_dm_replace()
817 xml_node_free(ctx->xml, tnds); in oma_dm_replace()
826 parent = xml_node_get_parent(ctx->xml, pps_node); in oma_dm_replace()
827 xml_node_detach(ctx->xml, pps_node); in oma_dm_replace()
828 xml_node_add_child(ctx->xml, parent, unode); in oma_dm_replace()
830 xml_node_set_text(ctx->xml, pps_node, data); in oma_dm_replace()
831 xml_node_get_text_free(ctx->xml, data); in oma_dm_replace()
839 ctx->pps_updated = 1; in oma_dm_replace()
860 if (os_strncasecmp(locuri, "./Wi-Fi/", 8) != 0) { in oma_dm_get()
861 wpa_printf(MSG_INFO, "Do not allow Get outside ./Wi-Fi"); in oma_dm_get()
867 if (ctx->fqdn == NULL) in oma_dm_get()
869 fqdn_len = os_strlen(ctx->fqdn); in oma_dm_get()
870 if (os_strncasecmp(pos, ctx->fqdn, fqdn_len) != 0 || in oma_dm_get()
872 wpa_printf(MSG_INFO, "Do not allow Get outside ./Wi-Fi/%s", in oma_dm_get()
873 ctx->fqdn); in oma_dm_get()
881 "Do not allow Get outside ./Wi-Fi/%s/PerProviderSubscription", in oma_dm_get()
882 ctx->fqdn); in oma_dm_get()
890 pps_node = get_node(ctx->xml, pps, pos); in oma_dm_get()
897 name = xml_node_get_localname(ctx->xml, pps_node); in oma_dm_get()
911 *value = xml_node_get_text(ctx->xml, pps_node); in oma_dm_get()
925 cnode = get_node(ctx->xml, node, "CmdID"); in oma_dm_get_cmdid()
929 str = xml_node_get_text(ctx->xml, cnode); in oma_dm_get_cmdid()
933 xml_node_get_text_free(ctx->xml, str); in oma_dm_get_cmdid()
949 str = xml_node_to_str(ctx->xml, syncml); in oma_dm_send_recv()
950 xml_node_free(ctx->xml, syncml); in oma_dm_send_recv()
956 os_free(ctx->server_url); in oma_dm_send_recv()
957 ctx->server_url = os_strdup(url); in oma_dm_send_recv()
958 res = http_post(ctx->http, url, str, "application/vnd.syncml.dm+xml", in oma_dm_send_recv()
959 ext_hdr, ctx->ca_fname, username, password, in oma_dm_send_recv()
966 const char *err = http_get_err(ctx->http); in oma_dm_send_recv()
979 resp = xml_node_from_buf(ctx->xml, res); in oma_dm_send_recv()
1010 name = xml_node_get_localname(ctx->xml, resp); in oma_dm_process()
1016 hdr = get_node(ctx->xml, resp, "SyncHdr"); in oma_dm_process()
1017 body = get_node(ctx->xml, resp, "SyncBody"); in oma_dm_process()
1023 xml_node_for_each_child(ctx->xml, child, hdr) { in oma_dm_process()
1024 xml_node_for_each_check(ctx->xml, child); in oma_dm_process()
1025 name = xml_node_get_localname(ctx->xml, child); in oma_dm_process()
1028 tmp = xml_node_get_text(ctx->xml, child); in oma_dm_process()
1031 xml_node_get_text_free(ctx->xml, tmp); in oma_dm_process()
1033 tmp = xml_node_get_text(ctx->xml, child); in oma_dm_process()
1036 xml_node_get_text_free(ctx->xml, tmp); in oma_dm_process()
1050 syncbody = xml_node_create(ctx->xml, syncml, NULL, "SyncBody"); in oma_dm_process()
1055 xml_node_for_each_child(ctx->xml, child, body) { in oma_dm_process()
1056 xml_node_for_each_check(ctx->xml, child); in oma_dm_process()
1058 name = xml_node_get_localname(ctx->xml, child); in oma_dm_process()
1059 wpa_printf(MSG_INFO, "SyncBody CmdID=%d - %s", in oma_dm_process()
1110 xml_node_get_text_free(ctx->xml, value); in oma_dm_process()
1133 xml_node_free(ctx->xml, syncml); in oma_dm_process()
1139 wpa_printf(MSG_INFO, "Exchange completed - no response needed"); in oma_dm_process()
1140 xml_node_free(ctx->xml, syncml); in oma_dm_process()
1145 xml_node_create(ctx->xml, syncbody, NULL, "Final"); in oma_dm_process()
1147 debug_dump_node(ctx, "OMA-DM Package 3", syncml); in oma_dm_process()
1162 return -1; in cmd_oma_dm_prov()
1165 wpa_printf(MSG_INFO, "OMA-DM credential provisioning requested"); in cmd_oma_dm_prov()
1166 write_summary(ctx, "OMA-DM credential provisioning"); in cmd_oma_dm_prov()
1171 return -1; in cmd_oma_dm_prov()
1177 return -1; in cmd_oma_dm_prov()
1182 xml_node_free(ctx->xml, resp); in cmd_oma_dm_prov()
1187 return ctx->pps_cred_set ? 0 : -1; in cmd_oma_dm_prov()
1199 return -1; in cmd_oma_dm_sim_prov()
1202 wpa_printf(MSG_INFO, "OMA-DM SIM provisioning requested"); in cmd_oma_dm_sim_prov()
1203 ctx->no_reconnect = 2; in cmd_oma_dm_sim_prov()
1208 if (wait_ip_addr(ctx->ifname, 15) < 0) { in cmd_oma_dm_sim_prov()
1209 wpa_printf(MSG_INFO, "Could not get IP address for WLAN - try connection anyway"); in cmd_oma_dm_sim_prov()
1211 write_summary(ctx, "OMA-DM SIM provisioning"); in cmd_oma_dm_sim_prov()
1216 return -1; in cmd_oma_dm_sim_prov()
1222 return -1; in cmd_oma_dm_sim_prov()
1227 xml_node_free(ctx->xml, resp); in cmd_oma_dm_sim_prov()
1232 if (ctx->pps_cred_set) { in cmd_oma_dm_sim_prov()
1234 cmd_set_pps(ctx, ctx->pps_fname); in cmd_oma_dm_sim_prov()
1238 if (wpa_command(ctx->ifname, "INTERWORKING_SELECT auto") < 0) { in cmd_oma_dm_sim_prov()
1241 return -1; in cmd_oma_dm_sim_prov()
1245 return ctx->pps_cred_set ? 0 : -1; in cmd_oma_dm_sim_prov()
1259 wpa_printf(MSG_INFO, "OMA-DM policy update"); in oma_dm_pol_upd()
1260 write_summary(ctx, "OMA-DM policy update"); in oma_dm_pol_upd()
1277 xml_node_free(ctx->xml, resp); in oma_dm_pol_upd()
1282 if (ctx->pps_updated) { in oma_dm_pol_upd()
1286 if (wpa_command(ctx->ifname, "INTERWORKING_SELECT auto") < 0) { in oma_dm_pol_upd()
1306 wpa_printf(MSG_INFO, "OMA-DM subscription remediation"); in oma_dm_sub_rem()
1307 write_summary(ctx, "OMA-DM subscription remediation"); in oma_dm_sub_rem()
1324 xml_node_free(ctx->xml, resp); in oma_dm_sub_rem()
1332 if (wpa_command(ctx->ifname, "INTERWORKING_SELECT auto") < 0) { in oma_dm_sub_rem()
1345 ctx->fqdn = os_strdup("wi-fi.org"); in cmd_oma_dm_add()
1347 pps = node_from_file(ctx->xml, pps_fname); in cmd_oma_dm_add()
1354 add = node_from_file(ctx->xml, add_fname); in cmd_oma_dm_add()
1358 xml_node_free(ctx->xml, pps); in cmd_oma_dm_add()
1363 wpa_printf(MSG_INFO, "oma_dm_add --> %d", res); in cmd_oma_dm_add()
1365 xml_node_free(ctx->xml, pps); in cmd_oma_dm_add()
1366 xml_node_free(ctx->xml, add); in cmd_oma_dm_add()
1376 ctx->fqdn = os_strdup("wi-fi.org"); in cmd_oma_dm_replace()
1378 pps = node_from_file(ctx->xml, pps_fname); in cmd_oma_dm_replace()
1385 replace = node_from_file(ctx->xml, replace_fname); in cmd_oma_dm_replace()
1389 xml_node_free(ctx->xml, pps); in cmd_oma_dm_replace()
1394 wpa_printf(MSG_INFO, "oma_dm_replace --> %d", res); in cmd_oma_dm_replace()
1396 xml_node_free(ctx->xml, pps); in cmd_oma_dm_replace()
1397 xml_node_free(ctx->xml, replace); in cmd_oma_dm_replace()