[PATCH v2] agent-connman: read SSID as byte array

2015-07-07 Thread Adam Moore
Read Agent provided SSID as an array of bytes and recurse where needed
---
 src/agent-connman.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/agent-connman.c b/src/agent-connman.c
index 8440451..1b6f8a3 100644
--- a/src/agent-connman.c
+++ b/src/agent-connman.c
@@ -141,17 +141,20 @@ static void request_input_passphrase_reply(DBusMessage 
*reply, void *user_data)
name_len = strlen(name);
} else if (g_str_equal(key, "SSID")) {
dbus_message_iter_next(&entry);
+   DBusMessageIter *array_iter = NULL;
if (dbus_message_iter_get_arg_type(&entry)
!= DBUS_TYPE_VARIANT)
break;
dbus_message_iter_recurse(&entry, &value);
if (dbus_message_iter_get_arg_type(&value)
-   != DBUS_TYPE_VARIANT)
+   != DBUS_TYPE_ARRAY)
break;
-   if (dbus_message_iter_get_element_type(&value)
-   != DBUS_TYPE_VARIANT)
+
+   dbus_message_iter_recurse(&value, &array_iter);
+   if (dbus_message_iter_get_arg_type(&array_iter)
+   != DBUS_TYPE_BYTE)
break;
-   dbus_message_iter_get_fixed_array(&value, &name,
+   dbus_message_iter_get_fixed_array(&array_iter, &name,
&name_len);
}
dbus_message_iter_next(&dict);
--
1.9.1


Statement of Confidentiality

The contents of this e-mail message and any attachments are confidential and 
are intended solely for the addressee. The information may also be legally 
privileged. This transmission is sent in trust, and the sole purpose of 
delivery to the intended recipient. If you have received this transmission in 
error, any use, reproduction or dissemination of this transmission is strictly 
prohibited. If you are not the intended recipient, please immediately notify 
the sender by reply e-mail or at 508.683.2500 and delete this message and its 
attachments, if any.

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] agent-connman: read SSID as byte array

2015-07-07 Thread Tomasz Bursztyka

Hi Adam,

Eh eh, indeed! Looks like nobody ever tried this code.
I guess people are fine with Name and never use the SSID alternative.

So your patch looks good, just remove the Signed-off-by, we don't apply 
this rule in connman's tree.


Tomasz


Read Agent provided SSID as an array of bytes and recurse where needed

Signed-off-by: Adam Moore 
---
  src/agent-connman.c | 11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/agent-connman.c b/src/agent-connman.c
index 8440451..1b6f8a3 100644
--- a/src/agent-connman.c
+++ b/src/agent-connman.c
@@ -141,17 +141,20 @@ static void request_input_passphrase_reply(DBusMessage 
*reply, void *user_data)
 name_len = strlen(name);
 } else if (g_str_equal(key, "SSID")) {
 dbus_message_iter_next(&entry);
+   DBusMessageIter *array_iter = NULL;
 if (dbus_message_iter_get_arg_type(&entry)
 != DBUS_TYPE_VARIANT)
 break;
 dbus_message_iter_recurse(&entry, &value);
 if (dbus_message_iter_get_arg_type(&value)
-   != DBUS_TYPE_VARIANT)
+   != DBUS_TYPE_ARRAY)
 break;
-   if (dbus_message_iter_get_element_type(&value)
-   != DBUS_TYPE_VARIANT)
+
+   dbus_message_iter_recurse(&value, &array_iter);
+   if (dbus_message_iter_get_arg_type(&array_iter)
+   != DBUS_TYPE_BYTE)
 break;
-   dbus_message_iter_get_fixed_array(&value, &name,
+   dbus_message_iter_get_fixed_array(&array_iter, &name,
 &name_len);
 }
 dbus_message_iter_next(&dict);
--
1.9.1


Statement of Confidentiality

The contents of this e-mail message and any attachments are confidential and 
are intended solely for the addressee. The information may also be legally 
privileged. This transmission is sent in trust, and the sole purpose of 
delivery to the intended recipient. If you have received this transmission in 
error, any use, reproduction or dissemination of this transmission is strictly 
prohibited. If you are not the intended recipient, please immediately notify 
the sender by reply e-mail or at 508.683.2500 and delete this message and its 
attachments, if any.

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman



