View | Details | Raw Unified | Return to bug 1111
Collapse All | Expand All

(-)ns-3-dev/src/internet/model//udp-l4-protocol.cc (-19 / +6 lines)
 Lines 258-279    Link Here 
258
                     Ipv4Address saddr, Ipv4Address daddr, 
258
                     Ipv4Address saddr, Ipv4Address daddr, 
259
                     uint16_t sport, uint16_t dport)
259
                     uint16_t sport, uint16_t dport)
260
{
260
{
261
  NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport);
262
263
  UdpHeader udpHeader;
261
  UdpHeader udpHeader;
264
  if(Node::ChecksumEnabled ())
262
265
    {
266
      udpHeader.EnableChecksums ();
267
      udpHeader.InitializeChecksum (saddr,
268
                                    daddr,
269
                                    PROT_NUMBER);
270
    }
271
  udpHeader.SetDestinationPort (dport);
263
  udpHeader.SetDestinationPort (dport);
272
  udpHeader.SetSourcePort (sport);
264
  udpHeader.SetSourcePort (sport);
273
274
  packet->AddHeader (udpHeader);
265
  packet->AddHeader (udpHeader);
275
266
276
  m_downTarget (packet, saddr, daddr, PROT_NUMBER, 0);
267
  Send (packet, saddr, daddr, sport, dport, 0);
277
}
268
}
278
269
279
void
270
void
 Lines 283-300    Link Here 
283
{
274
{
284
  NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport << route);
275
  NS_LOG_FUNCTION (this << packet << saddr << daddr << sport << dport << route);
285
276
286
  UdpHeader udpHeader;
287
  if(Node::ChecksumEnabled ())
277
  if(Node::ChecksumEnabled ())
288
    {
278
    {
279
	  UdpHeader udpHeader;
280
	  packet->PeekHeader(udpHeader);
281
289
      udpHeader.EnableChecksums ();
282
      udpHeader.EnableChecksums ();
290
      udpHeader.InitializeChecksum (saddr,
283
      udpHeader.InitializeChecksum (saddr, daddr, PROT_NUMBER);
291
                                    daddr,
292
                                    PROT_NUMBER);
293
    }
284
    }
294
  udpHeader.SetDestinationPort (dport);
295
  udpHeader.SetSourcePort (sport);
296
297
  packet->AddHeader (udpHeader);
298
285
299
  m_downTarget (packet, saddr, daddr, PROT_NUMBER, route);
286
  m_downTarget (packet, saddr, daddr, PROT_NUMBER, route);
300
}
287
}
(-)ns-3-dev/src/internet/model//udp-socket-impl.cc (-2 / +11 lines)
 Lines 31-36    Link Here 
31
#include "udp-socket-impl.h"
31
#include "udp-socket-impl.h"
32
#include "udp-l4-protocol.h"
32
#include "udp-l4-protocol.h"
33
#include "ipv4-end-point.h"
33
#include "ipv4-end-point.h"
34
#include "udp-header.h"
34
#include <limits>
35
#include <limits>
35
36
36
NS_LOG_COMPONENT_DEFINE ("UdpSocketImpl");
37
NS_LOG_COMPONENT_DEFINE ("UdpSocketImpl");
 Lines 440-445    Link Here 
440
      Ptr<Ipv4Route> route;
441
      Ptr<Ipv4Route> route;
441
      Ptr<NetDevice> oif = m_boundnetdevice; //specify non-zero if bound to a specific device
442
      Ptr<NetDevice> oif = m_boundnetdevice; //specify non-zero if bound to a specific device
442
      // TBD-- we could cache the route and just check its validity
443
      // TBD-- we could cache the route and just check its validity
444
445
      // Patch - BUG 1111 - UDP header does not attached before RouteOutput
446
      UdpHeader udpHeader;
447
      udpHeader.SetSourcePort(m_endPoint->GetLocalPort ());
448
      udpHeader.SetDestinationPort(port);
449
      p->AddHeader(udpHeader);
450
443
      route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); 
451
      route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); 
444
      if (route != 0)
452
      if (route != 0)
445
        {
453
        {
 Lines 462-469    Link Here 
462
          header.SetSource (route->GetSource ());
470
          header.SetSource (route->GetSource ());
463
          m_udp->Send (p->Copy (), header.GetSource (), header.GetDestination (),
471
          m_udp->Send (p->Copy (), header.GetSource (), header.GetDestination (),
464
                       m_endPoint->GetLocalPort (), port, route);
472
                       m_endPoint->GetLocalPort (), port, route);
465
          NotifyDataSent (p->GetSize ());
473
466
          return p->GetSize ();
474
          NotifyDataSent (p->GetSize () - udpHeader.GetSerializedSize());
475
          return (p->GetSize () - udpHeader.GetSerializedSize());
467
        }
476
        }
468
      else 
477
      else 
469
        {
478
        {

Return to bug 1111