From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.01.org
Subject: Re: [PATCH 04/17] p2p: Add peer WSC device type properties
Date: Fri, 17 Apr 2020 12:33:53 -0500 [thread overview]
Message-ID: <fb807c29-1ed8-2df7-c6de-7ffd2181cd83@gmail.com> (raw)
In-Reply-To: <20200403161430.14168-4-andrew.zaborowski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 6829 bytes --]
Hi Andrew,
On 4/3/20 11:14 AM, Andrew Zaborowski wrote:
> ---
> src/p2p.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 208 insertions(+)
>
> diff --git a/src/p2p.c b/src/p2p.c
> index 957482eb..49111a98 100644
> --- a/src/p2p.c
> +++ b/src/p2p.c
> @@ -68,10 +68,156 @@ struct p2p_peer {
> struct scan_bss *bss;
> struct p2p_device *dev;
> char *name;
> + struct wsc_primary_device_type primary_device_type;
> };
>
> static struct l_queue *p2p_device_list;
>
> +struct device_type_category_info {
> + char *category_str;
const char?
> + unsigned int subcategory_max;
> + char **subcategory_str;
const char **?
> +};
> +
> +/* Wi-Fi Simple Configuration Technical Specification v2.0.5 Table 41 */
> +struct device_type_category_info device_type_categories[] = {
> + [1] = {
> + "Computer",
> + 10,
> + (char *[]) {
> + [1] = "PC",
> + [2] = "Server",
> + [3] = "Media Center",
> + [4] = "Ultra-mobile PC",
> + [5] = "Notebook",
> + [6] = "Desktop",
> + [7] = "Mobile Internet Device",
> + [8] = "Netbook",
> + [9] = "Tablet",
> + [10] = "Ultrabook",
> + },
> + },
> + [2] = {
> + "Input Device",
> + 9,
> + (char *[]) {
> + [1] = "Keyboard",
> + [2] = "Mouse",
> + [3] = "Joystick",
> + [4] = "Trackball",
> + [5] = "Gaming controller",
> + [6] = "Remote",
> + [7] = "Touchscreen",
> + [8] = "Biometric reader",
> + [9] = "Barcode reader",
> + },
> + },
> + [3] = {
> + "Printer or Scanner",
> + 5,
> + (char *[]) {
> + [1] = "Printer/Print Server",
> + [2] = "Scanner",
> + [3] = "Fax",
> + [4] = "Copier",
> + [5] = "All-in-one printer, scanner, fax, copier",
> + },
> + },
> + [4] = {
> + "Camera",
> + 4,
> + (char *[]) {
> + [1] = "Digital Still Camera",
> + [2] = "Video Camera",
> + [3] = "Web Camera",
> + [4] = "Security Camera",
> + },
> + },
> + [5] = {
> + "Storage",
> + 1,
> + (char *[]) {
> + [1] = "NAS",
> + },
> + },
> + [6] = {
> + "Network Infrastructure",
> + 5,
> + (char *[]) {
> + [1] = "AP",
> + [2] = "Router",
> + [3] = "Switch",
> + [4] = "Gateway",
> + [5] = "Bridge",
> + },
> + },
> + [7] = {
> + "Display",
> + 4,
> + (char *[]) {
> + [1] = "Television",
> + [2] = "Electronic Picture Frame",
> + [3] = "Projector",
> + [4] = "Monitor",
> + },
> + },
> + [8] = {
> + "Multimedia Device",
> + 6,
> + (char *[]) {
> + [1] = "DAR",
> + [2] = "PVR",
> + [3] = "MCX",
> + [4] = "Set-top box",
> + [5] = "Media Server/Adapter/Extender",
> + [6] = "Portable Video Player",
> + },
> + },
> + [9] = {
> + "Gaming device",
> + 5,
> + (char *[]) {
> + [1] = "Xbox",
> + [2] = "Xbox360",
> + [3] = "Playstation",
> + [4] = "Game Console/Console Adapter",
> + [5] = "Portable Gaming Device",
> + },
> + },
> + [10] = {
> + "Telephone",
> + 5,
> + (char *[]) {
> + [1] = "Windows Mobile",
> + [2] = "Single mode phone",
> + [3] = "Dual mode phone",
> + [4] = "Single mode smartphone",
> + [5] = "Dual mode smartphone",
> + },
> + },
> + [11] = {
> + "Audio Device",
> + 7,
> + (char *[]) {
> + [1] = "Audio tuner/receiver",
> + [2] = "Speakers",
> + [3] = "Portable Music Player",
> + [4] = "Headset",
> + [5] = "Headphones",
> + [6] = "Microphone",
> + [7] = "Home Theater System",
> + },
> + },
> + [12] = {
> + "Docking Device",
> + 2,
> + (char *[]) {
> + [1] = "Computer docking station",
> + [2] = "Media kiosk",
> + },
> + },
> +};
> +
So two things I see here:
1. Does this belong in wscutil.c instead?
2. Your intent seems to be to expose these as D-Bus API values. If so,
then this gets a bit tricky. Our D-Bus APIs do not support translation.
This is by design, hence all values need to be defined in
doc/foo-api.txt. The values must also be all lower case.
> static bool p2p_device_match(const void *a, const void *b)
> {
> const struct p2p_device *dev = a;
> @@ -301,6 +447,64 @@ static bool p2p_peer_get_name(struct l_dbus *dbus,
> return true;
> }
>
> +static bool p2p_peer_get_category(struct l_dbus *dbus,
> + struct l_dbus_message *message,
> + struct l_dbus_message_builder *builder,
> + void *user_data)
> +{
> + struct p2p_peer *peer = user_data;
> + uint16_t category_id = peer->primary_device_type.category;
> + const char *category = NULL;
> +
> + if (category_id == 255)
> + category = "Other";
> + else if (category_id < L_ARRAY_SIZE(device_type_categories))
> + category = device_type_categories[category_id].category_str;
> +
> + if (!category)
> + category = "Unknown";
> +
> + l_dbus_message_builder_append_basic(builder, 's', category);
> + return true;
> +}
> +
> +static bool p2p_peer_get_subcategory(struct l_dbus *dbus,
> + struct l_dbus_message *message,
> + struct l_dbus_message_builder *builder,
> + void *user_data)
> +{
> + struct p2p_peer *peer = user_data;
> + uint16_t category_id = peer->primary_device_type.category;
> + uint16_t subcategory_id = peer->primary_device_type.subcategory;
> + const char *subcategory;
> +
> + /*
> + * Should we generate subcategory strings with the numerical
> + * values for the subcategories we don't know, such as
> + * "Vendor-specific 00:11:22:33 44" ?
> + */
> +
> + if (memcmp(peer->primary_device_type.oui, microsoft_oui, 3) ||
> + peer->primary_device_type.oui_type != 4)
> + return false;
> +
> + if (category_id >= L_ARRAY_SIZE(device_type_categories))
> + return false;
> +
> + if (!device_type_categories[category_id].subcategory_str ||
> + subcategory_id >
> + device_type_categories[category_id].subcategory_max)
> + return false;
> +
> + subcategory = device_type_categories[category_id].
> + subcategory_str[subcategory_id];
> + if (!subcategory)
> + return false;
> +
> + l_dbus_message_builder_append_basic(builder, 's', subcategory);
> + return true;
> +}
> +
> static bool p2p_peer_get_connected(struct l_dbus *dbus,
> struct l_dbus_message *message,
> struct l_dbus_message_builder *builder,
> @@ -316,6 +520,10 @@ static void p2p_peer_interface_setup(struct l_dbus_interface *interface)
> {
> l_dbus_interface_property(interface, "Name", 0, "s",
> p2p_peer_get_name, NULL);
> + l_dbus_interface_property(interface, "DeviceCategory", 0, "s",
> + p2p_peer_get_category, NULL);
> + l_dbus_interface_property(interface, "DeviceSubcategory", 0, "s",
> + p2p_peer_get_subcategory, NULL);
> l_dbus_interface_property(interface, "Connected", 0, "b",
> p2p_peer_get_connected, NULL);
> }
>
Regards,
-Denis
next prev parent reply other threads:[~2020-04-17 17:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 16:14 [PATCH 01/17] dbus: Add P2P interface name defines Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 02/17] Add minimal p2p.c and p2p.h Andrew Zaborowski
2020-04-17 15:19 ` Denis Kenzior
2020-04-17 21:01 ` Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 03/17] manager: Create/destroy P2P devices Andrew Zaborowski
2020-04-17 15:30 ` Denis Kenzior
2020-04-03 16:14 ` [PATCH 04/17] p2p: Add peer WSC device type properties Andrew Zaborowski
2020-04-17 17:33 ` Denis Kenzior [this message]
2020-04-17 20:55 ` Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 05/17] p2p: Add main device settings Andrew Zaborowski
2020-04-17 16:26 ` Denis Kenzior
2020-04-17 23:02 ` Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 06/17] p2p: Add device enable/disable logic Andrew Zaborowski
2020-04-17 16:41 ` Denis Kenzior
2020-04-25 8:45 ` Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 07/17] p2p: Add the Scan Phase Andrew Zaborowski
2020-04-17 17:27 ` Denis Kenzior
2020-04-03 16:14 ` [PATCH 08/17] p2p: Add the Listen State Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 09/17] p2p: Add the WSC interface on peer DBus objects Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 10/17] p2p: Build and send the GO Negotiation Request Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 11/17] p2p: Handle GO Negotiation Response, send Confirmation Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 12/17] p2p: Handle the Information Not Available response code Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 13/17] p2p: Respond to Probe Reqs when waiting for GO negotiation Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 14/17] p2p: Add the Provision Discovery frame sequence Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 15/17] p2p: Scan for the provision BSS Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 16/17] p2p: Create the P2P-Client interface Andrew Zaborowski
2020-04-03 16:14 ` [PATCH 17/17] p2p: WSC client provisioning and connection Andrew Zaborowski
2020-04-17 15:16 ` [PATCH 01/17] dbus: Add P2P interface name defines Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb807c29-1ed8-2df7-c6de-7ffd2181cd83@gmail.com \
--to=denkenz@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox