On 7/7/15, 1:24 AM, "connman on behalf of Tomasz Bursztyka"
<connman-boun...@connman.net on behalf of
tomasz.burszt...@linux.intel.com> 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

Reply via email to