LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2015 Université Pierre et Marie Curie |
| 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 * Author: Matthieu Coudron <matthieu.coudron@lip6.fr> |
| 19 */ |
| 20 #include "sll-header.h" |
| 21 #include "ns3/log.h" |
| 22 |
| 23 |
| 24 namespace ns3 { |
| 25 |
| 26 NS_LOG_COMPONENT_DEFINE ("SllHeader"); |
| 27 |
| 28 NS_OBJECT_ENSURE_REGISTERED (SllHeader); |
| 29 |
| 30 SllHeader::SllHeader () |
| 31 : m_packetType (UNICAST_FROM_PEER_TO_ME), |
| 32 m_arphdType (0), |
| 33 m_addressLength (0), |
| 34 m_address (0), |
| 35 m_protocolType (0) |
| 36 { |
| 37 NS_LOG_FUNCTION (this); |
| 38 } |
| 39 |
| 40 SllHeader::~SllHeader () |
| 41 { |
| 42 NS_LOG_FUNCTION (this); |
| 43 } |
| 44 |
| 45 |
| 46 TypeId |
| 47 SllHeader::GetTypeId (void) |
| 48 { |
| 49 static TypeId tid = TypeId ("ns3::SllHeader") |
| 50 .SetParent<Header> () |
| 51 .SetGroupName ("Network") |
| 52 .AddConstructor<SllHeader> () |
| 53 ; |
| 54 return tid; |
| 55 } |
| 56 |
| 57 TypeId |
| 58 SllHeader::GetInstanceTypeId (void) const |
| 59 { |
| 60 return GetTypeId (); |
| 61 } |
| 62 |
| 63 uint16_t |
| 64 SllHeader::GetArpType () const |
| 65 { |
| 66 return m_arphdType; |
| 67 } |
| 68 |
| 69 void |
| 70 SllHeader::SetArpType (uint16_t arphdType) |
| 71 { |
| 72 NS_LOG_FUNCTION (arphdType); |
| 73 m_arphdType = arphdType; |
| 74 } |
| 75 |
| 76 void |
| 77 SllHeader::SetPacketType (PacketType type) |
| 78 { |
| 79 NS_LOG_FUNCTION (type); |
| 80 m_packetType = type; |
| 81 } |
| 82 |
| 83 void |
| 84 SllHeader::Print (std::ostream &os) const |
| 85 { |
| 86 os << "SLLHeader packetType=" << m_packetType << " protocol=" << m_protocolTyp
e; |
| 87 } |
| 88 |
| 89 uint32_t |
| 90 SllHeader::GetSerializedSize (void) const |
| 91 { |
| 92 return 2 + 2 + 2 + 8 + 2; |
| 93 } |
| 94 |
| 95 void |
| 96 SllHeader::Serialize (Buffer::Iterator start) const |
| 97 { |
| 98 Buffer::Iterator i = start; |
| 99 i.WriteHtonU16 (m_packetType); |
| 100 i.WriteHtonU16 (m_arphdType); |
| 101 i.WriteHtonU16 (m_addressLength); |
| 102 i.WriteHtonU64 (m_address); |
| 103 i.WriteHtonU16 (m_protocolType); |
| 104 } |
| 105 |
| 106 uint32_t |
| 107 SllHeader::Deserialize (Buffer::Iterator start) |
| 108 { |
| 109 Buffer::Iterator i = start; |
| 110 m_packetType = static_cast<PacketType> (i.ReadNtohU16 ()); |
| 111 m_arphdType = i.ReadNtohU16 (); |
| 112 m_addressLength = i.ReadNtohU16 (); |
| 113 m_address = i.ReadNtohU64 (); |
| 114 m_protocolType = i.ReadNtohU16 (); |
| 115 |
| 116 return GetSerializedSize (); |
| 117 } |
| 118 |
| 119 } |
LEFT | RIGHT |