src/node/net-device.h
changeset 1866 e7dbcc4df546
parent 1451 e421081dd580
child 2191 347400c335f9
equal deleted inserted replaced
1865:829dc1815014 1866:e7dbcc4df546
    23 #define NET_DEVICE_H
    23 #define NET_DEVICE_H
    24 
    24 
    25 #include <string>
    25 #include <string>
    26 #include <stdint.h>
    26 #include <stdint.h>
    27 #include "ns3/callback.h"
    27 #include "ns3/callback.h"
    28 #include "ns3/packet.h"
       
    29 #include "ns3/object.h"
    28 #include "ns3/object.h"
    30 #include "ns3/ptr.h"
    29 #include "ns3/ptr.h"
    31 #include "address.h"
    30 #include "address.h"
    32 #include "ipv4-address.h"
    31 #include "ipv4-address.h"
    33 
    32 
    35 
    34 
    36 class Node;
    35 class Node;
    37 class TraceResolver;
    36 class TraceResolver;
    38 class TraceContext;
    37 class TraceContext;
    39 class Channel;
    38 class Channel;
       
    39 class Packet;
    40 
    40 
    41 /**
    41 /**
    42  * \brief Network layer to device interface
    42  * \brief Network layer to device interface
    43  *
    43  *
    44  * This interface defines the API which the IP and ARP
    44  * This interface defines the API which the IP and ARP
   208    *  Called from higher layer to send packet into Network Device
   208    *  Called from higher layer to send packet into Network Device
   209    *  to the specified destination Address
   209    *  to the specified destination Address
   210    * 
   210    * 
   211    * \return whether the Send operation succeeded 
   211    * \return whether the Send operation succeeded 
   212    */
   212    */
   213   bool Send(const Packet& p, const Address& dest, uint16_t protocolNumber);
   213   bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
   214   /**
   214   /**
   215    * \returns the node base class which contains this network
   215    * \returns the node base class which contains this network
   216    *          interface.
   216    *          interface.
   217    *
   217    *
   218    * When a subclass needs to get access to the underlying node
   218    * When a subclass needs to get access to the underlying node
   237    *        given to the Send method by the user on the sender side.
   237    *        given to the Send method by the user on the sender side.
   238    * \param address the address of the sender
   238    * \param address the address of the sender
   239    * \returns true if the callback could handle the packet successfully, false
   239    * \returns true if the callback could handle the packet successfully, false
   240    *          otherwise.
   240    *          otherwise.
   241    */
   241    */
   242   typedef Callback<bool,Ptr<NetDevice>,const Packet &,uint16_t,const Address &> ReceiveCallback;
   242   typedef Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &> ReceiveCallback;
   243 
   243 
   244   /**
   244   /**
   245    * \param cb callback to invoke whenever a packet has been received and must
   245    * \param cb callback to invoke whenever a packet has been received and must
   246    *        be forwarded to the higher layers.
   246    *        be forwarded to the higher layers.
   247    *
   247    *
   302    *
   302    *
   303    * When a subclass gets a packet from the channel, it 
   303    * When a subclass gets a packet from the channel, it 
   304    * forwards it to the higher layers by calling this method
   304    * forwards it to the higher layers by calling this method
   305    * which is responsible for passing it up to the Rx callback.
   305    * which is responsible for passing it up to the Rx callback.
   306    */
   306    */
   307   bool ForwardUp (const Packet& p, uint16_t param, const Address &address);
   307   bool ForwardUp (Ptr<Packet> p, uint16_t param, const Address &address);
   308 
   308 
   309 
   309 
   310   /**
   310   /**
   311    * The dispose method for this NetDevice class.
   311    * The dispose method for this NetDevice class.
   312    * Subclasses are expected to override this method _and_
   312    * Subclasses are expected to override this method _and_
   325    *
   325    *
   326    * This is the private virtual target function of the public Send()
   326    * This is the private virtual target function of the public Send()
   327    * method.  When the link is Up, this method is invoked to ask 
   327    * method.  When the link is Up, this method is invoked to ask 
   328    * subclasses to forward packets. Subclasses MUST override this method.
   328    * subclasses to forward packets. Subclasses MUST override this method.
   329    */
   329    */
   330   virtual bool SendTo (const Packet& p, const Address &dest, uint16_t protocolNumber) = 0;
   330   virtual bool SendTo (Ptr<Packet> p, const Address &dest, uint16_t protocolNumber) = 0;
   331   /**
   331   /**
   332    * \returns true if this NetDevice needs the higher-layers
   332    * \returns true if this NetDevice needs the higher-layers
   333    *          to perform ARP over it, false otherwise.
   333    *          to perform ARP over it, false otherwise.
   334    *
   334    *
   335    * Subclasses must implement this method.
   335    * Subclasses must implement this method.