File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 22cmake_minimum_required (VERSION 3.10 FATAL_ERROR)
33
44# Find a suitable compiler, and declare the version and language.
5- project (DNS-CPP VERSION 1.3.2 LANGUAGES CXX)
5+ project (DNS-CPP VERSION 1.3.3 LANGUAGES CXX)
66
77# All artefacts should end up at the root of the build dir for convenience
88set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ INCLUDE_DIR = ${PREFIX}/include
33LIBRARY_DIR = ${PREFIX}/lib
44export LIBRARY_NAME = dnscpp
55export SONAME = 1.3
6- export VERSION = 1.3.2
6+ export VERSION = 1.3.3
77
88all :
99 $(MAKE ) -C src all
Original file line number Diff line number Diff line change @@ -340,6 +340,12 @@ class Ip
340340 {
341341 return any ();
342342 }
343+
344+ /* *
345+ * Inverse operator
346+ * @return Ip
347+ */
348+ Ip operator ~() const ;
343349
344350 /* *
345351 * Bitwise assignment OR operator (x |= y)
Original file line number Diff line number Diff line change @@ -228,6 +228,37 @@ Ip &Ip::operator=(const struct in6_addr *ip)
228228 return *this ;
229229}
230230
231+ /* *
232+ * Inverse operator
233+ * @return Ip
234+ */
235+ Ip Ip::operator ~() const
236+ {
237+ // implementation depends on ip version
238+ if (_version == 6 )
239+ {
240+ // get the address
241+ auto address = _data.ipv6 ;
242+
243+ // iterate over the entire address
244+ for (unsigned i = 0 ; i < 16 ; ++i) address.s6_addr [i] = ~address.s6_addr [i];
245+
246+ // construct a new ip
247+ return DNS::Ip (address);
248+ }
249+ else
250+ {
251+ // get the address
252+ auto address = _data.ipv4 ;
253+
254+ // ipv4 can use a single cpu operation
255+ address.s_addr = ~address.s_addr ;
256+
257+ // construct a new ip
258+ return DNS::Ip (address);
259+ }
260+ }
261+
231262/* *
232263 * Bitwise assignment OR operator (x |= y)
233264 * @param that The other IP
You can’t perform that action at this time.
0 commit comments