diff options
Diffstat (limited to 'libtransport/includes/hicn/transport/core/name.h')
-rw-r--r-- | libtransport/includes/hicn/transport/core/name.h | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libtransport/includes/hicn/transport/core/name.h b/libtransport/includes/hicn/transport/core/name.h index ea72797ad..14ea10898 100644 --- a/libtransport/includes/hicn/transport/core/name.h +++ b/libtransport/includes/hicn/transport/core/name.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2021 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -46,12 +46,13 @@ class Name { friend class Packet; friend class ContentObject; friend class Interest; + friend class Prefix; static const uint32_t standard_name_string_length = 100; public: using NameStruct = hicn_name_t; - using Type = hicn_name_type_t; + enum class Type { UNDEFINED, V4, V6 }; Name(); @@ -69,6 +70,8 @@ class Name { Name(const Name &name); + ~Name(); + Name &operator=(const Name &name); bool operator==(const Name &name) const; @@ -77,6 +80,8 @@ class Name { operator bool() const; + bool isValid() const; + std::string toString() const; bool equals(const Name &name, bool consider_segment = true) const; @@ -89,23 +94,22 @@ class Name { uint32_t getSuffix() const; - std::shared_ptr<Sockaddr> getAddress() const; - Name &setSuffix(uint32_t seq_number); - ip_prefix_t toIpAddress() const; + hicn_ip_prefix_t toIpAddress() const; - void copyToDestination(uint8_t *destination, - bool include_suffix = false) const; + std::string getPrefix() const; + + void copyPrefixToDestination(uint8_t *destination) const; int getAddressFamily() const; private: - TRANSPORT_ALWAYS_INLINE const NameStruct *getConstStructReference() const { - return &name_; + TRANSPORT_ALWAYS_INLINE const NameStruct &getConstStructReference() const { + return name_; } - TRANSPORT_ALWAYS_INLINE NameStruct *getStructReference() { return &name_; } + TRANSPORT_ALWAYS_INLINE NameStruct &getStructReference() { return name_; } NameStruct name_; }; @@ -125,14 +129,14 @@ struct compare2 {}; template <> struct compare2<transport::core::Name> { - size_t operator()(const transport::core::Name &name1, const transport::core::Name &name2) const; + size_t operator()(const transport::core::Name &name1, + const transport::core::Name &name2) const; }; } // end namespace core } // end namespace transport - namespace std { template <> struct hash<transport::core::Name> { |