5 * Copyright (C) 2012 BMW Car IT GbmH. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #define CONNMAN_API_SUBJECT_TO_CHANGE
32 #include <connman/plugin.h>
33 #include <connman/log.h>
34 #include <connman/session.h>
36 static GHashTable *config_hash;
38 static int policy_create(struct connman_session *session,
39 connman_session_config_cb callback,
42 struct connman_session_config *config;
44 DBG("session %p", session);
49 config = connman_session_create_default_config();
53 g_hash_table_replace(config_hash, session, config);
55 (*callback)(session, config, user_data, 0);
60 static void policy_destroy(struct connman_session *session)
62 DBG("session %p", session);
64 g_hash_table_remove(config_hash, session);
67 static struct connman_session_policy session_policy = {
68 .name = "session policy configuration",
69 .priority = CONNMAN_SESSION_POLICY_PRIORITY_LOW,
70 .create = policy_create,
71 .destroy = policy_destroy,
74 static void cleanup_config(gpointer user_data)
76 struct connman_session_config *config = user_data;
78 connman_session_free_bearers(config->allowed_bearers);
82 static int session_policy_init(void)
86 err = connman_session_policy_register(&session_policy);
90 config_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
92 if (config_hash == NULL) {
93 connman_session_policy_unregister(&session_policy);
100 static void session_policy_exit(void)
102 g_hash_table_destroy(config_hash);
104 connman_session_policy_unregister(&session_policy);
107 CONNMAN_PLUGIN_DEFINE(session_policy, "Session policy configuration plugin",
108 VERSION, CONNMAN_PLUGIN_PRIORITY_DEFAULT,
109 session_policy_init, session_policy_exit)