summaryrefslogtreecommitdiff
path: root/lib/dgram.js
diff options
context:
space:
mode:
authorLucas Pardue <lucas.pardue@bbc.co.uk>2017-10-02 13:20:52 +0100
committerAnna Henningsen <anna@addaleax.net>2019-10-17 03:12:53 +0200
commit1784b7fafac2755f870db3de9eb45a754b7a6477 (patch)
tree670a84f1ba0c508578efa5254d1960d8bfe36cce /lib/dgram.js
parent273d38b1980fe308583c430eaeb837b8e6b3d204 (diff)
downloadandroid-node-v8-1784b7fafac2755f870db3de9eb45a754b7a6477.tar.gz
android-node-v8-1784b7fafac2755f870db3de9eb45a754b7a6477.tar.bz2
android-node-v8-1784b7fafac2755f870db3de9eb45a754b7a6477.zip
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 <rtrott@gmail.com> PR-URL: https://github.com/nodejs/node/pull/15735 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/dgram.js')
-rw-r--r--lib/dgram.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/dgram.js b/lib/dgram.js
index cc61d4d274..d29d1e7b19 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -832,6 +832,55 @@ Socket.prototype.dropMembership = function(multicastAddress,
}
};
+Socket.prototype.addSourceSpecificMembership = function(sourceAddress,
+ groupAddress,
+ interfaceAddress) {
+ healthCheck(this);
+
+ if (typeof sourceAddress !== 'string') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'sourceAddress',
+ 'string');
+ }
+
+ if (typeof groupAddress !== 'string') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'groupAddress',
+ 'string');
+ }
+
+ const err =
+ this[kStateSymbol].handle.addSourceSpecificMembership(sourceAddress,
+ groupAddress,
+ interfaceAddress);
+ if (err) {
+ throw errnoException(err, 'addSourceSpecificMembership');
+ }
+};
+
+
+Socket.prototype.dropSourceSpecificMembership = function(sourceAddress,
+ groupAddress,
+ interfaceAddress) {
+ healthCheck(this);
+
+ if (typeof sourceAddress !== 'string') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'sourceAddress',
+ 'string');
+ }
+
+ if (typeof groupAddress !== 'string') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'groupAddress',
+ 'string');
+ }
+
+ const err =
+ this[kStateSymbol].handle.dropSourceSpecificMembership(sourceAddress,
+ groupAddress,
+ interfaceAddress);
+ if (err) {
+ throw errnoException(err, 'dropSourceSpecificMembership');
+ }
+};
+
function healthCheck(socket) {
if (!socket[kStateSymbol].handle) {