___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: Providing SSID from Agent

2015-07-07 Thread Adam Moore
On 7/7/15, 1:24 AM, "connman on behalf of Tomasz Bursztyka"
 wrote:


>Hi Adam,
>
>> Has anyone tried returning the SSID field from a Connman Agent with
>>success recently?  I thought the SSID was to be encoded an array of
>>bytes in order to allow non printable characters in a hidden network, so
>>I¹ve written my agent to do this.
>>
>> When the agent runs, a series of validations are performed at line 143
>>of connman-agent.c.  The second check fails, as it finds a
>>DBUS_TYPE_ARRAY instead of a variant.  The check for an element type of
>>DBUS_TYPE_VARIANT for the fixed array, also doesnt seem quite right.
>>
>> I have a patch that accepts the array of bytes by tweaking these
>>validations and also recursing into the array before calling the array
>>getter.  Happy to submit, but wanted to check and make sure I haven¹t
>>misunderstood how we should be storing the SSID in the result dictionary.
>>
>
>Send both codes. It would be worth seeing your agent code actually.
>This part has been working well until now so, a double check won't hurt :)

Hey Tomasz,

Changes sent in a patch - here are the relevant parts of the agent.  I¹m
using glib 2.42.1.

static void agent_handle_method_call(GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
const gchar *interface_name,
const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
agent_t *agent = (agent_t*)user_data;
if (!g_strcmp0(method_name, "RequestInput")) {
GVariant *dict = agent_requestinput_process(agent, parameters);
g_dbus_method_invocation_return_value(invocation, dict);
}

}

static GVariant * agent_requestinput_process(agent_t *agent, GVariant
*parameters)
{
gchar *path = NULL;
GVariant *fields = NULL;
gchar *field = NULL;
GVariant *value = NULL;
GVariantIter iter;
GVariantDict dict;

g_variant_get(parameters, "(&o@a{sv})", &path, &fields);

if (!g_variant_iter_init(&iter, fields)) {
g_variant_unref(fields);
return NULL;
}

g_variant_dict_init(&dict, NULL);
while (g_variant_iter_loop(&iter, "{sv}", &field, &value)) {
if (!g_strcmp0(field, "SSID")) {
agent_requestinput_ssid(agent, &dict);
} else if (!g_strcmp0(field, "Passphrase")) {
agent_requestinput_passphrase(agent, &dict);
} else {
error("field %s not supported", field);
}
}

g_variant_unref(fields);
GVariant *result = g_variant_dict_end(&dict);
return g_variant_new_tuple(&result, 1);   // Needed to keep
g_dbus_method_invocation_return_value_internal happy
}

static void agent_requestinput_ssid(agent_t *agent, GVariantDict *dict)
{
size_t essid_bytes = strlen(agent->essid) / 2;
uint8_t *essid = g_malloc0(essid_bytes);


// Fill in the essid buffer - leaving this out for brevity

GVariant *ssid = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, essid,
essid_bytes, sizeof(essid[0]));
if (ssid == NULL) {
error("Failed to serialize SSID");
return;
}

g_variant_dict_insert_value(dict, "SSID", ssid);
}

Thanks!

Adam

>
>Tomasz
>___
>connman mailing list
>connman@connman.net
>https://lists.connman.net/mailman/listinfo/connman


Statement of Confidentiality

The contents of this e-mail message and any attachments are confidential and 
are intended solely for the addressee. The information may also be legally 
privileged. This transmission is sent in trust, and the sole purpose of 
delivery to the intended recipient. If you have received this transmission in 
error, any use, reproduction or dissemination of this transmission is strictly 
prohibited. If you are not the intended recipient, please immediately notify 
the sender by reply e-mail or at 508.683.2500 and delete this message and its 
attachments, if any.

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] agent-connman: read SSID as byte array

2015-07-07 Thread Adam Moore
Read Agent provided SSID as an array of bytes and recurse where needed

