EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Macros | Functions
ap_service.c File Reference

File containing the implementation of the hostapd service. More...

#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "ap_config.h"
#include "ap_service.h"
#include "hostapd.h"
#include <eloop.h>
#include "../radius/radius_server.h"
#include "../supervisor/supervisor_config.h"
#include "../utils/allocs.h"
#include "../utils/iface.h"
#include "../utils/log.h"
#include "../utils/os.h"
#include "../utils/sockctl.h"
Include dependency graph for ap_service.c:

Macros

#define AP_STA_DISCONNECTED   "AP-STA-DISCONNECTED"
 
#define AP_STA_CONNECTED   "AP-STA-CONNECTED"
 

Functions

int ping_ap_command (struct apconf *hconf)
 Pings the hostapd daemon. More...
 
int denyacl_ap_command (struct apconf *hconf, const char *cmd, const char *mac_addr)
 
int denyacl_add_ap_command (struct apconf *hconf, const char *mac_addr)
 Deny ACL ADD AP command. More...
 
int denyacl_del_ap_command (struct apconf *hconf, const char *mac_addr)
 Deny ACL DEL AP command. More...
 
int disconnect_ap_command (struct apconf *hconf, const char *mac_addr)
 Disconnect and reconnect a MAC device from the AP. More...
 
int check_sta_ap_command (struct apconf *hconf, const char *mac_addr)
 Check if a station is registered on the AP. More...
 
int find_ap_status (const char *ap_answer, uint8_t mac_addr[static ETHER_ADDR_LEN], enum AP_CONNECTION_STATUS *status)
 Finds the stauts of the given access point. More...
 
void ap_sock_handler (int sock, void *eloop_ctx, void *sock_ctx)
 
int register_ap_event (struct supervisor_context *context, struct run_ap_callback_fn_struct *ap_callback_fn)
 
int run_ap (struct supervisor_context *context, bool exec_ap, bool generate_ssid, struct run_ap_callback_fn_struct *ap_callback_fn)
 Runs the AP service. More...
 
bool close_ap (struct supervisor_context *context)
 Closes (terminates) AP process. More...
 

Detailed Description

File containing the implementation of the hostapd service.

Author
Alexandru Mereacre
Date
2020

Defines the functions to start and stop the acces point service (AP). It also defines auxiliary commands to manage the acces control list for stations connected to the AP.

Macro Definition Documentation

◆ AP_STA_CONNECTED

#define AP_STA_CONNECTED   "AP-STA-CONNECTED"

◆ AP_STA_DISCONNECTED

#define AP_STA_DISCONNECTED   "AP-STA-DISCONNECTED"

Function Documentation

◆ ap_sock_handler()

void ap_sock_handler ( int  sock,
void *  eloop_ctx,
void *  sock_ctx 
)

◆ check_sta_ap_command()

int check_sta_ap_command ( struct apconf hconf,
const char *  mac_addr 
)

Check if a station is registered on the AP.

Parameters
hconfAP config structure
mac_addrThe mac address of the station
Returns
int 0 on success, -1 on failure

◆ close_ap()

bool close_ap ( struct supervisor_context context)

Closes (terminates) AP process.

Parameters
contextThe supervisor context structure
Returns
true success, false otherwise

◆ denyacl_add_ap_command()

int denyacl_add_ap_command ( struct apconf hconf,
const char *  mac_addr 
)

Deny ACL ADD AP command.

Parameters
hconfAP config structure
mac_addrThe mac address to add to deny list
Returns
int 0 on success, -1 on failure

◆ denyacl_ap_command()

int denyacl_ap_command ( struct apconf hconf,
const char *  cmd,
const char *  mac_addr 
)

◆ denyacl_del_ap_command()

int denyacl_del_ap_command ( struct apconf hconf,
const char *  mac_addr 
)

Deny ACL DEL AP command.

Parameters
hconfAP config structure
mac_addrThe mac address to remove from deny list
Returns
int 0 on success, -1 on failure

◆ disconnect_ap_command()

int disconnect_ap_command ( struct apconf hconf,
const char *  mac_addr 
)

Disconnect and reconnect a MAC device from the AP.

Parameters
hconfAP config structure
mac_addrThe mac address to disconnect
Returns
int 0 on success, -1 on failure

◆ find_ap_status()

int find_ap_status ( const char *  ap_answer,
uint8_t  mac_addr[static ETHER_ADDR_LEN],
enum AP_CONNECTION_STATUS status 
)

Finds the stauts of the given access point.

Parameters
ap_answerResponse from ap socket.
[out]mac_addrThe MAC address of the AP.
[out]statusOutputs the the status of the AP to this variable.
Return values
0Sucess.
-1Error. No valid AP status found in the ap_answer string.

◆ ping_ap_command()

int ping_ap_command ( struct apconf hconf)

Pings the hostapd daemon.

Parameters
hconfAP config structure
Return values
<tt>0</tt>if the hostapd daemon responded okay.
<tt>-1</tt>if the hostapd daemon didn't respond or had an invalid response.

◆ register_ap_event()

int register_ap_event ( struct supervisor_context context,
struct run_ap_callback_fn_struct ap_callback_fn 
)

◆ run_ap()

int run_ap ( struct supervisor_context context,
bool  exec_ap,
bool  generate_ssid,
struct run_ap_callback_fn_struct ap_callback_fn 
)

Runs the AP service.

Parameters
contextThe supervisor context structure
exec_apFlag to execute/signal the AP process
generate_ssidFlag to generate the SSID for AP
[in]ap_callback_fnA stuct containing the callback for AP service
Returns
int 0 on success, -1 on failure