00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 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 SIMPLE_NET_DEVICE_H 00021 #define SIMPLE_NET_DEVICE_H 00022 00023 #include "net-device.h" 00024 #include "mac48-address.h" 00025 #include <stdint.h> 00026 #include <string> 00027 00028 namespace ns3 { 00029 00030 class SimpleChannel; 00031 class Node; 00032 00033 /** 00034 * \ingroup netdevice 00035 * 00036 * \brief simple net device for simple things and testing 00037 */ 00038 class SimpleNetDevice : public NetDevice 00039 { 00040 public: 00041 static TypeId GetTypeId (void); 00042 SimpleNetDevice (); 00043 00044 void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from); 00045 void SetChannel (Ptr<SimpleChannel> channel); 00046 void SetAddress (Mac48Address address); 00047 00048 // inherited from NetDevice base class. 00049 virtual void SetName(const std::string name); 00050 virtual std::string GetName(void) const; 00051 virtual void SetIfIndex(const uint32_t index); 00052 virtual uint32_t GetIfIndex(void) const; 00053 virtual Ptr<Channel> GetChannel (void) const; 00054 virtual Address GetAddress (void) const; 00055 virtual bool SetMtu (const uint16_t mtu); 00056 virtual uint16_t GetMtu (void) const; 00057 virtual bool IsLinkUp (void) const; 00058 virtual void SetLinkChangeCallback (Callback<void> callback); 00059 virtual bool IsBroadcast (void) const; 00060 virtual Address GetBroadcast (void) const; 00061 virtual bool IsMulticast (void) const; 00062 virtual Address GetMulticast (Ipv4Address multicastGroup) const; 00063 virtual bool IsPointToPoint (void) const; 00064 virtual bool IsBridge (void) const; 00065 virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber); 00066 virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber); 00067 virtual Ptr<Node> GetNode (void) const; 00068 virtual void SetNode (Ptr<Node> node); 00069 virtual bool NeedsArp (void) const; 00070 virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); 00071 00072 virtual Address GetMulticast (Ipv6Address addr) const; 00073 00074 virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb); 00075 virtual bool SupportsSendFrom (void) const; 00076 00077 protected: 00078 virtual void DoDispose (void); 00079 private: 00080 Ptr<SimpleChannel> m_channel; 00081 NetDevice::ReceiveCallback m_rxCallback; 00082 NetDevice::PromiscReceiveCallback m_promiscCallback; 00083 Ptr<Node> m_node; 00084 uint16_t m_mtu; 00085 std::string m_name; 00086 uint32_t m_ifIndex; 00087 Mac48Address m_address; 00088 }; 00089 00090 } // namespace ns3 00091 00092 #endif /* SIMPLE_NET_DEVICE_H */