A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
arp-header.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef ARP_HEADER_H
22 #define ARP_HEADER_H
23 
24 #include "ns3/header.h"
25 #include "ns3/address.h"
26 #include "ns3/ipv4-address.h"
27 #include <string>
28 
29 namespace ns3 {
34 class ArpHeader : public Header
35 {
36 public:
37  void SetRequest (Address sourceHardwareAddress,
38  Ipv4Address sourceProtocolAddress,
39  Address destinationHardwareAddress,
40  Ipv4Address destinationProtocolAddress);
41  void SetReply (Address sourceHardwareAddress,
42  Ipv4Address sourceProtocolAddress,
43  Address destinationHardwareAddress,
44  Ipv4Address destinationProtocolAddress);
45  bool IsRequest (void) const;
46  bool IsReply (void) const;
47  Address GetSourceHardwareAddress (void);
48  Address GetDestinationHardwareAddress (void);
49  Ipv4Address GetSourceIpv4Address (void);
50  Ipv4Address GetDestinationIpv4Address (void);
51 
52  static TypeId GetTypeId (void);
53  virtual TypeId GetInstanceTypeId (void) const;
54  virtual void Print (std::ostream &os) const;
55  virtual uint32_t GetSerializedSize (void) const;
56  virtual void Serialize (Buffer::Iterator start) const;
57  virtual uint32_t Deserialize (Buffer::Iterator start);
58 
59  enum ArpType_e {
60  ARP_TYPE_REQUEST = 1,
61  ARP_TYPE_REPLY = 2
62  };
63  uint16_t m_type;
64  Address m_macSource;
65  Address m_macDest;
66  Ipv4Address m_ipv4Source;
67  Ipv4Address m_ipv4Dest;
68 };
69 
70 } // namespace ns3
71 
72 #endif /* ARP_HEADER_H */
Protocol header serialization and deserialization.
Definition: header.h:42
virtual void Serialize(Buffer::Iterator start) const
Definition: arp-header.cc:148
The packet header for an ARP packet.
Definition: arp-header.h:34
iterator in a Buffer instance
Definition: buffer.h:98
a polymophic address class
Definition: address.h:86
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: arp-header.cc:168
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual TypeId GetInstanceTypeId(void) const
Definition: arp-header.cc:106
virtual void Print(std::ostream &os) const
Definition: arp-header.cc:112
a unique identifier for an interface.
Definition: type-id.h:44
virtual uint32_t GetSerializedSize(void) const
Definition: arp-header.cc:135