Rev

Rev 3322 | Details | Compare with Previous | Last modification | View Log | SVN | Bug Tracker

Rev Author Line No. Line
3318 filatov 1
/*!
2
 * \file      pcap_offline_layer.hh
3
 * \brief     Header file for ITS Offline Pcap port layer.
4
 * \author    ETSI STF525
5
 * \copyright ETSI Copyright Notification
6
 *            No part may be reproduced except as authorized by written permission.
7
 *            The copyright and the foregoing restriction extend to reproduction in all media.
8
 *            All rights reserved.
9
 * \version   0.1
10
 */
11
#pragma once
12
 
13
#include <thread>
14
#include <mutex>
15
 
16
#include "t_layer.hh"
17
#include "params.hh"
18
 
3320 filatov 19
#include <Octetstring.hh>
3318 filatov 20
 
21
class PORT; //! Forward declaration of TITAN class
22
 
23
typedef struct pcap pcap_t;
24
 
25
/*!
26
 * \class pcap_layer
27
 * \brief  This class provides description of ITS PCAP port protocol layer
28
 */
29
class pcap_offline_layer : public layer, public PORT {
30
  params _params;            //! Layer parameters
31
  pcap_t* _device;           //! Device handle
32
  std::thread* _thread;      //! Thread handle, used to read PCAP file instead of NIC, used in file mode
33
  std::mutex _resume;
34
  bool _running;             //! Set to true when the thread is running, used in file mode
35
  bool _realtime;            //! Set to true if realtime delay shall be added between packets
36
  bool _loop;                //! Set to true if playback shall be looped
3333 filatov 37
  int  _fd[2];                //! pipe to signal to Titan
3318 filatov 38
 
39
  params                _o_params;
40
  OCTETSTRING           _o_data;
41
 
3322 filatov 42
  std::string           _time_key;
43
 
3318 filatov 44
  static void* run(void* p_this);
45
public:
46
  void* thread(void);
47
public: //! \publicsection
48
  /*!
49
   * \brief Specialised constructor
50
   *        Create a new instance of the pcap_layer class
51
   * \param[in] p_type \todo
52
   * \param[in] p_param \todo
53
   */
54
  pcap_offline_layer(const std::string& p_type, const std::string& param);
55
  /*!
56
   * \brief Default destructor
57
   */
58
  virtual ~pcap_offline_layer();
59
 
60
  /*!
61
   * \virtual
62
   * \fn void send_data(OCTETSTRING& data, params& params);
63
   * \brief Send bytes formated data to the lower layers
64
   * \param[in] p_data The data to be sent
65
   * \param[in] p_params Some parameters to overwrite default value of the lower layers parameters
66
   */
67
  virtual void send_data(OCTETSTRING& data, params& params);
68
  /*!
69
   * \virtual
70
   * \fn void receive_data(OCTETSTRING& data, params& params);
71
   * \brief Receive bytes formated data from the lower layers
72
   * \param[in] p_data The bytes formated data received
73
   * \param[in] p_params Some lower layers parameters values when data was received
74
   */
75
  virtual void receive_data(OCTETSTRING& data, params& info);
76
 
77
  void Handle_Fd_Event_Readable(int fd);
78
};