8 #ifndef PROTOCOLS_PORT_H_ 9 #define PROTOCOLS_PORT_H_ 15 #include <linux/if_packet.h> 16 #include <sys/socket.h> 17 #include <arpa/inet.h> 19 #include "../GlobalBpiLib.hpp" 20 #include "MessageTypes.h" 49 pthread_mutex_t _mutex;
54 char error_buffer[PCAP_ERRBUF_SIZE];
56 char destination_mac[6];
57 pcap_t *pcap_port =
nullptr;
58 std::vector<EthernetMessage*> _msgQueue;
60 struct sockaddr_ll raw_port_address;
62 struct timeval lasttval;
63 double transmissionSpeed = 5;
65 static void * _egrPortThreadEntryFunction(
void * This);
66 static void * _ingPortThreadEntryFunction(
void * This);
67 void _startEgrPortThread();
68 void _startIngPortThread();
69 static void _packetHandlerCallback(u_char *user,
const struct pcap_pkthdr* pkthdr,
const u_char* packet);
70 void _packetHandler(
const struct pcap_pkthdr* pkthdr,
const u_char* packet);
71 void _setupPcapListener();
72 void _setupRawSocket();
73 void _retrieveMacAddress();
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
std::string getLocalMacAddr()
Definition: Port.cpp:63
virtual bool _handleOutgoingPaketFI(EthernetMessage *msg)
Definition: PortEgress.cpp:100
char * getRawDestMacAddress()
Definition: Port.cpp:86
void setLinkSpeed(double d)
Definition: Port.cpp:90
void stop()
Definition: Port.cpp:44
void addMessage(EthernetMessage *msg)
Definition: PortEgress.cpp:89
Default implementation of the logic of a protocol implementation.
Definition: ProtocolLogic.h:22
int getPortId()
Definition: Port.cpp:82
int txMsg
Definition: Port.h:33
BpiOutStream bpierr
Definition: Port.h:32
void setNeighbour(char *mac)
Definition: Port.cpp:55
char * getRawMacAddress()
Definition: Port.cpp:51
virtual bool _handleIncomingPaketFI(EthernetMessage *msg)
Definition: PortIngress.cpp:91
virtual bool _handleIncomingPaket(EthernetMessage *msg)
Definition: PortIngress.cpp:87
virtual bool _handleOutgoingPaket(EthernetMessage *msg)
Definition: PortEgress.cpp:96
BpiOutStream bpiout
Definition: Port.h:31
Ethernet v2 message type.
Definition: MessageTypes.h:56