author | Pedro Silva <pmms@inesctec.pt> |
Wed, 29 Oct 2014 10:12:53 -0700 | |
changeset 11040 | cd2eda848730 |
parent 10652 | dc18deba4502 |
child 11259 | ea2f6a3ed14e |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include "udp-header.h" |
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
22 |
#include "ns3/address-utils.h" |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
1236
cfa5e0b39281
rework the NS_XX_ENSURE_REGISTERED macros and make sure we typecheck the input to TraceContext::Add and TraceContext::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1234
diff
changeset
|
24 |
namespace ns3 { |
1152
1d06449f0a98
macros to ensure proper initialization
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1151
diff
changeset
|
25 |
|
10652
dc18deba4502
[doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10479
diff
changeset
|
26 |
NS_OBJECT_ENSURE_REGISTERED (UdpHeader); |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
/* The magic values below are used only for debugging. |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
* They can be used to easily detect memory corruption |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
* problems so you can see the patterns in memory. |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
*/ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
UdpHeader::UdpHeader () |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
: m_sourcePort (0xfffd), |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
m_destinationPort (0xfffd), |
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
35 |
m_payloadSize (0), |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
36 |
m_checksum (0), |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
37 |
m_calcChecksum (false), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
38 |
m_goodChecksum (true) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
39 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
40 |
} |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
UdpHeader::~UdpHeader () |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
m_sourcePort = 0xfffe; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
m_destinationPort = 0xfffe; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
m_payloadSize = 0xfffe; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
|
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
void |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
UdpHeader::EnableChecksums (void) |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
m_calcChecksum = true; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
|
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
void |
3238
3b24ac252fba
bug 195: naming inconsistency.
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
55 |
UdpHeader::SetDestinationPort (uint16_t port) |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
m_destinationPort = port; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
void |
3238
3b24ac252fba
bug 195: naming inconsistency.
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
60 |
UdpHeader::SetSourcePort (uint16_t port) |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
m_sourcePort = port; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
uint16_t |
3238
3b24ac252fba
bug 195: naming inconsistency.
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
65 |
UdpHeader::GetSourcePort (void) const |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
return m_sourcePort; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
uint16_t |
3238
3b24ac252fba
bug 195: naming inconsistency.
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2834
diff
changeset
|
70 |
UdpHeader::GetDestinationPort (void) const |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
return m_destinationPort; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
73 |
} |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
74 |
void |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
75 |
UdpHeader::InitializeChecksum (Address source, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
76 |
Address destination, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
77 |
uint8_t protocol) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
78 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
79 |
m_source = source; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
80 |
m_destination = destination; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
81 |
m_protocol = protocol; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
82 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
83 |
void |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
84 |
UdpHeader::InitializeChecksum (Ipv4Address source, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
85 |
Ipv4Address destination, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
86 |
uint8_t protocol) |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
87 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
88 |
m_source = source; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
89 |
m_destination = destination; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
90 |
m_protocol = protocol; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
91 |
} |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
void |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
93 |
UdpHeader::InitializeChecksum (Ipv6Address source, |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
94 |
Ipv6Address destination, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
95 |
uint8_t protocol) |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
{ |
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
97 |
m_source = source; |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
98 |
m_destination = destination; |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
99 |
m_protocol = protocol; |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
100 |
} |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
101 |
uint16_t |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
102 |
UdpHeader::CalculateHeaderChecksum (uint16_t size) const |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
103 |
{ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
104 |
Buffer buf = Buffer ((2 * Address::MAX_SIZE) + 8); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
105 |
buf.AddAtStart ((2 * Address::MAX_SIZE) + 8); |
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
106 |
Buffer::Iterator it = buf.Begin (); |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
107 |
uint32_t hdrSize = 0; |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
108 |
|
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
109 |
WriteTo (it, m_source); |
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
110 |
WriteTo (it, m_destination); |
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
111 |
if (Ipv4Address::IsMatchingType (m_source)) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
112 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
113 |
it.WriteU8 (0); /* protocol */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
114 |
it.WriteU8 (m_protocol); /* protocol */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
115 |
it.WriteU8 (size >> 8); /* length */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
116 |
it.WriteU8 (size & 0xff); /* length */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
117 |
hdrSize = 12; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
118 |
} |
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
119 |
else if (Ipv6Address::IsMatchingType (m_source)) |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
120 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
121 |
it.WriteU16 (0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
122 |
it.WriteU8 (size >> 8); /* length */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
123 |
it.WriteU8 (size & 0xff); /* length */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
124 |
it.WriteU16 (0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
125 |
it.WriteU8 (0); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
126 |
it.WriteU8 (m_protocol); /* protocol */ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
127 |
hdrSize = 40; |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
128 |
} |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
129 |
|
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
130 |
it = buf.Begin (); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
131 |
/* we don't CompleteChecksum ( ~ ) now */ |
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7386
diff
changeset
|
132 |
return ~(it.CalculateIpChecksum (hdrSize)); |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
133 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
134 |
|
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
135 |
bool |
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
136 |
UdpHeader::IsChecksumOk (void) const |
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
137 |
{ |
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
138 |
return m_goodChecksum; |
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
139 |
} |
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
140 |
|
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
141 |
void |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
142 |
UdpHeader::ForceChecksum (uint16_t checksum) |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
143 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
144 |
m_checksum = checksum; |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
145 |
} |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
146 |
|
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
147 |
void |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
148 |
UdpHeader::ForcePayloadSize (uint16_t payloadSize) |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
149 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
150 |
m_payloadSize = payloadSize; |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
151 |
} |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
152 |
|
2646
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
153 |
TypeId |
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
154 |
UdpHeader::GetTypeId (void) |
795
cd108c9817d0
add Chunk::GetName and implement it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
155 |
{ |
2646
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
156 |
static TypeId tid = TypeId ("ns3::UdpHeader") |
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
157 |
.SetParent<Header> () |
2650
3de4cacb8981
make sure all headers and trailers gets a constructor registered in their TypeId.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2646
diff
changeset
|
158 |
.AddConstructor<UdpHeader> () |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
159 |
; |
2646
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
160 |
return tid; |
795
cd108c9817d0
add Chunk::GetName and implement it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
161 |
} |
2646
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
162 |
TypeId |
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
163 |
UdpHeader::GetInstanceTypeId (void) const |
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
164 |
{ |
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
165 |
return GetTypeId (); |
c1fef7686472
remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2643
diff
changeset
|
166 |
} |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
167 |
void |
1232
2e8c3f8bb77f
remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1152
diff
changeset
|
168 |
UdpHeader::Print (std::ostream &os) const |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
169 |
{ |
2653
b8eff7186c5c
improve pretty-printing output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2650
diff
changeset
|
170 |
os << "length: " << m_payloadSize + GetSerializedSize () |
b8eff7186c5c
improve pretty-printing output.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2650
diff
changeset
|
171 |
<< " " |
900
2087082ba3ed
change default pretty printing output format, add doc to metadata data structures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
795
diff
changeset
|
172 |
<< m_sourcePort << " > " << m_destinationPort |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
173 |
; |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
174 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
175 |
|
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
176 |
uint32_t |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
177 |
UdpHeader::GetSerializedSize (void) const |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
178 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
179 |
return 8; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
180 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
181 |
|
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
235
diff
changeset
|
182 |
void |
1232
2e8c3f8bb77f
remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1152
diff
changeset
|
183 |
UdpHeader::Serialize (Buffer::Iterator start) const |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
Buffer::Iterator i = start; |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
186 |
|
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
i.WriteHtonU16 (m_sourcePort); |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
188 |
i.WriteHtonU16 (m_destinationPort); |
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
189 |
if (m_payloadSize == 0) |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
190 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
191 |
i.WriteHtonU16 (start.GetSize ()); |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
192 |
} |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
193 |
else |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
194 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
195 |
i.WriteHtonU16 (m_payloadSize); |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
196 |
} |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
197 |
|
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
198 |
if ( m_checksum == 0) |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
199 |
{ |
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
200 |
i.WriteU16 (0); |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
201 |
|
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
202 |
if (m_calcChecksum) |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
203 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
204 |
uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ()); |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
205 |
i = start; |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
206 |
uint16_t checksum = i.CalculateIpChecksum (start.GetSize (), headerChecksum); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
207 |
|
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
208 |
i = start; |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
209 |
i.Next (6); |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
210 |
i.WriteU16 (checksum); |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
211 |
} |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
212 |
} |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
213 |
else |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
214 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
215 |
i.WriteU16 (m_checksum); |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
216 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
217 |
} |
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
235
diff
changeset
|
218 |
uint32_t |
1232
2e8c3f8bb77f
remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1152
diff
changeset
|
219 |
UdpHeader::Deserialize (Buffer::Iterator start) |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
220 |
{ |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
221 |
Buffer::Iterator i = start; |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
222 |
m_sourcePort = i.ReadNtohU16 (); |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
223 |
m_destinationPort = i.ReadNtohU16 (); |
1232
2e8c3f8bb77f
remove Chunk base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1152
diff
changeset
|
224 |
m_payloadSize = i.ReadNtohU16 () - GetSerializedSize (); |
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
225 |
m_checksum = i.ReadU16 (); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
226 |
|
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
227 |
if (m_calcChecksum) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
228 |
{ |
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
229 |
uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ()); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
230 |
i = start; |
3404
b5d4a04c7b68
bug 247: tcp checksum crashes when enabled.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3363
diff
changeset
|
231 |
uint16_t checksum = i.CalculateIpChecksum (start.GetSize (), headerChecksum); |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
232 |
|
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
233 |
m_goodChecksum = (checksum == 0); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
234 |
} |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
235 |
|
463
c2082308e01a
merge Packet API changes needed for Packet pretty printing.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
235
diff
changeset
|
236 |
return GetSerializedSize (); |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
237 |
} |
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
238 |
|
10479
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
239 |
uint16_t |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
240 |
UdpHeader::GetChecksum () |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
241 |
{ |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
242 |
return m_checksum; |
fc4ee8106e4a
6LoWPAN module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10410
diff
changeset
|
243 |
} |
235
190d5bef3254
add ipv4 and udp header, add ipv4 checksum support to make the udp header compile. Need to be fixed in UdpHeader later.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
244 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
245 |
} // namespace ns3 |