summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jason Simmons <jsimmons@google.com> 2012-07-17 15:48:53 -0700
committer Jason Simmons <jsimmons@google.com> 2012-07-17 16:07:07 -0700
commit2da0bbc80545769541e2a24e8ce152f0ea2a113c (patch)
tree20f6f6852f35786b10d680b1dc0f097626ad99fd
parent194f6bc7ceac43884f62c2481f5c8d76db9320c5 (diff)
DO NOT MERGE - Set the SO_BROADCAST option if the master election endpoint is the broadcast address
Change-Id: I76aa9df717ee5ca32859e21c7e25635b44739c75
-rw-r--r--services/common_time/common_time_server.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/services/common_time/common_time_server.cpp b/services/common_time/common_time_server.cpp
index faf1b5fc71ab..75df85e9f449 100644
--- a/services/common_time/common_time_server.cpp
+++ b/services/common_time/common_time_server.cpp
@@ -487,7 +487,16 @@ bool CommonTimeServer::setupSocket_l() {
goto bailout;
}
} else
- if (ntohl(ipv4_addr->sin_addr.s_addr) != 0xFFFFFFFF) {
+ if (ntohl(ipv4_addr->sin_addr.s_addr) == 0xFFFFFFFF) {
+ // If the master election address is the broadcast address, then enable
+ // the broadcast socket option
+ const int one = 1;
+ rc = setsockopt(mSocket, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one));
+ if (rc == -1) {
+ LOGE("Failed to enable broadcast (errno = %d)", errno);
+ goto bailout;
+ }
+ } else {
// If the master election address is neither broadcast, nor multicast,
// then we are misconfigured. The config API layer should prevent this
// from ever happening.