A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv4-route.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
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  */
19 
20 #include "ipv4-route.h"
21 #include "ns3/net-device.h"
22 #include "ns3/assert.h"
23 
24 namespace ns3 {
25 
27 {
28 }
29 
30 void
32 {
33  m_dest = dest;
34 }
35 
38 {
39  return m_dest;
40 }
41 
42 void
44 {
45  m_source = src;
46 }
47 
50 {
51  return m_source;
52 }
53 
54 void
56 {
57  m_gateway = gw;
58 }
59 
62 {
63  return m_gateway;
64 }
65 
66 void
68 {
69  m_outputDevice = outputDevice;
70 }
71 
74 {
75  return m_outputDevice;
76 }
77 
78 std::ostream& operator<< (std::ostream& os, Ipv4Route const& route)
79 {
80  os << "source=" << route.GetSource () << " dest="<< route.GetDestination () <<" gw=" << route.GetGateway ();
81  return os;
82 }
83 
85 {
86  m_ttls.clear ();
87 }
88 
89 void
91 {
92  m_group = group;
93 }
94 
97 {
98  return m_group;
99 }
100 
101 void
103 {
104  m_origin = origin;
105 }
106 
109 {
110  return m_origin;
111 }
112 
113 void
115 {
116  m_parent = parent;
117 }
118 
119 uint32_t
121 {
122  return m_parent;
123 }
124 
125 void
126 Ipv4MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
127 {
128  if (ttl >= MAX_TTL)
129  {
130  // This TTL value effectively disables the interface
131  std::map<uint32_t, uint32_t>::iterator iter;
132  iter = m_ttls.find (oif);
133  if (iter != m_ttls.end ())
134  {
135  m_ttls.erase (iter);
136  }
137  }
138  else
139  {
140  m_ttls[oif] = ttl;
141  }
142 }
143 
144 uint32_t
146 {
147  // We keep this interface around for compatibility (for now)
148  std::map<uint32_t, uint32_t>::const_iterator iter = m_ttls.find (oif);
149  if (iter == m_ttls.end ())
150  return((uint32_t)MAX_TTL);
151  return(iter->second);
152 }
153 
154 std::map<uint32_t, uint32_t>
156 {
157  return(m_ttls);
158 }
159 
160 } // namespace ns3