Signed-off-by: Adam Moore 
---
 src/agent-connman.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/agent-connman.c b/src/agent-connman.c
index 8440451..1b6f8a3 100644
--- a/src/agent-connman.c
+++ b/src/agent-connman.c
@@ -141,17 +141,20 @@ static void request_input_passphrase_reply(DBusMessage 
*reply, void *user_data)
name_len = strlen(name);
} else if (g_str_equal(key, "SSID")) {
dbus_message_iter_next(&entry);
+   DBusMessageIter *array_iter = NULL;
if (dbus_message_iter_get_arg_type(&entry)
!= DBUS_TYPE_VARIANT)
break;
dbus_message_iter_recurse(&entry, &value);
if (dbus_message_iter_get_arg_type(&value)
-   != DBUS_TYPE_VARIANT)
+   != DBUS_TYPE_ARRAY)
break;
-   if (dbus_message_iter_get_element_type(&value)
-   != DBUS_TYPE_VARIANT)
+
+   dbus_message_iter_recurse(&value, &array_iter);
+   if (dbus_message_iter_get_arg_type(&array_iter)
+   != DBUS_TYPE_BYTE)
break;
-   dbus_message_iter_get_fixed_array(&value, &name,
+   dbus_message_iter_get_fixed_array(&array_iter, &name,
&name_len);
}
dbus_message_iter_next(&dict);
--
1.9.1


Statement of Confidentiality

The contents of this e-mail message and any attachments are confidential and 
are intended solely for the addressee. The information may also be legally 
privileged. This transmission is sent in trust, and the sole purpose of 
delivery to the intended recipient. If you have received this transmission in 
error, any use, reproduction or dissemination of this transmission is strictly 
prohibited. If you are not the intended recipient, please immediately notify 
the sender by reply e-mail or at 508.683.2500 and delete this message and its 
attachments, if any.

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: Providing SSID from Agent

2015-07-07 Thread Tomasz Bursztyka

Hi Adam,


Has anyone tried returning the SSID field from a Connman Agent with success 
recently?  I thought the SSID was to be encoded an array of bytes in order to 
allow non printable characters in a hidden network, so I’ve written my agent to 
do this.

When the agent runs, a series of validations are performed at line 143 of 
connman-agent.c.  The second check fails, as it finds a DBUS_TYPE_ARRAY instead 
of a variant.  The check for an element type of DBUS_TYPE_VARIANT for the fixed 
array, also doesnt seem quite right.

I have a patch that accepts the array of bytes by tweaking these validations 
and also recursing into the array before calling the array getter.  Happy to 
submit, but wanted to check and make sure I haven’t misunderstood how we should 
be storing the SSID in the result dictionary.



Send both codes. It would be worth seeing your agent code actually.
This part has been working well until now so, a double check won't hurt :)

Tomasz
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Providing SSID from Agent

2015-07-07 Thread Adam Moore
Has anyone tried returning the SSID field from a Connman Agent with success 
recently?  I thought the SSID was to be encoded an array of bytes in order to 
allow non printable characters in a hidden network, so I’ve written my agent to 
do this.

When the agent runs, a series of validations are performed at line 143 of 
connman-agent.c.  The second check fails, as it finds a DBUS_TYPE_ARRAY instead 
of a variant.  The check for an element type of DBUS_TYPE_VARIANT for the fixed 
array, also doesnt seem quite right.

I have a patch that accepts the array of bytes by tweaking these validations 
and also recursing into the array before calling the array getter.  Happy to 
submit, but wanted to check and make sure I haven’t misunderstood how we should 
be storing the SSID in the result dictionary.

Thanks,
Adam

Statement of Confidentiality

The contents of this e-mail message and any attachments are confidential and 
are intended solely for the addressee. The information may also be legally 
privileged. This transmission is sent in trust, and the sole purpose of 
delivery to the intended recipient. If you have received this transmission in 
error, any use, reproduction or dissemination of this transmission is strictly 
prohibited. If you are not the intended recipient, please immediately notify 
the sender by reply e-mail or at 508.683.2500 and delete this message and its 
attachments, if any.

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman