From ccf12f76d67a8c0a2c84672d823b5744e77bc178 Mon Sep 17 00:00:00 2001 From: Lucas Pardue Date: Mon, 2 Oct 2017 13:20:52 +0100 Subject: [PATCH] dgram: add source-specific multicast support This adds RFC 4607 support for IPv4 and IPv6. Co-Authored-By: Nicolas Thumann <46975855+n-thumann@users.noreply.github.com> Co-Authored-By: Rich Trott PR-URL: https://github.com/nodejs/node/pull/15735 Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/dgram.md | 33 +++ lib/dgram.js | 49 ++++ src/udp_wrap.cc | 42 ++++ src/udp_wrap.h | 7 + .../test-dgram-multicast-ssm-multi-process.js | 229 ++++++++++++++++++ ...est-dgram-multicast-ssmv6-multi-process.js | 229 ++++++++++++++++++ 6 files changed, 589 insertions(+) create mode 100644 test/internet/test-dgram-multicast-ssm-multi-process.js create mode 100644 test/internet/test-dgram-multicast-ssmv6-multi-process.js diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 9efd14c89e00d7..894f64f36e135f 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -123,6 +123,21 @@ if (cluster.isMaster) { } ``` +### socket.addSourceSpecificMembership(sourceAddress, groupAddress\[, multicastInterface\]) + +* `sourceAddress` {string} +* `groupAddress` {string} +* `multicastInterface` {string} + +Tells the kernel to join a source-specific multicast channel at the given +`sourceAddress` and `groupAddress`, using the `multicastInterface` with the +`IP_ADD_SOURCE_MEMBERSHIP` socket option. If the `multicastInterface` argument +is not specified, the operating system will choose one interface and will add +membership to it. To add membership to every available interface, call +`socket.addSourceSpecificMembership()` multiple times, once per interface. + ### socket.address() + +* `sourceAddress` {string} +* `groupAddress` {string} +* `multicastInterface` {string} + +Instructs the kernel to leave a source-specific multicast channel at the given +`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP` +socket option. This method is automatically called by the kernel when the +socket is closed or the process terminates, so most apps will never have +reason to call this. + +If `multicastInterface` is not specified, the operating system will attempt to +drop membership on all valid interfaces. + ### socket.getRecvBufferSize()