A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ip-l4-protocol.cc
Go to the documentation of this file.
1//
2// Copyright (c) 2006 Georgia Tech Research Corporation
3//
4// SPDX-License-Identifier: GPL-2.0-only
5//
6// Author: George F. Riley<riley@ece.gatech.edu>
7//
8
9// NS3 - Layer 4 Protocol base class
10// George F. Riley, Georgia Tech, Spring 2007
11
12#include "ip-l4-protocol.h"
13
14#include "ns3/integer.h"
15#include "ns3/log.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("IpL4Protocol");
21
23
26{
27 static TypeId tid = TypeId("ns3::IpL4Protocol")
29 .SetGroupName("Internet")
30 .AddAttribute("ProtocolNumber",
31 "The IP protocol number.",
33 IntegerValue(0),
36 return tid;
37}
38
43
44void
46 uint8_t icmpTtl,
47 uint8_t icmpType,
48 uint8_t icmpCode,
49 uint32_t icmpInfo,
50 Ipv4Address payloadSource,
51 Ipv4Address payloadDestination,
52 const uint8_t payload[8])
53{
54 NS_LOG_FUNCTION(this << icmpSource << static_cast<uint32_t>(icmpTtl)
55 << static_cast<uint32_t>(icmpType) << static_cast<uint32_t>(icmpCode)
56 << icmpInfo << payloadSource << payloadDestination << payload);
57}
58
59void
61 uint8_t icmpTtl,
62 uint8_t icmpType,
63 uint8_t icmpCode,
64 uint32_t icmpInfo,
65 Ipv6Address payloadSource,
66 Ipv6Address payloadDestination,
67 const uint8_t payload[8])
68{
69 NS_LOG_FUNCTION(this << icmpSource << static_cast<uint32_t>(icmpTtl)
70 << static_cast<uint32_t>(icmpType) << static_cast<uint32_t>(icmpCode)
71 << icmpInfo << payloadSource << payloadDestination << payload);
72}
73
74} // namespace ns3
Hold a signed integer type.
Definition integer.h:34
L4 Protocol abstract base class.
virtual void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv4Address payloadSource, Ipv4Address payloadDestination, const uint8_t payload[8])
Called from lower-level layers to send the ICMP packet up in the stack.
~IpL4Protocol() override
virtual int GetProtocolNumber() const =0
Returns the protocol number of this protocol.
static TypeId GetTypeId()
Get the type ID.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
Object()
Constructor.
Definition object.cc:96
a unique identifier for an interface.
Definition type-id.h:49
@ ATTR_GET
The attribute can be read.
Definition type-id.h:54
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeIntegerChecker()
Definition integer.h:99
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition integer.h:35