A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-end-point.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
7 */
8
9#include "ipv6-end-point.h"
10
11#include "ns3/log.h"
12#include "ns3/packet.h"
13#include "ns3/simulator.h"
14
15namespace ns3
16{
17
18NS_LOG_COMPONENT_DEFINE("Ipv6EndPoint");
19
21 : m_localAddr(addr),
22 m_localPort(port),
23 m_peerAddr(Ipv6Address::GetAny()),
24 m_peerPort(0),
25 m_rxEnabled(true)
26{
27}
28
39
42{
43 return m_localAddr;
44}
45
46void
51
52uint16_t
54{
55 return m_localPort;
56}
57
58void
63
66{
67 return m_peerAddr;
68}
69
70uint16_t
72{
73 return m_peerPort;
74}
75
76void
81
87
88void
90{
91 m_peerAddr = addr;
93}
94
95void
97 Callback<void, Ptr<Packet>, Ipv6Header, uint16_t, Ptr<Ipv6Interface>> callback)
98{
99 m_rxCallback = callback;
100}
101
102void
108
109void
114
115void
117 Ipv6Header header,
118 uint16_t port,
119 Ptr<Ipv6Interface> incomingInterface)
120{
121 if (!m_rxCallback.IsNull())
122 {
123 m_rxCallback(p, header, port, incomingInterface);
124 }
125}
126
127void
128Ipv6EndPoint::ForwardIcmp(Ipv6Address src, uint8_t ttl, uint8_t type, uint8_t code, uint32_t info)
129{
130 if (!m_icmpCallback.IsNull())
131 {
132 m_icmpCallback(src, ttl, type, code, info);
133 }
134}
135
136void
138{
139 m_rxEnabled = enabled;
140}
141
142bool
144{
145 return m_rxEnabled;
146}
147
148} /* namespace ns3 */
Callback template class.
Definition callback.h:422
void Nullify()
Discard the implementation, set it to null.
Definition callback.h:561
bool IsNull() const
Check for null implementation.
Definition callback.h:555
Describes an IPv6 address.
uint16_t m_peerPort
The peer port.
void ForwardUp(Ptr< Packet > p, Ipv6Header header, uint16_t port, Ptr< Ipv6Interface > incomingInterface)
Forward the packet to the upper level.
uint16_t GetLocalPort() const
Get the local port.
void SetPeer(Ipv6Address addr, uint16_t port)
Set the peer information (address and port).
Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
The ICMPv6 callback.
Ipv6Address GetPeerAddress() const
Get the peer address.
Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > m_rxCallback
The RX callback.
Ipv6Address m_peerAddr
The peer address.
void SetIcmpCallback(Callback< void, Ipv6Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
void SetLocalPort(uint16_t port)
Set the local port.
bool m_rxEnabled
true if the endpoint can receive packets.
Ipv6Address GetLocalAddress() const
Get the local address.
Callback< void > m_destroyCallback
The destroy callback.
Ipv6EndPoint(Ipv6Address addr, uint16_t port)
Constructor.
Ipv6Address m_localAddr
The local address.
void SetLocalAddress(Ipv6Address addr)
Set the local address.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
void SetRxEnabled(bool enabled)
Enable or Disable the endpoint Rx capability.
void ForwardIcmp(Ipv6Address src, uint8_t ttl, uint8_t type, uint8_t code, uint32_t info)
Forward the ICMP packet to the upper level.
Ptr< NetDevice > m_boundnetdevice
The NetDevice the EndPoint is bound to (if any).
uint16_t m_localPort
The local port.
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv6Header, uint16_t, Ptr< Ipv6Interface > > callback)
Set the reception callback.
bool IsRxEnabled() const
Checks if the endpoint can receive packets.
Ptr< NetDevice > GetBoundNetDevice() const
Returns socket's bound netdevice, if any.
uint16_t GetPeerPort() const
Get the peer port.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
Packet header for IPv6.
Definition ipv6-header.h:24
Smart pointer class similar to boost::intrusive_ptr.
uint16_t port
Definition dsdv-manet.cc:33
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Every class exported by the ns3 library is enclosed in the ns3 namespace.