aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/core/prefix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/core/prefix.cc')
-rw-r--r--libtransport/src/core/prefix.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/libtransport/src/core/prefix.cc b/libtransport/src/core/prefix.cc
index eea4aeb8b..1e2b2ed9d 100644
--- a/libtransport/src/core/prefix.cc
+++ b/libtransport/src/core/prefix.cc
@@ -25,12 +25,12 @@ extern "C" {
#include <hicn/transport/portability/win_portability.h>
#endif
+#include <openssl/rand.h>
+
#include <cstring>
#include <memory>
#include <random>
-#include <openssl/rand.h>
-
namespace transport {
namespace core {
@@ -99,7 +99,7 @@ void Prefix::buildPrefix(std::string &prefix, uint16_t prefix_length,
ip_prefix_.family = family;
}
-std::unique_ptr<Sockaddr> Prefix::toSockaddr() {
+std::unique_ptr<Sockaddr> Prefix::toSockaddr() const {
Sockaddr *ret = nullptr;
switch (ip_prefix_.family) {
@@ -120,14 +120,14 @@ std::unique_ptr<Sockaddr> Prefix::toSockaddr() {
return std::unique_ptr<Sockaddr>(ret);
}
-uint16_t Prefix::getPrefixLength() { return ip_prefix_.len; }
+uint16_t Prefix::getPrefixLength() const { return ip_prefix_.len; }
Prefix &Prefix::setPrefixLength(uint16_t prefix_length) {
ip_prefix_.len = prefix_length;
return *this;
}
-int Prefix::getAddressFamily() { return ip_prefix_.family; }
+int Prefix::getAddressFamily() const { return ip_prefix_.family; }
Prefix &Prefix::setAddressFamily(int address_family) {
ip_prefix_.family = address_family;
@@ -226,7 +226,7 @@ Name Prefix::getRandomName() const {
ip_prefix_.len;
size_t size = (size_t)ceil((float)addr_len / 8.0);
- uint8_t *buffer = (uint8_t *) malloc(sizeof(uint8_t) * size);
+ uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t) * size);
RAND_bytes(buffer, size);
@@ -332,7 +332,7 @@ bool Prefix::checkPrefixLengthAndAddressFamily(uint16_t prefix_length,
return true;
}
-ip_prefix_t &Prefix::toIpPrefixStruct() { return ip_prefix_; }
+const ip_prefix_t &Prefix::toIpPrefixStruct() const { return ip_prefix_; }
} // namespace core