mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
parent
be63ed4e64
commit
f8cdae3f29
7 changed files with 13 additions and 5 deletions
|
@ -227,6 +227,7 @@ grep 'CONFIG-N:' `find . -type f -name "*.[ch]"`|sed 's/^.*CONFIG-.: *\(.*\)$/|\
|
|||
|network_option|Method of networking between DAWN instances|0 = Broadcast; 2 = Multicast; [2 = TCP with UMDNS discovery]; 3 = TCP w/out UMDNS discovery|
|
||||
|server_ip|IP address when not using UMDNS|No default|
|
||||
|shared_key|Unused|N/A|
|
||||
|tcp_ip|IP address for TCP networking|[0.0.0.0]|
|
||||
|tcp_port|Port for TCP networking|[1026]|
|
||||
|use_symm_enc|Enable encryption of network traffic|[0 = Disabled]; 1 = Enabled|
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ config local
|
|||
config network
|
||||
option broadcast_ip '10.0.0.255'
|
||||
option broadcast_port '1025'
|
||||
option tcp_ip '0.0.0.0'
|
||||
option tcp_port '1026'
|
||||
option network_option '2'
|
||||
option shared_key 'Niiiiiiiiiiiiick'
|
||||
|
|
|
@ -124,6 +124,7 @@ struct network_config_s {
|
|||
char broadcast_ip[MAX_IP_LENGTH + 1];
|
||||
int broadcast_port;
|
||||
char server_ip[MAX_IP_LENGTH + 1];
|
||||
char tcp_ip[MAX_IP_LENGTH + 1];
|
||||
int tcp_port;
|
||||
int network_option; // 0:Broadcast; 1:Multicast; 2:TCP+UMDNS; 3:TCP
|
||||
char shared_key[MAX_KEY_LENGTH + 1];
|
||||
|
|
|
@ -30,7 +30,7 @@ int add_tcp_connection(char *ipv4, int port);
|
|||
* @param port
|
||||
* @return
|
||||
*/
|
||||
int run_server(int port);
|
||||
int run_server(char *ipv4, int port);
|
||||
|
||||
/**
|
||||
* Send message via tcp to all other hosts.
|
||||
|
|
|
@ -247,13 +247,13 @@ static void server_cb(struct uloop_fd *fd, unsigned int events) {
|
|||
dawnlog_info("New connection\n");
|
||||
}
|
||||
|
||||
int run_server(int port) {
|
||||
int run_server(char *ipv4, int port) {
|
||||
dawnlog_debug("Adding socket!\n");
|
||||
char port_str[12];
|
||||
sprintf(port_str, "%d", port); // TODO: Manage buffer length
|
||||
|
||||
server.cb = server_cb;
|
||||
server.fd = usock(USOCK_TCP | USOCK_SERVER | USOCK_IPV4ONLY | USOCK_NUMERIC, INADDR_ANY, port_str);
|
||||
server.fd = usock(USOCK_TCP | USOCK_SERVER | USOCK_IPV4ONLY | USOCK_NUMERIC, ipv4, port_str);
|
||||
if (server.fd < 0) {
|
||||
dawnlog_perror("usock");
|
||||
return 1;
|
||||
|
|
|
@ -382,6 +382,7 @@ struct network_config_s uci_get_dawn_network() {
|
|||
.broadcast_ip = "",
|
||||
.broadcast_port = 1025,
|
||||
.server_ip = "",
|
||||
.tcp_ip = "0.0.0.0",
|
||||
.tcp_port = 1026,
|
||||
.network_option = 2,
|
||||
.shared_key = "Niiiiiiiiiiiiiik",
|
||||
|
@ -424,6 +425,10 @@ struct network_config_s uci_get_dawn_network() {
|
|||
|
||||
// CONFIG-N: network_option|Method of networking between DAWN instances|0 = Broadcast; 2 = Multicast; [2 = TCP with UMDNS discovery]; 3 = TCP w/out UMDNS discovery
|
||||
DAWN_SET_CONFIG_INT(ret, s, network_option);
|
||||
// CONFIG-N: tcp_ip|IP address for TCP networking|[0.0.0.0]
|
||||
const char* str_tcp_ip = uci_lookup_option_string(uci_ctx, s, "tcp_ip");
|
||||
if (str_tcp_ip)
|
||||
strncpy(ret.tcp_ip, str_tcp_ip, MAX_IP_LENGTH);
|
||||
// CONFIG-N: tcp_port|Port for TCP networking|[1025]
|
||||
DAWN_SET_CONFIG_INT(ret, s, tcp_port);
|
||||
// CONFIG-N: use_symm_enc|Enable encryption of network traffic|[0 = Disabled]; 1 = Enabled
|
||||
|
|
|
@ -802,7 +802,7 @@ int dawn_init_ubus(const char *ubus_socket, const char *hostapd_dir) {
|
|||
|| network_config.network_option == 3)
|
||||
{
|
||||
start_tcp_con_update();
|
||||
if(run_server(network_config.tcp_port))
|
||||
if(run_server(network_config.tcp_ip, network_config.tcp_port))
|
||||
uloop_timeout_set(&usock_timer, 1 * 1000);
|
||||
}
|
||||
|
||||
|
@ -1009,7 +1009,7 @@ void update_clients(struct uloop_timeout *t) {
|
|||
void run_server_update(struct uloop_timeout *t) {
|
||||
dawnlog_debug_func("Entering...");
|
||||
|
||||
if(run_server(network_config.tcp_port))
|
||||
if(run_server(network_config.tcp_ip, network_config.tcp_port))
|
||||
uloop_timeout_set(&usock_timer, 1 * 1000);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue