forked from sonic-net/sonic-swss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacsecmgr.h
84 lines (70 loc) · 2.4 KB
/
macsecmgr.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
75
76
77
78
79
80
81
82
83
84
#ifndef __MACSECMGR__
#define __MACSECMGR__
#include <orch.h>
#include <swss/schema.h>
#include <swss/boolean.h>
#include <cinttypes>
#include <map>
#include <vector>
#include <sstream>
#include <sys/types.h>
namespace swss {
class MACsecMgr : public Orch
{
public:
using Orch::doTask;
MACsecMgr(DBConnector *cfgDb, DBConnector *stateDb, const std::vector<std::string> &tableNames);
~MACsecMgr();
private:
void doTask(Consumer &consumer);
public:
using TaskArgs = std::vector<FieldValueTuple>;
struct MACsecProfile
{
std::uint32_t priority;
enum CipherSuite
{
GCM_AES_128,
GCM_AES_256,
GCM_AES_XPN_128,
GCM_AES_XPN_256,
} cipher_suite;
std::string primary_cak;
std::string primary_ckn;
std::string fallback_cak;
std::string fallback_ckn;
enum Policy
{
INTEGRITY_ONLY,
SECURITY,
} policy;
swss::AlphaBoolean enable_replay_protect;
std::uint32_t replay_window;
swss::AlphaBoolean send_sci;
std::uint32_t rekey_period;
bool update(const TaskArgs & ta);
};
struct MKASession
{
std::string profile_name;
// wpa_supplicant communication socket
std::string sock;
// wpa_supplicant process id
pid_t wpa_supplicant_pid;
};
private:
std::map<std::string, struct MACsecProfile> m_profiles;
std::map<std::string, MKASession> m_macsec_ports;
task_process_status removeProfile(const std::string & profile_name, const TaskArgs & profile_attr);
task_process_status loadProfile(const std::string & profile_name, const TaskArgs & profile_attr);
task_process_status enableMACsec(const std::string & port_name, const TaskArgs & port_attr);
task_process_status disableMACsec(const std::string & port_name, const TaskArgs & port_attr);
Table m_statePortTable;
bool isPortStateOk(const std::string & port_name);
pid_t startWPASupplicant(const std::string & sock) const;
bool stopWPASupplicant(pid_t pid) const;
bool configureMACsec(const std::string & port_name, const MKASession & session, const MACsecProfile & profile) const;
bool unconfigureMACsec(const std::string & port_name, const MKASession & session) const;
};
}
#endif