1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3
* Copyright (c) 2005 INRIA
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;
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.
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
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
26
#include "ns3/header.h"
27
#include "ns3/ipv4-address.h"
32
* \brief Packet header for UDP packets
34
* This class has fields corresponding to those in a network UDP header
35
* (port numbers, payload size, checksum) as well as methods for serialization
36
* to and deserialization from a byte buffer.
38
class UdpHeader : public Header
45
* Creates a null header
51
* \brief Enable checksum calculation for UDP
53
void EnableChecksums (void);
55
* \param port the destination port for this UdpHeader
57
void SetDestinationPort (uint16_t port);
59
* \param port The source port for this UdpHeader
61
void SetSourcePort (uint16_t port);
63
* \return The source port for this UdpHeader
65
uint16_t GetSourcePort (void) const;
67
* \return the destination port for this UdpHeader
69
uint16_t GetDestinationPort (void) const;
72
* \param source the ip source to use in the underlying
74
* \param destination the ip destination to use in the
75
* underlying ip packet.
76
* \param protocol the protocol number to use in the underlying
79
* If you want to use udp checksums, you should call this
80
* method prior to adding the header to a packet.
82
void InitializeChecksum (Ipv4Address source,
83
Ipv4Address destination,
86
static TypeId GetTypeId (void);
87
virtual TypeId GetInstanceTypeId (void) const;
88
virtual void Print (std::ostream &os) const;
89
virtual uint32_t GetSerializedSize (void) const;
90
virtual void Serialize (Buffer::Iterator start) const;
91
virtual uint32_t Deserialize (Buffer::Iterator start);
94
* \brief Is the UDP checksum correct ?
95
* \returns true if the checksum is correct, false otherwise.
97
bool IsChecksumOk (void) const;
100
uint16_t CalculateHeaderChecksum (uint16_t size) const;
101
uint16_t m_sourcePort;
102
uint16_t m_destinationPort;
103
uint16_t m_payloadSize;
105
Ipv4Address m_source;
106
Ipv4Address m_destination;
114
#endif /* UDP_HEADER */