OLD | NEW |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005 INRIA | 3 * Copyright (c) 2005 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 else | 191 else |
192 { | 192 { |
193 NS_LOG_DEBUG ("no endpoint found source=" << payloadSource << | 193 NS_LOG_DEBUG ("no endpoint found source=" << payloadSource << |
194 ", destination="<<payloadDestination<< | 194 ", destination="<<payloadDestination<< |
195 ", src=" << src << ", dst=" << dst); | 195 ", src=" << src << ", dst=" << dst); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 enum Ipv4L4Protocol::RxStatus | 199 enum Ipv4L4Protocol::RxStatus |
200 UdpL4Protocol::Receive(Ptr<Packet> packet,· | 200 UdpL4Protocol::Receive(Ptr<Packet> packet,· |
201 Ipv4Address const &source, | 201 Ipv4Header const &header, |
202 Ipv4Address const &destination, | |
203 Ptr<Ipv4Interface> interface) | 202 Ptr<Ipv4Interface> interface) |
204 { | 203 { |
205 NS_LOG_FUNCTION (this << packet << source << destination); | 204 NS_LOG_FUNCTION (this << packet << header); |
206 UdpHeader udpHeader; | 205 UdpHeader udpHeader; |
207 if(Node::ChecksumEnabled ()) | 206 if(Node::ChecksumEnabled ()) |
208 { | 207 { |
209 udpHeader.EnableChecksums(); | 208 udpHeader.EnableChecksums(); |
210 } | 209 } |
211 | 210 |
212 udpHeader.InitializeChecksum (source, destination, PROT_NUMBER); | 211 udpHeader.InitializeChecksum (header.GetSource (), header.GetDestination (), P
ROT_NUMBER); |
213 | 212 |
214 packet->RemoveHeader (udpHeader); | 213 packet->RemoveHeader (udpHeader); |
215 | 214 |
216 if(!udpHeader.IsChecksumOk ()) | 215 if(!udpHeader.IsChecksumOk ()) |
217 { | 216 { |
218 NS_LOG_INFO("Bad checksum : dropping packet!"); | 217 NS_LOG_INFO("Bad checksum : dropping packet!"); |
219 return Ipv4L4Protocol::RX_CSUM_FAILED; | 218 return Ipv4L4Protocol::RX_CSUM_FAILED; |
220 } | 219 } |
221 | 220 |
222 Ipv4EndPointDemux::EndPoints endPoints = | 221 Ipv4EndPointDemux::EndPoints endPoints = |
223 m_endPoints->Lookup (destination, udpHeader.GetDestinationPort (), | 222 m_endPoints->Lookup (header.GetDestination (), udpHeader.GetDestinationPort
(), |
224 source, udpHeader.GetSourcePort (), interface); | 223 header.GetSource (), udpHeader.GetSourcePort (), interf
ace); |
225 if (endPoints.empty ()) | 224 if (endPoints.empty ()) |
226 { | 225 { |
227 NS_LOG_LOGIC ("RX_ENDPOINT_UNREACH"); | 226 NS_LOG_LOGIC ("RX_ENDPOINT_UNREACH"); |
228 return Ipv4L4Protocol::RX_ENDPOINT_UNREACH; | 227 return Ipv4L4Protocol::RX_ENDPOINT_UNREACH; |
229 } | 228 } |
230 for (Ipv4EndPointDemux::EndPointsI endPoint = endPoints.begin (); | 229 for (Ipv4EndPointDemux::EndPointsI endPoint = endPoints.begin (); |
231 endPoint != endPoints.end (); endPoint++) | 230 endPoint != endPoints.end (); endPoint++) |
232 { | 231 { |
233 (*endPoint)->ForwardUp (packet->Copy (), source, destination, udpHeader.Ge
tSourcePort ()); | 232 (*endPoint)->ForwardUp (packet->Copy (), header, udpHeader.GetSourcePort (
),· |
| 233 interface); |
234 } | 234 } |
235 return Ipv4L4Protocol::RX_OK; | 235 return Ipv4L4Protocol::RX_OK; |
236 } | 236 } |
237 | 237 |
238 void | 238 void |
239 UdpL4Protocol::Send (Ptr<Packet> packet,· | 239 UdpL4Protocol::Send (Ptr<Packet> packet,· |
240 Ipv4Address saddr, Ipv4Address daddr,· | 240 Ipv4Address saddr, Ipv4Address daddr,· |
241 uint16_t sport, uint16_t dport) | 241 uint16_t sport, uint16_t dport) |
242 { | 242 { |
243 NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport); | 243 NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (ipv4 != 0) | 288 if (ipv4 != 0) |
289 { | 289 { |
290 NS_LOG_LOGIC ("Sending to IP"); | 290 NS_LOG_LOGIC ("Sending to IP"); |
291 ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); | 291 ipv4->Send (packet, saddr, daddr, PROT_NUMBER, route); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 | 295 |
296 }; // namespace ns3 | 296 }; // namespace ns3 |
297 | 297 |
OLD | NEW |