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// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: George F. Riley<riley@ece.gatech.edu>
18//
19
20// NS3 - Layer 4 Protocol base class
21// George F. Riley, Georgia Tech, Spring 2007
22
23#include "ip-l4-protocol.h"
24
25#include "ns3/integer.h"
26#include "ns3/log.h"
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("IpL4Protocol");
32
33NS_OBJECT_ENSURE_REGISTERED(IpL4Protocol);
34
35TypeId
37{
38 static TypeId tid = TypeId("ns3::IpL4Protocol")
40 .SetGroupName("Internet")
41 .AddAttribute("ProtocolNumber",
42 "The IP protocol number.",
44 IntegerValue(0),
46 MakeIntegerChecker<int>(0, 255));
47 return tid;
48}
49
51{
52 NS_LOG_FUNCTION(this);
53}
54
55void
57 uint8_t icmpTtl,
58 uint8_t icmpType,
59 uint8_t icmpCode,
60 uint32_t icmpInfo,
61 Ipv4Address payloadSource,
62 Ipv4Address payloadDestination,
63 const uint8_t payload[8])
64{
65 NS_LOG_FUNCTION(this << icmpSource << static_cast<uint32_t>(icmpTtl)
66 << static_cast<uint32_t>(icmpType) << static_cast<uint32_t>(icmpCode)
67 << icmpInfo << payloadSource << payloadDestination << payload);
68}
69
70void
72 uint8_t icmpTtl,
73 uint8_t icmpType,
74 uint8_t icmpCode,
75 uint32_t icmpInfo,
76 Ipv6Address payloadSource,
77 Ipv6Address payloadDestination,
78 const uint8_t payload[8])
79{
80 NS_LOG_FUNCTION(this << icmpSource << static_cast<uint32_t>(icmpTtl)
81 << static_cast<uint32_t>(icmpType) << static_cast<uint32_t>(icmpCode)
82 << icmpInfo << payloadSource << payloadDestination << payload);
83}
84
85} // namespace ns3
Hold a signed integer type.
Definition: integer.h:45
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.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
@ ATTR_GET
The attribute can be read.
Definition: type-id.h:64
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition: integer.h:46
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.