-
Notifications
You must be signed in to change notification settings - Fork 1
/
cipher_2_uncipher_worker.h
executable file
·74 lines (63 loc) · 2.05 KB
/
cipher_2_uncipher_worker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __scable_cipher_2_uncipher_worker__
#define __scable_cipher_2_uncipher_worker__
#include "lcore_action.h"
#include "pkt_action.h"
#include "cipher_controller.h"
class Cipher2UncipherWorker {
private:
std::vector<Port *> ports;
const PktActionDelegate<Cipher2UncipherWorker> uncipherActionDelegate;
CipherController &cipherController;
std::vector<RXAction *> rxActions;
std::vector<TXAction *> txActions;
Cipher2UncipherWorker(CipherController &cipherController)
: uncipherActionDelegate(this),
cipherController(cipherController) {
}
public:
static Cipher2UncipherWorker *create(CipherController &cipherController) {
return new Cipher2UncipherWorker(cipherController);
}
Port *bindPort(Port *port) {
ports.push_back(port);
return port;
}
void pktPrepare() {
LOG(INFO) << "Starting PktAction "
<< "for RXActions:[" << join(rxActions, ",") << "]:"
<< "for TXActions:[" << join(txActions, ",") << "]:"
<< this << "=>" << name();
}
bool pktAction(struct rte_mbuf *buf) {
if (ports.end() != std::find_if(ports.begin(),
ports.end(),
[buf](const Port *obj) {
return obj->getId() == buf->port;
})) {
//if (buf->port == port->getId()) {
struct ether_hdr *eth = rte_pktmbuf_mtod(buf, struct ether_hdr *);
LOG(INFO) << "on[" << name() << buf->port << "] "
<< eth->s_addr << ">>" << eth->d_addr;
return true;
}
return false;
}
const PktAction& getCipherAction() const {
return uncipherActionDelegate.get();
}
// Port *getPort() const {
// return port;
// }
const char *name() const {
return "Cipher2UncipherWorker";
}
Cipher2UncipherWorker& bindRXAction(RXAction &rxa) {
rxActions.push_back(&rxa);
return *this;
}
Cipher2UncipherWorker& bindTXAction(TXAction &txa) {
txActions.push_back(&txa);
return *this;
}
};
#endif