A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv4-end-point.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef IPV4_END_POINT_H
22 #define IPV4_END_POINT_H
23 
24 #include <stdint.h>
25 #include "ns3/ipv4-address.h"
26 #include "ns3/callback.h"
27 #include "ns3/net-device.h"
28 #include "ns3/ipv4-header.h"
29 #include "ns3/ipv4-interface.h"
30 
31 namespace ns3 {
32 
33 class Header;
34 class Packet;
35 
47 class Ipv4EndPoint {
48 public:
55  ~Ipv4EndPoint ();
56 
62 
67  void SetLocalAddress (Ipv4Address address);
68 
73  uint16_t GetLocalPort (void);
74 
80 
85  uint16_t GetPeerPort (void);
86 
92  void SetPeer (Ipv4Address address, uint16_t port);
93 
112  void BindToNetDevice (Ptr<NetDevice> netdevice);
113 
124 
125  // Called from socket implementations to get notified about important events.
130  void SetRxCallback (Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > callback);
140  void SetDestroyCallback (Callback<void> callback);
141 
152  void ForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
153  Ptr<Ipv4Interface> incomingInterface);
154 
167  void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
168  uint8_t icmpType, uint8_t icmpCode,
169  uint32_t icmpInfo);
170 
171 private:
179  void DoForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
180  Ptr<Ipv4Interface> incomingInterface);
189  void DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
190  uint8_t icmpType, uint8_t icmpCode,
191  uint32_t icmpInfo);
192 
197 
201  uint16_t m_localPort;
202 
207 
211  uint16_t m_peerPort;
212 
217 
222 
227 
232 };
233 
234 } // namespace ns3
235 
236 
237 #endif /* IPV4_END_POINT_H */
Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > m_rxCallback
The RX callback.
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
Callback template class.
Definition: callback.h:920
Ptr< NetDevice > m_boundnetdevice
The NetDevice the EndPoint is bound to (if any).
void SetRxCallback(Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
Set the reception callback.
void SetDestroyCallback(Callback< void > callback)
Set the default destroy callback.
void ForwardUp(Ptr< Packet > p, const Ipv4Header &header, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
Forward the packet to the upper level.
void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
uint16_t port
Definition: dsdv-manet.cc:44
Packet header for IPv4.
Definition: ipv4-header.h:31
void DoForwardUp(Ptr< Packet > p, const Ipv4Header &header, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
ForwardUp wrapper.
Ipv4Address GetLocalAddress(void)
Get the local address.
Ptr< NetDevice > GetBoundNetDevice(void)
Returns socket's bound netdevice, if any.
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_peerPort
The peer port.
Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > m_icmpCallback
The ICMPv6 callback.
void SetPeer(Ipv4Address address, uint16_t port)
Set the peer informations (address and port).
Ipv4Address m_localAddr
The local address.
void SetLocalAddress(Ipv4Address address)
Set the local address.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
void DoForwardIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
ForwardIcmp wrapper.
uint16_t m_localPort
The local port.
uint16_t GetLocalPort(void)
Get the local port.
Ipv4Address GetPeerAddress(void)
Get the peer address.
uint16_t GetPeerPort(void)
Get the peer port.
tuple address
Definition: first.py:37
Ipv4EndPoint(Ipv4Address address, uint16_t port)
Constructor.
void SetIcmpCallback(Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
Set the ICMP callback.
Callback< void > m_destroyCallback
The destroy callback.
A representation of an internet endpoint/connection.
Ipv4Address m_peerAddr
The peer address.