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) 2011 The Boeing Company | 3 * Copyright (c) 2011 The Boeing Company |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 LrWpanMacTrailer::GetFcs (void) const | 84 LrWpanMacTrailer::GetFcs (void) const |
85 { | 85 { |
86 return m_fcs; | 86 return m_fcs; |
87 } | 87 } |
88 | 88 |
89 void | 89 void |
90 LrWpanMacTrailer::SetFcs (Ptr<const Packet> p) | 90 LrWpanMacTrailer::SetFcs (Ptr<const Packet> p) |
91 { | 91 { |
92 if (m_calcFcs) | 92 if (m_calcFcs) |
93 { | 93 { |
94 uint16_t size = p->GetSize (); | 94 uint16_t size = static_cast<uint16_t> (p->GetSize ()); |
95 uint8_t *serial_packet = new uint8_t[size]; | 95 uint8_t *serial_packet = new uint8_t[size]; |
96 | 96 |
97 p->CopyData (serial_packet, size); | 97 p->CopyData (serial_packet, size); |
98 | 98 |
99 m_fcs = GenerateCrc16 (serial_packet, size); | 99 m_fcs = GenerateCrc16 (serial_packet, size); |
100 delete[] serial_packet; | 100 delete[] serial_packet; |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 /* Be sure to have removed the trailer and only the trailer | 104 /* Be sure to have removed the trailer and only the trailer |
105 * from the packet before to use CheckFcs */ | 105 * from the packet before to use CheckFcs */ |
106 bool | 106 bool |
107 LrWpanMacTrailer::CheckFcs (Ptr<const Packet> p) | 107 LrWpanMacTrailer::CheckFcs (Ptr<const Packet> p) |
108 { | 108 { |
109 if (!m_calcFcs) | 109 if (!m_calcFcs) |
110 { | 110 { |
111 return true; | 111 return true; |
112 } | 112 } |
113 else | 113 else |
114 { | 114 { |
115 uint16_t checkFcs; | 115 uint16_t checkFcs; |
116 uint16_t size = p->GetSize (); | 116 uint16_t size = static_cast<uint16_t> (p->GetSize ()); |
117 uint8_t *serial_packet = new uint8_t[size]; | 117 uint8_t *serial_packet = new uint8_t[size]; |
118 | 118 |
119 p->CopyData (serial_packet, size); | 119 p->CopyData (serial_packet, size); |
120 | 120 |
121 checkFcs = GenerateCrc16 (serial_packet, size); | 121 checkFcs = GenerateCrc16 (serial_packet, size); |
122 delete[] serial_packet; | 122 delete[] serial_packet; |
123 return (checkFcs == GetFcs ()); | 123 return (checkFcs == GetFcs ()); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
(...skipping 25 matching lines...) Expand all Loading... |
152 accumulator = (accumulator >> 8) | (accumulator << 8); | 152 accumulator = (accumulator >> 8) | (accumulator << 8); |
153 accumulator ^= (accumulator & 0xff00) << 4; | 153 accumulator ^= (accumulator & 0xff00) << 4; |
154 accumulator ^= (accumulator >> 8) >> 4; | 154 accumulator ^= (accumulator >> 8) >> 4; |
155 accumulator ^= (accumulator & 0xff00) >> 5; | 155 accumulator ^= (accumulator & 0xff00) >> 5; |
156 ++data; | 156 ++data; |
157 } | 157 } |
158 return accumulator; | 158 return accumulator; |
159 } | 159 } |
160 | 160 |
161 } //namespace ns3 | 161 } //namespace ns3 |
OLD | NEW |