diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-18 11:01:41 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-10-18 11:01:41 -0400 |
| commit | b10871cedcdaa6f18779fcebcc889cdd35df546b (patch) | |
| tree | 4d36574c7e4f392c640256fdcd3a0a8e4d130d3d /node/MulticastGroup.hpp | |
| parent | 9f107dbd4eefdb4e5427f15e844aefbd573a6465 (diff) | |
| download | infinitytier-b10871cedcdaa6f18779fcebcc889cdd35df546b.tar.gz infinitytier-b10871cedcdaa6f18779fcebcc889cdd35df546b.zip | |
More work in netconf cleanup.
Diffstat (limited to 'node/MulticastGroup.hpp')
| -rw-r--r-- | node/MulticastGroup.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/node/MulticastGroup.hpp b/node/MulticastGroup.hpp index bb025ab1..426ef048 100644 --- a/node/MulticastGroup.hpp +++ b/node/MulticastGroup.hpp @@ -69,6 +69,16 @@ public: { } + MulticastGroup(const char *s) + { + fromString(s); + } + + MulticastGroup(const std::string &s) + { + fromString(s.c_str()); + } + /** * Derive the multicast group used for address resolution (ARP/NDP) for an IP * @@ -113,6 +123,24 @@ public: } /** + * Parse a human-readable multicast group + * + * @param s Multicast group in hex MAC/ADI format + */ + inline void fromString(const char *s) + { + char hex[17]; + unsigned int hexlen = 0; + while ((*s)&&(*s != '/')&&(hexlen < sizeof(hex) - 1)) + hex[hexlen++] = *s; + hex[hexlen] = (char)0; + _mac.fromString(hex); + if (*s == '/') + _adi = (uint32_t)Utils::hexStrToULong(++s); + else _adi = 0; + } + + /** * @return Multicast address */ inline const MAC &mac() const throw() { return _mac; } |
