dbus_new_handlers_p2p.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772
  1. /*
  2. * WPA Supplicant / dbus-based control interface (P2P)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Alternatively, this software may be distributed under the terms of BSD
  9. * license.
  10. *
  11. * See README and COPYING for more details.
  12. */
  13. #include "includes.h"
  14. #include "utils/includes.h"
  15. #include "common.h"
  16. #include "../config.h"
  17. #include "../wpa_supplicant_i.h"
  18. #include "../wps_supplicant.h"
  19. #include "dbus_new_helpers.h"
  20. #include "dbus_new.h"
  21. #include "dbus_new_handlers.h"
  22. #include "dbus_new_handlers_p2p.h"
  23. #include "dbus_dict_helpers.h"
  24. #include "p2p/p2p.h"
  25. #include "common/ieee802_11_defs.h"
  26. #include "ap/hostapd.h"
  27. #include "ap/ap_config.h"
  28. #include "ap/wps_hostapd.h"
  29. #include "../p2p_supplicant.h"
  30. /**
  31. * Parses out the mac address from the peer object path.
  32. * @peer_path - object path of the form
  33. * /fi/w1/wpa_supplicant1/Interfaces/n/Peers/00112233445566 (no colons)
  34. * @addr - out param must be of ETH_ALEN size
  35. * Returns 0 if valid (including MAC), -1 otherwise
  36. */
  37. static int parse_peer_object_path(char *peer_path, u8 addr[ETH_ALEN])
  38. {
  39. char *p;
  40. if (!peer_path)
  41. return -1;
  42. p = strrchr(peer_path, '/');
  43. if (!p)
  44. return -1;
  45. p++;
  46. return hwaddr_compact_aton(p, addr);
  47. }
  48. DBusMessage *wpas_dbus_handler_p2p_find(DBusMessage * message,
  49. struct wpa_supplicant * wpa_s)
  50. {
  51. struct wpa_dbus_dict_entry entry;
  52. DBusMessage *reply = NULL;
  53. DBusMessageIter iter;
  54. DBusMessageIter iter_dict;
  55. unsigned int timeout = 0;
  56. unsigned int searchonly = 0;
  57. enum p2p_discovery_type type = P2P_FIND_ONLY_SOCIAL;
  58. int num_req_dev_types = 0;
  59. unsigned int i;
  60. u8 *req_dev_types = NULL;
  61. dbus_message_iter_init(message, &iter);
  62. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  63. goto error;
  64. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  65. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  66. goto error;
  67. if (!os_strcmp(entry.key, "Timeout") &&
  68. (entry.type == DBUS_TYPE_INT32)) {
  69. timeout = entry.uint32_value;
  70. } else if (!os_strcmp(entry.key, "SearchOnly") &&
  71. (entry.type == DBUS_TYPE_BOOLEAN)) {
  72. searchonly = (entry.bool_value == TRUE) ? 1 : 0;
  73. } else if (os_strcmp(entry.key, "RequestedDeviceTypes") == 0) {
  74. if ((entry.type != DBUS_TYPE_ARRAY) ||
  75. (entry.array_type != WPAS_DBUS_TYPE_BINARRAY))
  76. goto error_clear;
  77. req_dev_types =
  78. os_malloc(WPS_DEV_TYPE_LEN * entry.array_len);
  79. if (!req_dev_types)
  80. goto error_clear;
  81. for (i = 0; i < entry.array_len; i++) {
  82. if (wpabuf_len(entry.binarray_value[i]) !=
  83. WPS_DEV_TYPE_LEN)
  84. goto error_clear;
  85. os_memcpy(req_dev_types + i * WPS_DEV_TYPE_LEN,
  86. wpabuf_head(entry.binarray_value[i]),
  87. WPS_DEV_TYPE_LEN);
  88. }
  89. num_req_dev_types = entry.array_len;
  90. } else
  91. goto error_clear;
  92. wpa_dbus_dict_entry_clear(&entry);
  93. }
  94. wpas_p2p_find(wpa_s, timeout, type, num_req_dev_types, req_dev_types);
  95. return reply;
  96. error_clear:
  97. os_free(req_dev_types);
  98. wpa_dbus_dict_entry_clear(&entry);
  99. error:
  100. reply = wpas_dbus_error_invalid_args(message, entry.key);
  101. return reply;
  102. }
  103. DBusMessage *wpas_dbus_handler_p2p_stop_find(DBusMessage * message,
  104. struct wpa_supplicant * wpa_s)
  105. {
  106. wpas_p2p_stop_find(wpa_s);
  107. return NULL;
  108. }
  109. DBusMessage *wpas_dbus_handler_p2p_rejectpeer(DBusMessage * message,
  110. struct wpa_supplicant * wpa_s)
  111. {
  112. DBusMessageIter iter;
  113. char *peer_object_path = NULL;
  114. u8 peer_addr[ETH_ALEN];
  115. dbus_message_iter_init(message, &iter);
  116. dbus_message_iter_get_basic(&iter, &peer_object_path);
  117. if (parse_peer_object_path(peer_object_path, peer_addr) < 0)
  118. return wpas_dbus_error_invalid_args(message, NULL);
  119. if (wpas_p2p_reject(wpa_s, peer_addr) < 0)
  120. return wpas_dbus_error_unknown_error(message,
  121. "Failed to call wpas_p2p_reject method.");
  122. return NULL;
  123. }
  124. DBusMessage *wpas_dbus_handler_p2p_listen(DBusMessage * message,
  125. struct wpa_supplicant * wpa_s)
  126. {
  127. dbus_int32_t timeout = 0;
  128. if (!dbus_message_get_args(message, NULL, DBUS_TYPE_INT32, &timeout,
  129. DBUS_TYPE_INVALID))
  130. return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
  131. NULL);
  132. if (wpas_p2p_listen(wpa_s, (unsigned int)timeout))
  133. return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
  134. NULL);
  135. return NULL;
  136. }
  137. DBusMessage *wpas_dbus_handler_p2p_extendedlisten(DBusMessage * message,
  138. struct wpa_supplicant * wpa_s)
  139. {
  140. unsigned int period = 0, interval = 0;
  141. struct wpa_dbus_dict_entry entry;
  142. DBusMessageIter iter;
  143. DBusMessageIter iter_dict;
  144. dbus_message_iter_init(message, &iter);
  145. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  146. goto error;
  147. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  148. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  149. goto error;
  150. if (!strcmp(entry.key, "period") &&
  151. (entry.type == DBUS_TYPE_INT32))
  152. period = entry.uint32_value;
  153. else if (!strcmp(entry.key, "interval") &&
  154. (entry.type == DBUS_TYPE_INT32))
  155. interval = entry.uint32_value;
  156. else
  157. goto error_clear;
  158. wpa_dbus_dict_entry_clear(&entry);
  159. }
  160. if (wpas_p2p_ext_listen(wpa_s, period, interval))
  161. return wpas_dbus_error_unknown_error(message,
  162. "failed to initiate a p2p_ext_listen.");
  163. return NULL;
  164. error_clear:
  165. wpa_dbus_dict_entry_clear(&entry);
  166. error:
  167. return wpas_dbus_error_invalid_args(message, entry.key);
  168. }
  169. DBusMessage *wpas_dbus_handler_p2p_presence_request(DBusMessage * message,
  170. struct wpa_supplicant *
  171. wpa_s)
  172. {
  173. unsigned int dur1 = 0, int1 = 0, dur2 = 0, int2 = 0;
  174. struct wpa_dbus_dict_entry entry;
  175. DBusMessageIter iter;
  176. DBusMessageIter iter_dict;
  177. dbus_message_iter_init(message, &iter);
  178. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  179. goto error;
  180. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  181. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  182. goto error;
  183. if (!strcmp(entry.key, "duration1") &&
  184. (entry.type == DBUS_TYPE_INT32))
  185. dur1 = entry.uint32_value;
  186. else if (!strcmp(entry.key, "interval1") &&
  187. entry.type == DBUS_TYPE_INT32)
  188. int1 = entry.uint32_value;
  189. else if (!strcmp(entry.key, "duration2") &&
  190. entry.type == DBUS_TYPE_INT32)
  191. dur2 = entry.uint32_value;
  192. else if (!strcmp(entry.key, "interval2") &&
  193. entry.type == DBUS_TYPE_INT32)
  194. int2 = entry.uint32_value;
  195. else
  196. goto error_clear;
  197. wpa_dbus_dict_entry_clear(&entry);
  198. }
  199. if (wpas_p2p_presence_req(wpa_s, dur1, int1, dur2, int2) < 0)
  200. return wpas_dbus_error_unknown_error(message,
  201. "Failed to invoke presence request.");
  202. return NULL;
  203. error_clear:
  204. wpa_dbus_dict_entry_clear(&entry);
  205. error:
  206. return wpas_dbus_error_invalid_args(message, entry.key);
  207. }
  208. DBusMessage *wpas_dbus_handler_p2p_group_add(DBusMessage * message,
  209. struct wpa_supplicant * wpa_s)
  210. {
  211. DBusMessageIter iter_dict;
  212. DBusMessage *reply = NULL;
  213. DBusMessageIter iter;
  214. struct wpa_dbus_dict_entry entry;
  215. char *network_object_path = NULL;
  216. int persistent_group = 0;
  217. int freq = 0;
  218. char *iface = NULL;
  219. char *net_id_str = NULL;
  220. unsigned int group_id = 0;
  221. struct wpa_ssid *ssid;
  222. dbus_message_iter_init(message, &iter);
  223. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  224. goto inv_args;
  225. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  226. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  227. goto inv_args;
  228. if (!strcmp(entry.key, "persistent") &&
  229. (entry.type == DBUS_TYPE_BOOLEAN)) {
  230. persistent_group = (entry.bool_value == TRUE) ? 1 : 0;
  231. } else if (!strcmp(entry.key, "frequency") &&
  232. (entry.type == DBUS_TYPE_INT32)) {
  233. freq = entry.int32_value;
  234. if (freq <= 0)
  235. goto inv_args_clear;
  236. } else if (!strcmp(entry.key, "network_object") &&
  237. entry.type == DBUS_TYPE_OBJECT_PATH)
  238. network_object_path = os_strdup(entry.str_value);
  239. else
  240. goto inv_args_clear;
  241. wpa_dbus_dict_entry_clear(&entry);
  242. }
  243. if (network_object_path != NULL) {
  244. /*
  245. * A Network Object Path is defined meaning we want to re-invoke
  246. * a persisatnt group.
  247. */
  248. iface = wpas_dbus_new_decompose_object_path(network_object_path,
  249. &net_id_str, NULL);
  250. if (iface == NULL ||
  251. os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
  252. reply =
  253. wpas_dbus_error_invalid_args(message,
  254. network_object_path);
  255. goto out;
  256. }
  257. group_id = strtoul(net_id_str, NULL, 10);
  258. if (errno == EINVAL) {
  259. reply = wpas_dbus_error_invalid_args(
  260. message, network_object_path);
  261. goto out;
  262. }
  263. /* Get the SSID structure form the persistant group id */
  264. ssid = wpa_config_get_network(wpa_s->conf, group_id);
  265. if (ssid == NULL || ssid->disabled != 2)
  266. goto inv_args;
  267. if (wpas_p2p_group_add_persistent(wpa_s, ssid, 0, freq)) {
  268. reply = wpas_dbus_error_unknown_error(message,
  269. "Failed to reinvoke a persistent group");
  270. goto out;
  271. }
  272. } else if (wpas_p2p_group_add(wpa_s, persistent_group, freq))
  273. goto inv_args;
  274. out:
  275. os_free(network_object_path);
  276. os_free(net_id_str);
  277. os_free(iface);
  278. return reply;
  279. inv_args_clear:
  280. wpa_dbus_dict_entry_clear(&entry);
  281. inv_args:
  282. reply = wpas_dbus_error_invalid_args(message, NULL);
  283. goto out;
  284. }
  285. DBusMessage *wpas_dbus_handler_p2p_disconnect(DBusMessage *message,
  286. struct wpa_supplicant *wpa_s)
  287. {
  288. if (wpas_p2p_disconnect(wpa_s))
  289. return wpas_dbus_error_unknown_error(message,
  290. "failed to disconnect");
  291. return NULL;
  292. }
  293. DBusMessage *wpas_dbus_handler_p2p_flush(DBusMessage * message,
  294. struct wpa_supplicant * wpa_s)
  295. {
  296. os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
  297. wpa_s->force_long_sd = 0;
  298. p2p_flush(wpa_s->global->p2p);
  299. return NULL;
  300. }
  301. DBusMessage *wpas_dbus_handler_p2p_connect(DBusMessage * message,
  302. struct wpa_supplicant * wpa_s)
  303. {
  304. DBusMessageIter iter_dict;
  305. DBusMessage *reply = NULL;
  306. DBusMessageIter iter;
  307. struct wpa_dbus_dict_entry entry;
  308. char *peer_object_path = NULL;
  309. int persistent_group = 0;
  310. int join = 0;
  311. int authorize_only = 0;
  312. int go_intent = -1;
  313. int freq = 0;
  314. u8 addr[ETH_ALEN];
  315. char *pin = NULL;
  316. enum p2p_wps_method wps_method = WPS_NOT_READY;
  317. int new_pin;
  318. char *err_msg = NULL;
  319. char *iface = NULL;
  320. dbus_message_iter_init(message, &iter);
  321. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  322. goto inv_args;
  323. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  324. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  325. goto inv_args;
  326. if (!strcmp(entry.key, "peer") &&
  327. (entry.type == DBUS_TYPE_OBJECT_PATH)) {
  328. peer_object_path = os_strdup(entry.str_value);
  329. } else if (!strcmp(entry.key, "persistent") &&
  330. (entry.type == DBUS_TYPE_BOOLEAN)) {
  331. persistent_group = (entry.bool_value == TRUE) ? 1 : 0;
  332. } else if (!strcmp(entry.key, "join") &&
  333. (entry.type == DBUS_TYPE_BOOLEAN)) {
  334. join = (entry.bool_value == TRUE) ? 1 : 0;
  335. } else if (!strcmp(entry.key, "authorize_only") &&
  336. (entry.type == DBUS_TYPE_BOOLEAN)) {
  337. authorize_only = (entry.bool_value == TRUE) ? 1 : 0;
  338. } else if (!strcmp(entry.key, "frequency") &&
  339. (entry.type == DBUS_TYPE_INT32)) {
  340. freq = entry.int32_value;
  341. if (freq <= 0)
  342. goto inv_args_clear;
  343. } else if (!strcmp(entry.key, "go_intent") &&
  344. (entry.type == DBUS_TYPE_INT32)) {
  345. go_intent = entry.int32_value;
  346. if ((go_intent < 0) || (go_intent > 15))
  347. goto inv_args_clear;
  348. } else if (!strcmp(entry.key, "wps_method") &&
  349. (entry.type == DBUS_TYPE_STRING)) {
  350. if (!strcmp(entry.str_value, "pbc"))
  351. wps_method = WPS_PBC;
  352. else if (!strcmp(entry.str_value, "pin"))
  353. wps_method = WPS_PIN_DISPLAY;
  354. else if (!strcmp(entry.str_value, "label"))
  355. wps_method = WPS_PIN_LABEL;
  356. else if (!strcmp(entry.str_value, "display"))
  357. wps_method = WPS_PIN_DISPLAY;
  358. else if (!strcmp(entry.str_value, "keypad"))
  359. wps_method = WPS_PIN_KEYPAD;
  360. else
  361. goto inv_args_clear;
  362. } else if (!strcmp(entry.key, "pin") &&
  363. (entry.type == DBUS_TYPE_STRING)) {
  364. pin = os_strdup(entry.str_value);
  365. } else
  366. goto inv_args_clear;
  367. wpa_dbus_dict_entry_clear(&entry);
  368. }
  369. if (!peer_object_path || (wps_method == WPS_NOT_READY) ||
  370. (parse_peer_object_path(peer_object_path, addr) < 0) ||
  371. (p2p_get_peer_info(wpa_s->global->p2p, addr, 0, NULL, 0) < 0)) {
  372. reply = wpas_dbus_error_invalid_args(message, NULL);
  373. goto inv_args;
  374. }
  375. /*
  376. * Validate the wps_method specified and the pin value.
  377. */
  378. if ((!pin || !pin[0]) &&
  379. ((wps_method == WPS_PIN_LABEL) || (wps_method == WPS_PIN_KEYPAD)))
  380. goto inv_args;
  381. new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
  382. persistent_group, join, authorize_only,
  383. go_intent, freq);
  384. if (new_pin >= 0) {
  385. reply = dbus_message_new_method_return(message);
  386. dbus_message_append_args(reply, DBUS_TYPE_INT32,
  387. &new_pin, DBUS_TYPE_INVALID);
  388. } else {
  389. switch (new_pin) {
  390. case -2:
  391. err_msg = "connect failed due to"
  392. " channel unavailability.";
  393. iface = WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE;
  394. break;
  395. case -3:
  396. err_msg = "connect failed due to"
  397. " unsupported channel.";
  398. iface = WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNSUPPORTED;
  399. break;
  400. default:
  401. err_msg = "connect failed due to"
  402. " unspecified error.";
  403. iface = WPAS_DBUS_ERROR_CONNECT_UNSPECIFIED_ERROR;
  404. break;
  405. }
  406. /*
  407. * TODO::
  408. * Do we need specialized errors corresponding to above
  409. * error conditions as against just returning a different
  410. * error message?
  411. */
  412. reply = dbus_message_new_error(message, iface, err_msg);
  413. }
  414. out:
  415. os_free(peer_object_path);
  416. os_free(pin);
  417. return reply;
  418. inv_args_clear:
  419. wpa_dbus_dict_entry_clear(&entry);
  420. inv_args:
  421. reply = wpas_dbus_error_invalid_args(message, NULL);
  422. goto out;
  423. }
  424. DBusMessage *wpas_dbus_handler_p2p_invite(DBusMessage * message,
  425. struct wpa_supplicant *wpa_s)
  426. {
  427. DBusMessageIter iter_dict;
  428. DBusMessage *reply = NULL;
  429. DBusMessageIter iter;
  430. struct wpa_dbus_dict_entry entry;
  431. char *peer_object_path = NULL;
  432. char *network_object_path = NULL;
  433. char *iface = NULL;
  434. char *net_id_str = NULL;
  435. u8 peer_addr[ETH_ALEN];
  436. unsigned int group_id = 0;
  437. int persistent = 0;
  438. struct wpa_ssid *ssid;
  439. dbus_message_iter_init(message, &iter);
  440. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  441. goto err;
  442. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  443. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  444. goto err;
  445. if (!strcmp(entry.key, "peer") &&
  446. (entry.type == DBUS_TYPE_OBJECT_PATH)) {
  447. peer_object_path = os_strdup(entry.str_value);
  448. wpa_dbus_dict_entry_clear(&entry);
  449. } else if (!strcmp(entry.key, "network_object") &&
  450. (entry.type == DBUS_TYPE_OBJECT_PATH)) {
  451. network_object_path = os_strdup(entry.str_value);
  452. persistent = 1;
  453. wpa_dbus_dict_entry_clear(&entry);
  454. } else {
  455. wpa_dbus_dict_entry_clear(&entry);
  456. goto err;
  457. }
  458. }
  459. if (!peer_object_path ||
  460. (parse_peer_object_path(peer_object_path, peer_addr) < 0) ||
  461. (p2p_get_peer_info(wpa_s->global->p2p,
  462. peer_addr, 0, NULL, 0) < 0)) {
  463. goto err;
  464. }
  465. if (persistent) {
  466. /*
  467. * A group ID is defined meaning we want to re-invoke a
  468. * persisatnt group
  469. */
  470. iface = wpas_dbus_new_decompose_object_path(network_object_path,
  471. &net_id_str, NULL);
  472. if (iface == NULL ||
  473. os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
  474. reply =
  475. wpas_dbus_error_invalid_args(message,
  476. network_object_path);
  477. goto out;
  478. }
  479. group_id = strtoul(net_id_str, NULL, 10);
  480. if (errno == EINVAL) {
  481. reply = wpas_dbus_error_invalid_args(
  482. message, network_object_path);
  483. goto out;
  484. }
  485. /* Get the SSID structure form the persistant group id */
  486. ssid = wpa_config_get_network(wpa_s->conf, group_id);
  487. if (ssid == NULL || ssid->disabled != 2)
  488. goto err;
  489. if (wpas_p2p_invite(wpa_s, peer_addr, ssid, NULL) < 0) {
  490. reply = wpas_dbus_error_unknown_error(
  491. message,
  492. "Failed to reinvoke a persistent group");
  493. goto out;
  494. }
  495. } else {
  496. /*
  497. * No group ID means propose to a peer to join my active group
  498. */
  499. if (wpas_p2p_invite_group(wpa_s, wpa_s->ifname,
  500. peer_addr, NULL)) {
  501. reply = wpas_dbus_error_unknown_error(
  502. message,
  503. "Failed to join to an active group");
  504. goto out;
  505. }
  506. }
  507. out:
  508. os_free(network_object_path);
  509. os_free(peer_object_path);
  510. return reply;
  511. err:
  512. reply = wpas_dbus_error_invalid_args(message, NULL);
  513. goto out;
  514. }
  515. DBusMessage *wpas_dbus_handler_p2p_prov_disc_req(DBusMessage * message,
  516. struct wpa_supplicant *wpa_s)
  517. {
  518. DBusMessageIter iter;
  519. char *peer_object_path = NULL;
  520. char *config_method = NULL;
  521. u8 peer_addr[ETH_ALEN];
  522. dbus_message_iter_init(message, &iter);
  523. dbus_message_iter_get_basic(&iter, &peer_object_path);
  524. if (parse_peer_object_path(peer_object_path, peer_addr) < 0)
  525. return wpas_dbus_error_invalid_args(message, NULL);
  526. dbus_message_iter_next(&iter);
  527. dbus_message_iter_get_basic(&iter, &config_method);
  528. /*
  529. * Validation checks on config_method are being duplicated here
  530. * to be able to return invalid args reply since the error code
  531. * from p2p module are not granular enough (yet).
  532. */
  533. if (os_strcmp(config_method, "display") &&
  534. os_strcmp(config_method, "keypad") &&
  535. os_strcmp(config_method, "pbc") &&
  536. os_strcmp(config_method, "pushbutton"))
  537. return wpas_dbus_error_invalid_args(message, NULL);
  538. if (wpas_p2p_prov_disc(wpa_s, peer_addr, config_method) < 0)
  539. return wpas_dbus_error_unknown_error(message,
  540. "Failed to send provision discovery request");
  541. return NULL;
  542. }
  543. /*
  544. * P2P Device property accessor methods.
  545. */
  546. DBusMessage *wpas_dbus_getter_p2p_device_properties(DBusMessage * message,
  547. struct wpa_supplicant *
  548. wpa_s)
  549. {
  550. DBusMessage *reply = NULL;
  551. DBusMessageIter iter, variant_iter, dict_iter;
  552. const char *dev_name;
  553. int num_sec_dev_types = 0;
  554. int num_vendor_extensions = 0;
  555. int i;
  556. const struct wpabuf *vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
  557. if (message == NULL)
  558. reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
  559. else
  560. reply = dbus_message_new_method_return(message);
  561. if (!reply)
  562. goto err_no_mem;
  563. dbus_message_iter_init_append(reply, &iter);
  564. if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
  565. "a{sv}", &variant_iter) ||
  566. !wpa_dbus_dict_open_write(&variant_iter, &dict_iter))
  567. goto err_no_mem;
  568. /* DeviceName */
  569. dev_name = wpa_s->conf->device_name;
  570. if (dev_name &&
  571. !wpa_dbus_dict_append_string(&dict_iter, "DeviceName", dev_name))
  572. goto err_no_mem;
  573. /* Primary device type */
  574. if (!wpa_dbus_dict_append_byte_array(&dict_iter, "PrimaryDeviceType",
  575. (char *)wpa_s->conf->device_type,
  576. WPS_DEV_TYPE_LEN))
  577. goto err_no_mem;
  578. /* Secondary device types */
  579. for (i = 0; i < MAX_SEC_DEVICE_TYPES; i++) {
  580. if (wpa_s->conf->sec_device_type[i] == NULL)
  581. break;
  582. num_sec_dev_types++;
  583. }
  584. if (!wpa_dbus_dict_append_string_array(
  585. &dict_iter, "SecondaryDeviceTypes",
  586. (const char **)wpa_s->conf->sec_device_type,
  587. num_sec_dev_types))
  588. goto err_no_mem;
  589. /* Vendor Extensions */
  590. for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  591. if (wpa_s->conf->wps_vendor_ext[i] == NULL)
  592. continue;
  593. vendor_ext[num_vendor_extensions++] =
  594. wpa_s->conf->wps_vendor_ext[i];
  595. }
  596. if (num_vendor_extensions &&
  597. !wpa_dbus_dict_append_wpabuf_array(&dict_iter,
  598. "VendorExtension",
  599. vendor_ext,
  600. num_vendor_extensions))
  601. goto err_no_mem;
  602. /* GO Intent */
  603. if (!wpa_dbus_dict_append_uint32(&dict_iter, "GOIntent",
  604. wpa_s->conf->p2p_go_intent))
  605. goto err_no_mem;
  606. /* Persistant Reconnect */
  607. if (!wpa_dbus_dict_append_bool(&dict_iter, "PersistantReconnect",
  608. wpa_s->conf->persistent_reconnect))
  609. goto err_no_mem;
  610. /* Listen Reg Class */
  611. if (!wpa_dbus_dict_append_uint32(&dict_iter, "ListenRegClass",
  612. wpa_s->conf->p2p_listen_reg_class))
  613. goto err_no_mem;
  614. /* Listen Channel */
  615. if (!wpa_dbus_dict_append_uint32(&dict_iter, "ListenChannel",
  616. wpa_s->conf->p2p_listen_channel))
  617. goto err_no_mem;
  618. /* Oper Reg Class */
  619. if (!wpa_dbus_dict_append_uint32(&dict_iter, "OperRegClass",
  620. wpa_s->conf->p2p_oper_reg_class))
  621. goto err_no_mem;
  622. /* Oper Channel */
  623. if (!wpa_dbus_dict_append_uint32(&dict_iter, "OperChannel",
  624. wpa_s->conf->p2p_oper_channel))
  625. goto err_no_mem;
  626. /* SSID Postfix */
  627. if (wpa_s->conf->p2p_ssid_postfix &&
  628. !wpa_dbus_dict_append_string(&dict_iter, "SsidPostfix",
  629. wpa_s->conf->p2p_ssid_postfix))
  630. goto err_no_mem;
  631. /* Intra Bss */
  632. if (!wpa_dbus_dict_append_bool(&dict_iter, "IntraBss",
  633. wpa_s->conf->p2p_intra_bss))
  634. goto err_no_mem;
  635. /* Group Idle */
  636. if (!wpa_dbus_dict_append_uint32(&dict_iter, "GroupIdle",
  637. wpa_s->conf->p2p_group_idle))
  638. goto err_no_mem;
  639. if (!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
  640. !dbus_message_iter_close_container(&iter, &variant_iter))
  641. goto err_no_mem;
  642. return reply;
  643. err_no_mem:
  644. dbus_message_unref(reply);
  645. return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
  646. }
  647. DBusMessage *wpas_dbus_setter_p2p_device_properties(DBusMessage * message,
  648. struct wpa_supplicant *
  649. wpa_s)
  650. {
  651. DBusMessage *reply = NULL;
  652. DBusMessageIter iter, variant_iter;
  653. struct wpa_dbus_dict_entry entry = {.type = DBUS_TYPE_STRING };
  654. DBusMessageIter iter_dict;
  655. unsigned int i;
  656. dbus_message_iter_init(message, &iter);
  657. dbus_message_iter_next(&iter);
  658. dbus_message_iter_next(&iter);
  659. dbus_message_iter_recurse(&iter, &variant_iter);
  660. if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict))
  661. return wpas_dbus_error_invalid_args(message, NULL);
  662. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  663. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  664. return wpas_dbus_error_invalid_args(message, NULL);
  665. if (os_strcmp(entry.key, "DeviceName") == 0) {
  666. char *devname;
  667. if (entry.type != DBUS_TYPE_STRING)
  668. goto error_clear;
  669. devname = os_strdup(entry.str_value);
  670. if (devname == NULL)
  671. goto err_no_mem_clear;
  672. os_free(wpa_s->conf->device_name);
  673. wpa_s->conf->device_name = devname;
  674. wpa_s->conf->changed_parameters |=
  675. CFG_CHANGED_DEVICE_NAME;
  676. } else if (os_strcmp(entry.key, "PrimaryDeviceType") == 0) {
  677. if (entry.type != DBUS_TYPE_ARRAY ||
  678. entry.array_type != DBUS_TYPE_BYTE ||
  679. entry.array_len != WPS_DEV_TYPE_LEN)
  680. goto error_clear;
  681. os_memcpy(wpa_s->conf->device_type,
  682. entry.bytearray_value,
  683. WPS_DEV_TYPE_LEN);
  684. wpa_s->conf->changed_parameters |=
  685. CFG_CHANGED_DEVICE_TYPE;
  686. } else if (os_strcmp(entry.key, "SecondaryDeviceTypes") == 0) {
  687. if (entry.type != DBUS_TYPE_ARRAY ||
  688. entry.array_type != WPAS_DBUS_TYPE_BINARRAY ||
  689. entry.array_len > MAX_SEC_DEVICE_TYPES)
  690. goto error;
  691. for (i = 0; i < entry.array_len; i++)
  692. if (wpabuf_len(entry.binarray_value[i]) != WPS_DEV_TYPE_LEN)
  693. goto err_no_mem_clear;
  694. for (i = 0; i < entry.array_len; i++)
  695. os_memcpy(wpa_s->conf->sec_device_type[i],
  696. wpabuf_head(entry.binarray_value[i]),
  697. WPS_DEV_TYPE_LEN);
  698. wpa_s->conf->num_sec_device_types = entry.array_len;
  699. wpa_s->conf->changed_parameters |=
  700. CFG_CHANGED_SEC_DEVICE_TYPE;
  701. } else if (os_strcmp(entry.key, "VendorExtension") == 0) {
  702. if ((entry.type != DBUS_TYPE_ARRAY) ||
  703. (entry.array_type != WPAS_DBUS_TYPE_BINARRAY) ||
  704. (entry.array_len > P2P_MAX_WPS_VENDOR_EXT))
  705. goto error_clear;
  706. wpa_s->conf->changed_parameters |=
  707. CFG_CHANGED_VENDOR_EXTENSION;
  708. for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  709. wpabuf_free(wpa_s->conf->wps_vendor_ext[i]);
  710. if (i < entry.array_len) {
  711. wpa_s->conf->wps_vendor_ext[i] =
  712. entry.binarray_value[i];
  713. entry.binarray_value[i] = NULL;
  714. } else
  715. wpa_s->conf->wps_vendor_ext[i] = NULL;
  716. }
  717. } else if ((os_strcmp(entry.key, "GOIntent") == 0) &&
  718. (entry.type == DBUS_TYPE_UINT32) &&
  719. (entry.uint32_value <= 15))
  720. wpa_s->conf->p2p_go_intent = entry.uint32_value;
  721. else if ((os_strcmp(entry.key, "PersistantReconnect") == 0) &&
  722. (entry.type == DBUS_TYPE_BOOLEAN))
  723. wpa_s->conf->persistent_reconnect = entry.bool_value;
  724. else if ((os_strcmp(entry.key, "ListenRegClass") == 0) &&
  725. (entry.type == DBUS_TYPE_UINT32))
  726. wpa_s->conf->p2p_listen_reg_class = entry.uint32_value;
  727. else if ((os_strcmp(entry.key, "ListenChannel") == 0) &&
  728. (entry.type == DBUS_TYPE_UINT32))
  729. wpa_s->conf->p2p_listen_channel = entry.uint32_value;
  730. else if ((os_strcmp(entry.key, "OperRegClass") == 0) &&
  731. (entry.type == DBUS_TYPE_UINT32))
  732. wpa_s->conf->p2p_oper_reg_class = entry.uint32_value;
  733. else if ((os_strcmp(entry.key, "OperChannel") == 0) &&
  734. (entry.type == DBUS_TYPE_UINT32))
  735. wpa_s->conf->p2p_oper_channel = entry.uint32_value;
  736. else if (os_strcmp(entry.key, "SsidPostfix") == 0) {
  737. char *postfix;
  738. if (entry.type != DBUS_TYPE_STRING)
  739. goto error_clear;
  740. postfix = os_strdup(entry.str_value);
  741. if (!postfix)
  742. goto err_no_mem_clear;
  743. os_free(wpa_s->conf->p2p_ssid_postfix);
  744. wpa_s->conf->p2p_ssid_postfix = postfix;
  745. wpa_s->conf->changed_parameters |=
  746. CFG_CHANGED_P2P_SSID_POSTFIX;
  747. } else if ((os_strcmp(entry.key, "IntraBss") == 0) &&
  748. (entry.type == DBUS_TYPE_BOOLEAN)) {
  749. wpa_s->conf->p2p_intra_bss = entry.bool_value;
  750. wpa_s->conf->changed_parameters |=
  751. CFG_CHANGED_P2P_INTRA_BSS;
  752. } else if ((os_strcmp(entry.key, "GroupIdle") == 0) &&
  753. (entry.type == DBUS_TYPE_UINT32))
  754. wpa_s->conf->p2p_group_idle = entry.uint32_value;
  755. else
  756. goto error_clear;
  757. wpa_dbus_dict_entry_clear(&entry);
  758. }
  759. if (wpa_s->conf->changed_parameters) {
  760. /* Some changed parameters requires to update config*/
  761. wpa_supplicant_update_config(wpa_s);
  762. }
  763. return reply;
  764. error_clear:
  765. wpa_dbus_dict_entry_clear(&entry);
  766. error:
  767. reply = wpas_dbus_error_invalid_args(message, entry.key);
  768. wpa_dbus_dict_entry_clear(&entry);
  769. return reply;
  770. err_no_mem_clear:
  771. wpa_dbus_dict_entry_clear(&entry);
  772. return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
  773. }
  774. DBusMessage *wpas_dbus_getter_p2p_peers(DBusMessage * message,
  775. struct wpa_supplicant * wpa_s)
  776. {
  777. DBusMessage *reply = NULL;
  778. struct p2p_data *p2p = wpa_s->global->p2p;
  779. int next = 0, i = 0;
  780. int num = 0, out_of_mem = 0;
  781. const u8 *addr;
  782. const struct p2p_peer_info *peer_info = NULL;
  783. struct dl_list peer_objpath_list;
  784. struct peer_objpath_node {
  785. struct dl_list list;
  786. char path[WPAS_DBUS_OBJECT_PATH_MAX];
  787. } *node, *tmp;
  788. char **peer_obj_paths = NULL;
  789. dl_list_init(&peer_objpath_list);
  790. /* Get the first peer info */
  791. peer_info = p2p_get_peer_found(p2p, NULL, next);
  792. /* Get next and accumulate them */
  793. next = 1;
  794. while (peer_info != NULL) {
  795. node = os_zalloc(sizeof(struct peer_objpath_node));
  796. if (!node) {
  797. out_of_mem = 1;
  798. goto error;
  799. }
  800. addr = peer_info->p2p_device_addr;
  801. os_snprintf(node->path, WPAS_DBUS_OBJECT_PATH_MAX,
  802. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART
  803. "/" COMPACT_MACSTR,
  804. wpa_s->dbus_new_path, MAC2STR(addr));
  805. dl_list_add_tail(&peer_objpath_list, &node->list);
  806. num++;
  807. peer_info = p2p_get_peer_found(p2p, addr, next);
  808. }
  809. /*
  810. * Now construct the peer object paths in a form suitable for
  811. * array_property_getter helper below.
  812. */
  813. peer_obj_paths = os_zalloc(num * sizeof(char *));
  814. if (!peer_obj_paths) {
  815. out_of_mem = 1;
  816. goto error;
  817. }
  818. dl_list_for_each_safe(node, tmp, &peer_objpath_list,
  819. struct peer_objpath_node, list)
  820. peer_obj_paths[i++] = node->path;
  821. reply = wpas_dbus_simple_array_property_getter(message,
  822. DBUS_TYPE_OBJECT_PATH,
  823. peer_obj_paths, num);
  824. error:
  825. if (peer_obj_paths)
  826. os_free(peer_obj_paths);
  827. dl_list_for_each_safe(node, tmp, &peer_objpath_list,
  828. struct peer_objpath_node, list) {
  829. dl_list_del(&node->list);
  830. os_free(node);
  831. }
  832. if (out_of_mem)
  833. reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
  834. NULL);
  835. return reply;
  836. }
  837. enum wpas_p2p_role {
  838. WPAS_P2P_ROLE_DEVICE,
  839. WPAS_P2P_ROLE_GO,
  840. WPAS_P2P_ROLE_CLIENT,
  841. };
  842. static enum wpas_p2p_role wpas_get_p2p_role(struct wpa_supplicant *wpa_s)
  843. {
  844. struct wpa_ssid *ssid = wpa_s->current_ssid;
  845. if (!ssid)
  846. return WPAS_P2P_ROLE_DEVICE;
  847. if (wpa_s->wpa_state != WPA_COMPLETED)
  848. return WPAS_P2P_ROLE_DEVICE;
  849. switch (ssid->mode) {
  850. case WPAS_MODE_P2P_GO:
  851. case WPAS_MODE_P2P_GROUP_FORMATION:
  852. return WPAS_P2P_ROLE_GO;
  853. case WPAS_MODE_INFRA:
  854. if (ssid->p2p_group)
  855. return WPAS_P2P_ROLE_CLIENT;
  856. return WPAS_P2P_ROLE_DEVICE;
  857. default:
  858. return WPAS_P2P_ROLE_DEVICE;
  859. }
  860. }
  861. DBusMessage *wpas_dbus_getter_p2p_role(DBusMessage * message,
  862. struct wpa_supplicant * wpa_s)
  863. {
  864. char *str;
  865. switch (wpas_get_p2p_role(wpa_s)) {
  866. case WPAS_P2P_ROLE_GO:
  867. str = "GO";
  868. break;
  869. case WPAS_P2P_ROLE_CLIENT:
  870. str = "client";
  871. break;
  872. default:
  873. str = "device";
  874. }
  875. return wpas_dbus_simple_property_getter(message, DBUS_TYPE_STRING,
  876. &str);
  877. }
  878. DBusMessage *wpas_dbus_getter_p2p_group(DBusMessage * message,
  879. struct wpa_supplicant * wpa_s)
  880. {
  881. if (wpa_s->dbus_groupobj_path == NULL)
  882. return NULL;
  883. return wpas_dbus_simple_property_getter(message,
  884. DBUS_TYPE_OBJECT_PATH,
  885. &wpa_s->dbus_groupobj_path);
  886. }
  887. DBusMessage *wpas_dbus_getter_p2p_peergo(DBusMessage * message,
  888. struct wpa_supplicant * wpa_s)
  889. {
  890. char go_peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  891. if (wpas_get_p2p_role(wpa_s) != WPAS_P2P_ROLE_CLIENT)
  892. return NULL;
  893. os_snprintf(go_peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  894. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  895. wpa_s->dbus_new_path, MAC2STR(wpa_s->go_dev_addr));
  896. path = go_peer_obj_path;
  897. return wpas_dbus_simple_property_getter(message,
  898. DBUS_TYPE_OBJECT_PATH, &path);
  899. }
  900. /*
  901. * Peer object properties accessor methods
  902. */
  903. DBusMessage *wpas_dbus_getter_p2p_peer_properties(DBusMessage * message,
  904. struct peer_handler_args *
  905. peer_args)
  906. {
  907. DBusMessage *reply = NULL;
  908. DBusMessageIter iter, variant_iter, dict_iter;
  909. const struct p2p_peer_info *info = NULL;
  910. char devtype[WPS_DEV_TYPE_BUFSIZE];
  911. /* get the peer info */
  912. info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
  913. peer_args->p2p_device_addr, 0);
  914. if (info == NULL)
  915. return NULL;
  916. if (message == NULL)
  917. reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
  918. else
  919. reply = dbus_message_new_method_return(message);
  920. if (!reply)
  921. goto err_no_mem;
  922. dbus_message_iter_init_append(reply, &iter);
  923. if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
  924. "a{sv}", &variant_iter) ||
  925. !wpa_dbus_dict_open_write(&variant_iter, &dict_iter))
  926. goto err_no_mem;
  927. /* Fill out the dictionary */
  928. wps_dev_type_bin2str(info->pri_dev_type, devtype, sizeof(devtype));
  929. if (!wpa_dbus_dict_append_string(&dict_iter, "DeviceName",
  930. info->device_name))
  931. goto err_no_mem;
  932. if (!wpa_dbus_dict_append_string(&dict_iter, "PrimaryDeviceType",
  933. devtype))
  934. goto err_no_mem;
  935. if (!wpa_dbus_dict_append_uint16(&dict_iter, "config_method",
  936. info->config_methods))
  937. goto err_no_mem;
  938. if (!wpa_dbus_dict_append_byte(&dict_iter, "devicecapability",
  939. info->dev_capab))
  940. goto err_no_mem;
  941. if (!wpa_dbus_dict_append_byte(&dict_iter, "groupcapability",
  942. info->group_capab))
  943. goto err_no_mem;
  944. if (info->wps_sec_dev_type_list_len) {
  945. char *sec_dev_types[MAX_SEC_DEVICE_TYPES];
  946. u8 *sec_dev_type_list = NULL;
  947. char secdevtype[WPS_DEV_TYPE_BUFSIZE];
  948. int num_sec_dev_types = 0;
  949. int i;
  950. sec_dev_type_list = os_zalloc(info->wps_sec_dev_type_list_len);
  951. if (sec_dev_type_list == NULL)
  952. goto err_no_mem;
  953. os_memcpy(sec_dev_type_list, info->wps_sec_dev_type_list,
  954. info->wps_sec_dev_type_list_len);
  955. for (i = 0; i < MAX_SEC_DEVICE_TYPES &&
  956. i < (int) (info->wps_sec_dev_type_list_len /
  957. WPS_DEV_TYPE_LEN);
  958. i++) {
  959. sec_dev_types[i] = os_zalloc(sizeof(secdevtype));
  960. if (!sec_dev_types[i] ||
  961. wps_dev_type_bin2str(
  962. &sec_dev_type_list[i *
  963. WPS_DEV_TYPE_LEN],
  964. sec_dev_types[i],
  965. sizeof(secdevtype)) == NULL) {
  966. while (--i >= 0)
  967. os_free(sec_dev_types[i]);
  968. os_free(sec_dev_type_list);
  969. goto err_no_mem;
  970. }
  971. num_sec_dev_types++;
  972. }
  973. os_free(sec_dev_type_list);
  974. if (num_sec_dev_types) {
  975. if (!wpa_dbus_dict_append_string_array(&dict_iter,
  976. "SecondaryDeviceTypes",
  977. (const char **)sec_dev_types,
  978. num_sec_dev_types)) {
  979. for (i = 0; i < num_sec_dev_types; i++)
  980. os_free(sec_dev_types[i]);
  981. goto err_no_mem;
  982. }
  983. for (i = 0; i < num_sec_dev_types; i++)
  984. os_free(sec_dev_types[i]);
  985. }
  986. }
  987. {
  988. /* Add WPS vendor extensions attribute */
  989. const struct wpabuf *vendor_extension[P2P_MAX_WPS_VENDOR_EXT];
  990. int i, num = 0;
  991. for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
  992. if (info->wps_vendor_ext[i] == NULL)
  993. continue;
  994. vendor_extension[num] = info->wps_vendor_ext[i];
  995. num++;
  996. }
  997. if (!wpa_dbus_dict_append_wpabuf_array(
  998. &dict_iter, "VendorExtension",
  999. vendor_extension, num))
  1000. goto err_no_mem;
  1001. }
  1002. if (!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
  1003. !dbus_message_iter_close_container(&iter, &variant_iter))
  1004. goto err_no_mem;
  1005. return reply;
  1006. err_no_mem:
  1007. dbus_message_unref(reply);
  1008. return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
  1009. }
  1010. DBusMessage *wpas_dbus_getter_p2p_peer_ies(DBusMessage * message,
  1011. struct peer_handler_args * peer_args)
  1012. {
  1013. return NULL;
  1014. }
  1015. /*
  1016. * Group object properties accessor methods
  1017. */
  1018. DBusMessage *wpas_dbus_getter_p2p_group_members(DBusMessage * message,
  1019. struct wpa_supplicant * wpa_s)
  1020. {
  1021. DBusMessage *reply = NULL;
  1022. struct wpa_ssid *ssid;
  1023. unsigned int num_members;
  1024. char **paths;
  1025. unsigned int i;
  1026. void *next = NULL;
  1027. const u8 *addr;
  1028. /* Ensure we are a GO */
  1029. if (wpa_s->wpa_state != WPA_COMPLETED)
  1030. goto out;
  1031. ssid = wpa_s->conf->ssid;
  1032. /* At present WPAS P2P_GO mode only applicable for p2p_go */
  1033. if (ssid->mode != WPAS_MODE_P2P_GO &&
  1034. ssid->mode != WPAS_MODE_AP &&
  1035. ssid->mode != WPAS_MODE_P2P_GROUP_FORMATION)
  1036. goto out;
  1037. num_members = p2p_get_group_num_members(wpa_s->p2p_group);
  1038. paths = os_zalloc(num_members * sizeof(char *));
  1039. if (!paths)
  1040. goto out_of_memory;
  1041. i = 0;
  1042. while ((addr = p2p_iterate_group_members(wpa_s->p2p_group, &next))) {
  1043. paths[i] = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
  1044. if (!paths[i])
  1045. goto out_of_memory;
  1046. os_snprintf(paths[i], WPAS_DBUS_OBJECT_PATH_MAX,
  1047. "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART
  1048. "/" COMPACT_MACSTR,
  1049. wpa_s->dbus_groupobj_path, MAC2STR(addr));
  1050. i++;
  1051. }
  1052. reply = wpas_dbus_simple_array_property_getter(message,
  1053. DBUS_TYPE_OBJECT_PATH,
  1054. paths, num_members);
  1055. out_free:
  1056. for (i = 0; i < num_members; i++)
  1057. os_free(paths[i]);
  1058. os_free(paths);
  1059. out:
  1060. return reply;
  1061. out_of_memory:
  1062. reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
  1063. goto out_free;
  1064. }
  1065. DBusMessage *wpas_dbus_getter_p2p_group_properties(
  1066. DBusMessage *message,
  1067. struct wpa_supplicant *wpa_s)
  1068. {
  1069. DBusMessage *reply = NULL;
  1070. DBusMessageIter iter, variant_iter, dict_iter;
  1071. struct hostapd_data *hapd = wpa_s->ap_iface->bss[0];
  1072. const struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
  1073. int num_vendor_ext = 0;
  1074. int i;
  1075. if (!hapd) {
  1076. reply = dbus_message_new_error(message, DBUS_ERROR_FAILED,
  1077. NULL);
  1078. return reply;
  1079. }
  1080. if (message == NULL)
  1081. reply = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
  1082. else
  1083. reply = dbus_message_new_method_return(message);
  1084. if (!reply)
  1085. goto err_no_mem;
  1086. dbus_message_iter_init_append(reply, &iter);
  1087. if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
  1088. "a{sv}", &variant_iter) ||
  1089. !wpa_dbus_dict_open_write(&variant_iter, &dict_iter))
  1090. goto err_no_mem;
  1091. /* Parse WPS Vendor Extensions sent in Beacon/Probe Response */
  1092. for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) {
  1093. if (hapd->conf->wps_vendor_ext[i] == NULL)
  1094. continue;
  1095. vendor_ext[num_vendor_ext++] = hapd->conf->wps_vendor_ext[i];
  1096. }
  1097. if (!wpa_dbus_dict_append_wpabuf_array(&dict_iter,
  1098. "WPSVendorExtensions",
  1099. vendor_ext, num_vendor_ext))
  1100. goto err_no_mem;
  1101. if (!wpa_dbus_dict_close_write(&variant_iter, &dict_iter) ||
  1102. !dbus_message_iter_close_container(&iter, &variant_iter))
  1103. goto err_no_mem;
  1104. return reply;
  1105. err_no_mem:
  1106. dbus_message_unref(reply);
  1107. return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, NULL);
  1108. }
  1109. DBusMessage *wpas_dbus_setter_p2p_group_properties(
  1110. DBusMessage *message,
  1111. struct wpa_supplicant *wpa_s)
  1112. {
  1113. DBusMessage *reply = NULL;
  1114. DBusMessageIter iter, variant_iter;
  1115. struct wpa_dbus_dict_entry entry = {.type = DBUS_TYPE_STRING };
  1116. DBusMessageIter iter_dict;
  1117. unsigned int i;
  1118. struct hostapd_data *hapd = wpa_s->ap_iface->bss[0];
  1119. if (!hapd)
  1120. goto error;
  1121. dbus_message_iter_init(message, &iter);
  1122. dbus_message_iter_next(&iter);
  1123. dbus_message_iter_next(&iter);
  1124. dbus_message_iter_recurse(&iter, &variant_iter);
  1125. if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict))
  1126. return wpas_dbus_error_invalid_args(message, NULL);
  1127. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1128. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
  1129. reply = wpas_dbus_error_invalid_args(message, NULL);
  1130. break;
  1131. }
  1132. if (os_strcmp(entry.key, "WPSVendorExtensions") == 0) {
  1133. if (entry.type != DBUS_TYPE_ARRAY ||
  1134. entry.array_type != WPAS_DBUS_TYPE_BINARRAY ||
  1135. entry.array_len > MAX_WPS_VENDOR_EXTENSIONS)
  1136. goto error;
  1137. for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) {
  1138. if (i < entry.array_len) {
  1139. hapd->conf->wps_vendor_ext[i] =
  1140. entry.binarray_value[i];
  1141. entry.binarray_value[i] = NULL;
  1142. } else
  1143. hapd->conf->wps_vendor_ext[i] = NULL;
  1144. }
  1145. hostapd_update_wps(hapd);
  1146. } else
  1147. goto error;
  1148. wpa_dbus_dict_entry_clear(&entry);
  1149. }
  1150. return reply;
  1151. error:
  1152. reply = wpas_dbus_error_invalid_args(message, entry.key);
  1153. wpa_dbus_dict_entry_clear(&entry);
  1154. return reply;
  1155. }
  1156. DBusMessage *wpas_dbus_handler_p2p_add_service(DBusMessage * message,
  1157. struct wpa_supplicant * wpa_s)
  1158. {
  1159. DBusMessageIter iter_dict;
  1160. DBusMessage *reply = NULL;
  1161. DBusMessageIter iter;
  1162. struct wpa_dbus_dict_entry entry;
  1163. int upnp = 0;
  1164. int bonjour = 0;
  1165. char *service = NULL;
  1166. struct wpabuf *query = NULL;
  1167. struct wpabuf *resp = NULL;
  1168. u8 version = 0;
  1169. dbus_message_iter_init(message, &iter);
  1170. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  1171. goto error;
  1172. if (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1173. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1174. goto error;
  1175. if (!strcmp(entry.key, "service_type") &&
  1176. (entry.type == DBUS_TYPE_STRING)) {
  1177. if (!strcmp(entry.str_value, "upnp"))
  1178. upnp = 1;
  1179. else if (!strcmp(entry.str_value, "bonjour"))
  1180. bonjour = 1;
  1181. else
  1182. goto error_clear;
  1183. wpa_dbus_dict_entry_clear(&entry);
  1184. }
  1185. }
  1186. if (upnp == 1) {
  1187. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1188. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1189. goto error;
  1190. if (!strcmp(entry.key, "version") &&
  1191. entry.type == DBUS_TYPE_INT32)
  1192. version = entry.uint32_value;
  1193. else if (!strcmp(entry.key, "service") &&
  1194. entry.type == DBUS_TYPE_STRING)
  1195. service = os_strdup(entry.str_value);
  1196. wpa_dbus_dict_entry_clear(&entry);
  1197. }
  1198. if (version <= 0 || service == NULL)
  1199. goto error;
  1200. if (wpas_p2p_service_add_upnp(wpa_s, version, service) != 0)
  1201. goto error;
  1202. os_free(service);
  1203. } else if (bonjour == 1) {
  1204. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1205. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1206. goto error;
  1207. if (!strcmp(entry.key, "query")) {
  1208. if ((entry.type != DBUS_TYPE_ARRAY) ||
  1209. (entry.array_type != DBUS_TYPE_BYTE))
  1210. goto error_clear;
  1211. query = wpabuf_alloc_copy(entry.bytearray_value,
  1212. entry.array_len);
  1213. } else if (!strcmp(entry.key, "response")) {
  1214. if ((entry.type != DBUS_TYPE_ARRAY) ||
  1215. (entry.array_type != DBUS_TYPE_BYTE))
  1216. goto error_clear;
  1217. resp = wpabuf_alloc_copy(entry.bytearray_value,
  1218. entry.array_len);
  1219. }
  1220. wpa_dbus_dict_entry_clear(&entry);
  1221. }
  1222. if (query == NULL || resp == NULL)
  1223. goto error;
  1224. if (wpas_p2p_service_add_bonjour(wpa_s, query, resp) < 0) {
  1225. wpabuf_free(query);
  1226. wpabuf_free(resp);
  1227. goto error;
  1228. }
  1229. } else
  1230. goto error;
  1231. return reply;
  1232. error_clear:
  1233. wpa_dbus_dict_entry_clear(&entry);
  1234. error:
  1235. return wpas_dbus_error_invalid_args(message, NULL);
  1236. }
  1237. DBusMessage *wpas_dbus_handler_p2p_delete_service(DBusMessage * message,
  1238. struct wpa_supplicant * wpa_s)
  1239. {
  1240. DBusMessageIter iter_dict;
  1241. DBusMessage *reply = NULL;
  1242. DBusMessageIter iter;
  1243. struct wpa_dbus_dict_entry entry;
  1244. int upnp = 0;
  1245. int bonjour = 0;
  1246. int ret = 0;
  1247. char *service = NULL;
  1248. struct wpabuf *query = NULL;
  1249. u8 version = 0;
  1250. dbus_message_iter_init(message, &iter);
  1251. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  1252. goto error;
  1253. if (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1254. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1255. goto error;
  1256. if (!strcmp(entry.key, "service_type") &&
  1257. (entry.type == DBUS_TYPE_STRING)) {
  1258. if (!strcmp(entry.str_value, "upnp"))
  1259. upnp = 1;
  1260. else if (!strcmp(entry.str_value, "bonjour"))
  1261. bonjour = 1;
  1262. else
  1263. goto error_clear;
  1264. wpa_dbus_dict_entry_clear(&entry);
  1265. }
  1266. }
  1267. if (upnp == 1) {
  1268. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1269. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1270. goto error;
  1271. if (!strcmp(entry.key, "version") &&
  1272. entry.type == DBUS_TYPE_INT32)
  1273. version = entry.uint32_value;
  1274. else if (!strcmp(entry.key, "service") &&
  1275. entry.type == DBUS_TYPE_STRING)
  1276. service = os_strdup(entry.str_value);
  1277. else
  1278. goto error_clear;
  1279. wpa_dbus_dict_entry_clear(&entry);
  1280. }
  1281. if (version <= 0 || service == NULL)
  1282. goto error;
  1283. ret = wpas_p2p_service_del_upnp(wpa_s, version, service);
  1284. os_free(service);
  1285. if (ret != 0)
  1286. goto error;
  1287. } else if (bonjour == 1) {
  1288. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1289. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1290. goto error;
  1291. if (!strcmp(entry.key, "query")) {
  1292. if ((entry.type != DBUS_TYPE_ARRAY) ||
  1293. (entry.array_type != DBUS_TYPE_BYTE))
  1294. goto error_clear;
  1295. query = wpabuf_alloc_copy(entry.bytearray_value,
  1296. entry.array_len);
  1297. } else
  1298. goto error_clear;
  1299. wpa_dbus_dict_entry_clear(&entry);
  1300. }
  1301. if (query == NULL)
  1302. goto error;
  1303. ret = wpas_p2p_service_del_bonjour(wpa_s, query);
  1304. if (ret != 0)
  1305. goto error;
  1306. wpabuf_free(query);
  1307. } else
  1308. goto error;
  1309. return reply;
  1310. error_clear:
  1311. wpa_dbus_dict_entry_clear(&entry);
  1312. error:
  1313. return wpas_dbus_error_invalid_args(message, NULL);
  1314. }
  1315. DBusMessage *wpas_dbus_handler_p2p_flush_service(DBusMessage * message,
  1316. struct wpa_supplicant * wpa_s)
  1317. {
  1318. wpas_p2p_service_flush(wpa_s);
  1319. return NULL;
  1320. }
  1321. DBusMessage *wpas_dbus_handler_p2p_service_sd_req(DBusMessage * message,
  1322. struct wpa_supplicant * wpa_s)
  1323. {
  1324. DBusMessageIter iter_dict;
  1325. DBusMessage *reply = NULL;
  1326. DBusMessageIter iter;
  1327. struct wpa_dbus_dict_entry entry;
  1328. int upnp = 0;
  1329. char *service = NULL;
  1330. char *peer_object_path = NULL;
  1331. struct wpabuf *tlv = NULL;
  1332. u8 version = 0;
  1333. u64 ref = 0;
  1334. u8 addr[ETH_ALEN];
  1335. dbus_message_iter_init(message, &iter);
  1336. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  1337. goto error;
  1338. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1339. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1340. goto error;
  1341. if (!strcmp(entry.key, "peer_object") &&
  1342. entry.type == DBUS_TYPE_OBJECT_PATH) {
  1343. peer_object_path = os_strdup(entry.str_value);
  1344. } else if (!strcmp(entry.key, "service_type") &&
  1345. entry.type == DBUS_TYPE_STRING) {
  1346. if (!strcmp(entry.str_value, "upnp"))
  1347. upnp = 1;
  1348. else
  1349. goto error_clear;
  1350. } else if (!strcmp(entry.key, "version") &&
  1351. entry.type == DBUS_TYPE_INT32) {
  1352. version = entry.uint32_value;
  1353. } else if (!strcmp(entry.key, "service") &&
  1354. entry.type == DBUS_TYPE_STRING) {
  1355. service = os_strdup(entry.str_value);
  1356. } else if (!strcmp(entry.key, "tlv")) {
  1357. if (entry.type != DBUS_TYPE_ARRAY ||
  1358. entry.array_type != DBUS_TYPE_BYTE)
  1359. goto error_clear;
  1360. tlv = wpabuf_alloc_copy(entry.bytearray_value,
  1361. entry.array_len);
  1362. } else
  1363. goto error_clear;
  1364. wpa_dbus_dict_entry_clear(&entry);
  1365. }
  1366. if (!peer_object_path ||
  1367. (parse_peer_object_path(peer_object_path, addr) < 0) ||
  1368. (p2p_get_peer_info(wpa_s->global->p2p, addr, 0, NULL, 0) < 0))
  1369. goto error;
  1370. if (upnp == 1) {
  1371. if (version <= 0 || service == NULL)
  1372. goto error;
  1373. ref = (unsigned long)wpas_p2p_sd_request_upnp(wpa_s, addr,
  1374. version, service);
  1375. } else {
  1376. if (tlv == NULL)
  1377. goto error;
  1378. ref = (unsigned long)wpas_p2p_sd_request(wpa_s, addr, tlv);
  1379. wpabuf_free(tlv);
  1380. }
  1381. if (ref != 0) {
  1382. reply = dbus_message_new_method_return(message);
  1383. dbus_message_append_args(reply, DBUS_TYPE_UINT64,
  1384. &ref, DBUS_TYPE_INVALID);
  1385. } else {
  1386. reply = wpas_dbus_error_unknown_error(message,
  1387. "Unable to send SD request");
  1388. }
  1389. out:
  1390. os_free(service);
  1391. os_free(peer_object_path);
  1392. return reply;
  1393. error_clear:
  1394. wpa_dbus_dict_entry_clear(&entry);
  1395. error:
  1396. if (tlv)
  1397. wpabuf_free(tlv);
  1398. reply = wpas_dbus_error_invalid_args(message, NULL);
  1399. goto out;
  1400. }
  1401. DBusMessage *wpas_dbus_handler_p2p_service_sd_res(
  1402. DBusMessage *message, struct wpa_supplicant *wpa_s)
  1403. {
  1404. DBusMessageIter iter_dict;
  1405. DBusMessage *reply = NULL;
  1406. DBusMessageIter iter;
  1407. struct wpa_dbus_dict_entry entry;
  1408. char *peer_object_path = NULL;
  1409. struct wpabuf *tlv = NULL;
  1410. int freq = 0;
  1411. int dlg_tok = 0;
  1412. u8 addr[ETH_ALEN];
  1413. dbus_message_iter_init(message, &iter);
  1414. if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
  1415. goto error;
  1416. while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
  1417. if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
  1418. goto error;
  1419. if (!strcmp(entry.key, "peer_object") &&
  1420. entry.type == DBUS_TYPE_OBJECT_PATH) {
  1421. peer_object_path = os_strdup(entry.str_value);
  1422. } else if (!strcmp(entry.key, "frequency") &&
  1423. entry.type == DBUS_TYPE_INT32) {
  1424. freq = entry.uint32_value;
  1425. } else if (!strcmp(entry.key, "dialog_token") &&
  1426. entry.type == DBUS_TYPE_UINT32) {
  1427. dlg_tok = entry.uint32_value;
  1428. } else if (!strcmp(entry.key, "tlvs")) {
  1429. if (entry.type != DBUS_TYPE_ARRAY ||
  1430. entry.array_type != DBUS_TYPE_BYTE)
  1431. goto error_clear;
  1432. tlv = wpabuf_alloc_copy(entry.bytearray_value,
  1433. entry.array_len);
  1434. } else
  1435. goto error_clear;
  1436. wpa_dbus_dict_entry_clear(&entry);
  1437. }
  1438. if (!peer_object_path ||
  1439. (parse_peer_object_path(peer_object_path, addr) < 0) ||
  1440. (p2p_get_peer_info(wpa_s->global->p2p, addr, 0, NULL, 0) < 0))
  1441. goto error;
  1442. if (tlv == NULL)
  1443. goto error;
  1444. wpas_p2p_sd_response(wpa_s, freq, addr, (u8) dlg_tok, tlv);
  1445. wpabuf_free(tlv);
  1446. out:
  1447. os_free(peer_object_path);
  1448. return reply;
  1449. error_clear:
  1450. wpa_dbus_dict_entry_clear(&entry);
  1451. error:
  1452. reply = wpas_dbus_error_invalid_args(message, NULL);
  1453. goto out;
  1454. }
  1455. DBusMessage *wpas_dbus_handler_p2p_service_sd_cancel_req(DBusMessage * message, struct wpa_supplicant
  1456. *wpa_s)
  1457. {
  1458. DBusMessageIter iter;
  1459. u64 req = 0;
  1460. dbus_message_iter_init(message, &iter);
  1461. dbus_message_iter_get_basic(&iter, &req);
  1462. if (req == 0)
  1463. goto error;
  1464. if (!wpas_p2p_sd_cancel_request(wpa_s, (void *)(unsigned long)req))
  1465. goto error;
  1466. return NULL;
  1467. error:
  1468. return wpas_dbus_error_invalid_args(message, NULL);
  1469. }
  1470. DBusMessage *wpas_dbus_handler_p2p_service_update(DBusMessage * message,
  1471. struct wpa_supplicant * wpa_s)
  1472. {
  1473. wpas_p2p_sd_service_update(wpa_s);
  1474. return NULL;
  1475. }
  1476. DBusMessage *wpas_dbus_handler_p2p_serv_disc_external(DBusMessage * message,
  1477. struct wpa_supplicant *
  1478. wpa_s)
  1479. {
  1480. DBusMessageIter iter;
  1481. int ext = 0;
  1482. dbus_message_iter_init(message, &iter);
  1483. dbus_message_iter_get_basic(&iter, &ext);
  1484. wpa_s->p2p_sd_over_ctrl_iface = ext;
  1485. return NULL;
  1486. }