X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=config.cpp;h=cf32c24ae81edb73187ccf883ca61f02648828b4;hp=4a3dfb3122a7061a65fb49d2ffbfcc36c3d9037d;hb=07569f8e011cd9b064c64bef1ce56f77bf7ddf53;hpb=5cc8cd703a637e276c2595953878fd9561592bfa diff --git a/config.cpp b/config.cpp index 4a3dfb3..cf32c24 100644 --- a/config.cpp +++ b/config.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -132,7 +133,10 @@ bool read_config(const string &filename, vector *lines) lines->push_back(line); } - fclose(fp); + if (fclose(fp) == EOF) { + log_perror(filename.c_str()); + return false; + } return true; } @@ -184,7 +188,7 @@ bool parse_port(const ConfigLine &line, Config *config) } AcceptorConfig acceptor; - acceptor.addr = CreateAnyAddress(port); + acceptor.addr = create_any_address(port); config->acceptors.push_back(acceptor); return true; @@ -287,6 +291,26 @@ bool parse_udpstream(const ConfigLine &line, Config *config) udpstream.pacing_rate = atoi(pacing_rate_it->second.c_str()) * 1024 / 8; } + // Parse the TTL. The same value is used for unicast and multicast. + map::const_iterator ttl_it = line.parameters.find("ttl"); + if (ttl_it == line.parameters.end()) { + udpstream.ttl = -1; + } else { + udpstream.ttl = atoi(ttl_it->second.c_str()); + } + + // Parse the multicast interface index. + map::const_iterator multicast_iface_it = line.parameters.find("multicast_output_interface"); + if (multicast_iface_it == line.parameters.end()) { + udpstream.multicast_iface_index = -1; + } else { + udpstream.multicast_iface_index = if_nametoindex(multicast_iface_it->second.c_str()); + if (udpstream.multicast_iface_index == 0) { + log(ERROR, "Interface '%s' does not exist", multicast_iface_it->second.c_str()); + return false; + } + } + config->udpstreams.push_back(udpstream); return true; }