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

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

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/un.h>
#include "cmd_processor.h"
#include "mac_mapper.h"
#include "network_commands.h"
#include "system_commands.h"
#include "utils/allocs.h"
#include "utils/base64.h"
#include "utils/log.h"
#include "utils/net.h"
#include "utils/os.h"
#include "utils/sockctl.h"
Include dependency graph for cmd_processor.c:

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...
 
int write_newline_socket_data (int sock, char *data, const struct client_address *client_addr)
 
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_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 implementation of the command processor functions.

Author
Alexandru Mereacre
Date
2020

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_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_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

◆ write_newline_socket_data()

int write_newline_socket_data ( int  sock,
char *  data,
const struct client_address client_addr 
)