From db63260758ad795d619073e41f273184ab629bbc Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 17 Jul 2012 15:48:53 -0700 Subject: Set the SO_BROADCAST option if the master election endpoint is the broadcast address Change-Id: I75b3815be73744b99a4bea52916984de76634e7e --- services/common_time/common_time_server.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'services/common_time') diff --git a/services/common_time/common_time_server.cpp b/services/common_time/common_time_server.cpp index 4e5d16e..0125709 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) { + ALOGE("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. -- cgit v1.1