GlobalBpiLib  1.0
ProtocolLogic.h
1 /*
2  * ProtocolLogic.h
3  *
4  * Author: Valentin Fitz
5  * Institute: University of Duisburg-Essen, Germany
6  */
7 
8 #ifndef PROTOCOLS_PROTOCOLLOGIC_H_
9 #define PROTOCOLS_PROTOCOLLOGIC_H_
10 
11 #include <pthread.h>
12 #include <vector>
13 #include <deque>
14 #include <string>
15 #include "Port.h"
16 #include "../GlobalBpiLib.hpp"
17 #include "MessageTypes.h"
18 
23 protected:
24  Port **ports;
25  std::vector<EthernetMessage*> protocol_messages;
26  std::deque<std::string> control_messages;
27  pthread_t protologic;
28  pthread_mutex_t _mutex;
29  pthread_cond_t _cond;
30  bool run = true;
31  void _runProtoLogic();
32  void _initializeProtocol();
33  void _sendMessage(EthernetMessage* msg, int outPorts);
34  virtual Port* _createPort(int i);
35  virtual void _executeProtocolLogic();
36  virtual void _handleControlMessages();
37  virtual void _handleControlMessage(std::string cmdId, std::string cmd);
38  virtual void _handleControlMessageFI(std::string cmdId, std::string cmd);
41  char source_mac[6];
42 public:
43  ProtocolLogic();
44  virtual ~ProtocolLogic();
45  static void * protoLogicEntry(void * This);
46  void start();
47  void stop();
48  void portInput(EthernetMessage* input);
49  void controlInput(std::string input);
50  virtual void sendMessage(EthernetMessage* msg, int outPorts);
51 };
52 
53 #endif /* PROTOCOLS_PROTOCOLLOGIC_H_ */
void _sendMessage(EthernetMessage *msg, int outPorts)
Definition: ProtocolLogic.cpp:147
Represents an BananaPi R1 ethernet port, starting an ingress port (pcap listener) as well as an egres...
Definition: Port.h:27
Custom bpi printer class.
Definition: GlobalBpiLib.hpp:41
Default implementation of the logic of a protocol implementation.
Definition: ProtocolLogic.h:22
BpiOutStream bpiout
Definition: ProtocolLogic.h:39
BpiOutStream bpierr
Definition: ProtocolLogic.h:40
virtual void sendMessage(EthernetMessage *msg, int outPorts)
Definition: ProtocolLogic.cpp:171
Ethernet v2 message type.
Definition: MessageTypes.h:56