1/* 2 * wpa_supplicant - D-Bus introspection 3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc. 4 * Copyright (c) 2009, Witold Sowa <witold.sowa@gmail.com> 5 * Copyright (c) 2010, 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 11#include "utils/includes.h" 12 13#include "utils/common.h" 14#include "utils/list.h" 15#include "utils/wpabuf.h" 16#include "dbus_common_i.h" --- 15 unchanged lines hidden (view full) --- 32 dl_list_for_each(iface, list, struct interfaces, list) { 33 if (os_strcmp(iface->dbus_interface, dbus_interface) == 0) 34 return iface; /* already in the list */ 35 } 36 37 iface = os_zalloc(sizeof(struct interfaces)); 38 if (!iface) 39 return NULL; |
40 iface->xml = wpabuf_alloc(6000); |
41 if (iface->xml == NULL) { 42 os_free(iface); 43 return NULL; 44 } 45 wpabuf_printf(iface->xml, "<interface name=\"%s\">", dbus_interface); 46 dl_list_add_tail(list, &iface->list); 47 iface->dbus_interface = os_strdup(dbus_interface); 48 return iface; --- 29 unchanged lines hidden (view full) --- 78 } 79 wpabuf_printf(xml, "</%s>", type); 80} 81 82 83static void add_property(struct wpabuf *xml, 84 const struct wpa_dbus_property_desc *dsc) 85{ |
86 wpabuf_printf(xml, "<property name=\"%s\" type=\"%s\" " 87 "access=\"%s%s\"/>", |
88 dsc->dbus_property, dsc->type, |
89 dsc->getter ? "read" : "", 90 dsc->setter ? "write" : ""); |
91} 92 93 94static void extract_interfaces_methods( 95 struct dl_list *list, const struct wpa_dbus_method_desc *methods) 96{ 97 const struct wpa_dbus_method_desc *dsc; 98 struct interfaces *iface; --- 54 unchanged lines hidden (view full) --- 153 154static void add_interfaces(struct dl_list *list, struct wpabuf *xml) 155{ 156 struct interfaces *iface, *n; 157 dl_list_for_each_safe(iface, n, list, struct interfaces, list) { 158 if (wpabuf_len(iface->xml) + 20 < wpabuf_tailroom(xml)) { 159 wpabuf_put_buf(xml, iface->xml); 160 wpabuf_put_str(xml, "</interface>"); |
161 } else { 162 wpa_printf(MSG_DEBUG, "dbus: Not enough room for " 163 "add_interfaces inspect data: tailroom %u, " 164 "add %u", 165 (unsigned int) wpabuf_tailroom(xml), 166 (unsigned int) wpabuf_len(iface->xml)); |
167 } 168 dl_list_del(&iface->list); 169 wpabuf_free(iface->xml); 170 os_free(iface->dbus_interface); 171 os_free(iface); 172 } 173} 174 --- 71 unchanged lines hidden (view full) --- 246 */ 247DBusMessage * wpa_dbus_introspect(DBusMessage *message, 248 struct wpa_dbus_object_desc *obj_dsc) 249{ 250 251 DBusMessage *reply; 252 struct wpabuf *xml; 253 |
254 xml = wpabuf_alloc(10000); |
255 if (xml == NULL) 256 return NULL; 257 258 wpabuf_put_str(xml, "<?xml version=\"1.0\"?>\n"); 259 wpabuf_put_str(xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE); 260 wpabuf_put_str(xml, "<node>"); 261 262 add_introspectable_interface(xml); --- 17 unchanged lines hidden --- |