|
121 |
NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0); |
121 |
NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0); |
122 |
uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); |
122 |
uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); |
123 |
|
123 |
|
124 |
// Multicast recognition; handle local delivery here |
124 |
retVal = m_ipv4->IsDestinationAddress (header.GetDestination (), iif); |
125 |
// |
125 |
if (retVal == true) |
126 |
if (header.GetDestination().IsMulticast ()) |
|
|
127 |
{ |
126 |
{ |
128 |
#ifdef NOTYET |
127 |
NS_LOG_LOGIC ("Address "<< header.GetDestination () << " is a match for local delivery"); |
129 |
if (m_ipv4->MulticastCheckGroup (iif, header.GetDestination ())) |
128 |
if (header.GetDestination ().IsMulticast ()) |
130 |
#endif |
|
|
131 |
if (true) |
132 |
{ |
129 |
{ |
133 |
NS_LOG_LOGIC ("Multicast packet for me-- local deliver"); |
|
|
134 |
Ptr<Packet> packetCopy = p->Copy(); |
130 |
Ptr<Packet> packetCopy = p->Copy(); |
135 |
// Here may want to disable lcb callback in recursive RouteInput |
|
|
136 |
// call below |
137 |
lcb (packetCopy, header, iif); |
131 |
lcb (packetCopy, header, iif); |
138 |
// Fall through-- we may also need to forward this |
|
|
139 |
retVal = true; |
132 |
retVal = true; |
|
|
133 |
// Fall through |
140 |
} |
134 |
} |
141 |
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = |
135 |
else |
142 |
m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); |
|
|
143 |
rprotoIter++) |
144 |
{ |
136 |
{ |
145 |
NS_LOG_LOGIC ("Multicast packet for me-- trying to forward"); |
137 |
lcb (p, header, iif); |
146 |
if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, ecb)) |
138 |
return true; |
147 |
{ |
|
|
148 |
retVal = true; |
149 |
} |
150 |
} |
151 |
return retVal; |
152 |
} |
153 |
|
154 |
if (header.GetDestination ().IsBroadcast ()) |
155 |
{ |
156 |
NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)"); |
157 |
// TODO: Local Deliver for broadcast |
158 |
// TODO: Forward broadcast |
159 |
} |
160 |
|
161 |
// TODO: Configurable option to enable RFC 1222 Strong End System Model |
162 |
// Right now, we will be permissive and allow a source to send us |
163 |
// a packet to one of our other interface addresses; that is, the |
164 |
// destination unicast address does not match one of the iif addresses, |
165 |
// but we check our other interfaces. This could be an option |
166 |
// (to remove the outer loop immediately below and just check iif). |
167 |
for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++) |
168 |
{ |
169 |
for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++) |
170 |
{ |
171 |
Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i); |
172 |
Ipv4Address addr = iaddr.GetLocal (); |
173 |
if (addr.IsEqual (header.GetDestination ())) |
174 |
{ |
175 |
if (j == iif) |
176 |
{ |
177 |
NS_LOG_LOGIC ("For me (destination " << addr << " match)"); |
178 |
} |
179 |
else |
180 |
{ |
181 |
NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ()); |
182 |
} |
183 |
lcb (p, header, iif); |
184 |
return true; |
185 |
} |
186 |
if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ())) |
187 |
{ |
188 |
NS_LOG_LOGIC ("For me (interface broadcast address)"); |
189 |
lcb (p, header, iif); |
190 |
return true; |
191 |
} |
192 |
NS_LOG_LOGIC ("Address "<< addr << " not a match"); |
193 |
} |
139 |
} |
194 |
} |
140 |
} |
195 |
// Check if input device supports IP forwarding |
141 |
// Check if input device supports IP forwarding |
|
200 |
return false; |
146 |
return false; |
201 |
} |
147 |
} |
202 |
// Next, try to find a route |
148 |
// Next, try to find a route |
|
|
149 |
// If we have already delivered a packet locally (e.g. multicast) |
150 |
// we suppress further downstream local delivery by nulling the callback |
151 |
LocalDeliverCallback downstreamLcb = lcb; |
152 |
if (retVal == true) |
153 |
{ |
154 |
downstreamLcb = MakeNullCallback<void, Ptr<const Packet>, const Ipv4Header &, uint32_t > (); |
155 |
} |
203 |
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = |
156 |
for (Ipv4RoutingProtocolList::const_iterator rprotoIter = |
204 |
m_routingProtocols.begin (); |
157 |
m_routingProtocols.begin (); |
205 |
rprotoIter != m_routingProtocols.end (); |
158 |
rprotoIter != m_routingProtocols.end (); |
206 |
rprotoIter++) |
159 |
rprotoIter++) |
207 |
{ |
160 |
{ |
208 |
if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, ecb)) |
161 |
if (retVal == false) |
209 |
{ |
162 |
{ |
210 |
return true; |
163 |
if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, downstreamLcb, ecb)) |
|
|
164 |
{ |
165 |
return true; |
166 |
} |
211 |
} |
167 |
} |
212 |
} |
168 |
} |
213 |
// No routing protocol has found a route. |
169 |
// No routing protocol has found a route. |