EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
cmd_processor.h
Go to the documentation of this file.
1 
11 #ifndef CMD_PROCESSOR_H
12 #define CMD_PROCESSOR_H
13 
14 #include <stdbool.h>
15 #include <sys/types.h>
16 #include <sys/un.h>
17 
18 #include <utarray.h>
19 #include "../utils/sockctl.h"
20 
21 #include "supervisor_config.h"
22 
23 // SYSTEM commands
24 #define CMD_PING "PING_SUPERVISOR"
25 #define CMD_SET_IP "SET_IP"
26 #define CMD_SUBSCRIBE_EVENTS "SUBSCRIBE_EVENTS"
27 
28 // NETCON commands
29 #define CMD_ACCEPT_MAC "ACCEPT_MAC"
30 #define CMD_DENY_MAC "DENY_MAC"
31 #define CMD_ADD_NAT "ADD_NAT"
32 #define CMD_REMOVE_NAT "REMOVE_NAT"
33 #define CMD_ASSIGN_PSK "ASSIGN_PSK"
34 #define CMD_GET_MAP "GET_MAP"
35 #define CMD_GET_ALL "GET_ALL"
36 #define CMD_ADD_BRIDGE "ADD_BRIDGE"
37 #define CMD_REMOVE_BRIDGE "REMOVE_BRIDGE"
38 #define CMD_CLEAR_BRIDGES "CLEAR_BRIDGE"
39 #define CMD_GET_BRIDGES "GET_BRIDGES"
40 #define CMD_REGISTER_TICKET "REGISTER_TICKET"
41 #define CMD_CLEAR_PSK "CLEAR_PSK"
42 
43 #ifdef WITH_CRYPTO_SERVICE
44 // CRYPT commands
45 #define CMD_PUT_CRYPT "PUT_CRYPT"
46 #define CMD_GET_CRYPT "GET_CRYPT"
47 #define CMD_GEN_RANDKEY "GEN_RANDKEY"
48 #define CMD_GEN_PRIVKEY "GEN_PRIVKEY"
49 #define CMD_GEN_PUBKEY "GEN_PUBKEY"
50 #define CMD_GEN_CERT "GEN_CERT"
51 #define CMD_ENCRYPT_BLOB "ENCRYPT_BLOB"
52 #define CMD_DECRYPT_BLOB "DECRYPT_BLOB"
53 #define CMD_SIGN_BLOB "SIGN_BLOB"
54 #endif
55 
56 #define CMD_DELIMITER '\x20'
57 
58 #define OK_REPLY "OK\n"
59 #define FAIL_REPLY "FAIL\n"
60 
61 #define MAX_QUERY_OP_LEN 3
62 
63 typedef ssize_t (*process_cmd_fn)(int sock,
64  const struct client_address *client_addr,
65  struct supervisor_context *context,
66  UT_array *cmd_arr);
67 
77 bool process_domain_buffer(char *domain_buffer, size_t domain_buffer_len,
78  UT_array *cmd_arr, char sep);
79 
89 ssize_t process_ping_cmd(int sock, const struct client_address *client_addr,
90  struct supervisor_context *context, UT_array *cmd_arr);
91 
101 ssize_t process_subscribe_events_cmd(int sock,
102  const struct client_address *client_addr,
103  struct supervisor_context *context,
104  UT_array *cmd_arr);
105 
115 ssize_t process_accept_mac_cmd(int sock,
116  const struct client_address *client_addr,
117  struct supervisor_context *context,
118  UT_array *cmd_arr);
119 
129 ssize_t process_deny_mac_cmd(int sock, const struct client_address *client_addr,
130  struct supervisor_context *context,
131  UT_array *cmd_arr);
132 
142 ssize_t process_add_nat_cmd(int sock, const struct client_address *client_addr,
143  struct supervisor_context *context,
144  UT_array *cmd_arr);
145 
155 ssize_t process_remove_nat_cmd(int sock,
156  const struct client_address *client_addr,
157  struct supervisor_context *context,
158  UT_array *cmd_arr);
159 
169 ssize_t process_assign_psk_cmd(int sock,
170  const struct client_address *client_addr,
171  struct supervisor_context *context,
172  UT_array *cmd_arr);
173 
183 ssize_t process_get_map_cmd(int sock, const struct client_address *client_addr,
184  struct supervisor_context *context,
185  UT_array *cmd_arr);
186 
196 ssize_t process_get_all_cmd(int sock, const struct client_address *client_addr,
197  struct supervisor_context *context,
198  UT_array *cmd_arr);
199 
209 ssize_t process_set_ip_cmd(int sock, const struct client_address *client_addr,
210  struct supervisor_context *context,
211  UT_array *cmd_arr);
212 
222 ssize_t process_add_bridge_cmd(int sock,
223  const struct client_address *client_addr,
224  struct supervisor_context *context,
225  UT_array *cmd_arr);
226 
236 ssize_t process_remove_bridge_cmd(int sock,
237  const struct client_address *client_addr,
238  struct supervisor_context *context,
239  UT_array *cmd_arr);
240 
250 ssize_t process_clear_bridges_cmd(int sock,
251  const struct client_address *client_addr,
252  struct supervisor_context *context,
253  UT_array *cmd_arr);
254 
264 ssize_t process_get_bridges_cmd(int sock,
265  const struct client_address *client_addr,
266  struct supervisor_context *context,
267  UT_array *cmd_arr);
268 
279  const struct client_address *client_addr,
280  struct supervisor_context *context,
281  UT_array *cmd_arr);
282 
293  const struct client_address *client_addr,
294  struct supervisor_context *context,
295  UT_array *cmd_arr);
296 
308 ssize_t process_register_ticket_cmd(int sock,
309  const struct client_address *client_addr,
310  struct supervisor_context *context,
311  UT_array *cmd_arr);
312 
322 ssize_t process_clear_psk_cmd(int sock,
323  const struct client_address *client_addr,
324  struct supervisor_context *context,
325  UT_array *cmd_arr);
326 
327 #ifdef WITH_CRYPTO_SERVICE
337 ssize_t process_put_crypt_cmd(int sock,
338  const struct client_address *client_addr,
339  struct supervisor_context *context,
340  UT_array *cmd_arr);
341 
351 ssize_t process_get_crypt_cmd(int sock,
352  const struct client_address *client_addr,
353  struct supervisor_context *context,
354  UT_array *cmd_arr);
355 
365 ssize_t process_gen_randkey_cmd(int sock,
366  const struct client_address *client_addr,
367  struct supervisor_context *context,
368  UT_array *cmd_arr);
369 
379 ssize_t process_gen_privkey_cmd(int sock,
380  const struct client_address *client_addr,
381  struct supervisor_context *context,
382  UT_array *cmd_arr);
383 
393 ssize_t process_gen_pubkey_cmd(int sock,
394  const struct client_address *client_addr,
395  struct supervisor_context *context,
396  UT_array *cmd_arr);
397 
407 ssize_t process_gen_cert_cmd(int sock, const struct client_address *client_addr,
408  struct supervisor_context *context,
409  UT_array *cmd_arr);
410 
420 ssize_t process_encrypt_blob_cmd(int sock,
421  const struct client_address *client_addr,
422  struct supervisor_context *context,
423  UT_array *cmd_arr);
424 
434 ssize_t process_decrypt_blob_cmd(int sock,
435  const struct client_address *client_addr,
436  struct supervisor_context *context,
437  UT_array *cmd_arr);
438 
448 ssize_t process_sign_blob_cmd(int sock,
449  const struct client_address *client_addr,
450  struct supervisor_context *context,
451  UT_array *cmd_arr);
452 #endif
453 
460 process_cmd_fn get_command_function(const char *cmd);
461 #endif
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.
Definition: cmd_processor.c:594
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.
Definition: cmd_processor.c:160
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.
Definition: cmd_processor.c:446
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.
Definition: cmd_processor.c:337
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.
Definition: cmd_processor.c:397
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.
Definition: cmd_processor.c:549
process_cmd_fn get_command_function(const char *cmd)
Get the command function pointer.
Definition: cmd_processor.c:987
bool process_domain_buffer(char *domain_buffer, size_t domain_buffer_len, UT_array *cmd_arr, char sep)
Processes the domain command string.
Definition: cmd_processor.c:35
ssize_t(* process_cmd_fn)(int sock, const struct client_address *client_addr, struct supervisor_context *context, UT_array *cmd_arr)
Definition: cmd_processor.h:63
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.
Definition: cmd_processor.c:137
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.
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.
Definition: cmd_processor.c:500
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.
Definition: cmd_processor.c:183
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.
Definition: cmd_processor.c:278
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.
Definition: cmd_processor.c:104
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.
Definition: cmd_processor.c:90
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.
Definition: cmd_processor.c:75
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.
Definition: cmd_processor.c:207
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.
Definition: cmd_processor.c:240
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.
Definition: cmd_processor.c:477
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.
Client address structure definition.
Definition: sockctl.h:28
Supervisor structure definition.
Definition: supervisor_config.h:45
File containing the definition of the supervisor service structure.