X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_setup.c;h=c4f2127ec0dee48bfe9a4f79c8ee48cfb35aef60;hb=fcf5b53e785fd191dd951b77ad831fe6ac78dce4;hp=0a97e03ff55284c4c48f5c6f0a33b0d82cea1038;hpb=415910897122da0073a862784d148802ca390020;p=tinc diff --git a/src/net_setup.c b/src/net_setup.c index 0a97e03f..c4f2127e 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -586,6 +586,20 @@ bool setup_myself_reloadable(void) { free(bmode); } + const char* const DEFAULT_BROADCAST_SUBNETS[] = { "ff:ff:ff:ff:ff:ff", "255.255.255.255", "224.0.0.0/4", "ff00::/8" }; + for (size_t i = 0; i < sizeof(DEFAULT_BROADCAST_SUBNETS) / sizeof(*DEFAULT_BROADCAST_SUBNETS); i++) { + subnet_t *s = new_subnet(); + if (!str2net(s, DEFAULT_BROADCAST_SUBNETS[i])) + abort(); + subnet_add(NULL, s); + } + for (config_t* cfg = lookup_config(config_tree, "BroadcastSubnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { + subnet_t *s; + if (!get_config_subnet(cfg, &s)) + continue; + subnet_add(NULL, s); + } + #if !defined(SOL_IP) || !defined(IP_TOS) if(priorityinheritance) logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "PriorityInheritance"); @@ -1023,7 +1037,7 @@ static bool setup_myself(void) { /* If no Port option was specified, set myport to the port used by the first listening socket. */ - if(!port_specified) { + if(!port_specified || atoi(myport) == 0) { sockaddr_t sa; socklen_t salen = sizeof sa; if(!getsockname(listen_socket[0].udp.fd, &sa.sa, &salen)) {