|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
33 #include <sys/ioctl.h>
35 #if defined(__linux__)
36 #include <netpacket/packet.h>
37 #include <sys/socket.h>
41 #if defined(__APPLE__) || defined(__FreeBSD__)
42 #include <net/if_dl.h>
55 #if defined(__linux__)
56 , m_interfaceIndex(localEndpoint.getIndex())
73 snprintf(filter,
sizeof(filter),
74 "(ether proto 0x%x) && (ether dst %s) && (not ether src %s) && (not vlan)",
86 MulticastEthernetTransport::joinMulticastGroup()
88 #if defined(__linux__)
90 mr.mr_ifindex = m_interfaceIndex;
91 mr.mr_type = PACKET_MR_MULTICAST;
95 if (::setsockopt(
m_socket.native_handle(), SOL_PACKET,
96 PACKET_ADD_MEMBERSHIP, &mr,
sizeof(mr)) == 0)
99 NFD_LOG_FACE_WARN(
"setsockopt(PACKET_ADD_MEMBERSHIP) failed: " << std::strerror(errno));
102 #if defined(SIOCADDMULTI)
104 std::strncpy(ifr.ifr_name,
m_interfaceName.data(),
sizeof(ifr.ifr_name) - 1);
106 #if defined(__APPLE__) || defined(__FreeBSD__)
108 using boost::asio::ip::udp;
110 int fd = sock.native_handle();
123 sockaddr_dl* sdl =
reinterpret_cast<sockaddr_dl*
>(&ifr.ifr_addr);
124 sdl->sdl_len =
sizeof(ifr.ifr_addr);
125 sdl->sdl_family = AF_LINK;
129 static_assert(
sizeof(ifr.ifr_addr) >= offsetof(sockaddr_dl, sdl_data) +
ethernet::ADDR_LEN,
130 "ifr_addr in struct ifreq is too small on this platform");
134 ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
138 "ifr_hwaddr in struct ifreq is too small on this platform");
141 if (::ioctl(fd, SIOCADDMULTI, &ifr) == 0)
147 NDN_THROW(Error(
"Failed to join multicast group"));
bool isBroadcast() const
True if this is a broadcast address (ff:ff:ff:ff:ff:ff)
boost::asio::posix::stream_descriptor m_socket
@ FACE_SCOPE_NON_LOCAL
face is non-local
void setRemoteUri(const FaceUri &uri)
ethernet::Address m_destAddress
Represents one network interface attached to the host.
represents the underlying protocol and address used by a Face
@ FACE_PERSISTENCY_PERMANENT
face is permanent
represents an Ethernet hardware address
void setScope(ndn::nfd::FaceScope scope)
const uint16_t ETHERTYPE_NDN
ethernet::Address m_srcAddress
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
detail::SimulatorIo & getGlobalIoService()
Returns the global io_service instance for the calling thread.
Copyright (c) 2011-2015 Regents of the University of California.
static FaceUri fromDev(const std::string &ifname)
create dev FaceUri from network device name
A multicast Transport that uses raw Ethernet II frames.
void setLinkType(ndn::nfd::LinkType linkType)
uint32_t getMtu() const
Returns the MTU (maximum transmission unit) of the interface.
std::string toString(char sep=':') const
Converts the address to a human-readable string.
Base class for Ethernet-based Transports.
const size_t ADDR_LEN
Octets in one Ethernet address.
std::string m_interfaceName
void setPersistency(ndn::nfd::FacePersistency newPersistency)
changes face persistency setting
MulticastEthernetTransport(const ndn::net::NetworkInterface &localEndpoint, const ethernet::Address &mcastAddress, ndn::nfd::LinkType linkType)
Creates an Ethernet-based transport for multicast communication.
void setPacketFilter(const char *filter) const
Install a BPF filter on the receiving socket.
bool isMulticast() const
True if this is a multicast address.
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
#define NFD_LOG_INIT(name)
void setLocalUri(const FaceUri &uri)