EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Macros | Typedefs | Functions
cmd_processor.h File Reference

File containing the definition of the command processor functions. More...

#include <stdbool.h>
#include <sys/types.h>
#include <sys/un.h>
#include <utarray.h>
#include "../utils/sockctl.h"
#include "supervisor_config.h"
Include dependency graph for cmd_processor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CMD_PING   "PING_SUPERVISOR"
 
#define CMD_SET_IP   "SET_IP"
 
#define CMD_SUBSCRIBE_EVENTS   "SUBSCRIBE_EVENTS"
 
#define CMD_ACCEPT_MAC   "ACCEPT_MAC"
 
#define CMD_DENY_MAC   "DENY_MAC"
 
#define CMD_ADD_NAT   "ADD_NAT"
 
#define CMD_REMOVE_NAT   "REMOVE_NAT"
 
#define CMD_ASSIGN_PSK   "ASSIGN_PSK"
 
#define CMD_GET_MAP   "GET_MAP"
 
#define CMD_GET_ALL   "GET_ALL"
 
#define CMD_ADD_BRIDGE   "ADD_BRIDGE"
 
#define CMD_REMOVE_BRIDGE   "REMOVE_BRIDGE"
 
#define CMD_CLEAR_BRIDGES   "CLEAR_BRIDGE"
 
#define CMD_GET_BRIDGES   "GET_BRIDGES"
 
#define CMD_REGISTER_TICKET   "REGISTER_TICKET"
 
#define CMD_CLEAR_PSK   "CLEAR_PSK"
 
#define CMD_DELIMITER   '\x20'
 
#define OK_REPLY   "OK\n"
 
#define FAIL_REPLY   "FAIL\n"
 
#define MAX_QUERY_OP_LEN   3
 

Typedefs

