Loading include/utils.h +2 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ int32_t parse_params(const int p_argc, char* const p_argv[]); int32_t parse_config_file(const char* p_config_file); void free_config_file_resources(void); char* bin2hex(char* p_hex, size_t p_hlen, const uint8_t* p_bin, size_t p_blen); void usage(const char* p_progname, const uint8_t p_role); Loading src/its_web_server_config.c +30 −22 Original line number Diff line number Diff line Loading @@ -111,12 +111,21 @@ static int32_t web_client_page(struct MHD_Connection *p_connection) { "<input type=\"text\" id=\"udp_nic\" name=\"udp_nic\" value=\"%s\"><br>" "<label for=\"udp_address\">Multicast Address:</label><br>" "<input type=\"text\" id=\"udp_address\" name=\"udp_address\" value=\"%s\"><br>" "<label for=\"https_port\">Multicqst Port:</label><br>" "<label for=\"https_port\">Multicast Port:</label><br>" "<input type=\"number\" id=\"udp_port\" name=\"udp_port\" value=\"%d\"><br><br>" "<input type=\"submit\" value=\"Submit\">" "<input type=\"reset\">" "</form></body></html>"; /* Load ITS_Bridge_client configuration file */ free_config_file_resources(); sprintf(client_config_file, "%s/client.conf", conf_path); printf("Parsing file %s.\n", client_config_file); if (parse_config_file(client_config_file) == -1) { fprintf(stderr, "Failed to parse configuration file %s, exit.\n", config_file); return MHD_NO; } printf("its_nic:%s/%s, IP:%s:%d.\n", its_nic, mac_address, udp_address, udp_port); /* Prepare the HTML page to sent to the browser */ if (buffer != NULL) { free(buffer); } Loading @@ -124,6 +133,7 @@ static int32_t web_client_page(struct MHD_Connection *p_connection) { buffer = (char*)malloc(size); memset((void*)buffer, 0x00, size); snprintf(buffer, size, page, its_nic, mac_address, udp_nic, udp_address, udp_port); /* Wait fir the response */ struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buffer), (void*)(const char*)buffer, MHD_RESPMEM_PERSISTENT); if (!response) { return MHD_NO; Loading @@ -137,8 +147,8 @@ static int32_t web_client_page(struct MHD_Connection *p_connection) { static int32_t web_server_page(struct MHD_Connection *p_connection) { const char* page = "<!DOCTYPE html><html><body><h2>ITS Bridge Web Confgurator</h2><p>Please enter ETSI ITS_Bridge_client configuration:</p>" "<form action=\"/client_url\" method=\"POST\">" "<!DOCTYPE html><html><body><h2>ITS Bridge Web Confgurator</h2><p>Please enter ETSI ITS_Bridge_server configuration:</p>" "<form action=\"/server_url\" method=\"POST\">" "<label for=\"its_nic\">NIC ITS:</label><br>" "<input type=\"text\" id=\"its_nic\" name=\"its_nic\" value=\"%s\"><br>" "<label for=\"mac_address\">Mac Address:</label><br>" Loading @@ -146,13 +156,22 @@ static int32_t web_server_page(struct MHD_Connection *p_connection) { "<label for=\"udp_nic\">NIC multicast:</label><br>" "<input type=\"text\" id=\"udp_nic\" name=\"udp_nic\" value=\"%s\"><br>" "<label for=\"udp_address\">Multicast Addresses (Enter multicast address of the other vendors of your session separarated by a semi-colon):</label><br>" "<input type=\"text\" id=\"udp_address\" name=\"udp_address\" value=\"%s\"><br>" "<input type=\"text\" id=\"udp_address\" name=\"udp_address\" value=\"%s\" size=\"100\"><br>" "<label for=\"https_port\">Multicqst Port:</label><br>" "<input type=\"number\" id=\"udp_port\" name=\"udp_port\" value=\"%d\"><br><br>" "<input type=\"submit\" value=\"Submit\">" "<input type=\"reset\">" "</form></body></html>"; /* Load ITS_Bridge_server configuration file */ free_config_file_resources(); sprintf(server_config_file, "%s/server.conf", conf_path); printf("Parsing file %s.\n", server_config_file); if (parse_config_file(server_config_file) == -1) { fprintf(stderr, "Failed to parse configuration file %s, exit.\n", config_file); return MHD_NO; } printf("its_nic:%s/%s, IP:%s:%d.\n", its_nic, mac_address, udp_address, udp_port); /* Prepare the HTML page to sent to the browser */ if (buffer != NULL) { free(buffer); } Loading @@ -160,6 +179,7 @@ static int32_t web_server_page(struct MHD_Connection *p_connection) { buffer = (char*)malloc(size); memset((void*)buffer, 0x00, size); snprintf(buffer, size, page, its_nic, mac_address, udp_nic, udp_address, udp_port); /* Wait fir the response */ struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buffer), (void*)(const char*)buffer, MHD_RESPMEM_PERSISTENT); if (!response) { return MHD_NO; Loading Loading @@ -466,10 +486,10 @@ static void request_completed(void *cls, struct MHD_Connection *connection, } else if (strcmp(con_info->url, "/server_url") == 0) { printf("request_completed: Update server.conf.\n"); /* Create a new one */ //save_configuration_file(client_config_file, "server", daemon_mode, 0, "mac_address", mac_address, "its_nic", its_nic, "udp_nic", udp_nic, "udp_address", udp_address, "udp_protocol", "multicast", "udp_port", udp_port, -1); //save_configuration_file(server_config_file, "server", daemon_mode, 0, "mac_address", mac_address, "its_nic", its_nic, "udp_nic", udp_nic, "udp_address", udp_address, "udp_protocol", "multicast", "udp_port", udp_port, -1); { printf("save_configuration_file: its_nic:%s/%s, IP:%s:%s:%d.\n", its_nic, mac_address, udp_nic, udp_address, udp_port); FILE* fp = fopen(client_config_file, "w"); FILE* fp = fopen(server_config_file, "w"); if (fp == NULL) { goto end; } Loading Loading @@ -554,16 +574,6 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) { } printf("realm=%s, login=%s:%s, pem=%s, key=%s, conf_path=%s.\n", realm, login, password, cert_pem, cert_key, conf_path); /* Load ITS_Bridge_client configuration file */ sprintf(client_config_file, "%s/client.conf", conf_path); printf("Parsing file %s.\n", client_config_file); if (parse_config_file(client_config_file) == -1) { fprintf(stderr, "Failed to parse configuration file %s, exit.\n", config_file); goto error; } printf("its_nic:%s/%s, IP:%s:%d.\n", its_nic, mac_address, udp_address, udp_port); /* Load ITS_Bridge_server configuration file */ /* Daemonize */ if (daemonized) { daemonize(); Loading Loading @@ -631,10 +641,7 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) { free(cert_key); } free(its_nic); free(mac_address); free(udp_nic); free(udp_address); free_config_file_resources(); if (state == _reload) { if (parse_config_file(config_file) == -1) { Loading @@ -648,6 +655,7 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) { return 0; error: free_config_file_resources(); if (buffer != NULL) { free(buffer); } Loading src/utils.c +26 −2 Original line number Diff line number Diff line Loading @@ -141,6 +141,30 @@ int32_t parse_config_file(const char* p_config_file) { return 0; } void free_config_file_resources() { if (mac_address != NULL) { free(mac_address); mac_address = NULL; } if (its_nic != NULL) { free(its_nic); its_nic = NULL; } if (udp_nic != NULL) { free(udp_nic); udp_nic = NULL; } if (udp_address != NULL) { free(udp_address); udp_address = NULL; } if (udp_protocol != NULL) { free(udp_protocol); udp_protocol = NULL; } udp_port = 0; } char* bin2hex(char* p_hex, size_t p_hlen, const uint8_t* p_bin, size_t p_blen) { static const char* _hexDigits = "0123456789ABCDEF"; const uint8_t *b, *e; Loading Loading @@ -435,7 +459,7 @@ char** str_split(const char* p_string, const char p_separator) { /* Count how many elements will be extracted */ size_t count = 0; char* current = p_string; char* current = (char*)p_string; char* previous = NULL; while (*current != 0x00) { if (p_separator == *current) { Loading Loading
include/utils.h +2 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ int32_t parse_params(const int p_argc, char* const p_argv[]); int32_t parse_config_file(const char* p_config_file); void free_config_file_resources(void); char* bin2hex(char* p_hex, size_t p_hlen, const uint8_t* p_bin, size_t p_blen); void usage(const char* p_progname, const uint8_t p_role); Loading
src/its_web_server_config.c +30 −22 Original line number Diff line number Diff line Loading @@ -111,12 +111,21 @@ static int32_t web_client_page(struct MHD_Connection *p_connection) { "<input type=\"text\" id=\"udp_nic\" name=\"udp_nic\" value=\"%s\"><br>" "<label for=\"udp_address\">Multicast Address:</label><br>" "<input type=\"text\" id=\"udp_address\" name=\"udp_address\" value=\"%s\"><br>" "<label for=\"https_port\">Multicqst Port:</label><br>" "<label for=\"https_port\">Multicast Port:</label><br>" "<input type=\"number\" id=\"udp_port\" name=\"udp_port\" value=\"%d\"><br><br>" "<input type=\"submit\" value=\"Submit\">" "<input type=\"reset\">" "</form></body></html>"; /* Load ITS_Bridge_client configuration file */ free_config_file_resources(); sprintf(client_config_file, "%s/client.conf", conf_path); printf("Parsing file %s.\n", client_config_file); if (parse_config_file(client_config_file) == -1) { fprintf(stderr, "Failed to parse configuration file %s, exit.\n", config_file); return MHD_NO; } printf("its_nic:%s/%s, IP:%s:%d.\n", its_nic, mac_address, udp_address, udp_port); /* Prepare the HTML page to sent to the browser */ if (buffer != NULL) { free(buffer); } Loading @@ -124,6 +133,7 @@ static int32_t web_client_page(struct MHD_Connection *p_connection) { buffer = (char*)malloc(size); memset((void*)buffer, 0x00, size); snprintf(buffer, size, page, its_nic, mac_address, udp_nic, udp_address, udp_port); /* Wait fir the response */ struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buffer), (void*)(const char*)buffer, MHD_RESPMEM_PERSISTENT); if (!response) { return MHD_NO; Loading @@ -137,8 +147,8 @@ static int32_t web_client_page(struct MHD_Connection *p_connection) { static int32_t web_server_page(struct MHD_Connection *p_connection) { const char* page = "<!DOCTYPE html><html><body><h2>ITS Bridge Web Confgurator</h2><p>Please enter ETSI ITS_Bridge_client configuration:</p>" "<form action=\"/client_url\" method=\"POST\">" "<!DOCTYPE html><html><body><h2>ITS Bridge Web Confgurator</h2><p>Please enter ETSI ITS_Bridge_server configuration:</p>" "<form action=\"/server_url\" method=\"POST\">" "<label for=\"its_nic\">NIC ITS:</label><br>" "<input type=\"text\" id=\"its_nic\" name=\"its_nic\" value=\"%s\"><br>" "<label for=\"mac_address\">Mac Address:</label><br>" Loading @@ -146,13 +156,22 @@ static int32_t web_server_page(struct MHD_Connection *p_connection) { "<label for=\"udp_nic\">NIC multicast:</label><br>" "<input type=\"text\" id=\"udp_nic\" name=\"udp_nic\" value=\"%s\"><br>" "<label for=\"udp_address\">Multicast Addresses (Enter multicast address of the other vendors of your session separarated by a semi-colon):</label><br>" "<input type=\"text\" id=\"udp_address\" name=\"udp_address\" value=\"%s\"><br>" "<input type=\"text\" id=\"udp_address\" name=\"udp_address\" value=\"%s\" size=\"100\"><br>" "<label for=\"https_port\">Multicqst Port:</label><br>" "<input type=\"number\" id=\"udp_port\" name=\"udp_port\" value=\"%d\"><br><br>" "<input type=\"submit\" value=\"Submit\">" "<input type=\"reset\">" "</form></body></html>"; /* Load ITS_Bridge_server configuration file */ free_config_file_resources(); sprintf(server_config_file, "%s/server.conf", conf_path); printf("Parsing file %s.\n", server_config_file); if (parse_config_file(server_config_file) == -1) { fprintf(stderr, "Failed to parse configuration file %s, exit.\n", config_file); return MHD_NO; } printf("its_nic:%s/%s, IP:%s:%d.\n", its_nic, mac_address, udp_address, udp_port); /* Prepare the HTML page to sent to the browser */ if (buffer != NULL) { free(buffer); } Loading @@ -160,6 +179,7 @@ static int32_t web_server_page(struct MHD_Connection *p_connection) { buffer = (char*)malloc(size); memset((void*)buffer, 0x00, size); snprintf(buffer, size, page, its_nic, mac_address, udp_nic, udp_address, udp_port); /* Wait fir the response */ struct MHD_Response *response = MHD_create_response_from_buffer(strlen(buffer), (void*)(const char*)buffer, MHD_RESPMEM_PERSISTENT); if (!response) { return MHD_NO; Loading Loading @@ -466,10 +486,10 @@ static void request_completed(void *cls, struct MHD_Connection *connection, } else if (strcmp(con_info->url, "/server_url") == 0) { printf("request_completed: Update server.conf.\n"); /* Create a new one */ //save_configuration_file(client_config_file, "server", daemon_mode, 0, "mac_address", mac_address, "its_nic", its_nic, "udp_nic", udp_nic, "udp_address", udp_address, "udp_protocol", "multicast", "udp_port", udp_port, -1); //save_configuration_file(server_config_file, "server", daemon_mode, 0, "mac_address", mac_address, "its_nic", its_nic, "udp_nic", udp_nic, "udp_address", udp_address, "udp_protocol", "multicast", "udp_port", udp_port, -1); { printf("save_configuration_file: its_nic:%s/%s, IP:%s:%s:%d.\n", its_nic, mac_address, udp_nic, udp_address, udp_port); FILE* fp = fopen(client_config_file, "w"); FILE* fp = fopen(server_config_file, "w"); if (fp == NULL) { goto end; } Loading Loading @@ -554,16 +574,6 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) { } printf("realm=%s, login=%s:%s, pem=%s, key=%s, conf_path=%s.\n", realm, login, password, cert_pem, cert_key, conf_path); /* Load ITS_Bridge_client configuration file */ sprintf(client_config_file, "%s/client.conf", conf_path); printf("Parsing file %s.\n", client_config_file); if (parse_config_file(client_config_file) == -1) { fprintf(stderr, "Failed to parse configuration file %s, exit.\n", config_file); goto error; } printf("its_nic:%s/%s, IP:%s:%d.\n", its_nic, mac_address, udp_address, udp_port); /* Load ITS_Bridge_server configuration file */ /* Daemonize */ if (daemonized) { daemonize(); Loading Loading @@ -631,10 +641,7 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) { free(cert_key); } free(its_nic); free(mac_address); free(udp_nic); free(udp_address); free_config_file_resources(); if (state == _reload) { if (parse_config_file(config_file) == -1) { Loading @@ -648,6 +655,7 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) { return 0; error: free_config_file_resources(); if (buffer != NULL) { free(buffer); } Loading
src/utils.c +26 −2 Original line number Diff line number Diff line Loading @@ -141,6 +141,30 @@ int32_t parse_config_file(const char* p_config_file) { return 0; } void free_config_file_resources() { if (mac_address != NULL) { free(mac_address); mac_address = NULL; } if (its_nic != NULL) { free(its_nic); its_nic = NULL; } if (udp_nic != NULL) { free(udp_nic); udp_nic = NULL; } if (udp_address != NULL) { free(udp_address); udp_address = NULL; } if (udp_protocol != NULL) { free(udp_protocol); udp_protocol = NULL; } udp_port = 0; } char* bin2hex(char* p_hex, size_t p_hlen, const uint8_t* p_bin, size_t p_blen) { static const char* _hexDigits = "0123456789ABCDEF"; const uint8_t *b, *e; Loading Loading @@ -435,7 +459,7 @@ char** str_split(const char* p_string, const char p_separator) { /* Count how many elements will be extracted */ size_t count = 0; char* current = p_string; char* current = (char*)p_string; char* previous = NULL; while (*current != 0x00) { if (p_separator == *current) { Loading