Example #1
0
int connman_session_config_update(struct connman_session *session)
{
    struct session_info *info = session->info;
    GSList *allowed_bearers;
    int err;

    DBG("session %p", session);

    /*
     * We update all configuration even though only one entry
     * might have changed. We can still optimize this later.
     */

    if (session->id_type != session->policy_config->id_type) {
        cleanup_firewall_session(session);
        err = init_firewall_session(session);
        if (err < 0) {
            connman_session_destroy(session);
            return err;
        }

        session->id_type = session->policy_config->id_type;
    }

    apply_policy_on_bearers(
        session->policy_config->allowed_bearers,
        session->user_allowed_bearers,
        &allowed_bearers);

    if (session->active)
        set_active_session(session, false);

    session->active = false;
    session_deactivate(session);

    g_slist_free(info->config.allowed_bearers);
    info->config.allowed_bearers = allowed_bearers;

    session_activate(session);

    info->config.type = apply_policy_on_type(
                            session->policy_config->type,
                            info->config.type);

    info->config.roaming_policy = session->policy_config->roaming_policy;

    info->config.ecall = session->policy_config->ecall;
    if (info->config.ecall)
        ecall_session = session;

    info->config.priority = session->policy_config->priority;

    session_notify(session);

    return 0;
}
Example #2
0
static int session_policy_config_cb(struct connman_session *session,
                                    struct connman_session_config *config,
                                    void *user_data, int err)
{
    struct creation_data *creation_data = user_data;
    struct session_info *info, *info_last;
    DBusMessage *reply;

    DBG("session %p config %p", session, config);

    if (err < 0)
        goto err;

    session->policy_config = config;

    session->mark = session_mark++;
    session->index = -1;

    err = init_firewall_session(session);
    if (err < 0)
        goto err;

    err = init_routing_table(session);
    if (err < 0)
        goto err;

    info = session->info;
    info_last = session->info_last;

    if (session->policy_config->ecall)
        ecall_session = session;

    info->state = CONNMAN_SESSION_STATE_DISCONNECTED;
    info->config.type = apply_policy_on_type(
                            session->policy_config->type,
                            creation_data->type);
    info->config.priority = session->policy_config->priority;
    info->config.roaming_policy = session->policy_config->roaming_policy;

    session->user_allowed_bearers = creation_data->allowed_bearers;
    creation_data->allowed_bearers = NULL;

    apply_policy_on_bearers(
        session->policy_config->allowed_bearers,
        session->user_allowed_bearers,
        &info->config.allowed_bearers);

    g_hash_table_replace(session_hash, session->session_path, session);

    DBG("add %s", session->session_path);

    if (!g_dbus_register_interface(connection, session->session_path,
                                   CONNMAN_SESSION_INTERFACE,
                                   session_methods, NULL, NULL,
                                   session, NULL)) {
        connman_error("Failed to register %s", session->session_path);
        g_hash_table_remove(session_hash, session->session_path);
        err = -EINVAL;
        goto err;
    }

    reply = g_dbus_create_reply(creation_data->pending,
                                DBUS_TYPE_OBJECT_PATH, &session->session_path,
                                DBUS_TYPE_INVALID);
    g_dbus_send_message(connection, reply);
    creation_data->pending = NULL;

    info_last->state = info->state;
    info_last->config.priority = info->config.priority;
    info_last->config.roaming_policy = info->config.roaming_policy;
    info_last->config.allowed_bearers = info->config.allowed_bearers;

    session->append_all = true;

    cleanup_creation_data(creation_data);

    session_activate(session);

    return 0;

err:
    reply = __connman_error_failed(creation_data->pending, -err);
    g_dbus_send_message(connection, reply);
    creation_data->pending = NULL;

    cleanup_session(session);
    cleanup_creation_data(creation_data);

    return err;
}
Example #3
0
static void update_firewall(struct connman_session *session)
{
	cleanup_firewall_session(session);
	init_firewall_session(session);
}