+-icd_context-+ +-GSList-------+ | |--->| request_list | +-------------+ +--------------+ | +-icd_policy_request-+ +---->icd_request--->| req |<---+ | +--------------------+ | | | | +-icd_policy_request-+ | +---->icd_request--->| req |<---+ | +--------------------+ |
... ...
| +-icd_policy_request-+ | +---->icd_request--->| req |<---+ +--------------------+ | | +-GSList------------+ | existing_requests | +-------------------+A policy module can make a request to wait for an external event such as UI dialog appearing by returning ICD_POLICY_WAITING. Policy processing will stop, whereby a new request is needed to clean up the waiting request. On cancelling a request, the request_cancel will be called for all policy modules to clean up an pending calls or timers left behind.
#define ICD_POLICY_API_PREFIX "libicd_policy_" |
prefix for the ICd policy API modules
#define ICD_POLICY_INIT "icd_policy_init" |
name of the policy API init function
Referenced by icd_policy_api_load_modules().
typedef gboolean(* icd_policy_api_async_call_fn)(struct icd_policy_module *module, struct icd_policy_request *request, struct icd_policy_api_async_data *async_data) |
Function prototype for calling the actual asynchronous policy function
module | the policy module | |
request | the requested connection | |
async_data | data for the asynchronous function call |
typedef void(* icd_policy_api_request_cb_fn)(enum icd_policy_status status, struct icd_policy_request *req) |
Callback for the new_connection policy request
status | status of the policy request | |
policy_request | the policy request structure |
static void icd_policy_api_add_iap | ( | struct icd_policy_request * | req, | |
gchar * | service_type, | |||
guint | service_attrs, | |||
gchar * | service_id, | |||
gchar * | network_type, | |||
guint | network_attrs, | |||
gchar * | network_id, | |||
gint | network_priority | |||
) | [static] |
Add a network connection to try in response to the policy decision. Any policy module using this function must be compatible with the corresponding network module in order to set correct *_type and *_id.
req | the request to which the new network is added | |
service_type | service provider type, see srv_provider_api.h | |
service_attrs | service provider attributes, see srv_provider_api.h | |
service_id | service_provider id, see srv_provider_api.h | |
network_type | network type, see network_api.h | |
network_attrs | network attributes, see network_api.h | |
network_id | network id, see network_api.h |
References icd_request_add_iap(), and icd_policy_request::request_token.
Referenced by icd_policy_api_init_cb().
static void icd_policy_api_async_data_free | ( | struct icd_policy_api_async_data * | data | ) | [static] |
Free async policy api data
data | the data to free |
Referenced by icd_policy_api_request_cb().
static void icd_policy_api_disconnect_iap | ( | struct icd_policy_request * | network | ) | [static] |
Disconnect an active IAP
network | the network to disconnect |
References ICD_POLICY_ATTRIBUTE_CONN_UI, icd_request_cancel(), ILOG_CRIT, icd_request::req, and icd_policy_request::request_token.
Referenced by icd_policy_api_init_cb().
static gboolean icd_policy_api_existing_conn_foreach | ( | struct icd_iap * | iap, | |
gpointer | user_data | |||
) | [static] |
Go through all connections and add them to the list in reverse order
iap | current iap | |
user_data | connection list |
References icd_iap::connection.
Referenced by icd_policy_api_existing_conn_get().
static GSList* icd_policy_api_existing_conn_get | ( | void | ) | [static] |
Get the list of existing connections
References icd_iap_foreach(), and icd_policy_api_existing_conn_foreach().
Referenced by icd_policy_api_iap_connect_iter(), icd_policy_api_iap_disconnect_iter(), icd_policy_api_iap_disconnected_iter(), and icd_policy_api_iap_succeeded_iter().
static GSList* icd_policy_api_existing_requests_get | ( | struct icd_request * | new_request | ) | [static] |
Create the list of existing requests the current request not to add to the list
References icd_iap::connection, icd_context_get(), icd_ctx, ICD_REQUEST_DENIED, ICD_REQUEST_DISCONNECTED, icd_request::req, icd_context::request_list, icd_request::state, and icd_request::try_iaps.
Referenced by icd_policy_api_new_request(), and icd_policy_api_request_cb().
enum icd_policy_status icd_policy_api_iap_connect | ( | struct icd_policy_request * | connection | ) |
Connect policy called when ICd attempts to connect to a network
connection | the connection that is to be tried |
References icd_policy_api_iap_connect_iter(), and icd_policy_api_run().
Referenced by icd_request_try_iap().
static enum icd_policy_status icd_policy_api_iap_connect_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Iterator for the connect policy
module | the policy module | |
request | the request to apply policy to | |
user_data | not used |
References connect, ICD_POLICY_ACCEPTED, icd_policy_api_existing_conn_get(), ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, and private.
Referenced by icd_policy_api_iap_connect().
enum icd_policy_status icd_policy_api_iap_disconnect | ( | struct icd_policy_request * | connection, | |
gint | refcount | |||
) |
Disconnect policy called when ICd attempts to disconnect from a network
connection | the connection that is to be tried | |
refcount | a reference count on the number of applications using this connection or -1 if disconnect forced by Connectivity UI |
References icd_policy_api_iap_disconnect_iter(), and icd_policy_api_run().
Referenced by icd_request_cancel().
static enum icd_policy_status icd_policy_api_iap_disconnect_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Iterator for the disconnect policy
module | the policy module | |
request | the request to apply policy to | |
user_data | reference count |
References disconnect, ICD_POLICY_ACCEPTED, icd_policy_api_existing_conn_get(), ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, and private.
Referenced by icd_policy_api_iap_disconnect().
void icd_policy_api_iap_disconnected | ( | struct icd_policy_request * | connection, | |
const gchar * | err_str | |||
) |
Informational policy to call when a network connection has been disconnected
connection | the connection that was disconnected | |
err_str | reason for disconnect; NULL on success |
References icd_policy_api_iap_disconnected_iter(), and icd_policy_api_run().
Referenced by icd_request_try_iap_cb().
static enum icd_policy_status icd_policy_api_iap_disconnected_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Iterator for the disconnected informational policy
module | the policy module | |
request | the request to apply policy to | |
user_data | reason for disconnect; NULL on success |
References disconnected, ICD_POLICY_ACCEPTED, icd_policy_api_existing_conn_get(), ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, and private.
Referenced by icd_policy_api_iap_disconnected().
enum icd_policy_status icd_policy_api_iap_restart | ( | struct icd_policy_request * | connection, | |
guint | restart_count | |||
) |
Restart policy
connection | the IAP network connection that is restarting | |
restart_count | restart count |
References icd_policy_api_iap_restart_iter(), and icd_policy_api_run().
Referenced by icd_iap_run_restart().
static enum icd_policy_status icd_policy_api_iap_restart_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Iterator for the restart policy
module | the policy module | |
request | the request to apply policy to | |
user_data | user data to pass to the module |
References ICD_POLICY_ACCEPTED, ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, private, and restart.
Referenced by icd_policy_api_iap_restart().
void icd_policy_api_iap_succeeded | ( | struct icd_policy_request * | connection | ) |
Informational policy to call when a network connection has been established
connection | the connection that was connected |
References icd_policy_api_iap_succeeded_iter(), and icd_policy_api_run().
Referenced by icd_request_try_iap_cb().
static enum icd_policy_status icd_policy_api_iap_succeeded_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Iterator for the connection succeeded informational policy
module | the policy module | |
request | the request to apply policy to | |
user_data | not used |
References connected, ICD_POLICY_ACCEPTED, icd_policy_api_existing_conn_get(), ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, and private.
Referenced by icd_policy_api_iap_succeeded().
static gboolean icd_policy_api_init_cb | ( | const gchar * | module_name, | |
void * | handle, | |||
gpointer | init_function, | |||
gpointer | data | |||
) | [static] |
Initialize the loaded module
module_name | module filename without path | |
handle | module handle; used for unloading | |
init_function | module init function | |
data | icd context |
References icd_policy_module::handle, icd_ctx, icd_network_priority(), icd_policy_api_add_iap(), icd_policy_api_disconnect_iap(), icd_policy_api_make_request(), icd_policy_api_merge_requests(), icd_policy_api_scan_start(), icd_policy_api_scan_stop(), icd_srv_provider_check(), icd_policy_module::name, icd_policy_module::policy, and icd_context::policy_module_list.
Referenced by icd_policy_api_load_modules().
gboolean icd_policy_api_load_modules | ( | struct icd_context * | icd_ctx | ) |
Load all policy API modules
icd_ctx | icd context |
References icd_plugin_load_list(), icd_policy_api_init_cb(), ICD_POLICY_INIT, and icd_policy_modules_get().
Referenced by main().
static void icd_policy_api_make_request | ( | guint | policy_attrs, | |
gchar * | service_type, | |||
guint | service_attrs, | |||
gchar * | service_id, | |||
gchar * | network_type, | |||
guint | network_attrs, | |||
gchar * | network_id | |||
) | [static] |
Function to create a new request
policy_attrs | ICD_POLICY_ATTRIBUTE_* attributes | |
service_type | service provider type, see srv_provider_api.h | |
service_attrs | service provider attributes, see srv_provider_api.h | |
service_id | service_provider id, see srv_provider_api.h | |
network_type | network type, see network_api.h | |
network_attrs | network attributes, see network_api.h | |
network_id | network id, see network_api.h |
References icd_request_make(), and icd_request_new().
Referenced by icd_policy_api_init_cb().
static void icd_policy_api_merge_requests | ( | struct icd_policy_request * | request_to_merge, | |
struct icd_policy_request * | existing_request | |||
) | [static] |
Merge two request together and free the request_to_merge structure.
request_to_merge | the request that will be joined with the existing one. The structure will also be freed and may point to anything after that. | |
existing_request | the request that continues to exists after a merge |
References icd_request_merge(), ILOG_CRIT, and icd_policy_request::request_token.
Referenced by icd_policy_api_init_cb().
void icd_policy_api_new_request | ( | struct icd_policy_request * | req, | |
icd_policy_api_request_cb_fn | cb, | |||
gpointer | user_data | |||
) |
New request policy
req | the new request | |
cb | the callback to call with the policy decision | |
user_data | user data to pass to the callback |
References icd_policy_api_request_data::cb, icd_policy_api_request_data::existing_requests, ICD_POLICY_ACCEPTED, icd_policy_api_existing_requests_get(), icd_policy_api_request_call(), icd_policy_api_run_async(), ILOG_INFO, icd_policy_request::request_token, and icd_policy_api_request_data::user_data.
Referenced by icd_request_make().
static gboolean icd_policy_api_request_call | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
struct icd_policy_api_async_data * | async_data | |||
) | [static] |
Function that calls the new_request policy module function
module | the policy module | |
request | the requested network | |
async_data | policy structure to pass as the policy_token to the policy module funcion |
References icd_policy_api_request_data::existing_requests, icd_policy_api_request_cb(), ILOG_INFO, icd_policy_module::name, new_request, icd_policy_module::policy, private, and icd_policy_api_async_data::user_data.
Referenced by icd_policy_api_new_request().
void icd_policy_api_request_cancel | ( | struct icd_policy_request * | req | ) |
Cancel a request that is in ICD_POLICY_WAITING state by informing each policy module.
req | the policy request structure |
References icd_policy_api_request_cancel_iter(), icd_policy_api_run(), ICD_REQUEST_POLICY_PENDING, ICD_REQUEST_WAITING, ILOG_ERR, icd_policy_request::request_token, and icd_request::state.
Referenced by icd_request_cancel(), and icd_request_merge().
static enum icd_policy_status icd_policy_api_request_cancel_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Module iterator for the 'cancel_request' function.
module | the policy module | |
request | the request to cancel | |
user_data | user data; not used |
References cancel_request, ICD_POLICY_ACCEPTED, ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, and private.
Referenced by icd_policy_api_request_cancel().
static void icd_policy_api_request_cb | ( | enum icd_policy_status | status, | |
struct icd_policy_request * | req, | |||
gpointer | policy_token | |||
) | [static] |
Status callback for the new request policy function
status | status of the new request function | |
req | the policy request | |
policy_token | data for the async policy function call |
References icd_policy_api_request_data::cb, icd_policy_api_request_data::existing_requests, ICD_POLICY_ACCEPTED, icd_policy_api_async_data_free(), icd_policy_api_existing_requests_get(), icd_policy_api_run_async_next(), ICD_POLICY_MERGED, ILOG_DEBUG, ILOG_INFO, icd_policy_request::request_token, and icd_policy_api_async_data::user_data.
Referenced by icd_policy_api_request_call().
static enum icd_policy_status icd_policy_api_run | ( | icd_policy_api_run_module_fn | policy_fn, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Iterate over all the modules and call the policy callback function for each of them.
policy_fn | the policy callback function call for each module | |
request | the request to apply policy to | |
user_data | user data to pass to the function |
References icd_context_get(), icd_ctx, ICD_POLICY_ACCEPTED, ICD_POLICY_REJECTED, ILOG_ERR, ILOG_WARN, and icd_context::policy_module_list.
Referenced by icd_policy_api_iap_connect(), icd_policy_api_iap_disconnect(), icd_policy_api_iap_disconnected(), icd_policy_api_iap_restart(), icd_policy_api_iap_succeeded(), icd_policy_api_request_cancel(), icd_policy_api_scan_start_status(), and icd_policy_api_scan_stop_status().
static gboolean icd_policy_api_run_async | ( | struct icd_policy_request * | req, | |
icd_policy_api_async_call_fn | call_policy, | |||
gpointer | user_data | |||
) | [static] |
Initialize the asynchronous policy module function data and start running the policy modules one by one
req | the request | |
call_policy | the function that calls the policy module function with correct parameters | |
user_data | user data for the function |
References icd_policy_api_async_data::call_policy, icd_context_get(), icd_ctx, icd_policy_api_run_async_next(), ILOG_DEBUG, icd_policy_api_async_data::module_list, icd_context::policy_module_list, and icd_policy_api_async_data::user_data.
Referenced by icd_policy_api_new_request().
static gboolean icd_policy_api_run_async_next | ( | struct icd_policy_request * | req, | |
struct icd_policy_api_async_data * | async_data | |||
) | [static] |
Call an asynchronous policy module function
req | the request | |
async_data | policy data |
References icd_policy_api_async_data::call_policy, and icd_policy_api_async_data::module_list.
Referenced by icd_policy_api_request_cb(), and icd_policy_api_run_async().
static struct icd_policy_scan_data* icd_policy_api_scan_find | ( | icd_policy_scan_cb_fn | cb, | |
gpointer | user_data | |||
) | [static, read] |
Find callback and user data
cb | callback | |
user_data | user_data |
References icd_policy_scan_data::cb, icd_policy_api_scan_list_get(), and icd_policy_scan_data::user_data.
Referenced by icd_policy_api_scan_stop().
static GSList** icd_policy_api_scan_list_get | ( | void | ) | [static] |
Get the callback and user data list
Referenced by icd_policy_api_scan_find(), icd_policy_api_scan_start(), and icd_policy_api_scan_stop().
static void icd_policy_api_scan_result | ( | enum icd_scan_status | status, | |
const struct icd_scan_srv_provider * | srv_provider, | |||
const struct icd_scan_cache * | cache_entry, | |||
gpointer | user_data | |||
) | [static] |
Scan results
status | status of this network | |
srv_provider | service provider entry; guaranteed to exist only for the lifetime of this callback function | |
cache_entry | scan results; guaranteed to exist only for the lifetime of this callback function | |
user_data | used data given to the scan callback |
References icd_policy_scan_data::cb, ICD_POLICY_SCAN_DONE, ICD_POLICY_SCAN_EXPIRED_NETWORK, ICD_POLICY_SCAN_NEW_NETWORK, ICD_POLICY_SCAN_UPDATE_NETWORK, ICD_SCAN_COMPLETE, ICD_SCAN_EXPIRE, ICD_SCAN_NEW, ICD_SCAN_NOTIFY, ICD_SCAN_UPDATE, ILOG_WARN, icd_scan_cache::network_attrs, icd_scan_cache::network_id, icd_scan_cache::network_name, icd_scan_cache::network_priority, icd_scan_cache::network_type, icd_scan_srv_provider::service_attrs, icd_scan_srv_provider::service_id, icd_scan_srv_provider::service_name, icd_scan_srv_provider::service_priority, icd_scan_srv_provider::service_type, icd_scan_cache::signal, and icd_policy_scan_data::user_data.
Referenced by icd_policy_api_scan_start(), and icd_policy_api_scan_stop().
static void icd_policy_api_scan_start | ( | const gchar * | type, | |
const guint | scope, | |||
icd_policy_scan_cb_fn | cb, | |||
gpointer | user_data | |||
) | [static] |
Function for a module to request a network scan. icd_policy_api_scan_stop() has to be called as many times as this function is called even if the same callback and user_data pair are added.
type | network type | |
scope | scan scope | |
cb | callback function to call with scan results | |
user_data | user data to pass to the callback function |
References icd_policy_scan_data::cb, ICD_NW_LEVEL_NONE, icd_policy_api_scan_list_get(), icd_policy_api_scan_result(), ICD_POLICY_SCAN_DONE, icd_scan_results_request(), ILOG_CRIT, ILOG_DEBUG, and icd_policy_scan_data::user_data.
Referenced by icd_policy_api_init_cb().
void icd_policy_api_scan_start_status | ( | const gchar * | network_type | ) |
Start scan informational policy
network_type | network type to start scan for |
References icd_policy_api_run(), and icd_policy_api_scan_start_status_iter().
static enum icd_policy_status icd_policy_api_scan_start_status_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Start scan iterator function
module | the policy module | |
request | NULL | |
user_data | network type |
References ICD_POLICY_ACCEPTED, ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, private, and scan_start.
Referenced by icd_policy_api_scan_start_status().
static void icd_policy_api_scan_stop | ( | icd_policy_scan_cb_fn | cb, | |
gpointer | user_data | |||
) | [static] |
Stop returning scan results for the given callback and user data
cb | scan callback | |
user_data | user_data given in icd_policy_api_scan_start() |
References icd_policy_api_scan_find(), icd_policy_api_scan_list_get(), icd_policy_api_scan_result(), icd_scan_results_unregister(), and ILOG_ERR.
Referenced by icd_policy_api_init_cb().
void icd_policy_api_scan_stop_status | ( | const gchar * | network_type | ) |
Stop scan informational policy
network_type | network type to start scan for |
References icd_policy_api_run(), and icd_policy_api_scan_stop_status_iter().
static enum icd_policy_status icd_policy_api_scan_stop_status_iter | ( | struct icd_policy_module * | module, | |
struct icd_policy_request * | request, | |||
gpointer | user_data | |||
) | [static] |
Stop scan iterator function
module | the policy module | |
request | NULL | |
user_data | network type |
References ICD_POLICY_ACCEPTED, ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, private, and scan_stop.
Referenced by icd_policy_api_scan_stop_status().
void icd_policy_api_unload_modules | ( | struct icd_context * | icd_ctx | ) |
Unload all policy modules
icd_ctx | icd context |
References destruct, icd_policy_module::handle, icd_plugin_unload_module(), ILOG_INFO, icd_policy_module::name, icd_policy_module::policy, icd_context::policy_module_list, and private.
Referenced by main().
enum icd_policy_status(* icd_policy_api_run_module_fn)(struct icd_policy_module *module, struct icd_policy_request *request, gpointer user_data) |
Policy module function that will be called once for each policy module until ICD_POLICY_REJECTED is returned
module | the policy module | |
request | the request to apply policy to | |
user_data | user data to pass to the module |
const gchar const* icd_policy_api_state[] |
Initial value:
{ "ICD_POLICY_ACCEPTED", "ICD_POLICY_MERGED", "ICD_POLICY_WAITING", "ICD_POLICY_REJECTED" }