wimax-tools 1.4.4
|
When the WiMAX devices change state, the kernel sends state change notification. More...
Typedefs | |
typedef int(* | wimaxll_state_change_cb_f )(struct wimaxll_handle *, void *priv, enum wimax_st old_state, enum wimax_st new_state) |
Callback for a state change notification from the WiMAX kernel stack. | |
Functions | |
void | wimaxll_get_cb_state_change (struct wimaxll_handle *wmx, wimaxll_state_change_cb_f *cb, void **priv) |
Get the callback and priv pointer for a WIMAX_GNL_RE_STATE_CHANGE message. | |
void | wimaxll_set_cb_state_change (struct wimaxll_handle *wmx, wimaxll_state_change_cb_f cb, void *priv) |
Set the callback and priv pointer for a WIMAX_GNL_RE_STATE_CHANGE message. | |
ssize_t | wimaxll_wait_for_state_change (struct wimaxll_handle *wmx, enum wimax_st *old_state, enum wimax_st *new_state) |
Wait for an state change notification from the kernel. |
When the WiMAX devices change state, the kernel sends state change notification.
An application can simply block a thread waiting for state changes using the following convenience function:
result = wimaxll_wait_for_state_change(wmx, &old_state, &new_state);
However, in most cases, applications will want to integrate into main loops and use the callback mechanism.
For that, they just need to set a callback for the state change notification:
wimaxll_set_cb_state_change(wmx, my_state_change_callback, context_pointer);
and then wait for notifications to be available (see receiving with select()). When data is available and wimax_recv() is called to process it, the callback will be executed for each state change notification.
Applications can query the current callback set for the state change notifications with wimaxll_get_cb_state_change().
typedef int(* wimaxll_state_change_cb_f)(struct wimaxll_handle *, void *priv, enum wimax_st old_state, enum wimax_st new_state) |
Callback for a state change notification from the WiMAX kernel stack.
The WiMAX device has changed state from old_state to new_state.
wmx | WiMAX device handle |
priv | ctx Context passed by the user with wimaxll_set_cb_state_change(). |
old_state | State the WiMAX device left |
new_state | State the WiMAX device entered |
void wimaxll_get_cb_state_change | ( | struct wimaxll_handle * | wmx, |
wimaxll_state_change_cb_f * | cb, | ||
void ** | priv | ||
) |
Get the callback and priv pointer for a WIMAX_GNL_RE_STATE_CHANGE message.
wmx | WiMAX handle. |
cb | Where to store the current callback function. |
priv | Where to store the private data pointer passed to the callback. |
Referenced by wimaxll_wait_for_state_change().
void wimaxll_set_cb_state_change | ( | struct wimaxll_handle * | wmx, |
wimaxll_state_change_cb_f | cb, | ||
void * | priv | ||
) |
Set the callback and priv pointer for a WIMAX_GNL_RE_STATE_CHANGE message.
wmx | WiMAX handle. |
cb | Callback function to set |
priv | Private data pointer to pass to the callback function. |
Referenced by wimaxll_wait_for_state_change().
ssize_t wimaxll_wait_for_state_change | ( | struct wimaxll_handle * | wmx, |
enum wimax_st * | old_state, | ||
enum wimax_st * | new_state | ||
) |
Wait for an state change notification from the kernel.
wmx | WiMAX device handle |
old_state | Pointer to where to store the previous state |
new_state | Pointer to where to store the new state |
Waits for the WiMAX device to change state and reports said state change.
Internally, this function uses wimax_recv() , which means that on reception (from the kernel) of notifications other than state change, any callbacks that are set for them will be executed.