|
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2007 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 #ifndef PACKET_SOCKET_ADDRESS_H |
|
21 #define PACKET_SOCKET_ADDRESS_H |
|
22 |
|
23 #include "address.h" |
|
24 #include "eui48-address.h" |
|
25 #include "eui64-address.h" |
|
26 |
|
27 namespace ns3 { |
|
28 |
|
29 class NetDevice; |
|
30 |
|
31 class PacketSocketAddress |
|
32 { |
|
33 public: |
|
34 PacketSocketAddress (); |
|
35 void SetProtocol (uint16_t protocol); |
|
36 void SetDevice (uint32_t index); |
|
37 void SetPhysicalAddress (const Address address); |
|
38 |
|
39 uint16_t GetProtocol (void) const; |
|
40 uint32_t GetDevice (void) const; |
|
41 Address GetPhysicalAddress (void) const; |
|
42 |
|
43 /** |
|
44 * \returns a new Address instance |
|
45 * |
|
46 * Convert an instance of this class to a polymorphic Address instance. |
|
47 */ |
|
48 Address ConvertTo (void) const; |
|
49 /** |
|
50 * \param address a polymorphic address |
|
51 * |
|
52 * Convert a polymorphic address to an Eui48Address instance. |
|
53 * The conversion performs a type check. |
|
54 */ |
|
55 static PacketSocketAddress ConvertFrom (const Address &address); |
|
56 /** |
|
57 * \returns true if the address matches, false otherwise. |
|
58 */ |
|
59 static bool IsMatchingType (const Address &address); |
|
60 private: |
|
61 static uint8_t GetType (void); |
|
62 static uint8_t GetSize (void); |
|
63 uint16_t m_protocol; |
|
64 uint32_t m_device; |
|
65 Address m_address; |
|
66 }; |
|
67 |
|
68 |
|
69 } // namespace ns3 |
|
70 |
|
71 #endif /* PACKET_SOCKET_ADDRESS_H */ |