tcpsocket: add option to add server ip

A new config option allows to add a server ip
	option server_ip '10.0.0.2'

However, this server does not send anything back. Therefore it is not
possible to change the node configuration. This will probably be added
soon. The main goal of this commit is to allow monitoring of all nodes
in a network with DAWN, e.g. clients, channel utilization, ...

Also a network option (3) has been added which allows to use TCP but
not to announce your daemon in the broadcast domain. This allows you to
create a monitor-only node that holds only the local information and
forwards it to the central server.

A monitor-only node could be configured like
	option server_ip '10.0.0.1'
	option tcp_port '1026'
	option network_option '3'

Another possible config is
        option server_ip '10.0.0.1'
        option tcp_port '1026'
        option network_option '3'
Here, the node shares information with a central server, which can be
located outside the broadcast domain. Nevertheless, it also shares
information within its broadcast domain and can therefore perform
client steering.
This commit is contained in:
Polynomialdivision 2020-08-21 20:23:20 +02:00
parent 1da5ad5a96
commit 25a493c438
4 changed files with 26 additions and 9 deletions

View file

@ -97,6 +97,7 @@ struct time_config_s {
struct network_config_s {
char broadcast_ip[MAX_IP_LENGTH];
int broadcast_port;
char server_ip[MAX_IP_LENGTH];
int tcp_port;
int network_option;
char shared_key[MAX_KEY_LENGTH];

View file

@ -29,7 +29,7 @@ int dawn_init_ubus(const char *ubus_socket, const char *hostapd_dir);
/**
* Start the umdns timer for updating the zeroconfiguration properties.
*/
void start_umdns_update();
void start_tcp_con_update();
/**
* Call umdns update to update the TCP connections.

View file

@ -138,6 +138,12 @@ struct network_config_s uci_get_dawn_network() {
const char* str_broadcast = uci_lookup_option_string(uci_ctx, s, "broadcast_ip");
strncpy(ret.broadcast_ip, str_broadcast, MAX_IP_LENGTH);
const char* str_server_ip = uci_lookup_option_string(uci_ctx, s, "server_ip");
if(str_server_ip)
strncpy(ret.server_ip, str_server_ip, MAX_IP_LENGTH);
else
ret.server_ip[0] = '\0';
ret.broadcast_port = uci_lookup_option_int(uci_ctx, s, "broadcast_port");
const char* str_shared_key = uci_lookup_option_string(uci_ctx, s, "shared_key");

View file

@ -45,7 +45,7 @@ struct uloop_timeout client_timer = {
struct uloop_timeout hostapd_timer = {
.cb = update_hostapd_sockets
};
struct uloop_timeout umdns_timer = {
struct uloop_timeout tcp_con_timer = {
.cb = update_tcp_connections
};
struct uloop_timeout channel_utilization_timer = {
@ -529,7 +529,8 @@ int send_blob_attr_via_network(struct blob_attr* msg, char* method) {
str = blobmsg_format_json(b_send_network.head, true);
dawn_regmem(str);
if (network_config.network_option == 2) {
if (network_config.network_option == 2
|| network_config.network_option == 3) {
send_tcp(str);
} else {
if (network_config.use_symm_enc) {
@ -618,9 +619,10 @@ int dawn_init_ubus(const char *ubus_socket, const char *hostapd_dir) {
ubus_add_oject();
if (network_config.network_option == 2)
if (network_config.network_option == 2
|| network_config.network_option == 3)
{
start_umdns_update();
start_tcp_con_update();
if(run_server(network_config.tcp_port))
uloop_timeout_set(&usock_timer, 1 * 1000);
}
@ -825,13 +827,21 @@ void update_beacon_reports(struct uloop_timeout *t) {
}
void update_tcp_connections(struct uloop_timeout *t) {
ubus_call_umdns();
uloop_timeout_set(&umdns_timer, timeout_config.update_tcp_con * 1000);
if (strcmp(network_config.server_ip, ""))
{
// nothing happens if tcp connection is already established
add_tcp_conncection(network_config.server_ip, network_config.tcp_port);
}
if (network_config.network_option == 2) // mdns enabled?
{
ubus_call_umdns();
}
uloop_timeout_set(&tcp_con_timer, timeout_config.update_tcp_con * 1000);
}
void start_umdns_update() {
void start_tcp_con_update() {
// update connections
uloop_timeout_add(&umdns_timer); // callback = update_tcp_connections
uloop_timeout_add(&tcp_con_timer); // callback = update_tcp_connections
}
void update_hostapd_sockets(struct uloop_timeout *t) {