2019-04-03 13:27:36 +02:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
#pragma once
|
|
|
|
|
2019-05-09 02:33:45 +02:00
|
|
|
#include <netinet/in.h>
|
2019-04-03 13:27:36 +02:00
|
|
|
#include <linux/if_macsec.h>
|
|
|
|
|
|
|
|
#include "in-addr-util.h"
|
|
|
|
#include "netdev.h"
|
|
|
|
#include "networkd-util.h"
|
|
|
|
#include "sparse-endian.h"
|
|
|
|
|
2019-04-10 10:29:10 +02:00
|
|
|
/* See the definition of MACSEC_NUM_AN in kernel's drivers/net/macsec.c */
|
|
|
|
#define MACSEC_MAX_ASSOCIATION_NUMBER 4
|
|
|
|
|
2019-04-03 13:27:36 +02:00
|
|
|
typedef struct MACsec MACsec;
|
|
|
|
|
|
|
|
typedef union MACsecSCI {
|
|
|
|
uint64_t as_uint64;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct ether_addr mac;
|
|
|
|
be16_t port;
|
|
|
|
} _packed_;
|
|
|
|
} MACsecSCI;
|
|
|
|
|
|
|
|
assert_cc(sizeof(MACsecSCI) == sizeof(uint64_t));
|
|
|
|
|
|
|
|
typedef struct SecurityAssociation {
|
|
|
|
uint8_t association_number;
|
|
|
|
uint32_t packet_number;
|
|
|
|
uint8_t key_id[MACSEC_KEYID_LEN];
|
|
|
|
uint8_t *key;
|
|
|
|
uint32_t key_len;
|
2019-04-10 11:07:10 +02:00
|
|
|
char *key_file;
|
2019-04-05 08:33:52 +02:00
|
|
|
int activate;
|
2019-04-05 08:52:26 +02:00
|
|
|
int use_for_encoding;
|
2019-04-03 13:27:36 +02:00
|
|
|
} SecurityAssociation;
|
|
|
|
|
|
|
|
typedef struct TransmitAssociation {
|
|
|
|
MACsec *macsec;
|
|
|
|
NetworkConfigSection *section;
|
|
|
|
|
|
|
|
SecurityAssociation sa;
|
|
|
|
} TransmitAssociation;
|
|
|
|
|
|
|
|
typedef struct ReceiveAssociation {
|
|
|
|
MACsec *macsec;
|
|
|
|
NetworkConfigSection *section;
|
|
|
|
|
|
|
|
MACsecSCI sci;
|
|
|
|
SecurityAssociation sa;
|
|
|
|
} ReceiveAssociation;
|
|
|
|
|
|
|
|
typedef struct ReceiveChannel {
|
|
|
|
MACsec *macsec;
|
|
|
|
NetworkConfigSection *section;
|
|
|
|
|
|
|
|
MACsecSCI sci;
|
2019-04-10 10:29:10 +02:00
|
|
|
ReceiveAssociation *rxsa[MACSEC_MAX_ASSOCIATION_NUMBER];
|
|
|
|
unsigned n_rxsa;
|
2019-04-03 13:27:36 +02:00
|
|
|
} ReceiveChannel;
|
|
|
|
|
|
|
|
struct MACsec {
|
|
|
|
NetDev meta;
|
|
|
|
|
|
|
|
uint16_t port;
|
|
|
|
int encrypt;
|
2019-04-05 08:52:26 +02:00
|
|
|
uint8_t encoding_an;
|
2019-04-03 13:27:36 +02:00
|
|
|
|
2019-04-10 10:29:10 +02:00
|
|
|
OrderedHashmap *receive_channels;
|
2019-04-03 13:27:36 +02:00
|
|
|
OrderedHashmap *receive_channels_by_section;
|
|
|
|
OrderedHashmap *transmit_associations_by_section;
|
|
|
|
OrderedHashmap *receive_associations_by_section;
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_NETDEV_CAST(MACSEC, MACsec);
|
|
|
|
extern const NetDevVTable macsec_vtable;
|
|
|
|
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_port);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_hw_address);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_packet_number);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key_id);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key);
|
2019-04-10 11:07:10 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_key_file);
|
2019-04-05 08:33:52 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_sa_activate);
|
2019-04-05 08:52:26 +02:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_macsec_use_for_encoding);
|