wimax-tools 1.4.4
Typedefs | Functions

Tracking state changes

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.

Detailed Description

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 Documentation

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.

Note:
See Callbacks callbacks for a set of warnings and guidelines for using callbacks.
Parameters:
wmxWiMAX device handle
privctx Context passed by the user with wimaxll_set_cb_state_change().
old_stateState the WiMAX device left
new_stateState the WiMAX device entered
Returns:
>= 0 if it is ok to keep processing messages, -EBUSY if message processing should stop and control be returned to the caller. Any other negative error code to continue processing messages skipping the current one.

Function Documentation

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.

Parameters:
wmxWiMAX handle.
cbWhere to store the current callback function.
privWhere 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.

Parameters:
wmxWiMAX handle.
cbCallback function to set
privPrivate 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.

Parameters:
wmxWiMAX device handle
old_statePointer to where to store the previous state
new_statePointer to where to store the new state
Returns:
If successful, 0 and the values pointed to by the old_state and new_state arguments are valid; on error, a negative errno code and the state pointers contain no valid information.

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.

Note:
This is a blocking call.
This function cannot be run in parallel with other code that modifies the state change callbacks for this same handle.