A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv6-end-point.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #include "ns3/packet.h"
22 #include "ns3/log.h"
23 #include "ns3/simulator.h"
24 
25 #include "ipv6-end-point.h"
26 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE ("Ipv6EndPoint");
31 
33  : m_localAddr (addr),
34  m_localPort (port),
35  m_peerAddr (Ipv6Address::GetAny ()),
36  m_peerPort (0)
37 {
38 }
39 
41 {
42  if (!m_destroyCallback.IsNull ())
43  {
45  }
49 }
50 
52 {
53  return m_localAddr;
54 }
55 
57 {
58  m_localAddr = addr;
59 }
60 
62 {
63  return m_localPort;
64 }
65 
67 {
68  m_localPort = port;
69 }
70 
72 {
73  return m_peerAddr;
74 }
75 
77 {
78  return m_peerPort;
79 }
80 
81 void Ipv6EndPoint::SetPeer (Ipv6Address addr, uint16_t port)
82 {
83  m_peerAddr = addr;
84  m_peerPort = port;
85 }
86 
88 {
89  m_rxCallback = callback;
90 }
91 
93 {
94  m_icmpCallback = callback;
95 }
96 
98 {
99  m_destroyCallback = callback;
100 }
101 
102 void Ipv6EndPoint::ForwardUp (Ptr<Packet> p, Ipv6Address srcAddr, Ipv6Address dstAddr, uint16_t port)
103 {
104  if (!m_rxCallback.IsNull ())
105  {
106  m_rxCallback (p, srcAddr, dstAddr, port);
107  }
108 }
109 
110 void Ipv6EndPoint::ForwardIcmp (Ipv6Address src, uint8_t ttl, uint8_t type,
111  uint8_t code, uint32_t info)
112 {
113  if (!m_icmpCallback.IsNull ())
114  {
116  src, ttl, type, code, info);
117  }
118 }
119 
120 void Ipv6EndPoint::DoForwardUp (Ptr<Packet> p, Ipv6Address saddr, Ipv6Address daddr, uint16_t sport)
121 {
122  m_rxCallback (p, saddr, daddr, sport);
123 }
124 
125 void Ipv6EndPoint::DoForwardIcmp (Ipv6Address src, uint8_t ttl, uint8_t type,
126  uint8_t code, uint32_t info)
127 {
128  m_icmpCallback (src, ttl, type, code, info);
129 }
130 
131 } /* namespace ns3 */
132