Psyllid  v1.12.4
Project 8 Data Acquisisition Software
packet_receiver_socket.hh
Go to the documentation of this file.
1 /*
2  * packet_receiver_socket.hh
3  *
4  * Created on: Nov 2, 2016
5  * Author: nsoblath
6  */
7 
8 #ifndef PSYLLID_PACKET_RECEIVER_SOCKET_HH_
9 #define PSYLLID_PACKET_RECEIVER_SOCKET_HH_
10 
11 #include "memory_block.hh"
12 #include "node_builder.hh"
13 
14 #include "producer.hh"
15 #include "shared_cancel.hh"
16 
17 #include <netinet/in.h>
18 
19 namespace scarab
20 {
21  class param_node;
22 }
23 
24 namespace psyllid
25 {
26 
49  class packet_receiver_socket : public midge::_producer< midge::type_list< memory_block > >
50  {
51  public:
53  virtual ~packet_receiver_socket();
54 
55  public:
56  mv_accessible( uint64_t, length );
57  mv_accessible( uint32_t, max_packet_size );
58  mv_accessible( uint32_t, port );
59  mv_referrable( std::string, ip );
60  mv_accessible( unsigned, timeout_sec );
61 
62  public:
63  virtual void initialize();
64  virtual void execute( midge::diptera* a_midge = nullptr );
65  virtual void finalize();
66 
67  private:
68  void cleanup_socket();
69 
70  int f_socket;
71  sockaddr_in* f_address;
72 
73  protected:
75 
76  };
77 
78  class packet_receiver_socket_binding : public _node_binding< packet_receiver_socket, packet_receiver_socket_binding >
79  {
80  public:
83 
84  private:
85  virtual void do_apply_config( packet_receiver_socket* a_node, const scarab::param_node& a_config ) const;
86  virtual void do_dump_config( const packet_receiver_socket* a_node, scarab::param_node& a_config ) const;
87  };
88 
89 } /* namespace psyllid */
90 
91 #endif /* PSYLLID_PACKET_RECEIVER_SOCKET_HH_ */
A producer to receive UDP packets via the standard socket interface and write them as raw blocks of m...