Kea  1.9.9-git
pkt_filter6.cc
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
8 
9 #include <dhcp/pkt_filter6.h>
10 
11 namespace isc {
12 namespace dhcp {
13 
14 bool
15 PktFilter6::joinMulticast(int sock, const std::string& ifname,
16  const std::string & mcast) {
17 
18  struct ipv6_mreq mreq;
19  memset(&mreq, 0, sizeof(ipv6_mreq));
20 
21  // Convert the multicast address to a binary form.
22  if (inet_pton(AF_INET6, mcast.c_str(), &mreq.ipv6mr_multiaddr) <= 0) {
23  return (false);
24  }
25  // Set the interface being used.
26  mreq.ipv6mr_interface = if_nametoindex(ifname.c_str());
27  // Join the multicast group.
28  if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
29  &mreq, sizeof(mreq)) < 0) {
30  return (false);
31  }
32 
33  return (true);
34 }
35 
36 
37 } // end of isc::dhcp namespace
38 } // end of isc namespace
static bool joinMulticast(int sock, const std::string &ifname, const std::string &mcast)
Joins IPv6 multicast group on a socket.
Definition: pkt_filter6.cc:15
Defines the logger used by the top-level component of kea-dhcp-ddns.