typedef ssize_t(* process_cmd_fn) (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 

Functions

bool process_domain_buffer (char *domain_buffer, size_t domain_buffer_len, UT_array *cmd_arr, char sep)
 Processes the domain command string. More...
 
ssize_t process_ping_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the PING command. More...
 
ssize_t process_subscribe_events_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the SUBSCRIBE_EVENTS command. More...
 
ssize_t process_accept_mac_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the ACCEPT_MAC command. More...
 
ssize_t process_deny_mac_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the DENY_MAC command. More...
 
ssize_t process_add_nat_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the ADD_NAT command. More...
 
ssize_t process_remove_nat_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the REMOVE_NAT command. More...
 
ssize_t process_assign_psk_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the ASSIGN_PSK command. More...
 
ssize_t process_get_map_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the GET_MAP command. More...
 
ssize_t process_get_all_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the GET_ALL command. More...
 
ssize_t process_set_ip_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the SET_IP command. More...
 
ssize_t process_add_bridge_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the ADD_BRIDGE command. More...
 
ssize_t process_remove_bridge_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the REMOVE_BRIDGE command. More...
 
ssize_t process_clear_bridges_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the CLEAR_BRIDGES command. More...
 
ssize_t process_get_bridges_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the GET_BRIDGES command. More...
 
ssize_t process_set_fingerprint_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the SET_FINGERPRINT command. More...
 
ssize_t process_query_fingerprint_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the QUERY_FINGERPRINT command. More...
 
ssize_t process_register_ticket_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the REGISTER_TICKET command. More...
 
ssize_t process_clear_psk_cmd (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
 Processes the CLEAR_PSK command. More...
 
process_cmd_fn get_command_function (const char *cmd)
 Get the command function pointer. More...
 

Detailed Description

File containing the definition of the command processor functions.

Author
Alexandru Mereacre
Date
2020

Macro Definition Documentation

◆ CMD_ACCEPT_MAC

#define CMD_ACCEPT_MAC   "ACCEPT_MAC"

◆ CMD_ADD_BRIDGE

#define CMD_ADD_BRIDGE   "ADD_BRIDGE"

◆ CMD_ADD_NAT

#define CMD_ADD_NAT   "ADD_NAT"

◆ CMD_ASSIGN_PSK

#define CMD_ASSIGN_PSK   "ASSIGN_PSK"

◆ CMD_CLEAR_BRIDGES

#define CMD_CLEAR_BRIDGES   "CLEAR_BRIDGE"

◆ CMD_CLEAR_PSK

#define CMD_CLEAR_PSK   "CLEAR_PSK"

◆ CMD_DELIMITER

#define CMD_DELIMITER   '\x20'

◆ CMD_DENY_MAC

#define CMD_DENY_MAC   "DENY_MAC"

◆ CMD_GET_ALL

#define CMD_GET_ALL   "GET_ALL"

◆ CMD_GET_BRIDGES

#define CMD_GET_BRIDGES   "GET_BRIDGES"

◆ CMD_GET_MAP

#define CMD_GET_MAP   "GET_MAP"

◆ CMD_PING

#define CMD_PING   "PING_SUPERVISOR"

◆ CMD_REGISTER_TICKET

#define CMD_REGISTER_TICKET   "REGISTER_TICKET"

◆ CMD_REMOVE_BRIDGE

#define CMD_REMOVE_BRIDGE   "REMOVE_BRIDGE"

◆ CMD_REMOVE_NAT

#define CMD_REMOVE_NAT   "REMOVE_NAT"

◆ CMD_SET_IP

#define CMD_SET_IP   "SET_IP"

◆ CMD_SUBSCRIBE_EVENTS

#define CMD_SUBSCRIBE_EVENTS   "SUBSCRIBE_EVENTS"

◆ FAIL_REPLY

#define FAIL_REPLY   "FAIL\n"

◆ MAX_QUERY_OP_LEN

#define MAX_QUERY_OP_LEN   3

◆ OK_REPLY

#define OK_REPLY   "OK\n"

Typedef Documentation

◆ process_cmd_fn

typedef ssize_t(* process_cmd_fn) (int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)

Function Documentation

◆ get_command_function()

process_cmd_fn get_command_function ( const char *  cmd)

Get the command function pointer.

Parameters
cmdThe command string
Returns
process_cmd_fn The returned function pointer

◆ process_accept_mac_cmd()

ssize_t process_accept_mac_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the ACCEPT_MAC command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_add_bridge_cmd()

ssize_t process_add_bridge_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the ADD_BRIDGE command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_add_nat_cmd()

ssize_t process_add_nat_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the ADD_NAT command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_assign_psk_cmd()

ssize_t process_assign_psk_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the ASSIGN_PSK command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_clear_bridges_cmd()

ssize_t process_clear_bridges_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the CLEAR_BRIDGES command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_clear_psk_cmd()

ssize_t process_clear_psk_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the CLEAR_PSK command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_deny_mac_cmd()

ssize_t process_deny_mac_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the DENY_MAC command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_domain_buffer()

bool process_domain_buffer ( char *  domain_buffer,
size_t  domain_buffer_len,
UT_array *  cmd_arr,
char  sep 
)

Processes the domain command string.

Parameters
domain_bufferThe domain command string
domain_buffer_lenThe domain command string length
cmd_arrThe processed command array
sepThe string separator
Returns
true on success, false otherwise

◆ process_get_all_cmd()

ssize_t process_get_all_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the GET_ALL command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data, or -1 on failure

◆ process_get_bridges_cmd()

ssize_t process_get_bridges_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the GET_BRIDGES command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_get_map_cmd()

ssize_t process_get_map_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the GET_MAP command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_ping_cmd()

ssize_t process_ping_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the PING command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_query_fingerprint_cmd()

ssize_t process_query_fingerprint_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the QUERY_FINGERPRINT command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_register_ticket_cmd()

ssize_t process_register_ticket_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the REGISTER_TICKET command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
Size of reply written data. This would be the length of the passphrase. Returns strlen(FAIL_REPLY) on error.

◆ process_remove_bridge_cmd()

ssize_t process_remove_bridge_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the REMOVE_BRIDGE command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_remove_nat_cmd()

ssize_t process_remove_nat_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the REMOVE_NAT command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_set_fingerprint_cmd()

ssize_t process_set_fingerprint_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the SET_FINGERPRINT command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_set_ip_cmd()

ssize_t process_set_ip_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the SET_IP command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data

◆ process_subscribe_events_cmd()

ssize_t process_subscribe_events_cmd ( int  sock,
const struct client_address client_addr,
struct supervisor_context context,
UT_array *  cmd_arr 
)

Processes the SUBSCRIBE_EVENTS command.

Parameters
sockThe domain server socket
client_addrThe client address for replies
contextThe supervisor structure instance
cmd_arrThe array of received commands
Returns
ssize_t Size of reply written data