49#include "../../QSC/QSC/collection.h"
70#define MPDC_SERVER_MINIMUM_COMMAND_LENGTH 4
79#define MPDC_SERVER_APPLICATION_STATE_SIZE (MPDC_STORAGE_DOMAINNAME_MAX + MPDC_STORAGE_HOSTNAME_MAX + \
80 MPDC_STORAGE_ADDRESS_MAX + MPDC_STORAGE_PATH_MAX + MPDC_STORAGE_USERNAME_MAX + MPDC_CERTIFICATE_ISSUER_SIZE + \
81 sizeof(uint16_t) + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint16_t) + sizeof(bool) + sizeof(bool) + \
82 MPDC_ASYMMETRIC_SIGNING_KEY_SIZE)
118 char domain[MPDC_STORAGE_DOMAINNAME_MAX];
MPDC Certificate Handling Functions.
The MPDC command enumerations.
mpdc_application_messages
The RDS application messages.
Definition commands.h:73
mpdc_console_modes
The RDS console modes.
Definition commands.h:331
mpdc_command_actions
The RDS command actions.
Definition commands.h:248
MPDC Common Definitions and Protocol Configuration.
#define MPDC_CERTIFICATE_ISSUER_SIZE
The maximum certificate issuer string length. The last character must be a string terminator.
Definition mpdc.h:795
mpdc_network_designations
The MPDC device designation.
Definition mpdc.h:1114
mpdc_protocol_errors
The MPDC protocol error values.
Definition mpdc.h:1219
MPDC_EXPORT_API void mpdc_server_set_command_prompt(mpdc_server_application_state *state)
Set the command prompt to the current state mode.
Definition server.c:1546
MPDC_EXPORT_API bool mpdc_server_child_certificate_from_issuer(mpdc_child_certificate *ccert, const mpdc_server_application_state *state, const char *issuer)
Get the certificate instance from file using the issuer string.
Definition server.c:703
MPDC_EXPORT_API bool mpdc_server_set_console_timeout(mpdc_server_application_state *state, const char *snum, size_t numlen)
Set the number of idle minutes before the user is logged out.
Definition server.c:1598
MPDC_EXPORT_API void mpdc_server_erase_signature_key(mpdc_server_application_state *state)
Erase the signature-scheme signing key.
Definition server.c:1827
MPDC_EXPORT_API void mpdc_server_topology_to_file(mpdc_server_application_state *state)
Copy the topology to an encrypted file.
Definition server.c:2399
MPDC_EXPORT_API bool mpdc_server_mfkcol_from_file(qsc_collection_state *mfkcol, const mpdc_server_application_state *state)
Convert an encrypted mfk collection file to a collection state.
Definition server.c:1074
MPDC_EXPORT_API void mpdc_server_mfkcol_path(const mpdc_server_application_state *state, char *fpath, size_t pathlen)
Get the path to the mfk collection file.
Definition server.c:1060
mpdc_server_server_loop_status
The MPDC server loop status.
Definition server.h:95
@ mpdc_server_loop_status_paused
Definition server.h:98
@ mpdc_server_loop_status_started
Definition server.h:97
@ mpdc_server_loop_status_stopped
Definition server.h:96
MPDC_EXPORT_API void mpdc_server_print_error(const mpdc_server_application_state *state, mpdc_application_messages appmsg, const char *message, mpdc_protocol_errors error)
Print a network error to the console.
Definition server.c:1195
MPDC_EXPORT_API void mpdc_server_print_configuration(const mpdc_server_application_state *state)
Print the server configuration.
Definition server.c:1210
MPDC_EXPORT_API bool mpdc_server_topology_dla_fetch(const mpdc_server_application_state *state, mpdc_child_certificate *dcert)
Load the DLA certificate from state.
Definition server.c:2110
MPDC_EXPORT_API void mpdc_server_certificate_path(const mpdc_server_application_state *state, char *fpath, size_t pathlen, const char *issuer)
Get the full path to a certificate.
Definition server.c:651
MPDC_EXPORT_API bool mpdc_server_topology_root_exists(const mpdc_server_application_state *state)
Check if the root certificate exists on file.
Definition server.c:2351
MPDC_EXPORT_API bool mpdc_server_topology_root_fetch(const mpdc_server_application_state *state, mpdc_root_certificate *rcert)
Load the root certificate from state.
Definition server.c:2369
MPDC_EXPORT_API void mpdc_server_topology_print_list(mpdc_server_application_state *state)
Print the topological list to the console.
Definition server.c:2235
MPDC_EXPORT_API void mpdc_server_user_logout(mpdc_server_application_state *state)
Log out of the server.
Definition server.c:2735
MPDC_EXPORT_API bool mpdc_server_topology_load(mpdc_server_application_state *state)
Load the topology from an encrypted file to state.
Definition server.c:2140
MPDC_EXPORT_API bool mpdc_server_child_certificate_import(mpdc_child_certificate *lcert, mpdc_server_application_state *state, const char *fpath)
Import the local certificate signed by the root.
Definition server.c:770
MPDC_EXPORT_API bool mpdc_server_root_certificate_print(const char *fpath, size_t pathlen)
Print a formatted root certificate to console.
Definition server.c:1449
MPDC_EXPORT_API void mpdc_server_state_unload(mpdc_server_application_state *state)
Unload the server state from memory.
Definition server.c:2098
MPDC_EXPORT_API void mpdc_server_clear_log(mpdc_server_application_state *state)
Erase the log file.
Definition server.c:932
MPDC_EXPORT_API void mpdc_server_topology_reset(mpdc_server_application_state *state)
Delete all nodes and certificates except for the root.
Definition server.c:2333
MPDC_EXPORT_API bool mpdc_server_set_domain_name(mpdc_server_application_state *state, const char *name, size_t namelen)
Rename the network domain.
Definition server.c:1635
MPDC_EXPORT_API void mpdc_server_topology_remove_certificate(mpdc_server_application_state *state, const char *issuer)
Delete the certificate.
Definition server.c:2292
MPDC_EXPORT_API void mpdc_server_erase_all(mpdc_server_application_state *state)
Erase all state, including log files, and reset configuration.
Definition server.c:946
MPDC_EXPORT_API void mpdc_server_clear_config(mpdc_server_application_state *state)
Erase and reset the configuration file.
Definition server.c:921
MPDC_EXPORT_API void mpdc_server_print_banner(const mpdc_server_application_state *state)
Print the server banner.
Definition server.c:1184
MPDC_EXPORT_API bool mpdc_server_state_store(mpdc_server_application_state *state)
Write the server state to file.
Definition server.c:2066
MPDC_EXPORT_API bool mpdc_server_root_certificate_load(const mpdc_server_application_state *state, mpdc_root_certificate *root, const mpdc_topology_list_state *tlist)
Load a root certificate using the issuer name.
Definition server.c:1391
MPDC_EXPORT_API bool mpdc_server_child_certificate_from_serial(mpdc_child_certificate *ccert, const mpdc_server_application_state *state, const uint8_t *serial)
Get the certificate instance from file using the serial number.
Definition server.c:720
MPDC_EXPORT_API void mpdc_server_certificate_directory(const mpdc_server_application_state *state, char *dpath, size_t pathlen)
Get the full delimited path to the certificate storage directory.
Definition server.c:631
MPDC_EXPORT_API void mpdc_server_state_initialize(mpdc_server_application_state *state, mpdc_network_designations srvtype)
Initialize the internal state.
Definition server.c:1941
MPDC_EXPORT_API bool mpdc_server_child_certificate_print(const char *fpath, size_t pathlen)
Print the local child certificate to console.
Definition server.c:854
MPDC_EXPORT_API void mpdc_server_log_print(mpdc_server_application_state *state)
Print the log file to the console.
Definition server.c:986
MPDC_EXPORT_API bool mpdc_server_child_certificate_export(const mpdc_server_application_state *state, const char *dpath)
Export the local certificate to a file.
Definition server.c:665
MPDC_EXPORT_API bool mpdc_server_root_import_dialogue(mpdc_server_application_state *state)
Import the root certificate.
Definition server.c:1316
MPDC_EXPORT_API void mpdc_server_state_backup_restore(const mpdc_server_application_state *state)
Restore the state from backup.
Definition server.c:1837
MPDC_EXPORT_API void mpdc_server_root_certificate_store(mpdc_server_application_state *state, const mpdc_root_certificate *rcert)
Store a root certificate to a file.
Definition server.c:1484
MPDC_EXPORT_API bool mpdc_server_log_write_message(mpdc_server_application_state *state, mpdc_application_messages msgtype, const char *message, size_t msglen)
Write a message to the log.
Definition server.c:1030
MPDC_EXPORT_API bool mpdc_server_user_login(mpdc_server_application_state *state)
Start the user login dialogue.
Definition server.c:2449
MPDC_EXPORT_API void mpdc_server_local_certificate_store(mpdc_server_application_state *state, const mpdc_child_certificate *ccert, const char *address)
Store a child certificate.
Definition server.c:889
MPDC_EXPORT_API void mpdc_server_topology_remove_node(mpdc_server_application_state *state, const char *issuer)
Remove a node from the topology.
Definition server.c:2316
MPDC_EXPORT_API bool mpdc_server_root_certificate_export(const mpdc_server_application_state *state, const char *dpath)
Export the root certificate to a directory.
Definition server.c:1278
MPDC_EXPORT_API void mpdc_server_child_certificate_path_from_issuer(const mpdc_server_application_state *state, char *fpath, size_t pathlen, const char *issuer)
Get the certificate file path from the certificate issuer name.
Definition server.c:840
MPDC_EXPORT_API void mpdc_server_root_certificate_generate(mpdc_server_application_state *state, mpdc_root_certificate *rcert, uint64_t period)
Generate a new root certificate.
Definition server.c:1363
MPDC_EXPORT_API void mpdc_server_log_host(mpdc_server_application_state *state)
Enable logging on the server.
Definition server.c:958
MPDC_EXPORT_API void mpdc_server_state_backup_save(const mpdc_server_application_state *state)
Backup the state.
Definition server.c:1895
MPDC_EXPORT_API bool mpdc_server_set_host_name(mpdc_server_application_state *state, const char *name, size_t namelen)
Rename the server host.
Definition server.c:1693
MPDC_EXPORT_API bool mpdc_server_set_ip_address(mpdc_server_application_state *state, const char *address, size_t addlen)
Set the IP address of the server.
Definition server.c:1750
MPDC_EXPORT_API void mpdc_server_topology_purge_externals(mpdc_server_application_state *state)
Clear the topology list except for the root and local nodes.
Definition server.c:2267
MPDC_EXPORT_API bool mpdc_server_topology_local_fetch(const mpdc_server_application_state *state, mpdc_child_certificate *ccert)
Load the local certificate from state.
Definition server.c:2205
MPDC_EXPORT_API bool mpdc_server_set_password_retries(mpdc_server_application_state *state, const char *snum, size_t numlen)
Set the number of failed password retries.
Definition server.c:1791
MPDC_EXPORT_API void mpdc_server_child_certificate_path(const mpdc_server_application_state *state, char *fpath, size_t pathlen)
Get the full path to the child certificate.
Definition server.c:827
MPDC_EXPORT_API void mpdc_server_child_certificate_generate(mpdc_server_application_state *state, mpdc_child_certificate *ccert, uint64_t period)
Generate a new child certificate.
Definition server.c:742
MPDC_EXPORT_API void mpdc_server_mfkcol_to_file(const qsc_collection_state *mfkcol, const mpdc_server_application_state *state)
Convert an mfk collection to an encrypted file.
Definition server.c:1140
The child certificate structure.
Definition mpdc.h:1293
The root certificate structure.
Definition mpdc.h:1411
The MPDC server state.
Definition server.h:116
uint8_t * kchain
Definition server.h:124
char hostname[MPDC_STORAGE_HOSTNAME_MAX]
Definition server.h:119
const char * aplpath
Definition server.h:126
const char * pubkeyname
Definition server.h:131
const char * srvname
Definition server.h:132
const char * promptdef
Definition server.h:130
uint8_t retries
Definition server.h:143
mpdc_root_certificate root
Definition server.h:136
const char * prikeyname
Definition server.h:129
char logpath[MPDC_STORAGE_PATH_MAX]
Definition server.h:122
char issuer[MPDC_CERTIFICATE_ISSUER_SIZE]
Definition server.h:120
mpdc_topology_list_state tlist
Definition server.h:137
mpdc_console_modes mode
Definition server.h:139
bool loghost
Definition server.h:145
uint16_t timeout
Definition server.h:142
const char * banner
Definition server.h:127
uint8_t * sigkey
Definition server.h:125
mpdc_command_actions action
Definition server.h:138
uint16_t port
Definition server.h:140
const char * topname
Definition server.h:133
char localip[MPDC_STORAGE_ADDRESS_MAX]
Definition server.h:121
bool joined
Definition server.h:144
mpdc_network_designations srvtype
Definition server.h:141
mpdc_child_certificate dla
Definition server.h:135
char username[MPDC_STORAGE_USERNAME_MAX]
Definition server.h:123
char cmdprompt[MPDC_STORAGE_PROMPT_MAX]
Definition server.h:117
char domain[MPDC_STORAGE_DOMAINNAME_MAX]
Definition server.h:118
const char * wtitle
Definition server.h:134
const char * cfgname
Definition server.h:128
The MPDC topology list structure.
Definition topology.h:185
The MPDC topology functions.