1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include <netinet/in.h>
5 #include <linux/if_macsec.h>
7 #include "in-addr-util.h"
9 #include "networkd-util.h"
10 #include "sparse-endian.h"
12 /* See the definition of MACSEC_NUM_AN in kernel's drivers/net/macsec.c */
13 #define MACSEC_MAX_ASSOCIATION_NUMBER 4
15 typedef struct MACsec MACsec
;
17 typedef union MACsecSCI
{
21 struct ether_addr mac
;
26 assert_cc(sizeof(MACsecSCI
) == sizeof(uint64_t));
28 typedef struct SecurityAssociation
{
29 uint8_t association_number
;
30 uint32_t packet_number
;
31 uint8_t key_id
[MACSEC_KEYID_LEN
];
37 } SecurityAssociation
;
39 typedef struct TransmitAssociation
{
41 NetworkConfigSection
*section
;
43 SecurityAssociation sa
;
44 } TransmitAssociation
;
46 typedef struct ReceiveAssociation
{
48 NetworkConfigSection
*section
;
51 SecurityAssociation sa
;
54 typedef struct ReceiveChannel
{
56 NetworkConfigSection
*section
;
59 ReceiveAssociation
*rxsa
[MACSEC_MAX_ASSOCIATION_NUMBER
];
70 OrderedHashmap
*receive_channels
;
71 OrderedHashmap
*receive_channels_by_section
;
72 OrderedHashmap
*transmit_associations_by_section
;
73 OrderedHashmap
*receive_associations_by_section
;
76 DEFINE_NETDEV_CAST(MACSEC
, MACsec
);
77 extern const NetDevVTable macsec_vtable
;
79 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_port
);
80 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_hw_address
);
81 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_packet_number
);
82 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key_id
);
83 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key
);
84 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key_file
);
85 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_sa_activate
);
86 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_use_for_encoding
);