|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "MACsecAttr.h" |
| 4 | +#include "MACsecFilter.h" |
| 5 | +#include "MACsecForwarder.h" |
| 6 | + |
| 7 | +namespace saivs |
| 8 | +{ |
| 9 | + class MACsecManager |
| 10 | + { |
| 11 | + public: |
| 12 | + MACsecManager(); |
| 13 | + |
| 14 | + virtual ~MACsecManager(); |
| 15 | + |
| 16 | + bool create_macsec_port( |
| 17 | + _In_ const MACsecAttr &attr); |
| 18 | + |
| 19 | + bool create_macsec_sc( |
| 20 | + _In_ const MACsecAttr &attr); |
| 21 | + |
| 22 | + bool create_macsec_sa( |
| 23 | + _In_ const MACsecAttr &attr); |
| 24 | + |
| 25 | + bool delete_macsec_port( |
| 26 | + _In_ const MACsecAttr &attr); |
| 27 | + |
| 28 | + bool delete_macsec_sc( |
| 29 | + _In_ const MACsecAttr &attr); |
| 30 | + |
| 31 | + bool delete_macsec_sa( |
| 32 | + _In_ const MACsecAttr &attr); |
| 33 | + |
| 34 | + bool enable_macsec_filter( |
| 35 | + _In_ const std::string &macsecInterface, |
| 36 | + _In_ bool enable); |
| 37 | + |
| 38 | + bool get_macsec_sa_pn( |
| 39 | + _In_ const MACsecAttr &attr, |
| 40 | + _Out_ sai_uint64_t &pn) const; |
| 41 | + |
| 42 | + private: |
| 43 | + |
| 44 | + bool create_macsec_egress_sc( |
| 45 | + _In_ const MACsecAttr &attr); |
| 46 | + |
| 47 | + bool create_macsec_ingress_sc( |
| 48 | + _In_ const MACsecAttr &attr); |
| 49 | + |
| 50 | + bool create_macsec_egress_sa( |
| 51 | + _In_ const MACsecAttr &attr); |
| 52 | + |
| 53 | + bool create_macsec_ingress_sa( |
| 54 | + _In_ const MACsecAttr &attr); |
| 55 | + |
| 56 | + bool delete_macsec_egress_sc( |
| 57 | + _In_ const MACsecAttr &attr); |
| 58 | + |
| 59 | + bool delete_macsec_ingress_sc( |
| 60 | + _In_ const MACsecAttr &attr); |
| 61 | + |
| 62 | + bool delete_macsec_egress_sa( |
| 63 | + _In_ const MACsecAttr &attr); |
| 64 | + |
| 65 | + bool delete_macsec_ingress_sa( |
| 66 | + _In_ const MACsecAttr &attr); |
| 67 | + |
| 68 | + bool add_macsec_filter( |
| 69 | + _In_ const std::string &macsecInterface); |
| 70 | + |
| 71 | + bool add_macsec_forwarder( |
| 72 | + _In_ const std::string &macsecInterface); |
| 73 | + |
| 74 | + bool delete_macsec_forwarder( |
| 75 | + _In_ const std::string &macsecInterface); |
| 76 | + |
| 77 | + bool add_macsec_manager( |
| 78 | + _In_ const std::string &macsecInterface, |
| 79 | + _In_ std::shared_ptr<HostInterfaceInfo> info); |
| 80 | + |
| 81 | + bool delete_macsec_manager( |
| 82 | + _In_ const std::string &macsecInterface); |
| 83 | + |
| 84 | + bool get_macsec_device_info( |
| 85 | + _In_ const std::string &macsecDevice, |
| 86 | + _Out_ std::string &info) const; |
| 87 | + |
| 88 | + bool is_macsec_device_existing( |
| 89 | + _In_ const std::string &macsecDevice) const; |
| 90 | + |
| 91 | + bool get_macsec_sc_info( |
| 92 | + _In_ const std::string &macsecDevice, |
| 93 | + _In_ sai_int32_t direction, |
| 94 | + _In_ const std::string &sci, |
| 95 | + _Out_ std::string &info) const; |
| 96 | + |
| 97 | + bool is_macsec_sc_existing( |
| 98 | + _In_ const std::string &macsecDevice, |
| 99 | + _In_ sai_int32_t direction, |
| 100 | + _In_ const std::string &sci) const; |
| 101 | + |
| 102 | + bool get_macsec_sa_info( |
| 103 | + _In_ const std::string &macsecDevice, |
| 104 | + _In_ sai_int32_t direction, |
| 105 | + _In_ const std::string &sci, |
| 106 | + _In_ macsec_an_t an, |
| 107 | + _Out_ std::string &info) const; |
| 108 | + |
| 109 | + bool is_macsec_sa_existing( |
| 110 | + _In_ const std::string &macsecDevice, |
| 111 | + _In_ sai_int32_t direction, |
| 112 | + _In_ const std::string &sci, |
| 113 | + _In_ macsec_an_t an) const; |
| 114 | + |
| 115 | + size_t get_macsec_sa_count( |
| 116 | + _In_ const std::string &macsecDevice, |
| 117 | + _In_ sai_int32_t direction, |
| 118 | + _In_ const std::string &sci) const; |
| 119 | + |
| 120 | + void cleanup_macsec_device() const; |
| 121 | + |
| 122 | + std::string shellquote( |
| 123 | + _In_ const std::string &str) const; |
| 124 | + |
| 125 | + bool exec( |
| 126 | + _In_ const std::string &command, |
| 127 | + _Out_ std::string &output) const; |
| 128 | + |
| 129 | + bool exec( |
| 130 | + _In_ const std::string &command) const; |
| 131 | + |
| 132 | + struct MACsecTrafficManager |
| 133 | + { |
| 134 | + MACsecTrafficManager() = default; |
| 135 | + |
| 136 | + ~MACsecTrafficManager() = default; |
| 137 | + |
| 138 | + std::shared_ptr<HostInterfaceInfo> m_info; |
| 139 | + std::shared_ptr<MACsecFilter> m_ingressFilter; |
| 140 | + std::shared_ptr<MACsecFilter> m_egressFilter; |
| 141 | + std::shared_ptr<MACsecForwarder> m_forwarder; |
| 142 | + }; |
| 143 | + |
| 144 | + std::map<std::string, MACsecTrafficManager> m_macsecTrafficManagers; |
| 145 | + }; |
| 146 | +} |
0 commit comments