# SCAN
[LMAC]

LMAC Scanning module. More...

Collaboration diagram for SCAN:

## Data Structures
struct | scan_probe_req_ie_tag
| Definition of a ProbeReq IE buffer. More...
struct | scan_env_tag
| SCAN Context. More...
## Modules
| SCAN_TASK

| Task responsible for scanning process.
## Defines
#define | SCAN_SSID_MAX 2
| Maximum number of SSIDs in a scan request.
#define | SCAN_CHANNEL_MAX (MAC_DOMAINCHANNEL_24G_MAX + MAC_DOMAINCHANNEL_5G_MAX)
| Maximum number of channels in a scan request.
#define | SCAN_MAX_IE_LEN 300
| Maximum length of the ProbeReq IEs.
#define | SCAN_ACTIVE_DURATION 30000
| Duration on channel (in TUs) when actively scanning.
#define | SCAN_PASSIVE_DURATION 110000
| Duration on channel (in TUs) when passively scanning.
## Functions
static void | scan_search_ds (void)
| Searchs for DS IE in probe request frame.
static void | dma_cb (void *env, int dma_queue)
| Callback for DMA transfer of probe request frame from host memory.
void | scan_init (void)
| SCAN Module main initialization function.
void | scan_ie_download (struct scan_start_req const *param)
| Download the information elements that will need to be added to the ProbeReq.
void | scan_set_channel_request (void)
| Send the appropriate channel request message.
void | scan_probe_req_tx (void)
| Prepare and program for TX the ProbeReq required for active scanning.
void | scan_send_cancel_cfm (uint8_t status, ke_task_id_t dest_id)
| Sends the SCAN_CANCEL_CFM message to the SCAN_CANCEL_REQ task source.
struct mac_chan_def const * | scan_get_chan (void)
| Returns scan channel information currently used.
## Variables
struct scan_env_tag | scan_env
| SCAN Context variable, used to store information related to scan module.
struct scan_env_tag | scan_env
| SCAN Context variable, used to store information related to scan module.
struct scan_probe_req_ie_tag | scan_probe_req_ie
| Global variable to store probe request frame downloaded from host memory.
struct scan_probe_req_ie_tag | scan_probe_req_ie
| Global variable to store probe request frame downloaded from host memory.

## Detailed Description

LMAC Scanning module.

## Function Documentation

static void dma_cb | ( | void * | env,
|  | int | dma_queue |
| ) |  |  | `[static]`

Callback for DMA transfer of probe request frame from host memory.

Parameters:

  `[in]` | env | Pointer associated to DMA transfer (NULL is this case)
  `[in]` | dma_queue | DMA queue on which transfer happened

Definition at line 71 of file scan.c.

References scan_search_ds(), and scan_set_channel_request().

struct mac_chan_def const * scan_get_chan | ( | void |  | ) | `[read]`

Returns scan channel information currently used.

Returns:
  Information of the channel that is currently scanned

Referenced by chan_send_survey_ind().

void scan_ie_download | ( | struct scan_start_req const * | param | ) |

Download the information elements that will need to be added to the ProbeReq.

Parameters:

  `[in]` | param | Pointer to the scan parameters

Referenced by scan_start_req_handler().

void scan_init | ( | void |  | ) |

SCAN Module main initialization function.

This function is called after reset and initializes all SCAN related env and data.

void scan_probe_req_tx | ( | void |  | ) |

Prepare and program for TX the ProbeReq required for active scanning.

Referenced by mm_scan_channel_start_ind_handler().

static void scan_search_ds | ( | void |  | ) | `[static]`

Searchs for DS IE in probe request frame.

If DS IE is present in the probe request frame provided by UMAC, then save pointer so that it can updated with the channel number before sending the probe request

Definition at line 54 of file scan.c.

References scan_start_req::add_ie_len, scan_probe_req_ie_tag::buf, CPU2HW, scan_env_tag::ds_ie, mac_ie_ds_find(), scan_env_tag::param, scan_env, and scan_probe_req_ie.

Referenced by dma_cb().

void scan_send_cancel_cfm | ( | uint8_t | status,
|  | ke_task_id_t | dest_id |
| ) |  |  |

Sends the SCAN_CANCEL_CFM message to the SCAN_CANCEL_REQ task source.

Parameters:

  `[in]` | status | Status to include in the message
  `[in]` | dest_id | ID of the requested task

Referenced by mm_scan_channel_end_ind_handler(), and scan_cancel_req_handler().