]> git.tdb.fi Git - netvis.git/blobdiff - source/address.h
Handle addresses in a more generic way
[netvis.git] / source / address.h
diff --git a/source/address.h b/source/address.h
new file mode 100644 (file)
index 0000000..42e671f
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef ADDRESS_H_
+#define ADDRESS_H_
+
+#include <netinet/ip.h>
+#include <string>
+
+struct Address
+{
+       unsigned short type;
+       unsigned char length;
+       unsigned char mask_bits;
+       unsigned char data[16];
+
+       Address();
+       Address(uint32_t);
+       Address(unsigned short, const unsigned char *, unsigned char);
+
+       void set_mask(const Address &);
+       std::string str() const;
+       unsigned common_prefix_length(const Address &) const;
+       bool masked_match(const Address &) const;
+       void to_sockaddr(sockaddr_storage &) const;
+
+       bool operator<(const Address &) const;
+};
+
+#endif