1 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/app/utils/EpollTask.hpp" 5 #include "hmbdc/app/Config.hpp" 6 #include "hmbdc/text/StringTrieSet.hpp" 7 #include "hmbdc/comm/inet/Misc.hpp" 8 #include "hmbdc/time/Timers.hpp" 12 #include <sys/types.h> 13 #include <sys/socket.h> 14 #include <netinet/ip.h> 15 #include <arpa/inet.h> 17 namespace hmbdc {
namespace app {
namespace mcast {
22 fd = socket(AF_INET, SOCK_DGRAM, 0);
24 HMBDC_THROW(runtime_error,
"failed to create socket");
26 struct in_addr localInterface;
27 memset(&mcAddr, 0,
sizeof(mcAddr));
28 mcAddr.sin_family = AF_INET;
29 mcAddr.sin_addr.s_addr = inet_addr(cfg.
getExt<
string>(
"mcastAddr").c_str());
30 mcAddr.sin_port = htons(cfg.
getExt<
short>(
"mcastPort"));
32 comm::inet::getLocalIpMatchMask(cfg.
getExt<
string>(
"ifaceAddr"));
33 localInterface.s_addr = inet_addr(iface.c_str());
34 if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF
35 , (
char *)&localInterface,
sizeof(localInterface)) < 0) {
36 HMBDC_THROW(runtime_error,
"failed to set ifaceAddr " << cfg.
getExt<
string>(
"ifaceAddr"));
40 struct sockaddr_in mcAddr;
44 using ptr = std::shared_ptr<Transport>;
49 , mtu_(config_.getExt<
size_t>(
"mtu")) {
51 cfg (hmbdcName_,
"hmbdcName")
52 (schedPolicy_,
"schedPolicy")
53 (schedPriority_,
"schedPriority")
57 char const* hmbdcName()
const {
58 return this->hmbdcName_.c_str();
61 std::tuple<char const*, int> schedSpec()
const {
62 return std::make_tuple(this->schedPolicy_.c_str(), this->schedPriority_);
65 bool operator == (
Transport const& other )
const {
66 return &config_ == &other.config_;
69 bool operator < (
Transport const& other )
const {
70 return &config_ < &other.config_;
74 std::string hmbdcName_;
75 std::string schedPolicy_;
class to hold an hmbdc configuration
Definition: Config.hpp:44
T getExt(const path_type ¶m) const
get a value from the config
Definition: Config.hpp:154
Definition: TypedString.hpp:74
Definition: EpollTask.hpp:31
Definition: Transport.hpp:19
Definition: Transport.hpp:43