# TDLS_TASK
[TLDS]

Task responsible for TDLS operations. More...

Collaboration diagram for TDLS_TASK:

## Data Structures
struct | tdls_chan_switch_req
| Structure containing the parameters of the TDLS_CHAN_SWITCH_REQ message. More...
struct | tdls_cancel_chan_switch_req
| Structure containing the parameters of the TDLS_CANCEL_CHAN_SWITCH_REQ message. More...
struct | tdls_chan_switch_cfm
| Structure containing the parameters of the TDLS_CHAN_SWITCH_CFM message. More...
struct | tdls_cancel_chan_switch_cfm
| Structure containing the parameters of the TDLS_CANCEL_CHAN_SWITCH_CFM message. More...
struct | tdls_chan_switch_ind
| Structure containing the parameters of the TDLS_CHAN_SWITCH_IND message. More...
struct | tdls_chan_switch_base_ind
| Structure containing the parameters of the TDLS_CHAN_SWITCH_BASE_IND message. More...
struct | tdls_peer_ps_ind
| Structure containing the parameters of the TDLS_PEER_PS_IND message. More...
struct | tdls_peer_traffic_ind_req
| Structure containing the parameters of the TDLS_PEER_TRAFFIC_IND_REQ message. More...
struct | tdls_peer_traffic_ind_cfm
| Structure containing the parameters of the TDLS_PEER_TRAFFIC_IND_CFM message. More...
## Defines
#define | TDLS_IDX_MAX 1
| TDLS TASK Instance Max.
## Enumerations
enum | tdls_state_tag { TDLS_BASE_CHANNEL, TDLS_TRAFFIC_IND_TX, TDLS_TRAFFIC_IND_RX, TDLS_CHSW_REQ_TX, TDLS_CHSW_REQ_RX, TDLS_OFF_CHANNEL, TDLS_STATE_MAX }
| Possible States of the TDLS Task. More...
enum | tdls_msg_tag { TDLS_CHAN_SWITCH_REQ = KE_FIRST_MSG(TASK_TDLS), TDLS_CHAN_SWITCH_CFM, TDLS_CHAN_SWITCH_IND, TDLS_CHAN_SWITCH_BASE_IND, TDLS_CANCEL_CHAN_SWITCH_REQ, TDLS_CANCEL_CHAN_SWITCH_CFM, TDLS_PEER_PS_IND, TDLS_PEER_TRAFFIC_IND_REQ, TDLS_PEER_TRAFFIC_IND_CFM, TDLS_MAX }
| List of messages related to the task. More...
## Functions
static int | tdls_chan_switch_req_handler (ke_msg_id_t const msgid, struct tdls_chan_switch_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| TDLS channel switch request handler.
static int | tdls_cancel_chan_switch_req_handler (ke_msg_id_t const msgid, struct tdls_cancel_chan_switch_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| TDLS cancel channel switch request handler.
static int | tdls_peer_traffic_ind_req_handler (ke_msg_id_t const msgid, struct tdls_peer_traffic_ind_req const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id)
| TDLS Peer Traffic Indication request handler.
## Variables
struct ke_msg_handler | tdls_default_state []
| Message handlers in state DEFAULT.
struct ke_state_handler | tdls_default_handler
| Specifies the message handlers that are common to all states.
ke_state_t | tdls_state [TDLS_IDX_MAX]
| Defines the placeholder for the states of all the task instances.
struct ke_state_handler | tdls_default_handler
| Specifies the message handlers that are common to all states.
ke_state_t | tdls_state [TDLS_IDX_MAX]
| Defines the placeholder for the states of all the task instances.

## Detailed Description

Task responsible for TDLS operations.

## Enumeration Type Documentation

enum tdls_msg_tag

List of messages related to the task.

Enumerator:

  TDLS_CHAN_SWITCH_REQ | TDLS channel Switch Request.
  TDLS_CHAN_SWITCH_CFM | TDLS channel switch confirmation.
  TDLS_CHAN_SWITCH_IND | TDLS channel switch indication.
  TDLS_CHAN_SWITCH_BASE_IND | TDLS channel switch to base channel indication.
  TDLS_CANCEL_CHAN_SWITCH_REQ | TDLS cancel channel switch request.
  TDLS_CANCEL_CHAN_SWITCH_CFM | TDLS cancel channel switch confirmation.
  TDLS_PEER_PS_IND | TDLS peer power save indication.
  TDLS_PEER_TRAFFIC_IND_REQ | TDLS peer traffic indication request.
  TDLS_PEER_TRAFFIC_IND_CFM | TDLS peer traffic indication confirmation.
  TDLS_MAX | MAX number of messages.

Definition at line 69 of file tdls_task.h.

enum tdls_state_tag

Possible States of the TDLS Task.

Enumerator:

  TDLS_BASE_CHANNEL | TDLS link on the base channel.
  TDLS_TRAFFIC_IND_TX | TDLS Peer Traffic Indication frame sent.
  TDLS_TRAFFIC_IND_RX | TDLS Peer Traffic Indication frame received.
  TDLS_CHSW_REQ_TX | TDLS Channel Switch Request frame sent.
  TDLS_CHSW_REQ_RX | TDLS Channel Switch Request frame received.
  TDLS_OFF_CHANNEL | TDLS link on the off-channel.
  TDLS_STATE_MAX | TDLS Max Number of states.

Definition at line 50 of file tdls_task.h.

## Function Documentation

static int tdls_cancel_chan_switch_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct tdls_cancel_chan_switch_req const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

TDLS cancel channel switch request handler.

This function handles the TDLS_CANCEL_CHAN_SWITCH_REQ message, which disables the channel switch to the TDLS target channel.

Parameters:

  `[in]` | msgid | Id of the message received.
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 164 of file tdls_task.c.

References chan_roc_req(), tdls_info_tag::chsw_active, tdls_info_tag::chsw_end_timer, tdls_info_tag::chsw_initiator, tdls_info_tag::chsw_req_timer, tdls_info_tag::chsw_time_timer, CO_FAIL, CO_OK, vif_info_tag::index, INVALID_STA_IDX, KE_MSG_ALLOC, KE_MSG_CONSUMED, ke_msg_send(), ke_state_get(), ke_state_set(), mm_timer_clear(), mm_remain_on_channel_req::op_code, PROF_TDLS_CHSW_END_TIMER_CLR, PROF_TDLS_CHSW_REQ_TX_TIMER_CLR, PROF_TDLS_CHSW_TIME_TIMER_CLR, PROF_TDLS_SWITCH_TO_BASECH_CLR, PROF_TDLS_SWITCH_TO_BASECH_SET, vif_info_tag::sta, tdls_cancel_chan_switch_req::sta_idx, sta_info_tab, tdls_cancel_chan_switch_cfm::status, tdls_chan_switch_cfm::status, TASK_TDLS, sta_info_tag::tdls, TDLS_BASE_CHANNEL, TDLS_CANCEL_CHAN_SWITCH_CFM, TRACE_TDLS, vif_info_tag::u, mm_remain_on_channel_req::vif_index, tdls_cancel_chan_switch_req::vif_index, and vif_info_tab.

static int tdls_chan_switch_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct tdls_chan_switch_req const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

TDLS channel switch request handler.

This function handles the TDLS_CHAN_SWITCH_REQ message, which enables the channel switch to the TDLS target channel.

Parameters:

  `[in]` | msgid | Id of the message received.
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 81 of file tdls_task.c.

References mm_timer_tag::cb, tdls_chan_switch_req::chan, tdls_info_tag::chsw, tdls_info_tag::chsw_active, tdls_info_tag::chsw_allowed, tdls_info_tag::chsw_initiator, tdls_info_tag::chsw_op_class, tdls_info_tag::chsw_req_timer, CO_FAIL, CO_OK, mm_timer_tag::env, INVALID_STA_IDX, INVALID_VIF_IDX, KE_MSG_ALLOC, KE_MSG_CONSUMED, ke_msg_send(), ke_state_set(), mm_timer_set(), tdls_chan_switch_req::op_class, PROF_TDLS_CHSW_REQ_TX_TIMER_SET, vif_info_tag::sta, tdls_chan_switch_req::sta_idx, sta_info_tab, tdls_chan_switch_cfm::status, TASK_TDLS, vif_info_tag::tbtt_timer, sta_info_tag::tdls, TDLS_BASE_CHANNEL, TDLS_CHAN_SWITCH_CFM, TDLS_CHSW_REQ_DELAY_US, tdls_chsw_req_evt(), mm_timer_tag::time, TRACE_TDLS, vif_info_tag::u, sta_info_tag::valid, tdls_chan_switch_req::vif_index, and vif_info_tab.

static int tdls_peer_traffic_ind_req_handler | ( | ke_msg_id_t const | msgid,
|  | struct tdls_peer_traffic_ind_req const * | param,
|  | ke_task_id_t const | dest_id,
|  | ke_task_id_t const | src_id |
| ) |  |  | `[static]`

TDLS Peer Traffic Indication request handler.

This function handles the TDLS_PEER_TRAFFIC_IND_REQ message, which sends the TDLS Peer Traffic Indication to the TDLS Peer, through the AP.

Parameters:

  `[in]` | msgid | Id of the message received.
  `[in]` | param | Pointer to the parameters of the message.
  `[in]` | dest_id | TaskId of the receiving task.
  `[in]` | src_id | TaskId of the sending task.

Returns:
  Whether the message was consumed or not.

Definition at line 247 of file tdls_task.c.

References CO_FAIL, CO_OK, tdls_peer_traffic_ind_req::dialog_token, tdls_info_tag::dialog_token, INVALID_STA_IDX, KE_MSG_ALLOC, KE_MSG_CONSUMED, ke_msg_send(), ke_state_set(), tdls_peer_traffic_ind_req::sta_idx, sta_info_tab, tdls_peer_traffic_ind_cfm::status, tdls_cancel_chan_switch_cfm::status, TASK_TDLS, sta_info_tag::tdls, TDLS_PEER_TRAFFIC_IND_CFM, tdls_peer_traffic_ind_tx_cfm(), TDLS_TRAFFIC_IND_TX, tdls_info_tag::traffic_available, and txl_frame_send_tdls_peer_traffic_ind_frame().

## Variable Documentation

struct ke_state_handler tdls_default_handler

Initial value:

        KE_STATE_HANDLER(tdls_default_state)

Specifies the message handlers that are common to all states.

Definition at line 304 of file tdls_task.c.

struct ke_msg_handler tdls_default_state[]

Initial value:

    {

        {TDLS_CHAN_SWITCH_REQ, (ke_msg_func_t)tdls_chan_switch_req_handler},

        {TDLS_CANCEL_CHAN_SWITCH_REQ, (ke_msg_func_t)tdls_cancel_chan_switch_req_handler},

        {TDLS_PEER_TRAFFIC_IND_REQ, (ke_msg_func_t)tdls_peer_traffic_ind_req_handler},

    }

Message handlers in state DEFAULT.

Definition at line 291 of file tdls_task.c.