src/devices/tap-bridge/tap-bridge.h
changeset 6747 9dccf3624839
parent 6273 8d70de29d514
equal deleted inserted replaced
6746:9724876b3ae1 6747:9dccf3624839
    29 #include "ns3/event-id.h"
    29 #include "ns3/event-id.h"
    30 #include "ns3/nstime.h"
    30 #include "ns3/nstime.h"
    31 #include "ns3/data-rate.h"
    31 #include "ns3/data-rate.h"
    32 #include "ns3/ptr.h"
    32 #include "ns3/ptr.h"
    33 #include "ns3/mac48-address.h"
    33 #include "ns3/mac48-address.h"
    34 #include "ns3/system-thread.h"
    34 #include "ns3/unix-fd-reader.h"
    35 #include "ns3/realtime-simulator-impl.h"
    35 #include "ns3/realtime-simulator-impl.h"
    36 
    36 
    37 namespace ns3 {
    37 namespace ns3 {
       
    38 
       
    39 class TapBridgeFdReader : public FdReader
       
    40 {
       
    41 private:
       
    42   FdReader::Data DoRead (void);
       
    43 };
    38 
    44 
    39 class Node;
    45 class Node;
    40 
    46 
    41 /**
    47 /**
    42  * \ingroup tap-bridge
    48  * \ingroup tap-bridge
   246   void StopTapDevice (void);
   252   void StopTapDevice (void);
   247 
   253 
   248   /**
   254   /**
   249    * \internal
   255    * \internal
   250    *
   256    *
   251    * Loop to read and process packets
   257    * Callback to process packets that are read
   252    */
   258    */
   253   void ReadThread (void);
   259   void ReadCallback (uint8_t *buf, ssize_t len);
   254 
   260 
   255   /*
   261   /*
   256    * \internal
   262    * \internal
   257    *
   263    *
   258    * Forward a packet received from the tap device to the bridged ns-3 
   264    * Forward a packet received from the tap device to the bridged ns-3 
   260    *
   266    *
   261    * \param buf A character buffer containing the actual packet bits that were
   267    * \param buf A character buffer containing the actual packet bits that were
   262    *            received from the host.
   268    *            received from the host.
   263    * \param buf The length of the buffer.
   269    * \param buf The length of the buffer.
   264    */
   270    */
   265   void ForwardToBridgedDevice (uint8_t *buf, uint32_t len);
   271   void ForwardToBridgedDevice (uint8_t *buf, ssize_t len);
   266 
   272 
   267   /**
   273   /**
   268    * \internal
   274    * \internal
   269    *
   275    *
   270    * The host we are bridged to is in the evil real world.  Do some sanity
   276    * The host we are bridged to is in the evil real world.  Do some sanity
   334    * \internal
   340    * \internal
   335    *
   341    *
   336    * The socket (actually interpreted as fd) to use to talk to the Tap device on
   342    * The socket (actually interpreted as fd) to use to talk to the Tap device on
   337    * the real internet host.
   343    * the real internet host.
   338    */
   344    */
   339   int32_t m_sock;
   345   int m_sock;
   340 
   346 
   341   /**
   347   /**
   342    * \internal
   348    * \internal
   343    *
   349    *
   344    * The ID of the ns-3 event used to schedule the start up of the underlying
   350    * The ID of the ns-3 event used to schedule the start up of the underlying
   355   EventId m_stopEvent;
   361   EventId m_stopEvent;
   356 
   362 
   357   /**
   363   /**
   358    * \internal
   364    * \internal
   359    *
   365    *
   360    * Used to identify the ns-3 read thread used to do blocking reads on the 
   366    * Includes the ns-3 read thread used to do blocking reads on the fd
   361    * socket (fd) corresponding to the host device.
   367    * corresponding to the host device.
   362    */
   368    */
   363   Ptr<SystemThread> m_readThread;
   369   Ptr<TapBridgeFdReader> m_fdReader;
   364 
   370 
   365   /**
   371   /**
   366    * \internal
   372    * \internal
   367    *     
   373    *     
   368    * The operating mode of the bridge.  Tells basically who creates and
   374    * The operating mode of the bridge.  Tells basically who creates and