dbus_new.c 116 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489
  1. /*
  2. * WPA Supplicant / dbus-based control interface
  3. * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
  4. * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
  5. * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
  6. *
  7. * This software may be distributed under the terms of the BSD license.
  8. * See README for more details.
  9. */
  10. #include "includes.h"
  11. #include "common.h"
  12. #include "common/ieee802_11_defs.h"
  13. #include "wps/wps.h"
  14. #include "../config.h"
  15. #include "../wpa_supplicant_i.h"
  16. #include "../bss.h"
  17. #include "../wpas_glue.h"
  18. #include "dbus_new_helpers.h"
  19. #include "dbus_dict_helpers.h"
  20. #include "dbus_new.h"
  21. #include "dbus_new_handlers.h"
  22. #include "dbus_common_i.h"
  23. #include "dbus_new_handlers_p2p.h"
  24. #include "p2p/p2p.h"
  25. #include "../p2p_supplicant.h"
  26. #ifdef CONFIG_AP /* until needed by something else */
  27. /*
  28. * NameOwnerChanged handling
  29. *
  30. * Some services we provide allow an application to register for
  31. * a signal that it needs. While it can also unregister, we must
  32. * be prepared for the case where the application simply crashes
  33. * and thus doesn't clean up properly. The way to handle this in
  34. * DBus is to register for the NameOwnerChanged signal which will
  35. * signal an owner change to NULL if the peer closes the socket
  36. * for whatever reason.
  37. *
  38. * Handle this signal via a filter function whenever necessary.
  39. * The code below also handles refcounting in case in the future
  40. * there will be multiple instances of this subscription scheme.
  41. */
  42. static const char wpas_dbus_noc_filter_str[] =
  43. "interface=org.freedesktop.DBus,member=NameOwnerChanged";
  44. static DBusHandlerResult noc_filter(DBusConnection *conn,
  45. DBusMessage *message, void *data)
  46. {
  47. struct wpas_dbus_priv *priv = data;
  48. if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
  49. return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
  50. if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
  51. "NameOwnerChanged")) {
  52. const char *name;
  53. const char *prev_owner;
  54. const char *new_owner;
  55. DBusError derr;
  56. struct wpa_supplicant *wpa_s;
  57. dbus_error_init(&derr);
  58. if (!dbus_message_get_args(message, &derr,
  59. DBUS_TYPE_STRING, &name,
  60. DBUS_TYPE_STRING, &prev_owner,
  61. DBUS_TYPE_STRING, &new_owner,
  62. DBUS_TYPE_INVALID)) {
  63. /* Ignore this error */
  64. dbus_error_free(&derr);
  65. return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
  66. }
  67. for (wpa_s = priv->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
  68. if (wpa_s->preq_notify_peer != NULL &&
  69. os_strcmp(name, wpa_s->preq_notify_peer) == 0 &&
  70. (new_owner == NULL || os_strlen(new_owner) == 0)) {
  71. /* probe request owner disconnected */
  72. os_free(wpa_s->preq_notify_peer);
  73. wpa_s->preq_notify_peer = NULL;
  74. wpas_dbus_unsubscribe_noc(priv);
  75. }
  76. }
  77. }
  78. return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
  79. }
  80. void wpas_dbus_subscribe_noc(struct wpas_dbus_priv *priv)
  81. {
  82. priv->dbus_noc_refcnt++;
  83. if (priv->dbus_noc_refcnt > 1)
  84. return;
  85. if (!dbus_connection_add_filter(priv->con, noc_filter, priv, NULL)) {
  86. wpa_printf(MSG_ERROR, "dbus: failed to add filter");
  87. return;
  88. }
  89. dbus_bus_add_match(priv->con, wpas_dbus_noc_filter_str, NULL);
  90. }
  91. void wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv *priv)
  92. {
  93. priv->dbus_noc_refcnt--;
  94. if (priv->dbus_noc_refcnt > 0)
  95. return;
  96. dbus_bus_remove_match(priv->con, wpas_dbus_noc_filter_str, NULL);
  97. dbus_connection_remove_filter(priv->con, noc_filter, priv);
  98. }
  99. #endif /* CONFIG_AP */
  100. /**
  101. * wpas_dbus_signal_interface - Send a interface related event signal
  102. * @wpa_s: %wpa_supplicant network interface data
  103. * @sig_name: signal name - InterfaceAdded or InterfaceRemoved
  104. * @properties: Whether to add second argument with object properties
  105. *
  106. * Notify listeners about event related with interface
  107. */
  108. static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s,
  109. const char *sig_name, int properties)
  110. {
  111. struct wpas_dbus_priv *iface;
  112. DBusMessage *msg;
  113. DBusMessageIter iter;
  114. iface = wpa_s->global->dbus;
  115. /* Do nothing if the control interface is not turned on */
  116. if (iface == NULL || !wpa_s->dbus_new_path)
  117. return;
  118. msg = dbus_message_new_signal(WPAS_DBUS_NEW_PATH,
  119. WPAS_DBUS_NEW_INTERFACE, sig_name);
  120. if (msg == NULL)
  121. return;
  122. dbus_message_iter_init_append(msg, &iter);
  123. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  124. &wpa_s->dbus_new_path) ||
  125. (properties &&
  126. !wpa_dbus_get_object_properties(
  127. iface, wpa_s->dbus_new_path,
  128. WPAS_DBUS_NEW_IFACE_INTERFACE, &iter)))
  129. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  130. else
  131. dbus_connection_send(iface->con, msg, NULL);
  132. dbus_message_unref(msg);
  133. }
  134. /**
  135. * wpas_dbus_signal_interface_added - Send a interface created signal
  136. * @wpa_s: %wpa_supplicant network interface data
  137. *
  138. * Notify listeners about creating new interface
  139. */
  140. static void wpas_dbus_signal_interface_added(struct wpa_supplicant *wpa_s)
  141. {
  142. wpas_dbus_signal_interface(wpa_s, "InterfaceAdded", TRUE);
  143. }
  144. /**
  145. * wpas_dbus_signal_interface_removed - Send a interface removed signal
  146. * @wpa_s: %wpa_supplicant network interface data
  147. *
  148. * Notify listeners about removing interface
  149. */
  150. static void wpas_dbus_signal_interface_removed(struct wpa_supplicant *wpa_s)
  151. {
  152. wpas_dbus_signal_interface(wpa_s, "InterfaceRemoved", FALSE);
  153. }
  154. /**
  155. * wpas_dbus_signal_scan_done - send scan done signal
  156. * @wpa_s: %wpa_supplicant network interface data
  157. * @success: indicates if scanning succeed or failed
  158. *
  159. * Notify listeners about finishing a scan
  160. */
  161. void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success)
  162. {
  163. struct wpas_dbus_priv *iface;
  164. DBusMessage *msg;
  165. dbus_bool_t succ;
  166. iface = wpa_s->global->dbus;
  167. /* Do nothing if the control interface is not turned on */
  168. if (iface == NULL || !wpa_s->dbus_new_path)
  169. return;
  170. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  171. WPAS_DBUS_NEW_IFACE_INTERFACE,
  172. "ScanDone");
  173. if (msg == NULL)
  174. return;
  175. succ = success ? TRUE : FALSE;
  176. if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &succ,
  177. DBUS_TYPE_INVALID))
  178. dbus_connection_send(iface->con, msg, NULL);
  179. else
  180. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  181. dbus_message_unref(msg);
  182. }
  183. /**
  184. * wpas_dbus_signal_bss - Send a BSS related event signal
  185. * @wpa_s: %wpa_supplicant network interface data
  186. * @bss_obj_path: BSS object path
  187. * @sig_name: signal name - BSSAdded or BSSRemoved
  188. * @properties: Whether to add second argument with object properties
  189. *
  190. * Notify listeners about event related with BSS
  191. */
  192. static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s,
  193. const char *bss_obj_path,
  194. const char *sig_name, int properties)
  195. {
  196. struct wpas_dbus_priv *iface;
  197. DBusMessage *msg;
  198. DBusMessageIter iter;
  199. iface = wpa_s->global->dbus;
  200. /* Do nothing if the control interface is not turned on */
  201. if (iface == NULL || !wpa_s->dbus_new_path)
  202. return;
  203. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  204. WPAS_DBUS_NEW_IFACE_INTERFACE,
  205. sig_name);
  206. if (msg == NULL)
  207. return;
  208. dbus_message_iter_init_append(msg, &iter);
  209. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  210. &bss_obj_path) ||
  211. (properties &&
  212. !wpa_dbus_get_object_properties(iface, bss_obj_path,
  213. WPAS_DBUS_NEW_IFACE_BSS,
  214. &iter)))
  215. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  216. else
  217. dbus_connection_send(iface->con, msg, NULL);
  218. dbus_message_unref(msg);
  219. }
  220. /**
  221. * wpas_dbus_signal_bss_added - Send a BSS added signal
  222. * @wpa_s: %wpa_supplicant network interface data
  223. * @bss_obj_path: new BSS object path
  224. *
  225. * Notify listeners about adding new BSS
  226. */
  227. static void wpas_dbus_signal_bss_added(struct wpa_supplicant *wpa_s,
  228. const char *bss_obj_path)
  229. {
  230. wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSAdded", TRUE);
  231. }
  232. /**
  233. * wpas_dbus_signal_bss_removed - Send a BSS removed signal
  234. * @wpa_s: %wpa_supplicant network interface data
  235. * @bss_obj_path: BSS object path
  236. *
  237. * Notify listeners about removing BSS
  238. */
  239. static void wpas_dbus_signal_bss_removed(struct wpa_supplicant *wpa_s,
  240. const char *bss_obj_path)
  241. {
  242. wpas_dbus_signal_bss(wpa_s, bss_obj_path, "BSSRemoved", FALSE);
  243. }
  244. /**
  245. * wpas_dbus_signal_blob - Send a blob related event signal
  246. * @wpa_s: %wpa_supplicant network interface data
  247. * @name: blob name
  248. * @sig_name: signal name - BlobAdded or BlobRemoved
  249. *
  250. * Notify listeners about event related with blob
  251. */
  252. static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s,
  253. const char *name, const char *sig_name)
  254. {
  255. struct wpas_dbus_priv *iface;
  256. DBusMessage *msg;
  257. iface = wpa_s->global->dbus;
  258. /* Do nothing if the control interface is not turned on */
  259. if (iface == NULL || !wpa_s->dbus_new_path)
  260. return;
  261. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  262. WPAS_DBUS_NEW_IFACE_INTERFACE,
  263. sig_name);
  264. if (msg == NULL)
  265. return;
  266. if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
  267. DBUS_TYPE_INVALID))
  268. dbus_connection_send(iface->con, msg, NULL);
  269. else
  270. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  271. dbus_message_unref(msg);
  272. }
  273. /**
  274. * wpas_dbus_signal_blob_added - Send a blob added signal
  275. * @wpa_s: %wpa_supplicant network interface data
  276. * @name: blob name
  277. *
  278. * Notify listeners about adding a new blob
  279. */
  280. void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
  281. const char *name)
  282. {
  283. wpas_dbus_signal_blob(wpa_s, name, "BlobAdded");
  284. }
  285. /**
  286. * wpas_dbus_signal_blob_removed - Send a blob removed signal
  287. * @wpa_s: %wpa_supplicant network interface data
  288. * @name: blob name
  289. *
  290. * Notify listeners about removing blob
  291. */
  292. void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
  293. const char *name)
  294. {
  295. wpas_dbus_signal_blob(wpa_s, name, "BlobRemoved");
  296. }
  297. /**
  298. * wpas_dbus_signal_network - Send a network related event signal
  299. * @wpa_s: %wpa_supplicant network interface data
  300. * @id: new network id
  301. * @sig_name: signal name - NetworkAdded, NetworkRemoved or NetworkSelected
  302. * @properties: determines if add second argument with object properties
  303. *
  304. * Notify listeners about event related with configured network
  305. */
  306. static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s,
  307. int id, const char *sig_name,
  308. int properties)
  309. {
  310. struct wpas_dbus_priv *iface;
  311. DBusMessage *msg;
  312. DBusMessageIter iter;
  313. char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  314. iface = wpa_s->global->dbus;
  315. /* Do nothing if the control interface is not turned on */
  316. if (iface == NULL || !wpa_s->dbus_new_path)
  317. return;
  318. os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  319. "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
  320. wpa_s->dbus_new_path, id);
  321. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  322. WPAS_DBUS_NEW_IFACE_INTERFACE,
  323. sig_name);
  324. if (msg == NULL)
  325. return;
  326. dbus_message_iter_init_append(msg, &iter);
  327. path = net_obj_path;
  328. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  329. &path) ||
  330. (properties &&
  331. !wpa_dbus_get_object_properties(
  332. iface, net_obj_path, WPAS_DBUS_NEW_IFACE_NETWORK,
  333. &iter)))
  334. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  335. else
  336. dbus_connection_send(iface->con, msg, NULL);
  337. dbus_message_unref(msg);
  338. }
  339. /**
  340. * wpas_dbus_signal_network_added - Send a network added signal
  341. * @wpa_s: %wpa_supplicant network interface data
  342. * @id: new network id
  343. *
  344. * Notify listeners about adding new network
  345. */
  346. static void wpas_dbus_signal_network_added(struct wpa_supplicant *wpa_s,
  347. int id)
  348. {
  349. wpas_dbus_signal_network(wpa_s, id, "NetworkAdded", TRUE);
  350. }
  351. /**
  352. * wpas_dbus_signal_network_removed - Send a network removed signal
  353. * @wpa_s: %wpa_supplicant network interface data
  354. * @id: network id
  355. *
  356. * Notify listeners about removing a network
  357. */
  358. static void wpas_dbus_signal_network_removed(struct wpa_supplicant *wpa_s,
  359. int id)
  360. {
  361. wpas_dbus_signal_network(wpa_s, id, "NetworkRemoved", FALSE);
  362. }
  363. /**
  364. * wpas_dbus_signal_network_selected - Send a network selected signal
  365. * @wpa_s: %wpa_supplicant network interface data
  366. * @id: network id
  367. *
  368. * Notify listeners about selecting a network
  369. */
  370. void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id)
  371. {
  372. wpas_dbus_signal_network(wpa_s, id, "NetworkSelected", FALSE);
  373. }
  374. /**
  375. * wpas_dbus_signal_network_request - Indicate that additional information
  376. * (EAP password, etc.) is required to complete the association to this SSID
  377. * @wpa_s: %wpa_supplicant network interface data
  378. * @rtype: The specific additional information required
  379. * @default_text: Optional description of required information
  380. *
  381. * Request additional information or passwords to complete an association
  382. * request.
  383. */
  384. void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s,
  385. struct wpa_ssid *ssid,
  386. enum wpa_ctrl_req_type rtype,
  387. const char *default_txt)
  388. {
  389. struct wpas_dbus_priv *iface;
  390. DBusMessage *msg;
  391. DBusMessageIter iter;
  392. char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  393. const char *field, *txt = NULL, *net_ptr;
  394. iface = wpa_s->global->dbus;
  395. /* Do nothing if the control interface is not turned on */
  396. if (iface == NULL || !wpa_s->dbus_new_path)
  397. return;
  398. field = wpa_supplicant_ctrl_req_to_string(rtype, default_txt, &txt);
  399. if (field == NULL)
  400. return;
  401. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  402. WPAS_DBUS_NEW_IFACE_INTERFACE,
  403. "NetworkRequest");
  404. if (msg == NULL)
  405. return;
  406. os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  407. "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
  408. wpa_s->dbus_new_path, ssid->id);
  409. net_ptr = &net_obj_path[0];
  410. dbus_message_iter_init_append(msg, &iter);
  411. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  412. &net_ptr) ||
  413. !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &field) ||
  414. !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &txt))
  415. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  416. else
  417. dbus_connection_send(iface->con, msg, NULL);
  418. dbus_message_unref(msg);
  419. }
  420. /**
  421. * wpas_dbus_signal_network_enabled_changed - Signals Enabled property changes
  422. * @wpa_s: %wpa_supplicant network interface data
  423. * @ssid: configured network which Enabled property has changed
  424. *
  425. * Sends PropertyChanged signals containing new value of Enabled property
  426. * for specified network
  427. */
  428. void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
  429. struct wpa_ssid *ssid)
  430. {
  431. char path[WPAS_DBUS_OBJECT_PATH_MAX];
  432. if (!wpa_s->dbus_new_path)
  433. return;
  434. os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
  435. "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
  436. wpa_s->dbus_new_path, ssid->id);
  437. wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
  438. WPAS_DBUS_NEW_IFACE_NETWORK, "Enabled");
  439. }
  440. #ifdef CONFIG_WPS
  441. /**
  442. * wpas_dbus_signal_wps_event_pbc_overlap - Signals PBC overlap WPS event
  443. * @wpa_s: %wpa_supplicant network interface data
  444. *
  445. * Sends Event dbus signal with name "pbc-overlap" and empty dict as arguments
  446. */
  447. void wpas_dbus_signal_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
  448. {
  449. DBusMessage *msg;
  450. DBusMessageIter iter, dict_iter;
  451. struct wpas_dbus_priv *iface;
  452. char *key = "pbc-overlap";
  453. iface = wpa_s->global->dbus;
  454. /* Do nothing if the control interface is not turned on */
  455. if (iface == NULL || !wpa_s->dbus_new_path)
  456. return;
  457. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  458. WPAS_DBUS_NEW_IFACE_WPS, "Event");
  459. if (msg == NULL)
  460. return;
  461. dbus_message_iter_init_append(msg, &iter);
  462. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
  463. !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  464. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  465. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  466. else
  467. dbus_connection_send(iface->con, msg, NULL);
  468. dbus_message_unref(msg);
  469. }
  470. /**
  471. * wpas_dbus_signal_wps_event_success - Signals Success WPS event
  472. * @wpa_s: %wpa_supplicant network interface data
  473. *
  474. * Sends Event dbus signal with name "success" and empty dict as arguments
  475. */
  476. void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s)
  477. {
  478. DBusMessage *msg;
  479. DBusMessageIter iter, dict_iter;
  480. struct wpas_dbus_priv *iface;
  481. char *key = "success";
  482. iface = wpa_s->global->dbus;
  483. /* Do nothing if the control interface is not turned on */
  484. if (iface == NULL || !wpa_s->dbus_new_path)
  485. return;
  486. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  487. WPAS_DBUS_NEW_IFACE_WPS, "Event");
  488. if (msg == NULL)
  489. return;
  490. dbus_message_iter_init_append(msg, &iter);
  491. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
  492. !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  493. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  494. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  495. else
  496. dbus_connection_send(iface->con, msg, NULL);
  497. dbus_message_unref(msg);
  498. }
  499. /**
  500. * wpas_dbus_signal_wps_event_fail - Signals Fail WPS event
  501. * @wpa_s: %wpa_supplicant network interface data
  502. * @fail: WPS failure information
  503. *
  504. * Sends Event dbus signal with name "fail" and dictionary containing
  505. * "msg field with fail message number (int32) as arguments
  506. */
  507. void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
  508. struct wps_event_fail *fail)
  509. {
  510. DBusMessage *msg;
  511. DBusMessageIter iter, dict_iter;
  512. struct wpas_dbus_priv *iface;
  513. char *key = "fail";
  514. iface = wpa_s->global->dbus;
  515. /* Do nothing if the control interface is not turned on */
  516. if (iface == NULL || !wpa_s->dbus_new_path)
  517. return;
  518. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  519. WPAS_DBUS_NEW_IFACE_WPS, "Event");
  520. if (msg == NULL)
  521. return;
  522. dbus_message_iter_init_append(msg, &iter);
  523. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
  524. !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  525. !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
  526. !wpa_dbus_dict_append_int32(&dict_iter, "config_error",
  527. fail->config_error) ||
  528. !wpa_dbus_dict_append_int32(&dict_iter, "error_indication",
  529. fail->error_indication) ||
  530. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  531. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  532. else
  533. dbus_connection_send(iface->con, msg, NULL);
  534. dbus_message_unref(msg);
  535. }
  536. /**
  537. * wpas_dbus_signal_wps_event_m2d - Signals M2D WPS event
  538. * @wpa_s: %wpa_supplicant network interface data
  539. * @m2d: M2D event data information
  540. *
  541. * Sends Event dbus signal with name "m2d" and dictionary containing
  542. * fields of wps_event_m2d structure.
  543. */
  544. void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
  545. struct wps_event_m2d *m2d)
  546. {
  547. DBusMessage *msg;
  548. DBusMessageIter iter, dict_iter;
  549. struct wpas_dbus_priv *iface;
  550. char *key = "m2d";
  551. iface = wpa_s->global->dbus;
  552. /* Do nothing if the control interface is not turned on */
  553. if (iface == NULL || !wpa_s->dbus_new_path)
  554. return;
  555. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  556. WPAS_DBUS_NEW_IFACE_WPS, "Event");
  557. if (msg == NULL)
  558. return;
  559. dbus_message_iter_init_append(msg, &iter);
  560. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
  561. !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  562. !wpa_dbus_dict_append_uint16(&dict_iter, "config_methods",
  563. m2d->config_methods) ||
  564. !wpa_dbus_dict_append_byte_array(&dict_iter, "manufacturer",
  565. (const char *) m2d->manufacturer,
  566. m2d->manufacturer_len) ||
  567. !wpa_dbus_dict_append_byte_array(&dict_iter, "model_name",
  568. (const char *) m2d->model_name,
  569. m2d->model_name_len) ||
  570. !wpa_dbus_dict_append_byte_array(&dict_iter, "model_number",
  571. (const char *) m2d->model_number,
  572. m2d->model_number_len) ||
  573. !wpa_dbus_dict_append_byte_array(&dict_iter, "serial_number",
  574. (const char *)
  575. m2d->serial_number,
  576. m2d->serial_number_len) ||
  577. !wpa_dbus_dict_append_byte_array(&dict_iter, "dev_name",
  578. (const char *) m2d->dev_name,
  579. m2d->dev_name_len) ||
  580. !wpa_dbus_dict_append_byte_array(&dict_iter, "primary_dev_type",
  581. (const char *)
  582. m2d->primary_dev_type, 8) ||
  583. !wpa_dbus_dict_append_uint16(&dict_iter, "config_error",
  584. m2d->config_error) ||
  585. !wpa_dbus_dict_append_uint16(&dict_iter, "dev_password_id",
  586. m2d->dev_password_id) ||
  587. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  588. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  589. else
  590. dbus_connection_send(iface->con, msg, NULL);
  591. dbus_message_unref(msg);
  592. }
  593. /**
  594. * wpas_dbus_signal_wps_cred - Signals new credentials
  595. * @wpa_s: %wpa_supplicant network interface data
  596. * @cred: WPS Credential information
  597. *
  598. * Sends signal with credentials in directory argument
  599. */
  600. void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
  601. const struct wps_credential *cred)
  602. {
  603. DBusMessage *msg;
  604. DBusMessageIter iter, dict_iter;
  605. struct wpas_dbus_priv *iface;
  606. char *auth_type[5]; /* we have five possible authentication types */
  607. int at_num = 0;
  608. char *encr_type[3]; /* we have three possible encryption types */
  609. int et_num = 0;
  610. iface = wpa_s->global->dbus;
  611. /* Do nothing if the control interface is not turned on */
  612. if (iface == NULL || !wpa_s->dbus_new_path)
  613. return;
  614. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  615. WPAS_DBUS_NEW_IFACE_WPS,
  616. "Credentials");
  617. if (msg == NULL)
  618. return;
  619. dbus_message_iter_init_append(msg, &iter);
  620. if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
  621. goto nomem;
  622. if (cred->auth_type & WPS_AUTH_OPEN)
  623. auth_type[at_num++] = "open";
  624. if (cred->auth_type & WPS_AUTH_WPAPSK)
  625. auth_type[at_num++] = "wpa-psk";
  626. if (cred->auth_type & WPS_AUTH_WPA)
  627. auth_type[at_num++] = "wpa-eap";
  628. if (cred->auth_type & WPS_AUTH_WPA2)
  629. auth_type[at_num++] = "wpa2-eap";
  630. if (cred->auth_type & WPS_AUTH_WPA2PSK)
  631. auth_type[at_num++] = "wpa2-psk";
  632. if (cred->encr_type & WPS_ENCR_NONE)
  633. encr_type[et_num++] = "none";
  634. if (cred->encr_type & WPS_ENCR_TKIP)
  635. encr_type[et_num++] = "tkip";
  636. if (cred->encr_type & WPS_ENCR_AES)
  637. encr_type[et_num++] = "aes";
  638. if ((wpa_s->current_ssid &&
  639. !wpa_dbus_dict_append_byte_array(
  640. &dict_iter, "BSSID",
  641. (const char *) wpa_s->current_ssid->bssid, ETH_ALEN)) ||
  642. !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
  643. (const char *) cred->ssid,
  644. cred->ssid_len) ||
  645. !wpa_dbus_dict_append_string_array(&dict_iter, "AuthType",
  646. (const char **) auth_type,
  647. at_num) ||
  648. !wpa_dbus_dict_append_string_array(&dict_iter, "EncrType",
  649. (const char **) encr_type,
  650. et_num) ||
  651. !wpa_dbus_dict_append_byte_array(&dict_iter, "Key",
  652. (const char *) cred->key,
  653. cred->key_len) ||
  654. !wpa_dbus_dict_append_uint32(&dict_iter, "KeyIndex",
  655. cred->key_idx) ||
  656. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  657. goto nomem;
  658. dbus_connection_send(iface->con, msg, NULL);
  659. nomem:
  660. dbus_message_unref(msg);
  661. }
  662. #endif /* CONFIG_WPS */
  663. #ifdef CONFIG_MESH
  664. void wpas_dbus_signal_mesh_group_started(struct wpa_supplicant *wpa_s,
  665. struct wpa_ssid *ssid)
  666. {
  667. struct wpas_dbus_priv *iface;
  668. DBusMessage *msg;
  669. DBusMessageIter iter, dict_iter;
  670. iface = wpa_s->global->dbus;
  671. /* Do nothing if the control interface is not turned on */
  672. if (!iface || !wpa_s->dbus_new_path)
  673. return;
  674. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  675. WPAS_DBUS_NEW_IFACE_MESH,
  676. "MeshGroupStarted");
  677. if (!msg)
  678. return;
  679. dbus_message_iter_init_append(msg, &iter);
  680. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  681. !wpa_dbus_dict_append_byte_array(&dict_iter, "SSID",
  682. (const char *) ssid->ssid,
  683. ssid->ssid_len) ||
  684. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  685. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  686. else
  687. dbus_connection_send(iface->con, msg, NULL);
  688. dbus_message_unref(msg);
  689. }
  690. #endif /* CONFIG_MESH */
  691. void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
  692. int depth, const char *subject,
  693. const char *altsubject[],
  694. int num_altsubject,
  695. const char *cert_hash,
  696. const struct wpabuf *cert)
  697. {
  698. struct wpas_dbus_priv *iface;
  699. DBusMessage *msg;
  700. DBusMessageIter iter, dict_iter;
  701. iface = wpa_s->global->dbus;
  702. /* Do nothing if the control interface is not turned on */
  703. if (iface == NULL || !wpa_s->dbus_new_path)
  704. return;
  705. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  706. WPAS_DBUS_NEW_IFACE_INTERFACE,
  707. "Certification");
  708. if (msg == NULL)
  709. return;
  710. dbus_message_iter_init_append(msg, &iter);
  711. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  712. !wpa_dbus_dict_append_uint32(&dict_iter, "depth", depth) ||
  713. !wpa_dbus_dict_append_string(&dict_iter, "subject", subject) ||
  714. (altsubject && num_altsubject &&
  715. !wpa_dbus_dict_append_string_array(&dict_iter, "altsubject",
  716. altsubject, num_altsubject)) ||
  717. (cert_hash &&
  718. !wpa_dbus_dict_append_string(&dict_iter, "cert_hash",
  719. cert_hash)) ||
  720. (cert &&
  721. !wpa_dbus_dict_append_byte_array(&dict_iter, "cert",
  722. wpabuf_head(cert),
  723. wpabuf_len(cert))) ||
  724. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  725. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  726. else
  727. dbus_connection_send(iface->con, msg, NULL);
  728. dbus_message_unref(msg);
  729. }
  730. void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s,
  731. const char *status, const char *parameter)
  732. {
  733. struct wpas_dbus_priv *iface;
  734. DBusMessage *msg;
  735. DBusMessageIter iter;
  736. iface = wpa_s->global->dbus;
  737. /* Do nothing if the control interface is not turned on */
  738. if (iface == NULL || !wpa_s->dbus_new_path)
  739. return;
  740. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  741. WPAS_DBUS_NEW_IFACE_INTERFACE,
  742. "EAP");
  743. if (msg == NULL)
  744. return;
  745. dbus_message_iter_init_append(msg, &iter);
  746. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &status) ||
  747. !dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
  748. &parameter))
  749. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  750. else
  751. dbus_connection_send(iface->con, msg, NULL);
  752. dbus_message_unref(msg);
  753. }
  754. /**
  755. * wpas_dbus_signal_sta - Send a station related event signal
  756. * @wpa_s: %wpa_supplicant network interface data
  757. * @sta: station mac address
  758. * @sig_name: signal name - StaAuthorized or StaDeauthorized
  759. *
  760. * Notify listeners about event related with station
  761. */
  762. static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s,
  763. const u8 *sta, const char *sig_name)
  764. {
  765. struct wpas_dbus_priv *iface;
  766. DBusMessage *msg;
  767. char sta_mac[WPAS_DBUS_OBJECT_PATH_MAX];
  768. char *dev_mac;
  769. os_snprintf(sta_mac, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(sta));
  770. dev_mac = sta_mac;
  771. iface = wpa_s->global->dbus;
  772. /* Do nothing if the control interface is not turned on */
  773. if (iface == NULL || !wpa_s->dbus_new_path)
  774. return;
  775. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  776. WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name);
  777. if (msg == NULL)
  778. return;
  779. if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac,
  780. DBUS_TYPE_INVALID))
  781. dbus_connection_send(iface->con, msg, NULL);
  782. else
  783. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  784. dbus_message_unref(msg);
  785. wpa_printf(MSG_DEBUG, "dbus: Station MAC address '%s' '%s'",
  786. sta_mac, sig_name);
  787. }
  788. /**
  789. * wpas_dbus_signal_sta_authorized - Send a STA authorized signal
  790. * @wpa_s: %wpa_supplicant network interface data
  791. * @sta: station mac address
  792. *
  793. * Notify listeners a new station has been authorized
  794. */
  795. void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s,
  796. const u8 *sta)
  797. {
  798. wpas_dbus_signal_sta(wpa_s, sta, "StaAuthorized");
  799. }
  800. /**
  801. * wpas_dbus_signal_sta_deauthorized - Send a STA deauthorized signal
  802. * @wpa_s: %wpa_supplicant network interface data
  803. * @sta: station mac address
  804. *
  805. * Notify listeners a station has been deauthorized
  806. */
  807. void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s,
  808. const u8 *sta)
  809. {
  810. wpas_dbus_signal_sta(wpa_s, sta, "StaDeauthorized");
  811. }
  812. #ifdef CONFIG_P2P
  813. /**
  814. * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
  815. * @wpa_s: %wpa_supplicant network interface data
  816. * @role: role of this device (client or GO)
  817. * Sends signal with i/f name and role as string arguments
  818. */
  819. void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
  820. const char *role)
  821. {
  822. DBusMessage *msg;
  823. DBusMessageIter iter, dict_iter;
  824. struct wpas_dbus_priv *iface = wpa_s->global->dbus;
  825. struct wpa_supplicant *parent;
  826. /* Do nothing if the control interface is not turned on */
  827. if (iface == NULL)
  828. return;
  829. parent = wpa_s->parent;
  830. if (parent->p2p_mgmt)
  831. parent = parent->parent;
  832. if (!wpa_s->dbus_groupobj_path || !wpa_s->dbus_new_path ||
  833. !parent->dbus_new_path)
  834. return;
  835. msg = dbus_message_new_signal(parent->dbus_new_path,
  836. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  837. "GroupFinished");
  838. if (msg == NULL)
  839. return;
  840. dbus_message_iter_init_append(msg, &iter);
  841. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  842. !wpa_dbus_dict_append_object_path(&dict_iter,
  843. "interface_object",
  844. wpa_s->dbus_new_path) ||
  845. !wpa_dbus_dict_append_string(&dict_iter, "role", role) ||
  846. !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
  847. wpa_s->dbus_groupobj_path) ||
  848. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  849. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  850. else
  851. dbus_connection_send(iface->con, msg, NULL);
  852. dbus_message_unref(msg);
  853. }
  854. /**
  855. * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
  856. *
  857. * @dev_addr - who sent the request or responded to our request.
  858. * @request - Will be 1 if request, 0 for response.
  859. * @status - valid only in case of response
  860. * @config_methods - wps config methods
  861. * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
  862. *
  863. * Sends following provision discovery related events:
  864. * ProvisionDiscoveryRequestDisplayPin
  865. * ProvisionDiscoveryResponseDisplayPin
  866. * ProvisionDiscoveryRequestEnterPin
  867. * ProvisionDiscoveryResponseEnterPin
  868. * ProvisionDiscoveryPBCRequest
  869. * ProvisionDiscoveryPBCResponse
  870. *
  871. * TODO::
  872. * ProvisionDiscoveryFailure (timeout case)
  873. */
  874. void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
  875. const u8 *dev_addr, int request,
  876. enum p2p_prov_disc_status status,
  877. u16 config_methods,
  878. unsigned int generated_pin)
  879. {
  880. DBusMessage *msg;
  881. DBusMessageIter iter;
  882. struct wpas_dbus_priv *iface;
  883. char *_signal;
  884. int add_pin = 0;
  885. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  886. int error_ret = 1;
  887. char pin[9], *p_pin = NULL;
  888. iface = wpa_s->global->dbus;
  889. /* Do nothing if the control interface is not turned on */
  890. if (iface == NULL)
  891. return;
  892. if (wpa_s->p2p_mgmt)
  893. wpa_s = wpa_s->parent;
  894. if (!wpa_s->dbus_new_path)
  895. return;
  896. if (request || !status) {
  897. if (config_methods & WPS_CONFIG_DISPLAY)
  898. _signal = request ?
  899. "ProvisionDiscoveryRequestDisplayPin" :
  900. "ProvisionDiscoveryResponseEnterPin";
  901. else if (config_methods & WPS_CONFIG_KEYPAD)
  902. _signal = request ?
  903. "ProvisionDiscoveryRequestEnterPin" :
  904. "ProvisionDiscoveryResponseDisplayPin";
  905. else if (config_methods & WPS_CONFIG_PUSHBUTTON)
  906. _signal = request ? "ProvisionDiscoveryPBCRequest" :
  907. "ProvisionDiscoveryPBCResponse";
  908. else
  909. return; /* Unknown or un-supported method */
  910. } else {
  911. /* Explicit check for failure response */
  912. _signal = "ProvisionDiscoveryFailure";
  913. }
  914. add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
  915. (!request && !status &&
  916. (config_methods & WPS_CONFIG_KEYPAD)));
  917. if (add_pin) {
  918. os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
  919. p_pin = pin;
  920. }
  921. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  922. WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
  923. if (msg == NULL)
  924. return;
  925. /* Check if this is a known peer */
  926. if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
  927. goto error;
  928. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  929. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
  930. COMPACT_MACSTR,
  931. wpa_s->dbus_new_path, MAC2STR(dev_addr));
  932. path = peer_obj_path;
  933. dbus_message_iter_init_append(msg, &iter);
  934. if (!dbus_message_iter_append_basic(&iter,
  935. DBUS_TYPE_OBJECT_PATH,
  936. &path))
  937. goto error;
  938. if (!request && status)
  939. /* Attach status to ProvisionDiscoveryFailure */
  940. error_ret = !dbus_message_iter_append_basic(&iter,
  941. DBUS_TYPE_INT32,
  942. &status);
  943. else
  944. error_ret = (add_pin &&
  945. !dbus_message_iter_append_basic(&iter,
  946. DBUS_TYPE_STRING,
  947. &p_pin));
  948. error:
  949. if (!error_ret)
  950. dbus_connection_send(iface->con, msg, NULL);
  951. else
  952. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  953. dbus_message_unref(msg);
  954. }
  955. /**
  956. * wpas_dbus_signal_p2p_go_neg_req - Signal P2P GO Negotiation Request RX
  957. * @wpa_s: %wpa_supplicant network interface data
  958. * @src: Source address of the message triggering this notification
  959. * @dev_passwd_id: WPS Device Password Id
  960. * @go_intent: Peer's GO Intent value
  961. *
  962. * Sends signal to notify that a peer P2P Device is requesting group owner
  963. * negotiation with us.
  964. */
  965. void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
  966. const u8 *src, u16 dev_passwd_id,
  967. u8 go_intent)
  968. {
  969. DBusMessage *msg;
  970. DBusMessageIter iter;
  971. struct wpas_dbus_priv *iface;
  972. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  973. iface = wpa_s->global->dbus;
  974. /* Do nothing if the control interface is not turned on */
  975. if (iface == NULL)
  976. return;
  977. if (wpa_s->p2p_mgmt)
  978. wpa_s = wpa_s->parent;
  979. if (!wpa_s->dbus_new_path)
  980. return;
  981. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  982. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  983. wpa_s->dbus_new_path, MAC2STR(src));
  984. path = peer_obj_path;
  985. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  986. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  987. "GONegotiationRequest");
  988. if (msg == NULL)
  989. return;
  990. dbus_message_iter_init_append(msg, &iter);
  991. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  992. &path) ||
  993. !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
  994. &dev_passwd_id) ||
  995. !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE,
  996. &go_intent))
  997. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  998. else
  999. dbus_connection_send(iface->con, msg, NULL);
  1000. dbus_message_unref(msg);
  1001. }
  1002. static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
  1003. const struct wpa_ssid *ssid,
  1004. char *group_obj_path)
  1005. {
  1006. char group_name[3];
  1007. if (!wpa_s->dbus_new_path ||
  1008. os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
  1009. return -1;
  1010. os_memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
  1011. group_name[2] = '\0';
  1012. os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1013. "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
  1014. wpa_s->dbus_new_path, group_name);
  1015. return 0;
  1016. }
  1017. struct group_changed_data {
  1018. struct wpa_supplicant *wpa_s;
  1019. struct p2p_peer_info *info;
  1020. };
  1021. static int match_group_where_peer_is_client(struct p2p_group *group,
  1022. void *user_data)
  1023. {
  1024. struct group_changed_data *data = user_data;
  1025. const struct p2p_group_config *cfg;
  1026. struct wpa_supplicant *wpa_s_go;
  1027. if (!p2p_group_is_client_connected(group, data->info->p2p_device_addr))
  1028. return 1;
  1029. cfg = p2p_group_get_config(group);
  1030. wpa_s_go = wpas_get_p2p_go_iface(data->wpa_s, cfg->ssid,
  1031. cfg->ssid_len);
  1032. if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
  1033. wpas_dbus_signal_peer_groups_changed(
  1034. data->wpa_s->p2pdev, data->info->p2p_device_addr);
  1035. return 0;
  1036. }
  1037. return 1;
  1038. }
  1039. static void signal_peer_groups_changed(struct p2p_peer_info *info,
  1040. void *user_data)
  1041. {
  1042. struct group_changed_data *data = user_data;
  1043. struct wpa_supplicant *wpa_s_go;
  1044. wpa_s_go = wpas_get_p2p_client_iface(data->wpa_s,
  1045. info->p2p_device_addr);
  1046. if (wpa_s_go != NULL && wpa_s_go == data->wpa_s) {
  1047. wpas_dbus_signal_peer_groups_changed(data->wpa_s->p2pdev,
  1048. info->p2p_device_addr);
  1049. return;
  1050. }
  1051. data->info = info;
  1052. p2p_loop_on_all_groups(data->wpa_s->global->p2p,
  1053. match_group_where_peer_is_client, data);
  1054. data->info = NULL;
  1055. }
  1056. static void peer_groups_changed(struct wpa_supplicant *wpa_s)
  1057. {
  1058. struct group_changed_data data;
  1059. os_memset(&data, 0, sizeof(data));
  1060. data.wpa_s = wpa_s;
  1061. p2p_loop_on_known_peers(wpa_s->global->p2p,
  1062. signal_peer_groups_changed, &data);
  1063. }
  1064. /**
  1065. * wpas_dbus_signal_p2p_group_started - Signals P2P group has
  1066. * started. Emitted when a group is successfully started
  1067. * irrespective of the role (client/GO) of the current device
  1068. *
  1069. * @wpa_s: %wpa_supplicant network interface data
  1070. * @client: this device is P2P client
  1071. * @persistent: 0 - non persistent group, 1 - persistent group
  1072. * @ip: When group role is client, it contains local IP address, netmask, and
  1073. * GO's IP address, if assigned; otherwise, NULL
  1074. */
  1075. void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
  1076. int client, int persistent,
  1077. const u8 *ip)
  1078. {
  1079. DBusMessage *msg;
  1080. DBusMessageIter iter, dict_iter;
  1081. struct wpas_dbus_priv *iface;
  1082. struct wpa_supplicant *parent;
  1083. parent = wpa_s->parent;
  1084. if (parent->p2p_mgmt)
  1085. parent = parent->parent;
  1086. iface = parent->global->dbus;
  1087. /* Do nothing if the control interface is not turned on */
  1088. if (iface == NULL || !parent->dbus_new_path || !wpa_s->dbus_new_path)
  1089. return;
  1090. if (wpa_s->dbus_groupobj_path == NULL)
  1091. return;
  1092. /* New interface has been created for this group */
  1093. msg = dbus_message_new_signal(parent->dbus_new_path,
  1094. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1095. "GroupStarted");
  1096. if (msg == NULL)
  1097. return;
  1098. dbus_message_iter_init_append(msg, &iter);
  1099. /*
  1100. * In case the device supports creating a separate interface the
  1101. * DBus client will need to know the object path for the interface
  1102. * object this group was created on, so include it here.
  1103. */
  1104. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1105. !wpa_dbus_dict_append_object_path(&dict_iter,
  1106. "interface_object",
  1107. wpa_s->dbus_new_path) ||
  1108. !wpa_dbus_dict_append_string(&dict_iter, "role",
  1109. client ? "client" : "GO") ||
  1110. !wpa_dbus_dict_append_bool(&dict_iter, "persistent", persistent) ||
  1111. !wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
  1112. wpa_s->dbus_groupobj_path) ||
  1113. (ip &&
  1114. (!wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddr",
  1115. (char *) ip, 4) ||
  1116. !wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddrMask",
  1117. (char *) ip + 4, 4) ||
  1118. !wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddrGo",
  1119. (char *) ip + 8, 4))) ||
  1120. !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
  1121. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1122. } else {
  1123. dbus_connection_send(iface->con, msg, NULL);
  1124. if (client)
  1125. peer_groups_changed(wpa_s);
  1126. }
  1127. dbus_message_unref(msg);
  1128. }
  1129. /**
  1130. * wpas_dbus_signal_p2p_go_neg_resp - Emit GONegotiation Success/Failure signal
  1131. * @wpa_s: %wpa_supplicant network interface data
  1132. * @res: Result of the GO Neg Request
  1133. */
  1134. void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
  1135. struct p2p_go_neg_results *res)
  1136. {
  1137. DBusMessage *msg;
  1138. DBusMessageIter iter, dict_iter;
  1139. DBusMessageIter iter_dict_entry, iter_dict_val, iter_dict_array;
  1140. struct wpas_dbus_priv *iface;
  1141. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  1142. dbus_int32_t freqs[P2P_MAX_CHANNELS];
  1143. dbus_int32_t *f_array = freqs;
  1144. iface = wpa_s->global->dbus;
  1145. if (wpa_s->p2p_mgmt)
  1146. wpa_s = wpa_s->parent;
  1147. os_memset(freqs, 0, sizeof(freqs));
  1148. /* Do nothing if the control interface is not turned on */
  1149. if (iface == NULL || !wpa_s->dbus_new_path)
  1150. return;
  1151. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1152. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  1153. wpa_s->dbus_new_path, MAC2STR(res->peer_device_addr));
  1154. path = peer_obj_path;
  1155. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1156. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1157. res->status ? "GONegotiationFailure" :
  1158. "GONegotiationSuccess");
  1159. if (msg == NULL)
  1160. return;
  1161. dbus_message_iter_init_append(msg, &iter);
  1162. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1163. !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
  1164. path) ||
  1165. !wpa_dbus_dict_append_int32(&dict_iter, "status", res->status))
  1166. goto err;
  1167. if (!res->status) {
  1168. int i = 0;
  1169. int freq_list_num = 0;
  1170. if ((res->role_go &&
  1171. !wpa_dbus_dict_append_string(&dict_iter, "passphrase",
  1172. res->passphrase)) ||
  1173. !wpa_dbus_dict_append_string(&dict_iter, "role_go",
  1174. res->role_go ? "GO" :
  1175. "client") ||
  1176. !wpa_dbus_dict_append_int32(&dict_iter, "frequency",
  1177. res->freq) ||
  1178. !wpa_dbus_dict_append_byte_array(&dict_iter, "ssid",
  1179. (const char *) res->ssid,
  1180. res->ssid_len) ||
  1181. !wpa_dbus_dict_append_byte_array(&dict_iter,
  1182. "peer_device_addr",
  1183. (const char *)
  1184. res->peer_device_addr,
  1185. ETH_ALEN) ||
  1186. !wpa_dbus_dict_append_byte_array(&dict_iter,
  1187. "peer_interface_addr",
  1188. (const char *)
  1189. res->peer_interface_addr,
  1190. ETH_ALEN) ||
  1191. !wpa_dbus_dict_append_string(&dict_iter, "wps_method",
  1192. p2p_wps_method_text(
  1193. res->wps_method)))
  1194. goto err;
  1195. for (i = 0; i < P2P_MAX_CHANNELS; i++) {
  1196. if (res->freq_list[i]) {
  1197. freqs[i] = res->freq_list[i];
  1198. freq_list_num++;
  1199. }
  1200. }
  1201. if (!wpa_dbus_dict_begin_array(&dict_iter,
  1202. "frequency_list",
  1203. DBUS_TYPE_INT32_AS_STRING,
  1204. &iter_dict_entry,
  1205. &iter_dict_val,
  1206. &iter_dict_array) ||
  1207. !dbus_message_iter_append_fixed_array(&iter_dict_array,
  1208. DBUS_TYPE_INT32,
  1209. &f_array,
  1210. freq_list_num) ||
  1211. !wpa_dbus_dict_end_array(&dict_iter,
  1212. &iter_dict_entry,
  1213. &iter_dict_val,
  1214. &iter_dict_array) ||
  1215. !wpa_dbus_dict_append_int32(&dict_iter, "persistent_group",
  1216. res->persistent_group) ||
  1217. !wpa_dbus_dict_append_uint32(&dict_iter,
  1218. "peer_config_timeout",
  1219. res->peer_config_timeout))
  1220. goto err;
  1221. }
  1222. if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
  1223. goto err;
  1224. dbus_connection_send(iface->con, msg, NULL);
  1225. err:
  1226. dbus_message_unref(msg);
  1227. }
  1228. /**
  1229. * wpas_dbus_signal_p2p_invitation_result - Emit InvitationResult signal
  1230. * @wpa_s: %wpa_supplicant network interface data
  1231. * @status: Status of invitation process
  1232. * @bssid: Basic Service Set Identifier
  1233. */
  1234. void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
  1235. int status, const u8 *bssid)
  1236. {
  1237. DBusMessage *msg;
  1238. DBusMessageIter iter, dict_iter;
  1239. struct wpas_dbus_priv *iface;
  1240. wpa_printf(MSG_DEBUG, "%s", __func__);
  1241. iface = wpa_s->global->dbus;
  1242. /* Do nothing if the control interface is not turned on */
  1243. if (iface == NULL)
  1244. return;
  1245. if (wpa_s->p2p_mgmt)
  1246. wpa_s = wpa_s->parent;
  1247. if (!wpa_s->dbus_new_path)
  1248. return;
  1249. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1250. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1251. "InvitationResult");
  1252. if (msg == NULL)
  1253. return;
  1254. dbus_message_iter_init_append(msg, &iter);
  1255. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1256. !wpa_dbus_dict_append_int32(&dict_iter, "status", status) ||
  1257. (bssid &&
  1258. !wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
  1259. (const char *) bssid,
  1260. ETH_ALEN)) ||
  1261. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  1262. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1263. else
  1264. dbus_connection_send(iface->con, msg, NULL);
  1265. dbus_message_unref(msg);
  1266. }
  1267. /**
  1268. *
  1269. * Method to emit a signal for a peer joining the group.
  1270. * The signal will carry path to the group member object
  1271. * constructed using p2p i/f addr used for connecting.
  1272. *
  1273. * @wpa_s: %wpa_supplicant network interface data
  1274. * @peer_addr: P2P Device Address of the peer joining the group
  1275. */
  1276. void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
  1277. const u8 *peer_addr)
  1278. {
  1279. struct wpas_dbus_priv *iface;
  1280. DBusMessage *msg;
  1281. DBusMessageIter iter;
  1282. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  1283. struct wpa_supplicant *parent;
  1284. iface = wpa_s->global->dbus;
  1285. /* Do nothing if the control interface is not turned on */
  1286. if (iface == NULL)
  1287. return;
  1288. if (!wpa_s->dbus_groupobj_path)
  1289. return;
  1290. parent = wpa_s->parent;
  1291. if (parent->p2p_mgmt)
  1292. parent = parent->parent;
  1293. if (!parent->dbus_new_path)
  1294. return;
  1295. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1296. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
  1297. COMPACT_MACSTR,
  1298. parent->dbus_new_path, MAC2STR(peer_addr));
  1299. msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
  1300. WPAS_DBUS_NEW_IFACE_P2P_GROUP,
  1301. "PeerJoined");
  1302. if (msg == NULL)
  1303. return;
  1304. dbus_message_iter_init_append(msg, &iter);
  1305. path = peer_obj_path;
  1306. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  1307. &path)) {
  1308. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1309. } else {
  1310. dbus_connection_send(iface->con, msg, NULL);
  1311. wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
  1312. }
  1313. dbus_message_unref(msg);
  1314. }
  1315. /**
  1316. *
  1317. * Method to emit a signal for a peer disconnecting the group.
  1318. * The signal will carry path to the group member object
  1319. * constructed using the P2P Device Address of the peer.
  1320. *
  1321. * @wpa_s: %wpa_supplicant network interface data
  1322. * @peer_addr: P2P Device Address of the peer joining the group
  1323. */
  1324. void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
  1325. const u8 *peer_addr)
  1326. {
  1327. struct wpas_dbus_priv *iface;
  1328. DBusMessage *msg;
  1329. DBusMessageIter iter;
  1330. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  1331. struct wpa_supplicant *parent;
  1332. iface = wpa_s->global->dbus;
  1333. /* Do nothing if the control interface is not turned on */
  1334. if (iface == NULL)
  1335. return;
  1336. if (!wpa_s->dbus_groupobj_path)
  1337. return;
  1338. parent = wpa_s->parent;
  1339. if (parent->p2p_mgmt)
  1340. parent = parent->parent;
  1341. if (!parent->dbus_new_path)
  1342. return;
  1343. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1344. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
  1345. COMPACT_MACSTR,
  1346. parent->dbus_new_path, MAC2STR(peer_addr));
  1347. msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
  1348. WPAS_DBUS_NEW_IFACE_P2P_GROUP,
  1349. "PeerDisconnected");
  1350. if (msg == NULL)
  1351. return;
  1352. dbus_message_iter_init_append(msg, &iter);
  1353. path = peer_obj_path;
  1354. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  1355. &path)) {
  1356. wpa_printf(MSG_ERROR,
  1357. "dbus: Failed to construct PeerDisconnected signal");
  1358. } else {
  1359. dbus_connection_send(iface->con, msg, NULL);
  1360. wpas_dbus_signal_peer_groups_changed(parent, peer_addr);
  1361. }
  1362. dbus_message_unref(msg);
  1363. }
  1364. /**
  1365. *
  1366. * Method to emit a signal for a service discovery request.
  1367. * The signal will carry station address, frequency, dialog token,
  1368. * update indicator and it tlvs
  1369. *
  1370. * @wpa_s: %wpa_supplicant network interface data
  1371. * @sa: station addr (p2p i/f) of the peer
  1372. * @dialog_token: service discovery request dialog token
  1373. * @update_indic: service discovery request update indicator
  1374. * @tlvs: service discovery request genrated byte array of tlvs
  1375. * @tlvs_len: service discovery request tlvs length
  1376. */
  1377. void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
  1378. int freq, const u8 *sa, u8 dialog_token,
  1379. u16 update_indic, const u8 *tlvs,
  1380. size_t tlvs_len)
  1381. {
  1382. DBusMessage *msg;
  1383. DBusMessageIter iter, dict_iter;
  1384. struct wpas_dbus_priv *iface;
  1385. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  1386. iface = wpa_s->global->dbus;
  1387. /* Do nothing if the control interface is not turned on */
  1388. if (iface == NULL)
  1389. return;
  1390. if (wpa_s->p2p_mgmt)
  1391. wpa_s = wpa_s->parent;
  1392. if (!wpa_s->dbus_new_path)
  1393. return;
  1394. /* Check if this is a known peer */
  1395. if (!p2p_peer_known(wpa_s->global->p2p, sa))
  1396. return;
  1397. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1398. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1399. "ServiceDiscoveryRequest");
  1400. if (msg == NULL)
  1401. return;
  1402. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1403. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
  1404. COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
  1405. path = peer_obj_path;
  1406. dbus_message_iter_init_append(msg, &iter);
  1407. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1408. !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
  1409. path) ||
  1410. !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
  1411. !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
  1412. dialog_token) ||
  1413. !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
  1414. update_indic) ||
  1415. !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
  1416. (const char *) tlvs,
  1417. tlvs_len) ||
  1418. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  1419. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1420. else
  1421. dbus_connection_send(iface->con, msg, NULL);
  1422. dbus_message_unref(msg);
  1423. }
  1424. /**
  1425. *
  1426. * Method to emit a signal for a service discovery response.
  1427. * The signal will carry station address, update indicator and it
  1428. * tlvs
  1429. *
  1430. * @wpa_s: %wpa_supplicant network interface data
  1431. * @sa: station addr (p2p i/f) of the peer
  1432. * @update_indic: service discovery request update indicator
  1433. * @tlvs: service discovery request genrated byte array of tlvs
  1434. * @tlvs_len: service discovery request tlvs length
  1435. */
  1436. void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
  1437. const u8 *sa, u16 update_indic,
  1438. const u8 *tlvs, size_t tlvs_len)
  1439. {
  1440. DBusMessage *msg;
  1441. DBusMessageIter iter, dict_iter;
  1442. struct wpas_dbus_priv *iface;
  1443. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  1444. iface = wpa_s->global->dbus;
  1445. /* Do nothing if the control interface is not turned on */
  1446. if (iface == NULL)
  1447. return;
  1448. if (wpa_s->p2p_mgmt)
  1449. wpa_s = wpa_s->parent;
  1450. if (!wpa_s->dbus_new_path)
  1451. return;
  1452. /* Check if this is a known peer */
  1453. if (!p2p_peer_known(wpa_s->global->p2p, sa))
  1454. return;
  1455. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1456. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1457. "ServiceDiscoveryResponse");
  1458. if (msg == NULL)
  1459. return;
  1460. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1461. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
  1462. COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
  1463. path = peer_obj_path;
  1464. dbus_message_iter_init_append(msg, &iter);
  1465. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1466. !wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
  1467. path) ||
  1468. !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
  1469. update_indic) ||
  1470. !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
  1471. (const char *) tlvs,
  1472. tlvs_len) ||
  1473. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  1474. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1475. else
  1476. dbus_connection_send(iface->con, msg, NULL);
  1477. dbus_message_unref(msg);
  1478. }
  1479. /**
  1480. * wpas_dbus_signal_persistent_group - Send a persistent group related
  1481. * event signal
  1482. * @wpa_s: %wpa_supplicant network interface data
  1483. * @id: new persistent group id
  1484. * @sig_name: signal name - PersistentGroupAdded, PersistentGroupRemoved
  1485. * @properties: determines if add second argument with object properties
  1486. *
  1487. * Notify listeners about an event related to persistent groups.
  1488. */
  1489. static void wpas_dbus_signal_persistent_group(struct wpa_supplicant *wpa_s,
  1490. int id, const char *sig_name,
  1491. int properties)
  1492. {
  1493. struct wpas_dbus_priv *iface;
  1494. DBusMessage *msg;
  1495. DBusMessageIter iter;
  1496. char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  1497. iface = wpa_s->global->dbus;
  1498. /* Do nothing if the control interface is not turned on */
  1499. if (iface == NULL)
  1500. return;
  1501. if (wpa_s->p2p_mgmt)
  1502. wpa_s = wpa_s->parent;
  1503. if (!wpa_s->dbus_new_path)
  1504. return;
  1505. os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  1506. "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
  1507. wpa_s->dbus_new_path, id);
  1508. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1509. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1510. sig_name);
  1511. if (msg == NULL)
  1512. return;
  1513. dbus_message_iter_init_append(msg, &iter);
  1514. path = pgrp_obj_path;
  1515. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  1516. &path) ||
  1517. (properties &&
  1518. !wpa_dbus_get_object_properties(
  1519. iface, pgrp_obj_path,
  1520. WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, &iter)))
  1521. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1522. else
  1523. dbus_connection_send(iface->con, msg, NULL);
  1524. dbus_message_unref(msg);
  1525. }
  1526. /**
  1527. * wpas_dbus_signal_persistent_group_added - Send a persistent_group
  1528. * added signal
  1529. * @wpa_s: %wpa_supplicant network interface data
  1530. * @id: new persistent group id
  1531. *
  1532. * Notify listeners about addition of a new persistent group.
  1533. */
  1534. static void wpas_dbus_signal_persistent_group_added(
  1535. struct wpa_supplicant *wpa_s, int id)
  1536. {
  1537. wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupAdded",
  1538. TRUE);
  1539. }
  1540. /**
  1541. * wpas_dbus_signal_persistent_group_removed - Send a persistent_group
  1542. * removed signal
  1543. * @wpa_s: %wpa_supplicant network interface data
  1544. * @id: persistent group id
  1545. *
  1546. * Notify listeners about removal of a persistent group.
  1547. */
  1548. static void wpas_dbus_signal_persistent_group_removed(
  1549. struct wpa_supplicant *wpa_s, int id)
  1550. {
  1551. wpas_dbus_signal_persistent_group(wpa_s, id, "PersistentGroupRemoved",
  1552. FALSE);
  1553. }
  1554. /**
  1555. * wpas_dbus_signal_p2p_wps_failed - Signals WpsFailed event
  1556. * @wpa_s: %wpa_supplicant network interface data
  1557. * @fail: WPS failure information
  1558. *
  1559. * Sends Event dbus signal with name "fail" and dictionary containing
  1560. * "msg" field with fail message number (int32) as arguments
  1561. */
  1562. void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
  1563. struct wps_event_fail *fail)
  1564. {
  1565. DBusMessage *msg;
  1566. DBusMessageIter iter, dict_iter;
  1567. struct wpas_dbus_priv *iface;
  1568. char *key = "fail";
  1569. iface = wpa_s->global->dbus;
  1570. /* Do nothing if the control interface is not turned on */
  1571. if (iface == NULL)
  1572. return;
  1573. if (wpa_s->p2p_mgmt)
  1574. wpa_s = wpa_s->parent;
  1575. if (!wpa_s->dbus_new_path)
  1576. return;
  1577. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1578. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1579. "WpsFailed");
  1580. if (msg == NULL)
  1581. return;
  1582. dbus_message_iter_init_append(msg, &iter);
  1583. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &key) ||
  1584. !wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1585. !wpa_dbus_dict_append_int32(&dict_iter, "msg", fail->msg) ||
  1586. !wpa_dbus_dict_append_int16(&dict_iter, "config_error",
  1587. fail->config_error) ||
  1588. !wpa_dbus_dict_close_write(&iter, &dict_iter))
  1589. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1590. else
  1591. dbus_connection_send(iface->con, msg, NULL);
  1592. dbus_message_unref(msg);
  1593. }
  1594. /**
  1595. * wpas_dbus_signal_p2p_group_formation_failure - Signals GroupFormationFailure event
  1596. * @wpa_s: %wpa_supplicant network interface data
  1597. * @reason: indicates the reason code for group formation failure
  1598. *
  1599. * Sends Event dbus signal and string reason code when available.
  1600. */
  1601. void wpas_dbus_signal_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
  1602. const char *reason)
  1603. {
  1604. DBusMessage *msg;
  1605. struct wpas_dbus_priv *iface;
  1606. iface = wpa_s->global->dbus;
  1607. /* Do nothing if the control interface is not turned on */
  1608. if (iface == NULL)
  1609. return;
  1610. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1611. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1612. "GroupFormationFailure");
  1613. if (msg == NULL)
  1614. return;
  1615. if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &reason,
  1616. DBUS_TYPE_INVALID))
  1617. dbus_connection_send(iface->con, msg, NULL);
  1618. else
  1619. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  1620. dbus_message_unref(msg);
  1621. }
  1622. /**
  1623. * wpas_dbus_signal_p2p_invitation_received - Emit InvitationReceived signal
  1624. * @wpa_s: %wpa_supplicant network interface data
  1625. * @sa: Source address of the Invitation Request
  1626. * @dev_add: GO Device Address
  1627. * @bssid: P2P Group BSSID or %NULL if not received
  1628. * @id: Persistent group id or %0 if not persistent group
  1629. * @op_freq: Operating frequency for the group
  1630. */
  1631. void wpas_dbus_signal_p2p_invitation_received(struct wpa_supplicant *wpa_s,
  1632. const u8 *sa, const u8 *dev_addr,
  1633. const u8 *bssid, int id,
  1634. int op_freq)
  1635. {
  1636. DBusMessage *msg;
  1637. DBusMessageIter iter, dict_iter;
  1638. struct wpas_dbus_priv *iface;
  1639. iface = wpa_s->global->dbus;
  1640. /* Do nothing if the control interface is not turned on */
  1641. if (iface == NULL)
  1642. return;
  1643. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  1644. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  1645. "InvitationReceived");
  1646. if (msg == NULL)
  1647. return;
  1648. dbus_message_iter_init_append(msg, &iter);
  1649. if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
  1650. (sa &&
  1651. !wpa_dbus_dict_append_byte_array(&dict_iter, "sa",
  1652. (const char *) sa, ETH_ALEN)) ||
  1653. (dev_addr &&
  1654. !wpa_dbus_dict_append_byte_array(&dict_iter, "go_dev_addr",
  1655. (const char *) dev_addr,
  1656. ETH_ALEN)) ||
  1657. (bssid &&
  1658. !wpa_dbus_dict_append_byte_array(&dict_iter, "bssid",
  1659. (const char *) bssid,
  1660. ETH_ALEN)) ||
  1661. (id &&
  1662. !wpa_dbus_dict_append_int32(&dict_iter, "persistent_id", id)) ||
  1663. !wpa_dbus_dict_append_int32(&dict_iter, "op_freq", op_freq) ||
  1664. !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
  1665. dbus_message_unref(msg);
  1666. return;
  1667. }
  1668. dbus_connection_send(iface->con, msg, NULL);
  1669. dbus_message_unref(msg);
  1670. }
  1671. #endif /* CONFIG_P2P */
  1672. /**
  1673. * wpas_dbus_signal_prop_changed - Signals change of property
  1674. * @wpa_s: %wpa_supplicant network interface data
  1675. * @property: indicates which property has changed
  1676. *
  1677. * Sends PropertyChanged signals with path, interface and arguments
  1678. * depending on which property has changed.
  1679. */
  1680. void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
  1681. enum wpas_dbus_prop property)
  1682. {
  1683. char *prop;
  1684. dbus_bool_t flush;
  1685. if (wpa_s->dbus_new_path == NULL)
  1686. return; /* Skip signal since D-Bus setup is not yet ready */
  1687. flush = FALSE;
  1688. switch (property) {
  1689. case WPAS_DBUS_PROP_AP_SCAN:
  1690. prop = "ApScan";
  1691. break;
  1692. #ifdef CONFIG_IEEE80211W
  1693. case WPAS_DBUS_PROP_PMF:
  1694. prop = "Pmf";
  1695. break;
  1696. #endif /* CONFIG_IEEE80211W */
  1697. case WPAS_DBUS_PROP_SCANNING:
  1698. prop = "Scanning";
  1699. break;
  1700. case WPAS_DBUS_PROP_STATE:
  1701. prop = "State";
  1702. break;
  1703. case WPAS_DBUS_PROP_CURRENT_BSS:
  1704. prop = "CurrentBSS";
  1705. break;
  1706. case WPAS_DBUS_PROP_CURRENT_NETWORK:
  1707. prop = "CurrentNetwork";
  1708. break;
  1709. case WPAS_DBUS_PROP_BSSS:
  1710. prop = "BSSs";
  1711. break;
  1712. case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
  1713. prop = "CurrentAuthMode";
  1714. break;
  1715. case WPAS_DBUS_PROP_DISCONNECT_REASON:
  1716. prop = "DisconnectReason";
  1717. flush = TRUE;
  1718. break;
  1719. case WPAS_DBUS_PROP_ASSOC_STATUS_CODE:
  1720. prop = "AssocStatusCode";
  1721. flush = TRUE;
  1722. break;
  1723. default:
  1724. wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
  1725. __func__, property);
  1726. return;
  1727. }
  1728. wpa_dbus_mark_property_changed(wpa_s->global->dbus,
  1729. wpa_s->dbus_new_path,
  1730. WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
  1731. if (flush) {
  1732. wpa_dbus_flush_object_changed_properties(
  1733. wpa_s->global->dbus->con, wpa_s->dbus_new_path);
  1734. }
  1735. }
  1736. /**
  1737. * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
  1738. * @wpa_s: %wpa_supplicant network interface data
  1739. * @property: indicates which property has changed
  1740. * @id: unique BSS identifier
  1741. *
  1742. * Sends PropertyChanged signals with path, interface, and arguments depending
  1743. * on which property has changed.
  1744. */
  1745. void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
  1746. enum wpas_dbus_bss_prop property,
  1747. unsigned int id)
  1748. {
  1749. char path[WPAS_DBUS_OBJECT_PATH_MAX];
  1750. char *prop;
  1751. if (!wpa_s->dbus_new_path)
  1752. return;
  1753. switch (property) {
  1754. case WPAS_DBUS_BSS_PROP_SIGNAL:
  1755. prop = "Signal";
  1756. break;
  1757. case WPAS_DBUS_BSS_PROP_FREQ:
  1758. prop = "Frequency";
  1759. break;
  1760. case WPAS_DBUS_BSS_PROP_MODE:
  1761. prop = "Mode";
  1762. break;
  1763. case WPAS_DBUS_BSS_PROP_PRIVACY:
  1764. prop = "Privacy";
  1765. break;
  1766. case WPAS_DBUS_BSS_PROP_RATES:
  1767. prop = "Rates";
  1768. break;
  1769. case WPAS_DBUS_BSS_PROP_WPA:
  1770. prop = "WPA";
  1771. break;
  1772. case WPAS_DBUS_BSS_PROP_RSN:
  1773. prop = "RSN";
  1774. break;
  1775. case WPAS_DBUS_BSS_PROP_WPS:
  1776. prop = "WPS";
  1777. break;
  1778. case WPAS_DBUS_BSS_PROP_IES:
  1779. prop = "IEs";
  1780. break;
  1781. case WPAS_DBUS_BSS_PROP_AGE:
  1782. prop = "Age";
  1783. break;
  1784. default:
  1785. wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
  1786. __func__, property);
  1787. return;
  1788. }
  1789. os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
  1790. "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
  1791. wpa_s->dbus_new_path, id);
  1792. wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
  1793. WPAS_DBUS_NEW_IFACE_BSS, prop);
  1794. }
  1795. /**
  1796. * wpas_dbus_signal_debug_level_changed - Signals change of debug param
  1797. * @global: wpa_global structure
  1798. *
  1799. * Sends PropertyChanged signals informing that debug level has changed.
  1800. */
  1801. void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
  1802. {
  1803. wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
  1804. WPAS_DBUS_NEW_INTERFACE,
  1805. "DebugLevel");
  1806. }
  1807. /**
  1808. * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
  1809. * @global: wpa_global structure
  1810. *
  1811. * Sends PropertyChanged signals informing that debug timestamp has changed.
  1812. */
  1813. void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
  1814. {
  1815. wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
  1816. WPAS_DBUS_NEW_INTERFACE,
  1817. "DebugTimestamp");
  1818. }
  1819. /**
  1820. * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
  1821. * @global: wpa_global structure
  1822. *
  1823. * Sends PropertyChanged signals informing that debug show_keys has changed.
  1824. */
  1825. void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
  1826. {
  1827. wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
  1828. WPAS_DBUS_NEW_INTERFACE,
  1829. "DebugShowKeys");
  1830. }
  1831. static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
  1832. void *priv,
  1833. WPADBusArgumentFreeFunction priv_free,
  1834. const struct wpa_dbus_method_desc *methods,
  1835. const struct wpa_dbus_property_desc *properties,
  1836. const struct wpa_dbus_signal_desc *signals)
  1837. {
  1838. int n;
  1839. obj_desc->user_data = priv;
  1840. obj_desc->user_data_free_func = priv_free;
  1841. obj_desc->methods = methods;
  1842. obj_desc->properties = properties;
  1843. obj_desc->signals = signals;
  1844. for (n = 0; properties && properties->dbus_property; properties++)
  1845. n++;
  1846. obj_desc->prop_changed_flags = os_zalloc(n);
  1847. if (!obj_desc->prop_changed_flags)
  1848. wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
  1849. __func__);
  1850. }
  1851. static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
  1852. { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
  1853. (WPADBusMethodHandler) wpas_dbus_handler_create_interface,
  1854. {
  1855. { "args", "a{sv}", ARG_IN },
  1856. { "path", "o", ARG_OUT },
  1857. END_ARGS
  1858. }
  1859. },
  1860. { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
  1861. (WPADBusMethodHandler) wpas_dbus_handler_remove_interface,
  1862. {
  1863. { "path", "o", ARG_IN },
  1864. END_ARGS
  1865. }
  1866. },
  1867. { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
  1868. (WPADBusMethodHandler) wpas_dbus_handler_get_interface,
  1869. {
  1870. { "ifname", "s", ARG_IN },
  1871. { "path", "o", ARG_OUT },
  1872. END_ARGS
  1873. }
  1874. },
  1875. { "ExpectDisconnect", WPAS_DBUS_NEW_INTERFACE,
  1876. (WPADBusMethodHandler) wpas_dbus_handler_expect_disconnect,
  1877. {
  1878. END_ARGS
  1879. }
  1880. },
  1881. { NULL, NULL, NULL, { END_ARGS } }
  1882. };
  1883. static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
  1884. { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
  1885. wpas_dbus_getter_debug_level,
  1886. wpas_dbus_setter_debug_level,
  1887. NULL
  1888. },
  1889. { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
  1890. wpas_dbus_getter_debug_timestamp,
  1891. wpas_dbus_setter_debug_timestamp,
  1892. NULL
  1893. },
  1894. { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
  1895. wpas_dbus_getter_debug_show_keys,
  1896. wpas_dbus_setter_debug_show_keys,
  1897. NULL
  1898. },
  1899. { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
  1900. wpas_dbus_getter_interfaces,
  1901. NULL,
  1902. NULL
  1903. },
  1904. { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
  1905. wpas_dbus_getter_eap_methods,
  1906. NULL,
  1907. NULL
  1908. },
  1909. { "Capabilities", WPAS_DBUS_NEW_INTERFACE, "as",
  1910. wpas_dbus_getter_global_capabilities,
  1911. NULL,
  1912. NULL
  1913. },
  1914. #ifdef CONFIG_WIFI_DISPLAY
  1915. { "WFDIEs", WPAS_DBUS_NEW_INTERFACE, "ay",
  1916. wpas_dbus_getter_global_wfd_ies,
  1917. wpas_dbus_setter_global_wfd_ies,
  1918. NULL
  1919. },
  1920. #endif /* CONFIG_WIFI_DISPLAY */
  1921. { NULL, NULL, NULL, NULL, NULL, NULL }
  1922. };
  1923. static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
  1924. { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
  1925. {
  1926. { "path", "o", ARG_OUT },
  1927. { "properties", "a{sv}", ARG_OUT },
  1928. END_ARGS
  1929. }
  1930. },
  1931. { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
  1932. {
  1933. { "path", "o", ARG_OUT },
  1934. END_ARGS
  1935. }
  1936. },
  1937. /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
  1938. { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
  1939. {
  1940. { "properties", "a{sv}", ARG_OUT },
  1941. END_ARGS
  1942. }
  1943. },
  1944. { NULL, NULL, { END_ARGS } }
  1945. };
  1946. static char * uscore_to_dbus(const char *uscore)
  1947. {
  1948. const char *p = uscore;
  1949. char *str, *s;
  1950. dbus_bool_t last_was_uscore = TRUE;
  1951. s = str = os_zalloc(os_strlen(uscore) + 1);
  1952. if (!str)
  1953. return NULL;
  1954. while (p && *p) {
  1955. if (*p == '_') {
  1956. last_was_uscore = TRUE;
  1957. } else {
  1958. *s++ = last_was_uscore ? toupper(*p) : *p;
  1959. last_was_uscore = FALSE;
  1960. }
  1961. p++;
  1962. }
  1963. return str;
  1964. }
  1965. static int wpa_dbus_ctrl_iface_props_init(struct wpas_dbus_priv *priv);
  1966. static void wpa_dbus_ctrl_iface_props_deinit(struct wpas_dbus_priv *priv)
  1967. {
  1968. int idx = priv->globals_start;
  1969. /* Free all allocated property values */
  1970. while (priv->all_interface_properties[idx].dbus_property)
  1971. os_free((char *)
  1972. priv->all_interface_properties[idx++].dbus_property);
  1973. os_free((char *) priv->all_interface_properties);
  1974. }
  1975. /**
  1976. * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
  1977. * @global: Pointer to global data from wpa_supplicant_init()
  1978. * Returns: 0 on success or -1 on failure
  1979. *
  1980. * Initialize the dbus control interface for wpa_supplicant and start
  1981. * receiving commands from external programs over the bus.
  1982. */
  1983. int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
  1984. {
  1985. struct wpa_dbus_object_desc *obj_desc;
  1986. int ret;
  1987. ret = wpa_dbus_ctrl_iface_props_init(priv);
  1988. if (ret < 0) {
  1989. wpa_printf(MSG_ERROR,
  1990. "dbus: Not enough memory to init interface properties");
  1991. return -1;
  1992. }
  1993. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  1994. if (!obj_desc) {
  1995. wpa_printf(MSG_ERROR,
  1996. "Not enough memory to create object description");
  1997. goto error;
  1998. }
  1999. wpas_dbus_register(obj_desc, priv->global, NULL,
  2000. wpas_dbus_global_methods,
  2001. wpas_dbus_global_properties,
  2002. wpas_dbus_global_signals);
  2003. wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
  2004. WPAS_DBUS_NEW_PATH);
  2005. ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
  2006. WPAS_DBUS_NEW_SERVICE,
  2007. obj_desc);
  2008. if (ret < 0) {
  2009. free_dbus_object_desc(obj_desc);
  2010. goto error;
  2011. }
  2012. priv->dbus_new_initialized = 1;
  2013. return 0;
  2014. error:
  2015. wpa_dbus_ctrl_iface_props_deinit(priv);
  2016. return -1;
  2017. }
  2018. /**
  2019. * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
  2020. * wpa_supplicant
  2021. * @priv: Pointer to dbus private data from wpas_dbus_init()
  2022. *
  2023. * Deinitialize the dbus control interface that was initialized with
  2024. * wpas_dbus_ctrl_iface_init().
  2025. */
  2026. void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *priv)
  2027. {
  2028. if (!priv->dbus_new_initialized)
  2029. return;
  2030. wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
  2031. WPAS_DBUS_NEW_PATH);
  2032. dbus_connection_unregister_object_path(priv->con, WPAS_DBUS_NEW_PATH);
  2033. wpa_dbus_ctrl_iface_props_deinit(priv);
  2034. }
  2035. static void wpa_dbus_free(void *ptr)
  2036. {
  2037. os_free(ptr);
  2038. }
  2039. static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
  2040. { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
  2041. wpas_dbus_getter_network_properties,
  2042. wpas_dbus_setter_network_properties,
  2043. NULL
  2044. },
  2045. { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
  2046. wpas_dbus_getter_enabled,
  2047. wpas_dbus_setter_enabled,
  2048. NULL
  2049. },
  2050. { NULL, NULL, NULL, NULL, NULL, NULL }
  2051. };
  2052. static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
  2053. /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
  2054. { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
  2055. {
  2056. { "properties", "a{sv}", ARG_OUT },
  2057. END_ARGS
  2058. }
  2059. },
  2060. { NULL, NULL, { END_ARGS } }
  2061. };
  2062. /**
  2063. * wpas_dbus_register_network - Register a configured network with dbus
  2064. * @wpa_s: wpa_supplicant interface structure
  2065. * @ssid: network configuration data
  2066. * Returns: 0 on success, -1 on failure
  2067. *
  2068. * Registers network representing object with dbus
  2069. */
  2070. int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
  2071. struct wpa_ssid *ssid)
  2072. {
  2073. struct wpas_dbus_priv *ctrl_iface;
  2074. struct wpa_dbus_object_desc *obj_desc;
  2075. struct network_handler_args *arg;
  2076. char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  2077. #ifdef CONFIG_P2P
  2078. /*
  2079. * If it is a persistent group register it as such.
  2080. * This is to handle cases where an interface is being initialized
  2081. * with a list of networks read from config.
  2082. */
  2083. if (network_is_persistent_group(ssid))
  2084. return wpas_dbus_register_persistent_group(wpa_s, ssid);
  2085. #endif /* CONFIG_P2P */
  2086. /* Do nothing if the control interface is not turned on */
  2087. if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
  2088. return 0;
  2089. ctrl_iface = wpa_s->global->dbus;
  2090. if (ctrl_iface == NULL)
  2091. return 0;
  2092. os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  2093. "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
  2094. wpa_s->dbus_new_path, ssid->id);
  2095. wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
  2096. net_obj_path);
  2097. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  2098. if (!obj_desc) {
  2099. wpa_printf(MSG_ERROR,
  2100. "Not enough memory to create object description");
  2101. goto err;
  2102. }
  2103. /* allocate memory for handlers arguments */
  2104. arg = os_zalloc(sizeof(struct network_handler_args));
  2105. if (!arg) {
  2106. wpa_printf(MSG_ERROR,
  2107. "Not enough memory to create arguments for method");
  2108. goto err;
  2109. }
  2110. arg->wpa_s = wpa_s;
  2111. arg->ssid = ssid;
  2112. wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
  2113. wpas_dbus_network_properties,
  2114. wpas_dbus_network_signals);
  2115. if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
  2116. wpa_s->ifname, obj_desc))
  2117. goto err;
  2118. wpas_dbus_signal_network_added(wpa_s, ssid->id);
  2119. return 0;
  2120. err:
  2121. free_dbus_object_desc(obj_desc);
  2122. return -1;
  2123. }
  2124. /**
  2125. * wpas_dbus_unregister_network - Unregister a configured network from dbus
  2126. * @wpa_s: wpa_supplicant interface structure
  2127. * @nid: network id
  2128. * Returns: 0 on success, -1 on failure
  2129. *
  2130. * Unregisters network representing object from dbus
  2131. */
  2132. int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
  2133. {
  2134. struct wpas_dbus_priv *ctrl_iface;
  2135. char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  2136. int ret;
  2137. #ifdef CONFIG_P2P
  2138. struct wpa_ssid *ssid;
  2139. ssid = wpa_config_get_network(wpa_s->conf, nid);
  2140. /* If it is a persistent group unregister it as such */
  2141. if (ssid && network_is_persistent_group(ssid))
  2142. return wpas_dbus_unregister_persistent_group(wpa_s, nid);
  2143. #endif /* CONFIG_P2P */
  2144. /* Do nothing if the control interface is not turned on */
  2145. if (wpa_s->global == NULL || wpa_s->dbus_new_path == NULL)
  2146. return 0;
  2147. ctrl_iface = wpa_s->global->dbus;
  2148. if (ctrl_iface == NULL)
  2149. return 0;
  2150. os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  2151. "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
  2152. wpa_s->dbus_new_path, nid);
  2153. wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
  2154. net_obj_path);
  2155. ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
  2156. if (!ret)
  2157. wpas_dbus_signal_network_removed(wpa_s, nid);
  2158. return ret;
  2159. }
  2160. static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
  2161. { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
  2162. wpas_dbus_getter_bss_ssid,
  2163. NULL,
  2164. NULL
  2165. },
  2166. { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
  2167. wpas_dbus_getter_bss_bssid,
  2168. NULL,
  2169. NULL
  2170. },
  2171. { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
  2172. wpas_dbus_getter_bss_privacy,
  2173. NULL,
  2174. NULL
  2175. },
  2176. { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
  2177. wpas_dbus_getter_bss_mode,
  2178. NULL,
  2179. NULL
  2180. },
  2181. { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
  2182. wpas_dbus_getter_bss_signal,
  2183. NULL,
  2184. NULL
  2185. },
  2186. { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
  2187. wpas_dbus_getter_bss_frequency,
  2188. NULL,
  2189. NULL
  2190. },
  2191. { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
  2192. wpas_dbus_getter_bss_rates,
  2193. NULL,
  2194. NULL
  2195. },
  2196. { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
  2197. wpas_dbus_getter_bss_wpa,
  2198. NULL,
  2199. NULL
  2200. },
  2201. { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
  2202. wpas_dbus_getter_bss_rsn,
  2203. NULL,
  2204. NULL
  2205. },
  2206. { "WPS", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
  2207. wpas_dbus_getter_bss_wps,
  2208. NULL,
  2209. NULL
  2210. },
  2211. { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
  2212. wpas_dbus_getter_bss_ies,
  2213. NULL,
  2214. NULL
  2215. },
  2216. { "Age", WPAS_DBUS_NEW_IFACE_BSS, "u",
  2217. wpas_dbus_getter_bss_age,
  2218. NULL,
  2219. NULL
  2220. },
  2221. { NULL, NULL, NULL, NULL, NULL, NULL }
  2222. };
  2223. static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
  2224. /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
  2225. { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
  2226. {
  2227. { "properties", "a{sv}", ARG_OUT },
  2228. END_ARGS
  2229. }
  2230. },
  2231. { NULL, NULL, { END_ARGS } }
  2232. };
  2233. /**
  2234. * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
  2235. * @wpa_s: wpa_supplicant interface structure
  2236. * @bssid: scanned network bssid
  2237. * @id: unique BSS identifier
  2238. * Returns: 0 on success, -1 on failure
  2239. *
  2240. * Unregisters BSS representing object from dbus
  2241. */
  2242. int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
  2243. u8 bssid[ETH_ALEN], unsigned int id)
  2244. {
  2245. struct wpas_dbus_priv *ctrl_iface;
  2246. char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  2247. /* Do nothing if the control interface is not turned on */
  2248. if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
  2249. return 0;
  2250. ctrl_iface = wpa_s->global->dbus;
  2251. if (ctrl_iface == NULL)
  2252. return 0;
  2253. os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  2254. "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
  2255. wpa_s->dbus_new_path, id);
  2256. wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
  2257. bss_obj_path);
  2258. if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
  2259. wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
  2260. bss_obj_path);
  2261. return -1;
  2262. }
  2263. wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
  2264. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
  2265. return 0;
  2266. }
  2267. /**
  2268. * wpas_dbus_register_bss - Register a scanned BSS with dbus
  2269. * @wpa_s: wpa_supplicant interface structure
  2270. * @bssid: scanned network bssid
  2271. * @id: unique BSS identifier
  2272. * Returns: 0 on success, -1 on failure
  2273. *
  2274. * Registers BSS representing object with dbus
  2275. */
  2276. int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
  2277. u8 bssid[ETH_ALEN], unsigned int id)
  2278. {
  2279. struct wpas_dbus_priv *ctrl_iface;
  2280. struct wpa_dbus_object_desc *obj_desc;
  2281. char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  2282. struct bss_handler_args *arg;
  2283. /* Do nothing if the control interface is not turned on */
  2284. if (wpa_s == NULL || wpa_s->global == NULL || !wpa_s->dbus_new_path)
  2285. return 0;
  2286. ctrl_iface = wpa_s->global->dbus;
  2287. if (ctrl_iface == NULL)
  2288. return 0;
  2289. os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  2290. "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
  2291. wpa_s->dbus_new_path, id);
  2292. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  2293. if (!obj_desc) {
  2294. wpa_printf(MSG_ERROR,
  2295. "Not enough memory to create object description");
  2296. goto err;
  2297. }
  2298. arg = os_zalloc(sizeof(struct bss_handler_args));
  2299. if (!arg) {
  2300. wpa_printf(MSG_ERROR,
  2301. "Not enough memory to create arguments for handler");
  2302. goto err;
  2303. }
  2304. arg->wpa_s = wpa_s;
  2305. arg->id = id;
  2306. wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
  2307. wpas_dbus_bss_properties,
  2308. wpas_dbus_bss_signals);
  2309. wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
  2310. bss_obj_path);
  2311. if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
  2312. wpa_s->ifname, obj_desc)) {
  2313. wpa_printf(MSG_ERROR,
  2314. "Cannot register BSSID dbus object %s.",
  2315. bss_obj_path);
  2316. goto err;
  2317. }
  2318. wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
  2319. wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
  2320. return 0;
  2321. err:
  2322. free_dbus_object_desc(obj_desc);
  2323. return -1;
  2324. }
  2325. static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
  2326. { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2327. (WPADBusMethodHandler) wpas_dbus_handler_scan,
  2328. {
  2329. { "args", "a{sv}", ARG_IN },
  2330. END_ARGS
  2331. }
  2332. },
  2333. { "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2334. (WPADBusMethodHandler) wpas_dbus_handler_signal_poll,
  2335. {
  2336. { "args", "a{sv}", ARG_OUT },
  2337. END_ARGS
  2338. }
  2339. },
  2340. { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2341. (WPADBusMethodHandler) wpas_dbus_handler_disconnect,
  2342. {
  2343. END_ARGS
  2344. }
  2345. },
  2346. { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2347. (WPADBusMethodHandler) wpas_dbus_handler_add_network,
  2348. {
  2349. { "args", "a{sv}", ARG_IN },
  2350. { "path", "o", ARG_OUT },
  2351. END_ARGS
  2352. }
  2353. },
  2354. { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2355. (WPADBusMethodHandler) wpas_dbus_handler_reassociate,
  2356. {
  2357. END_ARGS
  2358. }
  2359. },
  2360. { "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2361. (WPADBusMethodHandler) wpas_dbus_handler_reattach,
  2362. {
  2363. END_ARGS
  2364. }
  2365. },
  2366. { "Reconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2367. (WPADBusMethodHandler) wpas_dbus_handler_reconnect,
  2368. {
  2369. END_ARGS
  2370. }
  2371. },
  2372. { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2373. (WPADBusMethodHandler) wpas_dbus_handler_remove_network,
  2374. {
  2375. { "path", "o", ARG_IN },
  2376. END_ARGS
  2377. }
  2378. },
  2379. { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2380. (WPADBusMethodHandler) wpas_dbus_handler_remove_all_networks,
  2381. {
  2382. END_ARGS
  2383. }
  2384. },
  2385. { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2386. (WPADBusMethodHandler) wpas_dbus_handler_select_network,
  2387. {
  2388. { "path", "o", ARG_IN },
  2389. END_ARGS
  2390. }
  2391. },
  2392. { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2393. (WPADBusMethodHandler) wpas_dbus_handler_network_reply,
  2394. {
  2395. { "path", "o", ARG_IN },
  2396. { "field", "s", ARG_IN },
  2397. { "value", "s", ARG_IN },
  2398. END_ARGS
  2399. }
  2400. },
  2401. #ifndef CONFIG_NO_CONFIG_BLOBS
  2402. { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2403. (WPADBusMethodHandler) wpas_dbus_handler_add_blob,
  2404. {
  2405. { "name", "s", ARG_IN },
  2406. { "data", "ay", ARG_IN },
  2407. END_ARGS
  2408. }
  2409. },
  2410. { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2411. (WPADBusMethodHandler) wpas_dbus_handler_get_blob,
  2412. {
  2413. { "name", "s", ARG_IN },
  2414. { "data", "ay", ARG_OUT },
  2415. END_ARGS
  2416. }
  2417. },
  2418. { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2419. (WPADBusMethodHandler) wpas_dbus_handler_remove_blob,
  2420. {
  2421. { "name", "s", ARG_IN },
  2422. END_ARGS
  2423. }
  2424. },
  2425. #endif /* CONFIG_NO_CONFIG_BLOBS */
  2426. { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2427. (WPADBusMethodHandler)
  2428. wpas_dbus_handler_set_pkcs11_engine_and_module_path,
  2429. {
  2430. { "pkcs11_engine_path", "s", ARG_IN },
  2431. { "pkcs11_module_path", "s", ARG_IN },
  2432. END_ARGS
  2433. }
  2434. },
  2435. #ifdef CONFIG_WPS
  2436. { "Start", WPAS_DBUS_NEW_IFACE_WPS,
  2437. (WPADBusMethodHandler) wpas_dbus_handler_wps_start,
  2438. {
  2439. { "args", "a{sv}", ARG_IN },
  2440. { "output", "a{sv}", ARG_OUT },
  2441. END_ARGS
  2442. }
  2443. },
  2444. { "Cancel", WPAS_DBUS_NEW_IFACE_WPS,
  2445. (WPADBusMethodHandler) wpas_dbus_handler_wps_cancel,
  2446. {
  2447. END_ARGS
  2448. }
  2449. },
  2450. #endif /* CONFIG_WPS */
  2451. #ifdef CONFIG_P2P
  2452. { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2453. (WPADBusMethodHandler) wpas_dbus_handler_p2p_find,
  2454. {
  2455. { "args", "a{sv}", ARG_IN },
  2456. END_ARGS
  2457. }
  2458. },
  2459. { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2460. (WPADBusMethodHandler) wpas_dbus_handler_p2p_stop_find,
  2461. {
  2462. END_ARGS
  2463. }
  2464. },
  2465. { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2466. (WPADBusMethodHandler) wpas_dbus_handler_p2p_listen,
  2467. {
  2468. { "timeout", "i", ARG_IN },
  2469. END_ARGS
  2470. }
  2471. },
  2472. { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2473. (WPADBusMethodHandler) wpas_dbus_handler_p2p_extendedlisten,
  2474. {
  2475. { "args", "a{sv}", ARG_IN },
  2476. END_ARGS
  2477. }
  2478. },
  2479. { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2480. (WPADBusMethodHandler) wpas_dbus_handler_p2p_presence_request,
  2481. {
  2482. { "args", "a{sv}", ARG_IN },
  2483. END_ARGS
  2484. }
  2485. },
  2486. { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2487. (WPADBusMethodHandler) wpas_dbus_handler_p2p_prov_disc_req,
  2488. {
  2489. { "peer", "o", ARG_IN },
  2490. { "config_method", "s", ARG_IN },
  2491. END_ARGS
  2492. }
  2493. },
  2494. { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2495. (WPADBusMethodHandler) wpas_dbus_handler_p2p_connect,
  2496. {
  2497. { "args", "a{sv}", ARG_IN },
  2498. { "generated_pin", "s", ARG_OUT },
  2499. END_ARGS
  2500. }
  2501. },
  2502. { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2503. (WPADBusMethodHandler) wpas_dbus_handler_p2p_group_add,
  2504. {
  2505. { "args", "a{sv}", ARG_IN },
  2506. END_ARGS
  2507. }
  2508. },
  2509. { "Cancel", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2510. (WPADBusMethodHandler) wpas_dbus_handler_p2p_cancel,
  2511. {
  2512. END_ARGS
  2513. }
  2514. },
  2515. { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2516. (WPADBusMethodHandler) wpas_dbus_handler_p2p_invite,
  2517. {
  2518. { "args", "a{sv}", ARG_IN },
  2519. END_ARGS
  2520. }
  2521. },
  2522. { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2523. (WPADBusMethodHandler) wpas_dbus_handler_p2p_disconnect,
  2524. {
  2525. END_ARGS
  2526. }
  2527. },
  2528. { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2529. (WPADBusMethodHandler) wpas_dbus_handler_p2p_rejectpeer,
  2530. {
  2531. { "peer", "o", ARG_IN },
  2532. END_ARGS
  2533. }
  2534. },
  2535. { "RemoveClient", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2536. (WPADBusMethodHandler) wpas_dbus_handler_p2p_remove_client,
  2537. {
  2538. { "args", "a{sv}", ARG_IN },
  2539. END_ARGS
  2540. }
  2541. },
  2542. { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2543. (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush,
  2544. {
  2545. END_ARGS
  2546. }
  2547. },
  2548. { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2549. (WPADBusMethodHandler) wpas_dbus_handler_p2p_add_service,
  2550. {
  2551. { "args", "a{sv}", ARG_IN },
  2552. END_ARGS
  2553. }
  2554. },
  2555. { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2556. (WPADBusMethodHandler) wpas_dbus_handler_p2p_delete_service,
  2557. {
  2558. { "args", "a{sv}", ARG_IN },
  2559. END_ARGS
  2560. }
  2561. },
  2562. { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2563. (WPADBusMethodHandler) wpas_dbus_handler_p2p_flush_service,
  2564. {
  2565. END_ARGS
  2566. }
  2567. },
  2568. { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2569. (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_req,
  2570. {
  2571. { "args", "a{sv}", ARG_IN },
  2572. { "ref", "t", ARG_OUT },
  2573. END_ARGS
  2574. }
  2575. },
  2576. { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2577. (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_res,
  2578. {
  2579. { "args", "a{sv}", ARG_IN },
  2580. END_ARGS
  2581. }
  2582. },
  2583. { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2584. (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_sd_cancel_req,
  2585. {
  2586. { "args", "t", ARG_IN },
  2587. END_ARGS
  2588. }
  2589. },
  2590. { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2591. (WPADBusMethodHandler) wpas_dbus_handler_p2p_service_update,
  2592. {
  2593. END_ARGS
  2594. }
  2595. },
  2596. { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2597. (WPADBusMethodHandler) wpas_dbus_handler_p2p_serv_disc_external,
  2598. {
  2599. { "arg", "i", ARG_IN },
  2600. END_ARGS
  2601. }
  2602. },
  2603. { "AddPersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2604. (WPADBusMethodHandler) wpas_dbus_handler_add_persistent_group,
  2605. {
  2606. { "args", "a{sv}", ARG_IN },
  2607. { "path", "o", ARG_OUT },
  2608. END_ARGS
  2609. }
  2610. },
  2611. { "RemovePersistentGroup", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2612. (WPADBusMethodHandler) wpas_dbus_handler_remove_persistent_group,
  2613. {
  2614. { "path", "o", ARG_IN },
  2615. END_ARGS
  2616. }
  2617. },
  2618. { "RemoveAllPersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  2619. (WPADBusMethodHandler)
  2620. wpas_dbus_handler_remove_all_persistent_groups,
  2621. {
  2622. END_ARGS
  2623. }
  2624. },
  2625. #endif /* CONFIG_P2P */
  2626. { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2627. (WPADBusMethodHandler) wpas_dbus_handler_flush_bss,
  2628. {
  2629. { "age", "u", ARG_IN },
  2630. END_ARGS
  2631. }
  2632. },
  2633. #ifdef CONFIG_AP
  2634. { "SubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2635. (WPADBusMethodHandler) wpas_dbus_handler_subscribe_preq,
  2636. {
  2637. END_ARGS
  2638. }
  2639. },
  2640. { "UnsubscribeProbeReq", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2641. (WPADBusMethodHandler) wpas_dbus_handler_unsubscribe_preq,
  2642. {
  2643. END_ARGS
  2644. }
  2645. },
  2646. #endif /* CONFIG_AP */
  2647. { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2648. (WPADBusMethodHandler) wpas_dbus_handler_eap_logoff,
  2649. {
  2650. END_ARGS
  2651. }
  2652. },
  2653. { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2654. (WPADBusMethodHandler) wpas_dbus_handler_eap_logon,
  2655. {
  2656. END_ARGS
  2657. }
  2658. },
  2659. #ifdef CONFIG_AUTOSCAN
  2660. { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2661. (WPADBusMethodHandler) wpas_dbus_handler_autoscan,
  2662. {
  2663. { "arg", "s", ARG_IN },
  2664. END_ARGS
  2665. }
  2666. },
  2667. #endif /* CONFIG_AUTOSCAN */
  2668. #ifdef CONFIG_TDLS
  2669. { "TDLSDiscover", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2670. (WPADBusMethodHandler) wpas_dbus_handler_tdls_discover,
  2671. {
  2672. { "peer_address", "s", ARG_IN },
  2673. END_ARGS
  2674. }
  2675. },
  2676. { "TDLSSetup", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2677. (WPADBusMethodHandler) wpas_dbus_handler_tdls_setup,
  2678. {
  2679. { "peer_address", "s", ARG_IN },
  2680. END_ARGS
  2681. }
  2682. },
  2683. { "TDLSStatus", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2684. (WPADBusMethodHandler) wpas_dbus_handler_tdls_status,
  2685. {
  2686. { "peer_address", "s", ARG_IN },
  2687. { "status", "s", ARG_OUT },
  2688. END_ARGS
  2689. }
  2690. },
  2691. { "TDLSTeardown", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2692. (WPADBusMethodHandler) wpas_dbus_handler_tdls_teardown,
  2693. {
  2694. { "peer_address", "s", ARG_IN },
  2695. END_ARGS
  2696. }
  2697. },
  2698. { "TDLSChannelSwitch", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2699. (WPADBusMethodHandler) wpas_dbus_handler_tdls_channel_switch,
  2700. {
  2701. { "args", "a{sv}", ARG_IN },
  2702. END_ARGS
  2703. }
  2704. },
  2705. { "TDLSCancelChannelSwitch", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2706. (WPADBusMethodHandler) wpas_dbus_handler_tdls_cancel_channel_switch,
  2707. {
  2708. { "peer_address", "s", ARG_IN },
  2709. END_ARGS
  2710. }
  2711. },
  2712. #endif /* CONFIG_TDLS */
  2713. { "VendorElemAdd", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2714. (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_add,
  2715. {
  2716. { "frame_id", "i", ARG_IN },
  2717. { "ielems", "ay", ARG_IN },
  2718. END_ARGS
  2719. }
  2720. },
  2721. { "VendorElemGet", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2722. (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_get,
  2723. {
  2724. { "frame_id", "i", ARG_IN },
  2725. { "ielems", "ay", ARG_OUT },
  2726. END_ARGS
  2727. }
  2728. },
  2729. { "VendorElemRem", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2730. (WPADBusMethodHandler) wpas_dbus_handler_vendor_elem_remove,
  2731. {
  2732. { "frame_id", "i", ARG_IN },
  2733. { "ielems", "ay", ARG_IN },
  2734. END_ARGS
  2735. }
  2736. },
  2737. #ifndef CONFIG_NO_CONFIG_WRITE
  2738. { "SaveConfig", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2739. (WPADBusMethodHandler) wpas_dbus_handler_save_config,
  2740. {
  2741. END_ARGS
  2742. }
  2743. },
  2744. #endif /* CONFIG_NO_CONFIG_WRITE */
  2745. { "AbortScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2746. (WPADBusMethodHandler) wpas_dbus_handler_abort_scan,
  2747. {
  2748. END_ARGS
  2749. }
  2750. },
  2751. { NULL, NULL, NULL, { END_ARGS } }
  2752. };
  2753. static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
  2754. { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
  2755. wpas_dbus_getter_capabilities,
  2756. NULL,
  2757. NULL
  2758. },
  2759. { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2760. wpas_dbus_getter_state,
  2761. NULL,
  2762. NULL
  2763. },
  2764. { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
  2765. wpas_dbus_getter_scanning,
  2766. NULL,
  2767. NULL
  2768. },
  2769. { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
  2770. wpas_dbus_getter_ap_scan,
  2771. wpas_dbus_setter_ap_scan,
  2772. NULL
  2773. },
  2774. #ifdef CONFIG_IEEE80211W
  2775. { "Pmf", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
  2776. wpas_dbus_getter_pmf,
  2777. wpas_dbus_setter_pmf,
  2778. NULL
  2779. },
  2780. #endif /* CONFIG_IEEE80211W */
  2781. { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
  2782. wpas_dbus_getter_bss_expire_age,
  2783. wpas_dbus_setter_bss_expire_age,
  2784. NULL
  2785. },
  2786. { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
  2787. wpas_dbus_getter_bss_expire_count,
  2788. wpas_dbus_setter_bss_expire_count,
  2789. NULL
  2790. },
  2791. { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2792. wpas_dbus_getter_country,
  2793. wpas_dbus_setter_country,
  2794. NULL
  2795. },
  2796. { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2797. wpas_dbus_getter_ifname,
  2798. NULL,
  2799. NULL
  2800. },
  2801. { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2802. wpas_dbus_getter_driver,
  2803. NULL,
  2804. NULL
  2805. },
  2806. { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2807. wpas_dbus_getter_bridge_ifname,
  2808. NULL,
  2809. NULL
  2810. },
  2811. { "ConfigFile", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2812. wpas_dbus_getter_config_file,
  2813. NULL,
  2814. NULL
  2815. },
  2816. { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
  2817. wpas_dbus_getter_current_bss,
  2818. NULL,
  2819. NULL
  2820. },
  2821. { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
  2822. wpas_dbus_getter_current_network,
  2823. NULL,
  2824. NULL
  2825. },
  2826. { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2827. wpas_dbus_getter_current_auth_mode,
  2828. NULL,
  2829. NULL
  2830. },
  2831. { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
  2832. wpas_dbus_getter_blobs,
  2833. NULL,
  2834. NULL
  2835. },
  2836. { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
  2837. wpas_dbus_getter_bsss,
  2838. NULL,
  2839. NULL
  2840. },
  2841. { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
  2842. wpas_dbus_getter_networks,
  2843. NULL,
  2844. NULL
  2845. },
  2846. { "FastReauth", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
  2847. wpas_dbus_getter_fast_reauth,
  2848. wpas_dbus_setter_fast_reauth,
  2849. NULL
  2850. },
  2851. { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
  2852. wpas_dbus_getter_scan_interval,
  2853. wpas_dbus_setter_scan_interval,
  2854. NULL
  2855. },
  2856. { "PKCS11EnginePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2857. wpas_dbus_getter_pkcs11_engine_path,
  2858. NULL,
  2859. NULL
  2860. },
  2861. { "PKCS11ModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
  2862. wpas_dbus_getter_pkcs11_module_path,
  2863. NULL,
  2864. NULL
  2865. },
  2866. #ifdef CONFIG_WPS
  2867. { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
  2868. wpas_dbus_getter_process_credentials,
  2869. wpas_dbus_setter_process_credentials,
  2870. NULL
  2871. },
  2872. { "ConfigMethods", WPAS_DBUS_NEW_IFACE_WPS, "s",
  2873. wpas_dbus_getter_config_methods,
  2874. wpas_dbus_setter_config_methods,
  2875. NULL
  2876. },
  2877. {
  2878. "DeviceName", WPAS_DBUS_NEW_IFACE_WPS, "s",
  2879. wpas_dbus_getter_wps_device_name,
  2880. wpas_dbus_setter_wps_device_name,
  2881. NULL
  2882. },
  2883. {
  2884. "Manufacturer", WPAS_DBUS_NEW_IFACE_WPS, "s",
  2885. wpas_dbus_getter_wps_manufacturer,
  2886. wpas_dbus_setter_wps_manufacturer,
  2887. NULL
  2888. },
  2889. {
  2890. "ModelName", WPAS_DBUS_NEW_IFACE_WPS, "s",
  2891. wpas_dbus_getter_wps_device_model_name,
  2892. wpas_dbus_setter_wps_device_model_name,
  2893. NULL
  2894. },
  2895. {
  2896. "ModelNumber", WPAS_DBUS_NEW_IFACE_WPS, "s",
  2897. wpas_dbus_getter_wps_device_model_number,
  2898. wpas_dbus_setter_wps_device_model_number,
  2899. NULL
  2900. },
  2901. {
  2902. "SerialNumber", WPAS_DBUS_NEW_IFACE_WPS, "s",
  2903. wpas_dbus_getter_wps_device_serial_number,
  2904. wpas_dbus_setter_wps_device_serial_number,
  2905. NULL
  2906. },
  2907. {
  2908. "DeviceType", WPAS_DBUS_NEW_IFACE_WPS, "ay",
  2909. wpas_dbus_getter_wps_device_device_type,
  2910. wpas_dbus_setter_wps_device_device_type,
  2911. NULL
  2912. },
  2913. #endif /* CONFIG_WPS */
  2914. #ifdef CONFIG_P2P
  2915. { "P2PDeviceConfig", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
  2916. wpas_dbus_getter_p2p_device_config,
  2917. wpas_dbus_setter_p2p_device_config,
  2918. NULL
  2919. },
  2920. { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
  2921. wpas_dbus_getter_p2p_peers,
  2922. NULL,
  2923. NULL
  2924. },
  2925. { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
  2926. wpas_dbus_getter_p2p_role,
  2927. NULL,
  2928. NULL
  2929. },
  2930. { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
  2931. wpas_dbus_getter_p2p_group,
  2932. NULL,
  2933. NULL
  2934. },
  2935. { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
  2936. wpas_dbus_getter_p2p_peergo,
  2937. NULL,
  2938. NULL
  2939. },
  2940. { "PersistentGroups", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
  2941. wpas_dbus_getter_persistent_groups,
  2942. NULL,
  2943. NULL
  2944. },
  2945. #endif /* CONFIG_P2P */
  2946. { "DisconnectReason", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
  2947. wpas_dbus_getter_disconnect_reason,
  2948. NULL,
  2949. NULL
  2950. },
  2951. { "AssocStatusCode", WPAS_DBUS_NEW_IFACE_INTERFACE, "i",
  2952. wpas_dbus_getter_assoc_status_code,
  2953. NULL,
  2954. NULL
  2955. },
  2956. { NULL, NULL, NULL, NULL, NULL, NULL }
  2957. };
  2958. static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
  2959. { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2960. {
  2961. { "success", "b", ARG_OUT },
  2962. END_ARGS
  2963. }
  2964. },
  2965. { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2966. {
  2967. { "path", "o", ARG_OUT },
  2968. { "properties", "a{sv}", ARG_OUT },
  2969. END_ARGS
  2970. }
  2971. },
  2972. { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2973. {
  2974. { "path", "o", ARG_OUT },
  2975. END_ARGS
  2976. }
  2977. },
  2978. { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2979. {
  2980. { "name", "s", ARG_OUT },
  2981. END_ARGS
  2982. }
  2983. },
  2984. { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2985. {
  2986. { "name", "s", ARG_OUT },
  2987. END_ARGS
  2988. }
  2989. },
  2990. { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2991. {
  2992. { "path", "o", ARG_OUT },
  2993. { "properties", "a{sv}", ARG_OUT },
  2994. END_ARGS
  2995. }
  2996. },
  2997. { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
  2998. {
  2999. { "path", "o", ARG_OUT },
  3000. END_ARGS
  3001. }
  3002. },
  3003. { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3004. {
  3005. { "path", "o", ARG_OUT },
  3006. END_ARGS
  3007. }
  3008. },
  3009. /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
  3010. { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3011. {
  3012. { "properties", "a{sv}", ARG_OUT },
  3013. END_ARGS
  3014. }
  3015. },
  3016. #ifdef CONFIG_WPS
  3017. { "Event", WPAS_DBUS_NEW_IFACE_WPS,
  3018. {
  3019. { "name", "s", ARG_OUT },
  3020. { "args", "a{sv}", ARG_OUT },
  3021. END_ARGS
  3022. }
  3023. },
  3024. { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
  3025. {
  3026. { "credentials", "a{sv}", ARG_OUT },
  3027. END_ARGS
  3028. }
  3029. },
  3030. /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
  3031. { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
  3032. {
  3033. { "properties", "a{sv}", ARG_OUT },
  3034. END_ARGS
  3035. }
  3036. },
  3037. #endif /* CONFIG_WPS */
  3038. #ifdef CONFIG_P2P
  3039. { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3040. {
  3041. { "path", "o", ARG_OUT },
  3042. END_ARGS
  3043. }
  3044. },
  3045. { "DeviceFoundProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3046. {
  3047. { "path", "o", ARG_OUT },
  3048. { "properties", "a{sv}", ARG_OUT },
  3049. END_ARGS
  3050. }
  3051. },
  3052. { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3053. {
  3054. { "path", "o", ARG_OUT },
  3055. END_ARGS
  3056. }
  3057. },
  3058. { "FindStopped", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3059. {
  3060. END_ARGS
  3061. }
  3062. },
  3063. { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3064. {
  3065. { "peer_object", "o", ARG_OUT },
  3066. { "pin", "s", ARG_OUT },
  3067. END_ARGS
  3068. }
  3069. },
  3070. { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3071. {
  3072. { "peer_object", "o", ARG_OUT },
  3073. { "pin", "s", ARG_OUT },
  3074. END_ARGS
  3075. }
  3076. },
  3077. { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3078. {
  3079. { "peer_object", "o", ARG_OUT },
  3080. END_ARGS
  3081. }
  3082. },
  3083. { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3084. {
  3085. { "peer_object", "o", ARG_OUT },
  3086. END_ARGS
  3087. }
  3088. },
  3089. { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3090. {
  3091. { "peer_object", "o", ARG_OUT },
  3092. END_ARGS
  3093. }
  3094. },
  3095. { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3096. {
  3097. { "peer_object", "o", ARG_OUT },
  3098. END_ARGS
  3099. }
  3100. },
  3101. { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3102. {
  3103. { "peer_object", "o", ARG_OUT },
  3104. { "status", "i", ARG_OUT },
  3105. END_ARGS
  3106. }
  3107. },
  3108. { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3109. {
  3110. { "properties", "a{sv}", ARG_OUT },
  3111. END_ARGS
  3112. }
  3113. },
  3114. { "GroupFormationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3115. {
  3116. { "reason", "s", ARG_OUT },
  3117. END_ARGS
  3118. }
  3119. },
  3120. { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3121. {
  3122. { "properties", "a{sv}", ARG_OUT },
  3123. END_ARGS
  3124. }
  3125. },
  3126. { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3127. {
  3128. { "properties", "a{sv}", ARG_OUT },
  3129. END_ARGS
  3130. }
  3131. },
  3132. { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3133. {
  3134. { "path", "o", ARG_OUT },
  3135. { "dev_passwd_id", "q", ARG_OUT },
  3136. { "device_go_intent", "y", ARG_OUT },
  3137. END_ARGS
  3138. }
  3139. },
  3140. { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3141. {
  3142. { "invite_result", "a{sv}", ARG_OUT },
  3143. END_ARGS
  3144. }
  3145. },
  3146. { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3147. {
  3148. { "properties", "a{sv}", ARG_OUT },
  3149. END_ARGS
  3150. }
  3151. },
  3152. { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3153. {
  3154. { "sd_request", "a{sv}", ARG_OUT },
  3155. END_ARGS
  3156. }
  3157. },
  3158. { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3159. {
  3160. { "sd_response", "a{sv}", ARG_OUT },
  3161. END_ARGS
  3162. }
  3163. },
  3164. { "PersistentGroupAdded", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3165. {
  3166. { "path", "o", ARG_OUT },
  3167. { "properties", "a{sv}", ARG_OUT },
  3168. END_ARGS
  3169. }
  3170. },
  3171. { "PersistentGroupRemoved", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3172. {
  3173. { "path", "o", ARG_OUT },
  3174. END_ARGS
  3175. }
  3176. },
  3177. { "WpsFailed", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3178. {
  3179. { "name", "s", ARG_OUT },
  3180. { "args", "a{sv}", ARG_OUT },
  3181. END_ARGS
  3182. }
  3183. },
  3184. { "InvitationReceived", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3185. {
  3186. { "properties", "a{sv}", ARG_OUT },
  3187. END_ARGS
  3188. }
  3189. },
  3190. #endif /* CONFIG_P2P */
  3191. #ifdef CONFIG_AP
  3192. { "ProbeRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3193. {
  3194. { "args", "a{sv}", ARG_OUT },
  3195. END_ARGS
  3196. }
  3197. },
  3198. #endif /* CONFIG_AP */
  3199. { "Certification", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3200. {
  3201. { "certification", "a{sv}", ARG_OUT },
  3202. END_ARGS
  3203. }
  3204. },
  3205. { "EAP", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3206. {
  3207. { "status", "s", ARG_OUT },
  3208. { "parameter", "s", ARG_OUT },
  3209. END_ARGS
  3210. }
  3211. },
  3212. { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3213. {
  3214. { "name", "s", ARG_OUT },
  3215. END_ARGS
  3216. }
  3217. },
  3218. { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3219. {
  3220. { "name", "s", ARG_OUT },
  3221. END_ARGS
  3222. }
  3223. },
  3224. { "NetworkRequest", WPAS_DBUS_NEW_IFACE_INTERFACE,
  3225. {
  3226. { "path", "o", ARG_OUT },
  3227. { "field", "s", ARG_OUT },
  3228. { "text", "s", ARG_OUT },
  3229. END_ARGS
  3230. }
  3231. },
  3232. #ifdef CONFIG_MESH
  3233. { "MeshGroupStarted", WPAS_DBUS_NEW_IFACE_MESH,
  3234. {
  3235. { "args", "a{sv}", ARG_OUT },
  3236. END_ARGS
  3237. }
  3238. },
  3239. #endif /* CONFIG_MESH */
  3240. { NULL, NULL, { END_ARGS } }
  3241. };
  3242. static int wpa_dbus_ctrl_iface_props_init(struct wpas_dbus_priv *priv)
  3243. {
  3244. size_t all_size;
  3245. unsigned int i, j, count, num_const, num_globals;
  3246. const char *global_name;
  3247. static const char * const ignored_globals[] = {
  3248. "bss_expiration_age", "bss_expiration_scan_count",
  3249. "ap_scan", "country", "fast_reauth",
  3250. "pkcs11_engine_path", "pkcs11_module_path"
  3251. };
  3252. /* wpas_dbus_interface_properties terminates with a NULL element */
  3253. num_const = ARRAY_SIZE(wpas_dbus_interface_properties) - 1;
  3254. num_globals = wpa_config_get_num_global_field_names();
  3255. priv->globals_start = num_const;
  3256. /* allocate enough for all properties + terminating NULL element */
  3257. all_size = (num_globals + num_const + 1) *
  3258. sizeof(wpas_dbus_interface_properties[0]);
  3259. priv->all_interface_properties = os_zalloc(all_size);
  3260. if (!priv->all_interface_properties) {
  3261. wpa_printf(MSG_ERROR,
  3262. "dbus: Not enough memory for interface properties");
  3263. return -1;
  3264. }
  3265. /* Copy constant interface properties to the start of the array */
  3266. os_memcpy(priv->all_interface_properties,
  3267. wpas_dbus_interface_properties,
  3268. sizeof(wpas_dbus_interface_properties));
  3269. /* Dynamically construct interface global properties */
  3270. for (i = 0, count = num_const; i < num_globals; i++) {
  3271. struct wpa_dbus_property_desc *desc;
  3272. int no_var = 0;
  3273. /* ignore globals that are actually just methods */
  3274. global_name = wpa_config_get_global_field_name(i, &no_var);
  3275. if (no_var)
  3276. continue;
  3277. /* Ignore fields already explicitly exposed */
  3278. for (j = 0; j < ARRAY_SIZE(ignored_globals); j++) {
  3279. if (os_strcmp(global_name, ignored_globals[j]) == 0)
  3280. break;
  3281. }
  3282. if (j < ARRAY_SIZE(ignored_globals))
  3283. continue;
  3284. desc = &priv->all_interface_properties[count++];
  3285. desc->dbus_property = uscore_to_dbus(global_name);
  3286. if (!desc->dbus_property) {
  3287. wpa_printf(MSG_ERROR,
  3288. "dbus: Not enough memory for D-Bus property name");
  3289. goto error;
  3290. }
  3291. desc->dbus_interface = WPAS_DBUS_NEW_IFACE_INTERFACE;
  3292. desc->type = "s";
  3293. desc->getter = wpas_dbus_getter_iface_global;
  3294. desc->setter = wpas_dbus_setter_iface_global;
  3295. desc->data = global_name;
  3296. }
  3297. return 0;
  3298. error:
  3299. wpa_dbus_ctrl_iface_props_deinit(priv);
  3300. return -1;
  3301. }
  3302. /**
  3303. * wpas_dbus_register_interface - Register an interface with D-Bus
  3304. * @wpa_s: wpa_supplicant interface structure
  3305. * Returns: 0 on success, -1 on failure
  3306. */
  3307. int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
  3308. {
  3309. struct wpa_dbus_object_desc *obj_desc = NULL;
  3310. struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
  3311. int next;
  3312. /* Do nothing if the control interface is not turned on */
  3313. if (ctrl_iface == NULL)
  3314. return 0;
  3315. /* Create and set the interface's object path */
  3316. wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
  3317. if (wpa_s->dbus_new_path == NULL)
  3318. return -1;
  3319. next = ctrl_iface->next_objid++;
  3320. os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3321. WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
  3322. next);
  3323. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  3324. if (!obj_desc) {
  3325. wpa_printf(MSG_ERROR,
  3326. "Not enough memory to create object description");
  3327. goto err;
  3328. }
  3329. wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
  3330. ctrl_iface->all_interface_properties,
  3331. wpas_dbus_interface_signals);
  3332. wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
  3333. wpa_s->dbus_new_path);
  3334. if (wpa_dbus_register_object_per_iface(ctrl_iface,
  3335. wpa_s->dbus_new_path,
  3336. wpa_s->ifname, obj_desc))
  3337. goto err;
  3338. wpas_dbus_signal_interface_added(wpa_s);
  3339. return 0;
  3340. err:
  3341. os_free(wpa_s->dbus_new_path);
  3342. wpa_s->dbus_new_path = NULL;
  3343. free_dbus_object_desc(obj_desc);
  3344. return -1;
  3345. }
  3346. /**
  3347. * wpas_dbus_unregister_interface - Unregister the interface from D-Bus
  3348. * @wpa_s: wpa_supplicant interface structure
  3349. * Returns: 0 on success, -1 on failure
  3350. */
  3351. int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
  3352. {
  3353. struct wpas_dbus_priv *ctrl_iface;
  3354. /* Do nothing if the control interface is not turned on */
  3355. if (wpa_s == NULL || wpa_s->global == NULL)
  3356. return 0;
  3357. ctrl_iface = wpa_s->global->dbus;
  3358. if (ctrl_iface == NULL || wpa_s->dbus_new_path == NULL)
  3359. return 0;
  3360. wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
  3361. wpa_s->dbus_new_path);
  3362. #ifdef CONFIG_AP
  3363. if (wpa_s->preq_notify_peer) {
  3364. wpas_dbus_unsubscribe_noc(ctrl_iface);
  3365. os_free(wpa_s->preq_notify_peer);
  3366. wpa_s->preq_notify_peer = NULL;
  3367. }
  3368. #endif /* CONFIG_AP */
  3369. if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
  3370. wpa_s->dbus_new_path))
  3371. return -1;
  3372. wpas_dbus_signal_interface_removed(wpa_s);
  3373. os_free(wpa_s->dbus_new_path);
  3374. wpa_s->dbus_new_path = NULL;
  3375. return 0;
  3376. }
  3377. #ifdef CONFIG_P2P
  3378. static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
  3379. { "DeviceName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
  3380. wpas_dbus_getter_p2p_peer_device_name,
  3381. NULL,
  3382. NULL
  3383. },
  3384. { "Manufacturer", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
  3385. wpas_dbus_getter_p2p_peer_manufacturer,
  3386. NULL,
  3387. NULL
  3388. },
  3389. { "ModelName", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
  3390. wpas_dbus_getter_p2p_peer_modelname,
  3391. NULL,
  3392. NULL
  3393. },
  3394. { "ModelNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
  3395. wpas_dbus_getter_p2p_peer_modelnumber,
  3396. NULL,
  3397. NULL
  3398. },
  3399. { "SerialNumber", WPAS_DBUS_NEW_IFACE_P2P_PEER, "s",
  3400. wpas_dbus_getter_p2p_peer_serialnumber,
  3401. NULL,
  3402. NULL
  3403. },
  3404. { "PrimaryDeviceType", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
  3405. wpas_dbus_getter_p2p_peer_primary_device_type,
  3406. NULL,
  3407. NULL
  3408. },
  3409. { "config_method", WPAS_DBUS_NEW_IFACE_P2P_PEER, "q",
  3410. wpas_dbus_getter_p2p_peer_config_method,
  3411. NULL,
  3412. NULL
  3413. },
  3414. { "level", WPAS_DBUS_NEW_IFACE_P2P_PEER, "i",
  3415. wpas_dbus_getter_p2p_peer_level,
  3416. NULL,
  3417. NULL
  3418. },
  3419. { "devicecapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
  3420. wpas_dbus_getter_p2p_peer_device_capability,
  3421. NULL,
  3422. NULL
  3423. },
  3424. { "groupcapability", WPAS_DBUS_NEW_IFACE_P2P_PEER, "y",
  3425. wpas_dbus_getter_p2p_peer_group_capability,
  3426. NULL,
  3427. NULL
  3428. },
  3429. { "SecondaryDeviceTypes", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
  3430. wpas_dbus_getter_p2p_peer_secondary_device_types,
  3431. NULL,
  3432. NULL
  3433. },
  3434. { "VendorExtension", WPAS_DBUS_NEW_IFACE_P2P_PEER, "aay",
  3435. wpas_dbus_getter_p2p_peer_vendor_extension,
  3436. NULL,
  3437. NULL
  3438. },
  3439. { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
  3440. wpas_dbus_getter_p2p_peer_ies,
  3441. NULL,
  3442. NULL
  3443. },
  3444. { "DeviceAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
  3445. wpas_dbus_getter_p2p_peer_device_address,
  3446. NULL,
  3447. NULL
  3448. },
  3449. { "Groups", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ao",
  3450. wpas_dbus_getter_p2p_peer_groups,
  3451. NULL,
  3452. NULL
  3453. },
  3454. { NULL, NULL, NULL, NULL, NULL, NULL }
  3455. };
  3456. static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
  3457. /* Deprecated: use org.freedesktop.DBus.Properties.PropertiesChanged */
  3458. { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_P2P_PEER,
  3459. {
  3460. { "properties", "a{sv}", ARG_OUT },
  3461. END_ARGS
  3462. }
  3463. },
  3464. { NULL, NULL, { END_ARGS } }
  3465. };
  3466. /**
  3467. * wpas_dbus_signal_peer - Send a peer related event signal
  3468. * @wpa_s: %wpa_supplicant network interface data
  3469. * @dev: peer device object
  3470. * @interface: name of the interface emitting this signal.
  3471. * In case of peer objects, it would be emitted by either
  3472. * the "interface object" or by "peer objects"
  3473. * @sig_name: signal name - DeviceFound
  3474. * @properties: Whether to add a second argument with object properties
  3475. *
  3476. * Notify listeners about event related with p2p peer device
  3477. */
  3478. static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
  3479. const u8 *dev_addr, const char *interface,
  3480. const char *sig_name, int properties)
  3481. {
  3482. struct wpas_dbus_priv *iface;
  3483. DBusMessage *msg;
  3484. DBusMessageIter iter;
  3485. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
  3486. if (wpa_s->p2p_mgmt)
  3487. wpa_s = wpa_s->parent;
  3488. iface = wpa_s->global->dbus;
  3489. /* Do nothing if the control interface is not turned on */
  3490. if (iface == NULL || !wpa_s->dbus_new_path)
  3491. return;
  3492. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3493. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  3494. wpa_s->dbus_new_path, MAC2STR(dev_addr));
  3495. msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
  3496. sig_name);
  3497. if (msg == NULL)
  3498. return;
  3499. dbus_message_iter_init_append(msg, &iter);
  3500. path = peer_obj_path;
  3501. if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
  3502. &path) ||
  3503. (properties && !wpa_dbus_get_object_properties(
  3504. iface, peer_obj_path, WPAS_DBUS_NEW_IFACE_P2P_PEER,
  3505. &iter)))
  3506. wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
  3507. else
  3508. dbus_connection_send(iface->con, msg, NULL);
  3509. dbus_message_unref(msg);
  3510. }
  3511. /**
  3512. * wpas_dbus_signal_peer_found - Send a peer found signal
  3513. * @wpa_s: %wpa_supplicant network interface data
  3514. * @dev_addr: Peer P2P Device Address
  3515. *
  3516. * Notify listeners about find a p2p peer device found
  3517. */
  3518. void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
  3519. const u8 *dev_addr)
  3520. {
  3521. wpas_dbus_signal_peer(wpa_s, dev_addr,
  3522. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3523. "DeviceFound", FALSE);
  3524. wpas_dbus_signal_peer(wpa_s, dev_addr,
  3525. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3526. "DeviceFoundProperties", TRUE);
  3527. }
  3528. /**
  3529. * wpas_dbus_signal_peer_lost - Send a peer lost signal
  3530. * @wpa_s: %wpa_supplicant network interface data
  3531. * @dev_addr: Peer P2P Device Address
  3532. *
  3533. * Notify listeners about lost a p2p peer device
  3534. */
  3535. void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
  3536. const u8 *dev_addr)
  3537. {
  3538. wpas_dbus_signal_peer(wpa_s, dev_addr,
  3539. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3540. "DeviceLost", FALSE);
  3541. }
  3542. /**
  3543. * wpas_dbus_register_peer - Register a discovered peer object with dbus
  3544. * @wpa_s: wpa_supplicant interface structure
  3545. * @dev_addr: P2P Device Address of the peer
  3546. * Returns: 0 on success, -1 on failure
  3547. *
  3548. * Registers network representing object with dbus
  3549. */
  3550. int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
  3551. {
  3552. struct wpas_dbus_priv *ctrl_iface;
  3553. struct wpa_dbus_object_desc *obj_desc;
  3554. struct peer_handler_args *arg;
  3555. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  3556. /* Do nothing if the control interface is not turned on */
  3557. if (wpa_s == NULL || wpa_s->global == NULL)
  3558. return 0;
  3559. ctrl_iface = wpa_s->global->dbus;
  3560. if (ctrl_iface == NULL)
  3561. return 0;
  3562. wpa_s = wpa_s->parent->parent;
  3563. if (!wpa_s->dbus_new_path)
  3564. return 0;
  3565. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3566. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  3567. wpa_s->dbus_new_path, MAC2STR(dev_addr));
  3568. wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
  3569. peer_obj_path);
  3570. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  3571. if (!obj_desc) {
  3572. wpa_printf(MSG_ERROR,
  3573. "Not enough memory to create object description");
  3574. goto err;
  3575. }
  3576. /* allocate memory for handlers arguments */
  3577. arg = os_zalloc(sizeof(struct peer_handler_args));
  3578. if (!arg) {
  3579. wpa_printf(MSG_ERROR,
  3580. "Not enough memory to create arguments for method");
  3581. goto err;
  3582. }
  3583. arg->wpa_s = wpa_s;
  3584. os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
  3585. wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
  3586. NULL,
  3587. wpas_dbus_p2p_peer_properties,
  3588. wpas_dbus_p2p_peer_signals);
  3589. if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
  3590. wpa_s->ifname, obj_desc))
  3591. goto err;
  3592. return 0;
  3593. err:
  3594. free_dbus_object_desc(obj_desc);
  3595. return -1;
  3596. }
  3597. /**
  3598. * wpas_dbus_unregister_peer - Unregister a peer object with dbus
  3599. * @wpa_s: wpa_supplicant interface structure
  3600. * @dev_addr: p2p device addr
  3601. * Returns: 0 on success, -1 on failure
  3602. *
  3603. * Registers network representing object with dbus
  3604. */
  3605. int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
  3606. const u8 *dev_addr)
  3607. {
  3608. struct wpas_dbus_priv *ctrl_iface;
  3609. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  3610. int ret;
  3611. /* Do nothing if the control interface is not turned on */
  3612. if (wpa_s == NULL || wpa_s->global == NULL)
  3613. return 0;
  3614. wpa_s = wpa_s->parent->parent;
  3615. if (!wpa_s->dbus_new_path)
  3616. return 0;
  3617. ctrl_iface = wpa_s->global->dbus;
  3618. if (ctrl_iface == NULL)
  3619. return 0;
  3620. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3621. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  3622. wpa_s->dbus_new_path, MAC2STR(dev_addr));
  3623. wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
  3624. peer_obj_path);
  3625. ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
  3626. return ret;
  3627. }
  3628. /**
  3629. * wpas_dbus_signal_p2p_find_stopped - Send P2P Find stopped signal
  3630. * @wpa_s: %wpa_supplicant network interface data
  3631. *
  3632. * Notify listeners about P2P Find stopped
  3633. */
  3634. void wpas_dbus_signal_p2p_find_stopped(struct wpa_supplicant *wpa_s)
  3635. {
  3636. struct wpas_dbus_priv *iface;
  3637. DBusMessage *msg;
  3638. iface = wpa_s->global->dbus;
  3639. /* Do nothing if the control interface is not turned on */
  3640. if (iface == NULL || !wpa_s->dbus_new_path)
  3641. return;
  3642. msg = dbus_message_new_signal(wpa_s->dbus_new_path,
  3643. WPAS_DBUS_NEW_IFACE_P2PDEVICE,
  3644. "FindStopped");
  3645. if (msg == NULL)
  3646. return;
  3647. dbus_connection_send(iface->con, msg, NULL);
  3648. dbus_message_unref(msg);
  3649. }
  3650. /**
  3651. * wpas_dbus_signal_peer_groups_changed - Send peer group change property signal
  3652. * @wpa_s: %wpa_supplicant network interface data
  3653. * @dev_addr: P2P Device Address
  3654. *
  3655. * Notify listeners about peer Groups property changes.
  3656. */
  3657. void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s,
  3658. const u8 *dev_addr)
  3659. {
  3660. char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  3661. if (wpa_s->p2p_mgmt)
  3662. wpa_s = wpa_s->parent;
  3663. if (!wpa_s->dbus_new_path)
  3664. return;
  3665. os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3666. "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
  3667. wpa_s->dbus_new_path, MAC2STR(dev_addr));
  3668. wpa_dbus_mark_property_changed(wpa_s->global->dbus, peer_obj_path,
  3669. WPAS_DBUS_NEW_IFACE_P2P_PEER, "Groups");
  3670. }
  3671. static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
  3672. { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
  3673. wpas_dbus_getter_p2p_group_members,
  3674. NULL,
  3675. NULL
  3676. },
  3677. { "Group", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "o",
  3678. wpas_dbus_getter_p2p_group,
  3679. NULL,
  3680. NULL
  3681. },
  3682. { "Role", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
  3683. wpas_dbus_getter_p2p_role,
  3684. NULL,
  3685. NULL
  3686. },
  3687. { "SSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
  3688. wpas_dbus_getter_p2p_group_ssid,
  3689. NULL,
  3690. NULL
  3691. },
  3692. { "BSSID", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
  3693. wpas_dbus_getter_p2p_group_bssid,
  3694. NULL,
  3695. NULL
  3696. },
  3697. { "Frequency", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "q",
  3698. wpas_dbus_getter_p2p_group_frequency,
  3699. NULL,
  3700. NULL
  3701. },
  3702. { "Passphrase", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "s",
  3703. wpas_dbus_getter_p2p_group_passphrase,
  3704. NULL,
  3705. NULL
  3706. },
  3707. { "PSK", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ay",
  3708. wpas_dbus_getter_p2p_group_psk,
  3709. NULL,
  3710. NULL
  3711. },
  3712. { "WPSVendorExtensions", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "aay",
  3713. wpas_dbus_getter_p2p_group_vendor_ext,
  3714. wpas_dbus_setter_p2p_group_vendor_ext,
  3715. NULL
  3716. },
  3717. { NULL, NULL, NULL, NULL, NULL, NULL }
  3718. };
  3719. static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
  3720. { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
  3721. {
  3722. { "peer", "o", ARG_OUT },
  3723. END_ARGS
  3724. }
  3725. },
  3726. { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
  3727. {
  3728. { "peer", "o", ARG_OUT },
  3729. END_ARGS
  3730. }
  3731. },
  3732. { NULL, NULL, { END_ARGS } }
  3733. };
  3734. /**
  3735. * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
  3736. * @wpa_s: wpa_supplicant interface structure
  3737. * @ssid: SSID struct
  3738. * Returns: 0 on success, -1 on failure
  3739. *
  3740. * Registers p2p group representing object with dbus
  3741. */
  3742. void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
  3743. struct wpa_ssid *ssid)
  3744. {
  3745. struct wpas_dbus_priv *ctrl_iface;
  3746. struct wpa_dbus_object_desc *obj_desc;
  3747. char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  3748. /* Do nothing if the control interface is not turned on */
  3749. if (wpa_s == NULL || wpa_s->global == NULL)
  3750. return;
  3751. ctrl_iface = wpa_s->global->dbus;
  3752. if (ctrl_iface == NULL)
  3753. return;
  3754. if (wpa_s->dbus_groupobj_path) {
  3755. wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
  3756. __func__, wpa_s->dbus_groupobj_path);
  3757. return;
  3758. }
  3759. if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
  3760. return;
  3761. wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
  3762. if (wpa_s->dbus_groupobj_path == NULL)
  3763. return;
  3764. wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
  3765. group_obj_path);
  3766. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  3767. if (!obj_desc) {
  3768. wpa_printf(MSG_ERROR,
  3769. "Not enough memory to create object description");
  3770. goto err;
  3771. }
  3772. wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
  3773. wpas_dbus_p2p_group_properties,
  3774. wpas_dbus_p2p_group_signals);
  3775. if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
  3776. wpa_s->ifname, obj_desc))
  3777. goto err;
  3778. return;
  3779. err:
  3780. if (wpa_s->dbus_groupobj_path) {
  3781. os_free(wpa_s->dbus_groupobj_path);
  3782. wpa_s->dbus_groupobj_path = NULL;
  3783. }
  3784. free_dbus_object_desc(obj_desc);
  3785. }
  3786. /**
  3787. * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
  3788. * @wpa_s: wpa_supplicant interface structure
  3789. * @ssid: network name of the p2p group started
  3790. */
  3791. void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
  3792. const struct wpa_ssid *ssid)
  3793. {
  3794. struct wpas_dbus_priv *ctrl_iface;
  3795. /* Do nothing if the control interface is not turned on */
  3796. if (wpa_s == NULL || wpa_s->global == NULL)
  3797. return;
  3798. if (wpa_s->p2p_mgmt)
  3799. wpa_s = wpa_s->parent;
  3800. ctrl_iface = wpa_s->global->dbus;
  3801. if (ctrl_iface == NULL)
  3802. return;
  3803. if (!wpa_s->dbus_groupobj_path) {
  3804. wpa_printf(MSG_DEBUG,
  3805. "%s: Group object '%s' already unregistered",
  3806. __func__, wpa_s->dbus_groupobj_path);
  3807. return;
  3808. }
  3809. peer_groups_changed(wpa_s);
  3810. wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
  3811. wpa_s->dbus_groupobj_path);
  3812. wpa_dbus_unregister_object_per_iface(ctrl_iface,
  3813. wpa_s->dbus_groupobj_path);
  3814. os_free(wpa_s->dbus_groupobj_path);
  3815. wpa_s->dbus_groupobj_path = NULL;
  3816. }
  3817. static const struct wpa_dbus_property_desc
  3818. wpas_dbus_persistent_group_properties[] = {
  3819. { "Properties", WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP, "a{sv}",
  3820. wpas_dbus_getter_persistent_group_properties,
  3821. wpas_dbus_setter_persistent_group_properties,
  3822. NULL
  3823. },
  3824. { NULL, NULL, NULL, NULL, NULL, NULL }
  3825. };
  3826. /* No signals intended for persistent group objects */
  3827. /**
  3828. * wpas_dbus_register_persistent_group - Register a configured(saved)
  3829. * persistent group with dbus
  3830. * @wpa_s: wpa_supplicant interface structure
  3831. * @ssid: persistent group (still represented as a network within wpa)
  3832. * configuration data
  3833. * Returns: 0 on success, -1 on failure
  3834. *
  3835. * Registers a persistent group representing object with dbus.
  3836. */
  3837. int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
  3838. struct wpa_ssid *ssid)
  3839. {
  3840. struct wpas_dbus_priv *ctrl_iface;
  3841. struct wpa_dbus_object_desc *obj_desc;
  3842. struct network_handler_args *arg;
  3843. char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  3844. /* Do nothing if the control interface is not turned on */
  3845. if (wpa_s == NULL || wpa_s->global == NULL)
  3846. return 0;
  3847. wpa_s = wpa_s->parent->parent;
  3848. if (!wpa_s->dbus_new_path)
  3849. return 0;
  3850. /* Make sure ssid is a persistent group */
  3851. if (ssid->disabled != 2 && !ssid->p2p_persistent_group)
  3852. return -1; /* should we return w/o complaining? */
  3853. if (wpa_s->p2p_mgmt)
  3854. wpa_s = wpa_s->parent;
  3855. ctrl_iface = wpa_s->global->dbus;
  3856. if (ctrl_iface == NULL)
  3857. return 0;
  3858. /*
  3859. * Intentionally not coming up with different numbering scheme
  3860. * for persistent groups.
  3861. */
  3862. os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3863. "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
  3864. wpa_s->dbus_new_path, ssid->id);
  3865. wpa_printf(MSG_DEBUG, "dbus: Register persistent group object '%s'",
  3866. pgrp_obj_path);
  3867. obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
  3868. if (!obj_desc) {
  3869. wpa_printf(MSG_ERROR,
  3870. "dbus: Not enough memory to create object description");
  3871. goto err;
  3872. }
  3873. /*
  3874. * Reusing the same context structure as that for networks
  3875. * since these are represented using same data structure.
  3876. */
  3877. /* allocate memory for handlers arguments */
  3878. arg = os_zalloc(sizeof(struct network_handler_args));
  3879. if (!arg) {
  3880. wpa_printf(MSG_ERROR,
  3881. "dbus: Not enough memory to create arguments for method");
  3882. goto err;
  3883. }
  3884. arg->wpa_s = wpa_s;
  3885. arg->ssid = ssid;
  3886. wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
  3887. wpas_dbus_persistent_group_properties,
  3888. NULL);
  3889. if (wpa_dbus_register_object_per_iface(ctrl_iface, pgrp_obj_path,
  3890. wpa_s->ifname, obj_desc))
  3891. goto err;
  3892. wpas_dbus_signal_persistent_group_added(wpa_s, ssid->id);
  3893. return 0;
  3894. err:
  3895. free_dbus_object_desc(obj_desc);
  3896. return -1;
  3897. }
  3898. /**
  3899. * wpas_dbus_unregister_persistent_group - Unregister a persistent_group
  3900. * from dbus
  3901. * @wpa_s: wpa_supplicant interface structure
  3902. * @nid: network id
  3903. * Returns: 0 on success, -1 on failure
  3904. *
  3905. * Unregisters persistent group representing object from dbus
  3906. *
  3907. * NOTE: There is a slight issue with the semantics here. While the
  3908. * implementation simply means the persistent group is unloaded from memory,
  3909. * it should not get interpreted as the group is actually being erased/removed
  3910. * from persistent storage as well.
  3911. */
  3912. int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
  3913. int nid)
  3914. {
  3915. struct wpas_dbus_priv *ctrl_iface;
  3916. char pgrp_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
  3917. int ret;
  3918. /* Do nothing if the control interface is not turned on */
  3919. if (wpa_s == NULL || wpa_s->global == NULL)
  3920. return 0;
  3921. wpa_s = wpa_s->parent->parent;
  3922. ctrl_iface = wpa_s->global->dbus;
  3923. if (ctrl_iface == NULL || !wpa_s->dbus_new_path)
  3924. return 0;
  3925. os_snprintf(pgrp_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
  3926. "%s/" WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "/%u",
  3927. wpa_s->dbus_new_path, nid);
  3928. wpa_printf(MSG_DEBUG, "dbus: Unregister persistent group object '%s'",
  3929. pgrp_obj_path);
  3930. ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, pgrp_obj_path);
  3931. if (!ret)
  3932. wpas_dbus_signal_persistent_group_removed(wpa_s, nid);
  3933. return ret;
  3934. }
  3935. #endif /* CONFIG_P2P */