LEFT | RIGHT |
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) 2012 INRIA, 2012 University of Washington | 3 * Copyright (c) 2012 INRIA, 2012 University of Washington |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 "This value limits number of packets that have been read " | 112 "This value limits number of packets that have been read " |
113 "from the network into a memory buffer but have not yet " | 113 "from the network into a memory buffer but have not yet " |
114 "been processed by the simulator.", | 114 "been processed by the simulator.", |
115 UintegerValue (1000), | 115 UintegerValue (1000), |
116 MakeUintegerAccessor (&FdNetDevice::m_maxPendingReads), | 116 MakeUintegerAccessor (&FdNetDevice::m_maxPendingReads), |
117 MakeUintegerChecker<uint32_t> ()) | 117 MakeUintegerChecker<uint32_t> ()) |
118 // | 118 // |
119 // Trace sources at the "top" of the net device, where packets transition | 119 // Trace sources at the "top" of the net device, where packets transition |
120 // to/from higher layers. These points do not really correspond to the | 120 // to/from higher layers. These points do not really correspond to the |
121 // MAC layer of the underlying operating system, but exist to provide | 121 // MAC layer of the underlying operating system, but exist to provide |
122 // a consitent tracing environment. These trace hooks should really be | 122 // a consistent tracing environment. These trace hooks should really be |
123 // interpreted as the points at which a packet leaves the ns-3 environment | 123 // interpreted as the points at which a packet leaves the ns-3 environment |
124 // destined for the underlying operating system or vice-versa. | 124 // destined for the underlying operating system or vice-versa. |
125 // | 125 // |
126 .AddTraceSource ("MacTx", | 126 .AddTraceSource ("MacTx", |
127 "Trace source indicating a packet has " | 127 "Trace source indicating a packet has " |
128 "arrived for transmission by this device", | 128 "arrived for transmission by this device", |
129 MakeTraceSourceAccessor (&FdNetDevice::m_macTxTrace), | 129 MakeTraceSourceAccessor (&FdNetDevice::m_macTxTrace), |
130 "ns3::Packet::TracedCallback") | 130 "ns3::Packet::TracedCallback") |
131 .AddTraceSource ("MacTxDrop", | 131 .AddTraceSource ("MacTxDrop", |
132 "Trace source indicating a packet has " | 132 "Trace source indicating a packet has " |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 // We need to remove the PI header and ignore it | 402 // We need to remove the PI header and ignore it |
403 if (m_encapMode == DIXPI) | 403 if (m_encapMode == DIXPI) |
404 { | 404 { |
405 RemovePIHeader (buf, len); | 405 RemovePIHeader (buf, len); |
406 } | 406 } |
407 | 407 |
408 // | 408 // |
409 // Create a packet out of the buffer we received and free that buffer. | 409 // Create a packet out of the buffer we received and free that buffer. |
410 // | 410 // |
411 Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf),
len); | 411 Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf),
static_cast<uint32_t> (len)); |
412 free (buf); | 412 free (buf); |
413 buf = 0; | 413 buf = 0; |
414 | 414 |
415 // | 415 // |
416 // Trace sinks will expect complete packets, not packets without some of the | 416 // Trace sinks will expect complete packets, not packets without some of the |
417 // headers | 417 // headers |
418 // | 418 // |
419 Ptr<Packet> originalPacket = packet->Copy (); | 419 Ptr<Packet> originalPacket = packet->Copy (); |
420 | 420 |
421 Mac48Address destination; | 421 Mac48Address destination; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 header.SetDestination (destination); | 548 header.SetDestination (destination); |
549 | 549 |
550 NS_ASSERT_MSG (packet->GetSize () <= m_mtu, "FdNetDevice::SendFrom(): Packet t
oo big " << packet->GetSize ()); | 550 NS_ASSERT_MSG (packet->GetSize () <= m_mtu, "FdNetDevice::SendFrom(): Packet t
oo big " << packet->GetSize ()); |
551 | 551 |
552 if (m_encapMode == LLC) | 552 if (m_encapMode == LLC) |
553 { | 553 { |
554 LlcSnapHeader llc; | 554 LlcSnapHeader llc; |
555 llc.SetType (protocolNumber); | 555 llc.SetType (protocolNumber); |
556 packet->AddHeader (llc); | 556 packet->AddHeader (llc); |
557 | 557 |
558 header.SetLengthType ((uint16_t)packet->GetSize ()); | 558 header.SetLengthType (static_cast<uint16_t> (packet->GetSize ())); |
559 } | 559 } |
560 else | 560 else |
561 { | 561 { |
562 header.SetLengthType (protocolNumber); | 562 header.SetLengthType (protocolNumber); |
563 } | 563 } |
564 | 564 |
565 packet->AddHeader (header); | 565 packet->AddHeader (header); |
566 | 566 |
567 // | 567 // |
568 // there's not much meaning associated with the different layers in this | 568 // there's not much meaning associated with the different layers in this |
569 // device, so don't be surprised when they're all stacked together in | 569 // device, so don't be surprised when they're all stacked together in |
570 // essentially one place. We do this for trace consistency across devices. | 570 // essentially one place. We do this for trace consistency across devices. |
571 // | 571 // |
572 m_macTxTrace (packet); | 572 m_macTxTrace (packet); |
573 | 573 |
574 m_promiscSnifferTrace (packet); | 574 m_promiscSnifferTrace (packet); |
575 m_snifferTrace (packet); | 575 m_snifferTrace (packet); |
576 | 576 |
577 NS_LOG_LOGIC ("calling write"); | 577 NS_LOG_LOGIC ("calling write"); |
578 | 578 |
579 | 579 |
580 size_t len = (size_t) packet->GetSize (); | 580 size_t len = (size_t) packet->GetSize (); |
581 uint8_t *buffer = (uint8_t*)malloc (len); | 581 uint8_t *buffer = (uint8_t*)malloc (len); |
582 packet->CopyData (buffer, len); | 582 packet->CopyData (buffer, static_cast<uint32_t> (len)); |
583 | 583 |
584 // We need to add the PI header | 584 // We need to add the PI header |
585 if (m_encapMode == DIXPI) | 585 if (m_encapMode == DIXPI) |
586 { | 586 { |
587 AddPIHeader (buffer, len); | 587 AddPIHeader (buffer, len); |
588 } | 588 } |
589 | 589 |
590 ssize_t written = write (m_fd, buffer, len); | 590 ssize_t written = write (m_fd, buffer, len); |
591 free (buffer); | 591 free (buffer); |
592 | 592 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 m_promiscRxCallback = cb; | 760 m_promiscRxCallback = cb; |
761 } | 761 } |
762 | 762 |
763 bool | 763 bool |
764 FdNetDevice::SupportsSendFrom (void) const | 764 FdNetDevice::SupportsSendFrom (void) const |
765 { | 765 { |
766 return true; | 766 return true; |
767 } | 767 } |
768 | 768 |
769 } // namespace ns3 | 769 } // namespace ns3 |
LEFT | RIGHT |