diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-02-01 04:25:08 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-02-01 04:25:08 +0100 |
commit | af8fb6c3210f3c3923cdfe8660687f8a330dd6b2 (patch) | |
tree | 4657e9a399c3531727d7902e97d083fee65f198b | |
parent | fdff20e96d7198124542e6d03c27e1d496c4b328 (diff) | |
download | dabmod-af8fb6c3210f3c3923cdfe8660687f8a330dd6b2.tar.gz dabmod-af8fb6c3210f3c3923cdfe8660687f8a330dd6b2.tar.bz2 dabmod-af8fb6c3210f3c3923cdfe8660687f8a330dd6b2.zip |
Code cosmetics and udp multicast documentation
-rw-r--r-- | doc/example.ini | 20 | ||||
-rw-r--r-- | lib/UdpSocket.cpp | 5 | ||||
-rw-r--r-- | src/EtiReader.cpp | 22 |
3 files changed, 33 insertions, 14 deletions
diff --git a/doc/example.ini b/doc/example.ini index 098765e..7fa0721 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -39,13 +39,27 @@ loop=0 ;max_frames_queued=100 ; EDI input. -; Listen for EDI data on a given UDP port +; Listen for EDI data on a given UDP port, unicast or multicast. ;transport=edi -;source=udp://:12002 +; +; Supported syntax for the source setting: +; Bind to default interface and receive data from port 12000 +;source=udp://:12000 +; +; Bind to interface with IP:192.168.1.22 and receive data from port 12000 +;source=udp://192.168.1.22:12000 +; +; Bind to interface with IP:192.168.1.22 and join multicast group: +; 239.100.101.22 and receive data from port 12000 +;source=udp://192.168.1.22@239.100.101.22:12000 +; +; Bind to default interafce (which routes to multicast) and join multicast +; group: 239.100.101.22 and receive data from port 12000 +;source=udp://@239.100.101.22:12000 +; ; Maximum delay in milliseconds that the EDI input is willing to wait ; before it timeouts ;edi_max_delay=240 -; No support yet for multicast, should work with and without PFT ; This EDI implementation does not support EDI Packet Resend diff --git a/lib/UdpSocket.cpp b/lib/UdpSocket.cpp index 7c99724..7645eaf 100644 --- a/lib/UdpSocket.cpp +++ b/lib/UdpSocket.cpp @@ -290,11 +290,12 @@ void UdpReceiver::m_run() private: atomic<bool>& m_stop; } autoSetStop(m_stop); - if(IN_MULTICAST(ntohl(inet_addr(m_mcastaddr.c_str())))){ + if (IN_MULTICAST(ntohl(inet_addr(m_mcastaddr.c_str())))) { m_sock.reinit(m_port, m_mcastaddr); m_sock.setMulticastSource(m_bindto.c_str()); m_sock.joinGroup(m_mcastaddr.c_str(), m_bindto.c_str()); - } else { + } + else { m_sock.reinit(m_port, m_bindto); } diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index 499e837..d1c7110 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -543,21 +543,25 @@ void EdiUdpInput::Open(const std::string& uri) { etiLog.level(info) << "Opening EDI :" << uri; size_t found_port = uri.find_first_of(":", 6); - if(found_port == string::npos) + if (found_port == string::npos) { throw std::invalid_argument("EDI input port must be provided"); + } - m_port =std::stoi(uri.substr(found_port+1)); - std::string host_full=uri.substr(6, found_port-6);// ignore udp:// + m_port = std::stoi(uri.substr(found_port+1)); + std::string host_full = uri.substr(6, found_port-6);// ignore udp:// size_t found_mcast = host_full.find_first_of("@"); //have multicast address: - if(found_mcast != string::npos) { - if(found_mcast>0) - m_bindto=host_full.substr(0,found_mcast); - m_mcastaddr=host_full.substr(found_mcast+1); - } else if(found_port != 6) { + if (found_mcast != string::npos) { + if (found_mcast > 0) { + m_bindto = host_full.substr(0, found_mcast); + } + m_mcastaddr = host_full.substr(found_mcast+1); + } + else if (found_port != 6) { m_bindto=host_full; } - etiLog.level(info) << "EDI input: host:" << m_bindto << ", source:" << m_mcastaddr << ", port:" << m_port; + etiLog.level(info) << "EDI input: host:" << m_bindto << + ", source:" << m_mcastaddr << ", port:" << m_port; // The max_fragments_queued is only a protection against a runaway // memory usage. |