Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|

Expand Down
1 change: 1 addition & 0 deletions dawn-config
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions src/include/datastorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/include/tcpsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/network/tcpsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/utils/dawn_uci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down