internet: Use constexpr for PROT_NUMBERs

This commit is contained in:
Ivey
2024-11-19 12:13:06 -05:00
committed by Gabriel Ferreira
parent 9e3803138e
commit e6e5d4a0ea
11 changed files with 12 additions and 18 deletions

View File

@@ -28,9 +28,6 @@ NS_LOG_COMPONENT_DEFINE("Icmpv4L4Protocol");
NS_OBJECT_ENSURE_REGISTERED(Icmpv4L4Protocol);
// see rfc 792
const uint8_t Icmpv4L4Protocol::PROT_NUMBER = 1;
TypeId
Icmpv4L4Protocol::GetTypeId()
{

View File

@@ -40,7 +40,8 @@ class Icmpv4L4Protocol : public IpL4Protocol
* @return the object TypeId
*/
static TypeId GetTypeId();
static const uint8_t PROT_NUMBER; //!< ICMP protocol number (0x1)
static constexpr uint8_t PROT_NUMBER = 1; //!< ICMP protocol number (see \RFC{792})
Icmpv4L4Protocol();
~Icmpv4L4Protocol() override;

View File

@@ -11,6 +11,7 @@
#include "icmpv6-l4-protocol.h"
#include "ipv4-interface.h"
#include "ipv6-interface.h"
#include "ipv6-l3-protocol.h"
#include "ipv6-route.h"

View File

@@ -36,8 +36,6 @@ namespace ns3
NS_LOG_COMPONENT_DEFINE("Ipv4L3Protocol");
const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800;
NS_OBJECT_ENSURE_REGISTERED(Ipv4L3Protocol);
TypeId

View File

@@ -77,7 +77,8 @@ class Ipv4L3Protocol : public Ipv4
* @return the object TypeId
*/
static TypeId GetTypeId();
static const uint16_t PROT_NUMBER; //!< Protocol number (0x0800)
static constexpr uint16_t PROT_NUMBER = 0x0800; //!< Protocol number
Ipv4L3Protocol();
~Ipv4L3Protocol() override;

View File

@@ -44,8 +44,6 @@ NS_LOG_COMPONENT_DEFINE("Ipv6L3Protocol");
NS_OBJECT_ENSURE_REGISTERED(Ipv6L3Protocol);
const uint16_t Ipv6L3Protocol::PROT_NUMBER = 0x86DD;
TypeId
Ipv6L3Protocol::GetTypeId()
{

View File

@@ -61,7 +61,7 @@ class Ipv6L3Protocol : public Ipv6
/**
* @brief The protocol number for IPv6 (0x86DD).
*/
static const uint16_t PROT_NUMBER;
static constexpr uint16_t PROT_NUMBER = 0x86DD;
/**
* @enum DropReason

View File

@@ -56,9 +56,6 @@ NS_OBJECT_ENSURE_REGISTERED(TcpL4Protocol);
std::clog << " [node " << m_node->GetId() << "] "; \
}
/* see http://www.iana.org/assignments/protocol-numbers */
const uint8_t TcpL4Protocol::PROT_NUMBER = 6;
TypeId
TcpL4Protocol::GetTypeId()
{

View File

@@ -74,7 +74,9 @@ class TcpL4Protocol : public IpL4Protocol
* @return the object TypeId
*/
static TypeId GetTypeId();
static const uint8_t PROT_NUMBER; //!< protocol number (0x6)
/// Protocol number (see http://www.iana.org/assignments/protocol-numbers)
static constexpr uint8_t PROT_NUMBER = 6;
TcpL4Protocol();
~TcpL4Protocol() override;

View File

@@ -36,9 +36,6 @@ NS_LOG_COMPONENT_DEFINE("UdpL4Protocol");
NS_OBJECT_ENSURE_REGISTERED(UdpL4Protocol);
/* see http://www.iana.org/assignments/protocol-numbers */
const uint8_t UdpL4Protocol::PROT_NUMBER = 17;
TypeId
UdpL4Protocol::GetTypeId()
{

View File

@@ -57,7 +57,9 @@ class UdpL4Protocol : public IpL4Protocol
* @return the object TypeId
*/
static TypeId GetTypeId();
static const uint8_t PROT_NUMBER; //!< protocol number (0x11)
/// Protocol number (see http://www.iana.org/assignments/protocol-numbers)
static constexpr uint8_t PROT_NUMBER = 17;
UdpL4Protocol();
~UdpL4Protocol() override;