This ticket adds support for NAT in DTM. --- src/dtm/dtmnd/dtm_cb.h | 1 + src/dtm/dtmnd/dtm_main.cc | 5 +++-- src/dtm/dtmnd/dtm_read_config.cc | 10 ++++++++++ src/dtm/dtmnd/dtmd.conf | 4 ++++ src/dtm/dtmnd/multicast.cc | 5 ++++- src/dtm/dtmnd/multicast.h | 4 +++- 6 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/dtm/dtmnd/dtm_cb.h b/src/dtm/dtmnd/dtm_cb.h index a78249919..5aabd2ba9 100644 --- a/src/dtm/dtmnd/dtm_cb.h +++ b/src/dtm/dtmnd/dtm_cb.h @@ -74,6 +74,7 @@ class DTM_INTERNODE_CB { NODE_ID node_id; // Self Node Id char node_name[_POSIX_HOST_NAME_MAX]; // optional std::string ip_addr; // ipv4 ipv6 addrBuffer + std::string public_ip; // ipv4 ipv6 addrBuffer std::string mcast_addr; // ipv4 ipv6 addrBuffer std::string bcast_addr; std::string ifname; // ipv6mr_interface to diff --git a/src/dtm/dtmnd/dtm_main.cc b/src/dtm/dtmnd/dtm_main.cc index 04230165d..46dd2e0ed 100644 --- a/src/dtm/dtmnd/dtm_main.cc +++ b/src/dtm/dtmnd/dtm_main.cc @@ -83,6 +83,7 @@ DTM_INTERNODE_CB::DTM_INTERNODE_CB() node_id{}, node_name{}, ip_addr{}, + public_ip{}, mcast_addr{}, bcast_addr{}, ifname{}, @@ -268,8 +269,8 @@ int main(int argc, char *argv[]) { dtms_cb->multicast_ = new Multicast{ dtms_cb->cluster_id, dtms_cb->node_id, dtms_cb->stream_port, dtms_cb->dgram_port_rcvr, dtms_cb->i_addr_family, dtms_cb->ip_addr, - dtms_cb->bcast_addr, dtms_cb->mcast_addr, dtms_cb->ifname, - dtms_cb->scope_link}; + dtms_cb->public_ip, dtms_cb->bcast_addr, dtms_cb->mcast_addr, + dtms_cb->ifname, dtms_cb->scope_link}; if (dtms_cb->multicast_ == nullptr || dtms_cb->multicast_->fd() < 0) { LOG_ER("Failed to initialize Multicast instance"); goto done3; diff --git a/src/dtm/dtmnd/dtm_read_config.cc b/src/dtm/dtmnd/dtm_read_config.cc index 6f0045af1..5424be367 100644 --- a/src/dtm/dtmnd/dtm_read_config.cc +++ b/src/dtm/dtmnd/dtm_read_config.cc @@ -84,6 +84,8 @@ void dtm_print_config(DTM_INTERNODE_CB *config) { TRACE(" %d", config->node_id); TRACE(" IP_ADDR: "); TRACE(" %s", config->ip_addr.c_str()); + TRACE(" PUBLIC_IP_ADDR: "); + TRACE(" %s", config->public_ip.c_str()); TRACE(" STREAM_PORT: "); TRACE(" %u", config->stream_port); TRACE(" DGRAM_PORT_SNDR: "); @@ -335,6 +337,14 @@ int dtm_read_config(DTM_INTERNODE_CB *config, const char *dtm_config_file) { tag = 0; tag_len = 0; } + + if (strncmp(line, "DTM_PUBLIC_IP=", strlen("DTM_PUBLIC_IP=")) == 0) { + tag_len = strlen("DTM_PUBLIC_IP="); + config->public_ip = std::string(&line[tag_len]); + tag = 0; + tag_len = 0; + } + if (strncmp(line, "DTM_TCP_LISTENING_PORT=", strlen("DTM_TCP_LISTENING_PORT=")) == 0) { tag_len = strlen("DTM_TCP_LISTENING_PORT="); diff --git a/src/dtm/dtmnd/dtmd.conf b/src/dtm/dtmnd/dtmd.conf index a69414e14..4c1c58f8d 100644 --- a/src/dtm/dtmnd/dtmd.conf +++ b/src/dtm/dtmnd/dtmd.conf @@ -56,6 +56,10 @@ DTM_NODE_IP=10.130.100.114 #DTM_MCAST_ADDR=dns:peers.opensaf.org DTM_MCAST_ADDR= +# If using NAT, this is the public IP remote nodes should send to to reach +# this node. If blank, it defaults to DTM_NODE_IP. +DTM_PUBLIC_IP= + # tcp_listening_port: The TCP port that the DTMSv listens on # Mandatory DTM_TCP_LISTENING_PORT=6700 diff --git a/src/dtm/dtmnd/multicast.cc b/src/dtm/dtmnd/multicast.cc index 9752a01c9..ed5079d08 100644 --- a/src/dtm/dtmnd/multicast.cc +++ b/src/dtm/dtmnd/multicast.cc @@ -34,6 +34,7 @@ Multicast::Multicast(uint16_t cluster_id, uint32_t node_id, in_port_t stream_port, in_port_t dgram_port, sa_family_t address_family, const std::string &stream_address, + const std::string &public_address, const std::string &dgram_address, const std::string &multicast_address, const std::string &ifname, bool scope_link) @@ -43,6 +44,7 @@ Multicast::Multicast(uint16_t cluster_id, uint32_t node_id, dgram_port_{dgram_port}, address_family_{address_family}, stream_address_{stream_address}, + public_address_{public_address}, dgram_address_{dgram_address}, multicast_address_{multicast_address}, ifname_{ifname}, @@ -788,7 +790,8 @@ uint32_t Multicast::dgram_set_mcast_ttl(int mcast_ttl, int family) { bool Multicast::Send() { TRACE_ENTER(); Message msg{cluster_id_, node_id_, !multicast_address_.empty(), - stream_port_, address_family_, stream_address_}; + stream_port_, address_family_, + !public_address_.empty() ? public_address_ : stream_address_}; bool success = true; for (const auto &addr : peers_) { ssize_t num_bytes; diff --git a/src/dtm/dtmnd/multicast.h b/src/dtm/dtmnd/multicast.h index 94078cac8..d93d182de 100644 --- a/src/dtm/dtmnd/multicast.h +++ b/src/dtm/dtmnd/multicast.h @@ -48,7 +48,8 @@ class Multicast { // parameters. Multicast(uint16_t cluster_id, uint32_t node_id, in_port_t stream_port, in_port_t dgram_port, sa_family_t address_family, - const std::string& stream_address, const std::string& dgram_address, + const std::string& stream_address, + const std::string& public_address, const std::string& dgram_address, const std::string& multicast_address, const std::string& ifname, bool scope_link); ~Multicast(); @@ -133,6 +134,7 @@ class Multicast { in_port_t dgram_port_; sa_family_t address_family_; std::string stream_address_; + std::string public_address_; std::string dgram_address_; std::string multicast_address_; std::string ifname_; -- 2.20.1 ----------------------------------------------------------------------------------------------------------------------- Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments. ----------------------------------------------------------------------------------------------------------------------- _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel