diff options
author | srinivas%netscape.com <devnull@localhost> | 1999-10-06 18:31:22 +0000 |
---|---|---|
committer | srinivas%netscape.com <devnull@localhost> | 1999-10-06 18:31:22 +0000 |
commit | 5165ccc87a2dd960c0176adfb514574c56df0757 (patch) | |
tree | 4601057115c469dbbbd143d16a248c1ed25dcce9 | |
parent | dd2f3e83b5e2dee3da50984c80ce78758b837233 (diff) | |
download | nspr-hg-5165ccc87a2dd960c0176adfb514574c56df0757.tar.gz |
Add the SO_BROADCAST option. Bug #365862.
-rw-r--r-- | pr/include/prio.h | 2 | ||||
-rw-r--r-- | pr/src/io/prmapopt.c | 6 | ||||
-rw-r--r-- | pr/src/pthreads/ptio.c | 2 | ||||
-rw-r--r-- | pr/tests/sockopt.c | 7 |
4 files changed, 15 insertions, 2 deletions
diff --git a/pr/include/prio.h b/pr/include/prio.h index 76575c2b..e893a067 100644 --- a/pr/include/prio.h +++ b/pr/include/prio.h @@ -218,6 +218,7 @@ typedef enum PRSockOption PR_SockOpt_NoDelay, /* don't delay send to coalesce packets */ PR_SockOpt_MaxSegment, /* maximum segment size */ + PR_SockOpt_Broadcast, /* enable broadcast */ PR_SockOpt_Last } PRSockOption; @@ -244,6 +245,7 @@ typedef struct PRSocketOptionData PRBool keep_alive; /* Keep connections alive */ PRBool mcast_loopback; /* IP multicast loopback */ PRBool no_delay; /* Don't delay send to coalesce packets */ + PRBool broadcast; /* Enable broadcast */ PRSize max_segment; /* Maximum segment size */ PRSize recv_buffer_size; /* Receive buffer size */ PRSize send_buffer_size; /* Send buffer size */ diff --git a/pr/src/io/prmapopt.c b/pr/src/io/prmapopt.c index 1d618187..e99ce600 100644 --- a/pr/src/io/prmapopt.c +++ b/pr/src/io/prmapopt.c @@ -92,6 +92,7 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat case PR_SockOpt_Reuseaddr: case PR_SockOpt_Keepalive: case PR_SockOpt_NoDelay: + case PR_SockOpt_Broadcast: { #ifdef WIN32 /* Winsock */ BOOL value; @@ -242,6 +243,7 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt case PR_SockOpt_Reuseaddr: case PR_SockOpt_Keepalive: case PR_SockOpt_NoDelay: + case PR_SockOpt_Broadcast: { #ifdef WIN32 /* Winsock */ BOOL value; @@ -454,14 +456,14 @@ PRStatus _PR_MapOptionName( 0, SO_LINGER, SO_REUSEADDR, SO_KEEPALIVE, SO_RCVBUF, SO_SNDBUF, IP_TTL, IP_TOS, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP, - TCP_NODELAY, TCP_MAXSEG + TCP_NODELAY, TCP_MAXSEG, SO_BROADCAST }; static PRInt32 socketLevels[PR_SockOpt_Last] = { 0, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, - IPPROTO_TCP, IPPROTO_TCP + IPPROTO_TCP, IPPROTO_TCP, SOL_SOCKET }; if ((optname < PR_SockOpt_Linger) diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index eabf762a..01f965cc 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -2639,6 +2639,7 @@ static PRStatus pt_SetSocketOption(PRFileDesc *fd, const PRSocketOptionData *dat rv = setsockopt( fd->secret->md.osfd, level, name, (char*)&ttl, sizeof(ttl)); + case PR_SockOpt_Broadcast: break; } case PR_SockOpt_AddMember: @@ -2757,6 +2758,7 @@ static PRIOMethods _pr_udp_methods = { pt_Connect, (PRAcceptFN)_PR_InvalidDesc, pt_Bind, + case PR_SockOpt_Broadcast: pt_Listen, pt_Shutdown, pt_Recv, diff --git a/pr/tests/sockopt.c b/pr/tests/sockopt.c index 7162960e..6b4907b9 100644 --- a/pr/tests/sockopt.c +++ b/pr/tests/sockopt.c @@ -84,6 +84,7 @@ PRIntn main(PRIntn argc, char *argv) "PR_SockOpt_NoDelay", /* don't delay send to coalesce packets */ "PR_SockOpt_MaxSegment", /* maximum segment size */ + "PR_SockOpt_Broadcast", /* Enable broadcast */ "PR_SockOpt_Last" }; @@ -143,6 +144,8 @@ PRIntn main(PRIntn argc, char *argv) value = &ttl; size = &ttlsize; break; + case PR_SockOpt_Broadcast: + break; case PR_SockOpt_IpTypeOfService: /* type of service and precedence */ case PR_SockOpt_AddMember: /* add an IP group membership */ case PR_SockOpt_DropMember: /* drop an IP group membership */ @@ -218,6 +221,10 @@ PRIntn main(PRIntn argc, char *argv) data.value.max_segment = segment; break; #endif + case PR_SockOpt_Broadcast: + fd = udp; + data.value.broadcast = PR_TRUE; + break; default: continue; } |