00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2007 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef PACKET_SOCKET_ADDRESS_H 00021 #define PACKET_SOCKET_ADDRESS_H 00022 00023 #include "ns3/ptr.h" 00024 #include "address.h" 00025 #include "mac48-address.h" 00026 #include "mac64-address.h" 00027 #include "net-device.h" 00028 00029 namespace ns3 { 00030 00031 class NetDevice; 00032 00033 /** 00034 * \ingroup address 00035 * 00036 * \brief an address for a packet socket 00037 */ 00038 class PacketSocketAddress 00039 { 00040 public: 00041 PacketSocketAddress (); 00042 void SetProtocol (uint16_t protocol); 00043 00044 void SetAllDevices (void); 00045 void SetSingleDevice (uint32_t device); 00046 void SetPhysicalAddress (const Address address); 00047 00048 uint16_t GetProtocol (void) const; 00049 uint32_t GetSingleDevice (void) const; 00050 bool IsSingleDevice (void) const; 00051 Address GetPhysicalAddress (void) const; 00052 00053 /** 00054 * \returns a new Address instance 00055 * 00056 * Convert an instance of this class to a polymorphic Address instance. 00057 */ 00058 operator Address () const; 00059 /** 00060 * \param address a polymorphic address 00061 * 00062 * Convert a polymorphic address to an Mac48Address instance. 00063 * The conversion performs a type check. 00064 */ 00065 static PacketSocketAddress ConvertFrom (const Address &address); 00066 /** 00067 * \returns true if the address matches, false otherwise. 00068 */ 00069 static bool IsMatchingType (const Address &address); 00070 private: 00071 static uint8_t GetType (void); 00072 Address ConvertTo (void) const; 00073 uint16_t m_protocol; 00074 bool m_isSingleDevice; 00075 uint32_t m_device; 00076 Address m_address; 00077 }; 00078 00079 00080 } // namespace ns3 00081 00082 #endif /* PACKET_SOCKET_ADDRESS_H */