Skip to content

Commit d76618d

Browse files
smrsodhiGallegosAlberto
authored andcommitted
network: (fixes #1047) Adds IANA protocol numbers
1 parent 7bf1c17 commit d76618d

21 files changed

Lines changed: 127 additions & 46 deletions

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,5 @@ ra1nst0rm3d (GCI 2019)
412412
SaiMyGuy (GCI 2019)
413413
TheBear (25639689-thebear132@users.noreply.gitlab.com)
414414
Lorenzo Bartolini (l.bartolini02@gmail.com)
415+
Samar Sodhi (smrsodhi@gmail.com)
416+

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This file is a best-effort approach to solving this issue; we will do our best b
2121
### Changes to existing API
2222

2323
* Pcap helpers now use ``LinkType`` enum contained in the ``iana`` namespace (``iana-link-type-numbers.h``).
24+
* Centralization of ``PPP`` and ``IEEE802`` numbers. These are now contained in network model in ``iana-ppp-numbers.h`` and ``iana-ieee802-numbers.h`` respectively.
2425

2526
### Changes to build system
2627

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ been tested on Linux. As of this release, the latest known version to work with
3636

3737
### New user-visible features
3838

39+
- (network) IANA protocol and link types are now centralized in network module headers.
40+
3941
### Bugs fixed
4042

4143
- (lr-wpan) !2916 Pcap files are now correctly generated with and without FCS cases.

src/click/model/ipv4-l3-click-protocol.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ namespace ns3
2929

3030
NS_LOG_COMPONENT_DEFINE("Ipv4L3ClickProtocol");
3131

32-
const uint16_t Ipv4L3ClickProtocol::PROT_NUMBER = 0x0800;
33-
3432
NS_OBJECT_ENSURE_REGISTERED(Ipv4L3ClickProtocol);
3533

3634
TypeId

src/click/model/ipv4-l3-click-protocol.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IPV4_L3_CLICK_PROTOCOL_H
1212

1313
#include "ns3/deprecated.h"
14+
#include "ns3/iana-ieee802-numbers.h"
1415
#include "ns3/ipv4-interface.h"
1516
#include "ns3/ipv4-routing-protocol.h"
1617
#include "ns3/ipv4.h"
@@ -59,9 +60,9 @@ class Ipv4L3ClickProtocol : public Ipv4
5960
static TypeId GetTypeId();
6061

6162
/**
62-
* Protocol number for Ipv4 L3 (0x0800).
63+
* Protocol number for Ipv4 L3
6364
*/
64-
static const uint16_t PROT_NUMBER;
65+
static constexpr uint16_t PROT_NUMBER = iana::ieee802::IPV4;
6566

6667
Ipv4L3ClickProtocol();
6768
~Ipv4L3ClickProtocol() override;

src/internet/model/arp-header.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "ns3/address-utils.h"
1212
#include "ns3/assert.h"
13+
#include "ns3/iana-ieee802-numbers.h"
1314
#include "ns3/log.h"
1415

1516
namespace ns3
@@ -180,7 +181,7 @@ ArpHeader::Serialize(Buffer::Iterator start) const
180181

181182
i.WriteHtonU16(static_cast<uint16_t>(m_hardwareType));
182183
/* ipv4 */
183-
i.WriteHtonU16(0x0800);
184+
i.WriteHtonU16(iana::Ieee802Numbers::IPV4);
184185
i.WriteU8(m_macSource.GetLength());
185186
i.WriteU8(4);
186187
i.WriteHtonU16(m_type);

src/internet/model/arp-l3-protocol.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace ns3
2828

2929
NS_LOG_COMPONENT_DEFINE("ArpL3Protocol");
3030

31-
const uint16_t ArpL3Protocol::PROT_NUMBER = 0x0806;
32-
3331
NS_OBJECT_ENSURE_REGISTERED(ArpL3Protocol);
3432

3533
TypeId

src/internet/model/arp-l3-protocol.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ipv4-header.h"
1212

1313
#include "ns3/address.h"
14+
#include "ns3/iana-ieee802-numbers.h"
1415
#include "ns3/internet-export.h"
1516
#include "ns3/net-device.h"
1617
#include "ns3/ptr.h"
@@ -50,7 +51,7 @@ class INTERNET_EXPORT ArpL3Protocol : public Object
5051
* @return the object TypeId
5152
*/
5253
static TypeId GetTypeId();
53-
static const uint16_t PROT_NUMBER; //!< ARP protocol number (0x0806)
54+
static constexpr uint16_t PROT_NUMBER = iana::Ieee802Numbers::ARP; //!< ARP protocol number
5455

5556
ArpL3Protocol();
5657
~ArpL3Protocol() override;

src/internet/model/ipv4-l3-protocol.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "ipv4.h"
1515

1616
#include "ns3/deprecated.h"
17+
#include "ns3/iana-ieee802-numbers.h"
1718
#include "ns3/ipv4-address.h"
1819
#include "ns3/net-device.h"
1920
#include "ns3/nstime.h"
@@ -77,8 +78,7 @@ class Ipv4L3Protocol : public Ipv4
7778
* @return the object TypeId
7879
*/
7980
static TypeId GetTypeId();
80-
81-
static constexpr uint16_t PROT_NUMBER = 0x0800; //!< Protocol number
81+
static constexpr uint16_t PROT_NUMBER = iana::Ieee802Numbers::IPV4; //!< Protocol number
8282

8383
Ipv4L3Protocol();
8484
~Ipv4L3Protocol() override;

src/internet/model/ipv6-l3-protocol.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "ipv6-routing-protocol.h"
1515
#include "ipv6.h"
1616

17+
#include "ns3/iana-ieee802-numbers.h"
1718
#include "ns3/ipv6-address.h"
1819
#include "ns3/net-device.h"
1920
#include "ns3/traced-callback.h"
@@ -59,9 +60,9 @@ class Ipv6L3Protocol : public Ipv6
5960
static TypeId GetTypeId();
6061

6162
/**
62-
* @brief The protocol number for IPv6 (0x86DD).
63+
* @brief The protocol number for IPv6
6364
*/
64-
static constexpr uint16_t PROT_NUMBER = 0x86DD;
65+
static constexpr uint16_t PROT_NUMBER = iana::Ieee802Numbers::IPV6;
6566

6667
/**
6768
* @enum DropReason

0 commit comments

Comments
 (0)