diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-10-27 14:43:24 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-10-29 01:10:06 +0100 |
commit | ed197fd4f923512fca5b93b90c2132845896fa59 (patch) | |
tree | 26d80bb2798387ac77280f5a87326d26aada5b1c /src/stats.c | |
parent | 4aa11770622ae9009074d68cc8c340821b19adf3 (diff) |
stats: Make net config optional
To support reporters without network configuration, this commit
introduces the have_net_config flag to provide corresponding error
messages.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/stats.c')
-rw-r--r-- | src/stats.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/stats.c b/src/stats.c index 8faed89a..6189cb38 100644 --- a/src/stats.c +++ b/src/stats.c @@ -166,6 +166,9 @@ int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->dest_addr; struct in_addr inaddr; + if (!srep->have_net_config) + return -ENOTSUP; + OSMO_ASSERT(addr != NULL); rc = inet_pton(AF_INET, addr, &inaddr); @@ -186,6 +189,9 @@ int stats_reporter_set_remote_port(struct stats_reporter *srep, int port) { struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->dest_addr; + if (!srep->have_net_config) + return -ENOTSUP; + srep->dest_port = port; sock_addr->sin_port = htons(port); @@ -198,6 +204,9 @@ int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr) struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->bind_addr; struct in_addr inaddr; + if (!srep->have_net_config) + return -ENOTSUP; + if (addr) { rc = inet_pton(AF_INET, addr, &inaddr); if (rc <= 0) @@ -218,6 +227,9 @@ int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr) int stats_reporter_set_mtu(struct stats_reporter *srep, int mtu) { + if (!srep->have_net_config) + return -ENOTSUP; + if (mtu < 0) return -EINVAL; @@ -296,6 +308,8 @@ struct stats_reporter *stats_reporter_create_statsd(const char *name) struct stats_reporter *srep; srep = stats_reporter_alloc(STATS_REPORTER_STATSD, name); + srep->have_net_config = 1; + return srep; } |