A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-end-point.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef IPV4_END_POINT_H
21#define IPV4_END_POINT_H
22
23#include "ns3/callback.h"
24#include "ns3/ipv4-address.h"
25#include "ns3/ipv4-header.h"
26#include "ns3/ipv4-interface.h"
27#include "ns3/net-device.h"
28
29#include <stdint.h>
30
31namespace ns3
32{
33
34class Header;
35class Packet;
36
51{
52 public:
58 Ipv4EndPoint(Ipv4Address address, uint16_t port);
60
66
71 void SetLocalAddress(Ipv4Address address);
72
77 uint16_t GetLocalPort() const;
78
84
89 uint16_t GetPeerPort() const;
90
96 void SetPeer(Ipv4Address address, uint16_t port);
97
116 void BindToNetDevice(Ptr<NetDevice> netdevice);
117
128
129 // Called from socket implementations to get notified about important events.
134 void SetRxCallback(
135 Callback<void, Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface>> callback);
145 void SetDestroyCallback(Callback<void> callback);
146
157 void ForwardUp(Ptr<Packet> p,
158 const Ipv4Header& header,
159 uint16_t sport,
160 Ptr<Ipv4Interface> incomingInterface);
161
174 void ForwardIcmp(Ipv4Address icmpSource,
175 uint8_t icmpTtl,
176 uint8_t icmpType,
177 uint8_t icmpCode,
178 uint32_t icmpInfo);
179
184 void SetRxEnabled(bool enabled);
185
190 bool IsRxEnabled() const;
191
192 private:
197
201 uint16_t m_localPort;
202
207
211 uint16_t m_peerPort;
212
217
222
227
232
237};
238
239} // namespace ns3
240
241#endif /* IPV4_END_POINT_H */
Callback template class.
Definition: callback.h:438
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
A representation of an internet endpoint/connection.
bool m_rxEnabled
true if the endpoint can receive packets.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
The ICMPv6 callback.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
Ipv4Address GetLocalAddress() const
Get the local address.
void SetLocalAddress(Ipv4Address address)
Set the local address.
uint16_t GetPeerPort() const
Get the peer port.
void ForwardUp(Ptr< Packet > p, const Ipv4Header &header, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
Forward the packet to the upper level.
void ForwardIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Forward the ICMP packet to the upper level.
uint16_t m_localPort
The local port.
Ptr< NetDevice > GetBoundNetDevice() const
Returns socket's bound netdevice, if any.
uint16_t GetLocalPort() const
Get the local port.
bool IsRxEnabled() const
Checks if the endpoint can receive packets.
void SetRxEnabled(bool enabled)
Enable or Disable the endpoint Rx capability.
Ipv4Address GetPeerAddress() const
Get the peer address.
Ipv4Address m_peerAddr
The peer address.
uint16_t m_peerPort
The peer port.
Ptr< NetDevice > m_boundnetdevice
The NetDevice the EndPoint is bound to (if any).
void SetIcmpCallback(Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
void SetPeer(Ipv4Address address, uint16_t port)
Set the peer information (address and port).
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
Ipv4Address m_localAddr
The local address.
Callback< void > m_destroyCallback
The destroy callback.
Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > m_rxCallback
The RX callback.
Packet header for IPv4.
Definition: ipv4-header.h:34
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
uint16_t port
Definition: dsdv-manet.cc:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.