1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include <netinet/in.h>
5 #include <linux/if_macsec.h>
7 #include "ether-addr-util.h"
8 #include "in-addr-util.h"
10 #include "networkd-util.h"
11 #include "sparse-endian.h"
13 /* See the definition of MACSEC_NUM_AN in kernel's drivers/net/macsec.c */
14 #define MACSEC_MAX_ASSOCIATION_NUMBER 4
16 typedef struct MACsec MACsec
;
18 typedef union MACsecSCI
{
22 struct ether_addr mac
;
27 assert_cc(sizeof(MACsecSCI
) == sizeof(uint64_t));
29 typedef struct SecurityAssociation
{
30 uint8_t association_number
;
31 uint32_t packet_number
;
32 uint8_t key_id
[MACSEC_KEYID_LEN
];
38 } SecurityAssociation
;
40 typedef struct TransmitAssociation
{
42 NetworkConfigSection
*section
;
44 SecurityAssociation sa
;
45 } TransmitAssociation
;
47 typedef struct ReceiveAssociation
{
49 NetworkConfigSection
*section
;
52 SecurityAssociation sa
;
55 typedef struct ReceiveChannel
{
57 NetworkConfigSection
*section
;
60 ReceiveAssociation
*rxsa
[MACSEC_MAX_ASSOCIATION_NUMBER
];
71 OrderedHashmap
*receive_channels
;
72 OrderedHashmap
*receive_channels_by_section
;
73 OrderedHashmap
*transmit_associations_by_section
;
74 OrderedHashmap
*receive_associations_by_section
;
77 DEFINE_NETDEV_CAST(MACSEC
, MACsec
);
78 extern const NetDevVTable macsec_vtable
;
80 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_port
);
81 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_hw_address
);
82 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_packet_number
);
83 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key_id
);
84 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key
);
85 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key_file
);
86 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_sa_activate
);
87 CONFIG_PARSER_PROTOTYPE(config_parse_macsec_use_for_encoding
);