/* format_wps_device_xml -- produce content of "file" wps_device.xml * (UPNP_WPS_DEVICE_XML_FILE) */ static void format_wps_device_xml(struct upnp_wps_device_interface *iface, struct upnp_wps_device_sm *sm, struct wpabuf *buf) { const char *s; char uuid_string[80]; wpabuf_put_str(buf, wps_device_xml_prefix); /* * Add required fields with default values if not configured. Add * optional and recommended fields only if configured. */ s = iface->wps->friendly_name; s = ((s && *s) ? s : "WPS Access Point"); xml_add_tagged_data(buf, "friendlyName", s); s = iface->wps->dev.manufacturer; s = ((s && *s) ? s : ""); xml_add_tagged_data(buf, "manufacturer", s); if (iface->wps->manufacturer_url) xml_add_tagged_data(buf, "manufacturerURL", iface->wps->manufacturer_url); if (iface->wps->model_description) xml_add_tagged_data(buf, "modelDescription", iface->wps->model_description); s = iface->wps->dev.model_name; s = ((s && *s) ? s : ""); xml_add_tagged_data(buf, "modelName", s); if (iface->wps->dev.model_number) xml_add_tagged_data(buf, "modelNumber", iface->wps->dev.model_number); if (iface->wps->model_url) xml_add_tagged_data(buf, "modelURL", iface->wps->model_url); if (iface->wps->dev.serial_number) xml_add_tagged_data(buf, "serialNumber", iface->wps->dev.serial_number); uuid_bin2str(iface->wps->uuid, uuid_string, sizeof(uuid_string)); s = uuid_string; /* Need "uuid:" prefix, thus we can't use xml_add_tagged_data() * easily... */ wpabuf_put_str(buf, "<UDN>uuid:"); xml_data_encode(buf, s, os_strlen(s)); wpabuf_put_str(buf, "</UDN>\n"); if (iface->wps->upc) xml_add_tagged_data(buf, "UPC", iface->wps->upc); wpabuf_put_str(buf, wps_device_xml_postfix); }
/* xml_add_tagged_data -- format tagged data as a new xml line. * * tag must not have any special chars. * data may have special chars, which are escaped. */ void xml_add_tagged_data(struct wpabuf *buf, const char *tag, const char *data) { wpabuf_printf(buf, "<%s>", tag); xml_data_encode(buf, data, os_strlen(data)); wpabuf_printf(buf, "</%s>\n", tag); }