original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,239 @@
/* ipmacsec_crypto_if.h - IPMACSEC Crypto Interface header file */
/*
* Copyright (c) 2010 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*
*/
/*
modification history
--------------------
01a,19feb10,mry Created
*/
#ifndef IPMACSEC_CRYPTO_IF_H
#define IPMACSEC_CRYPTO_IF_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#ifdef IP_PORT_VWORKS
#include <vsbConfig.h>
#endif
#include "ipmacsec_h.h"
#include "ipmacsec.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/* Crypto context passed to the crypto validate and protect fucntions */
typedef struct {
Ip_u8 sci[IPMACSEC_SCI_LEN];
Ip_u8 *macsec_hdr; /* ptr to concatenated DA, SA and SecTAG fields */
Ip_u8 *userdata; /* Set to pointer to data to encrypt, or will return pointer to decrypted data */
Ip_u8 *securedata; /* Set to pointer to data to decrypt, or will return pointer to encrypted data */
Ip_u8 *icv; /* ICV value to validate, or ptr to buffer to copy generated ICV into */
Ip_u32 pn; /* Packet Number */
Ip_u8 macsec_hdr_len; /* aggregate size of DA, SA and SecTAG fields (in octets) */
Ip_u8 icv_len; /* in octets; size of ICV to validate, or size of buffer to copy generated ICV into */
Ip_u16 userdata_len; /* in octets; Set to len of data to encrypt, or will return len of decrypted data */
Ip_u16 securedata_len; /* in octets; Set to len of data to decrypt, or will return len of encrypted data */
Ip_u16 key_index; /* corresponds to tx/rx SA AN */
union {
Ip_bool encrypt; /* Set to encrypt userdata in addition to ICV generation */
Ip_bool decrypt; /* Set to decrypt userdata in addition to ICV validation */
} oper;
} Ipmacsec_crypto_ctx;
/* Crypto interface structure definition
* =====================================
* Usage:
* -----
* - One crypto_if per SC is created using ipmacsec_crypto_create() when the SC is created and
* destroyed with ipmacsec_crypto_delete() when the SC is deleted
* - init_cipher() is called when an SA is created for the corresponding SC.
* The AN for that SA is passed as a key_index and the corresponding SAK is also specified.
* - destroy_cipher() is called when an SA is deleted for the corresponding SC.
* The AN for that SA is passed as a key_index.
* - protect() and validate() are called whenever a frames needs to be protected or validated for
* the SC corresponding to this crypto_if. The Ipmacsec_crypto_ctx MUST be updated with the proper
* fields, including the key_index which equals the AN for the SA that is processing the frame.
* - Non private members of this structure are READ ONLY values for entities external to the crypto_if.
* - Private members of this structure MUST NOT be ACCESSED by entities external to the crypto_if.
*/
typedef struct Ipmacsec_crypto_if_struct {
Ip_bool valid; /* Set when Crypto If is properly instantiated */
Ip_bool cipher_set; /* Set when a cipher is selected */
Ip_u16 icvbits; /* ICV length (in bits) of selected cipher suite */
Ip_u16 gcmaes_accel_level; /* The AES-GCM acceleration level to use for this crypto if (when gcm-aes-128 is used) */
Ip_bool changesDataLength; /* selected cipher suite changes data length upon protection/validation */
Ip_u32 confidentialityOffset; /* # of octets to be used as offset for Confidentiality (default is 0)*/
int (* init_cipher)(struct Ipmacsec_crypto_if_struct *crypto, Ip_u8 key_index, Ipmacsec_secy_sak *sak);
int (* destroy_cipher)(struct Ipmacsec_crypto_if_struct *crypto, Ip_u8 key_index);
int (* protect)(struct Ipmacsec_crypto_if_struct *crypto, Ipmacsec_crypto_ctx *ctx);
int (* validate)(struct Ipmacsec_crypto_if_struct *crypto, Ipmacsec_crypto_ctx *ctx, Ip_bool *valid);
struct {
Ipnet_secy *secy; /* backpointer to SecY */
struct Ipmacsec_crypto_cipher_struct IP_CONST *cipher; /* Cipher pointer */
void *cs_ctx[IPMACSEC_MAX_SA]; /* cipher specific context */
Ip_u8 *result_buf; /* buffer used to store temporary crypto results */
Ip_u32 result_buf_len; /* length of buffer used to store temporary crypto results */
Ipmacsec_secy_sak sak[IPMACSEC_MAX_SA]; /* SAKs to be used by this crypto i/f */
} priv; /* Private members */
} Ipmacsec_crypto_if;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipmacsec_crypto_cipher_suite_supported
*===========================================================================
* Description: Verify if a cipher suite is supported by our MACsec implementation
* Parameters: cipher_suite_index - Cipher Suite index
* Returns: IP_TRUE is the cipher suite is supported, IP_FALSE otherwise.
*
*/
IPMACSEC_PRIVATE Ip_bool
ipmacsec_crypto_cipher_suite_supported(IP_CONST Ipmacsec_cipher_suite_index cipher_suite_index);
/*
*===========================================================================
* ipmacsec_crypto_cipher_suite_get_info
*===========================================================================
* Description: Retrieve detailed information about a supported cipher suite
* Parameters: cipher_suite_index - Cipher Suite index
* Returns: 0 if successful, < 0 otherwise
*
*/
IPMACSEC_PRIVATE int
ipmacsec_crypto_cipher_suite_get_info(IP_CONST Ipmacsec_cipher_suite_index cipher_suite_index, Ipmacsec_ciphersuite_descriptor *info);
/*
*===========================================================================
* ipmacsec_crypto_cipher_suite_id_resolve
*===========================================================================
* Description: Resolve the Cipher Suite ID from a specified cipher_suite_index
* Parameters: cipher_suite_index - cipher_suite_index value to resolve
* cipher_suite_id - pointer to variable to hold the resolved
* Cipher Suite ID
* Returns: 0 upon success, <0 on error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_crypto_cipher_suite_id_resolve(IP_CONST Ipmacsec_cipher_suite_index cipher_suite_index, Ip_u8 *cipher_suite_id) ;
/*
*===========================================================================
* ipmacsec_crypto_cipher_suite_name
*===========================================================================
* Description: Return the name of the specified Cipher Suite
* Parameters: cipher_suite_index - index of Cipher Suite whose name to return
* Returns: Pointer to string containing the Cipher Suite name (never null).
*
*/
IPMACSEC_PRIVATE IP_CONST char *
ipmacsec_crypto_cipher_suite_name(IP_CONST Ipmacsec_cipher_suite_index cipher_suite_index);
/*
*===========================================================================
* ipmacsec_crypto_cipher_suite_index_resolve
*===========================================================================
* Description: Resolve the Cipher Suite Index from a specified cipher_suite_id
* Parameters: cipher_suite_id - Cipher Suite ID value to resolve
* cipher_suite_index - pointer to variable to hold the resolved
* cipher_suite_index
* Returns: 0 upon success, <0 on error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_crypto_cipher_suite_index_resolve(IP_CONST Ip_u8 *cipher_suite_id, Ipmacsec_cipher_suite_index *cipher_suite_index);
/*
*===========================================================================
* ipmacsec_crypto_get_icvbits
*===========================================================================
* Description: Retrieve # of ICV bits for currently configured SecY cipher
* Parameters: secy - SecY pointer
* Returns: > 0 if successful, 0 otherwise.
*
*/
IPMACSEC_PRIVATE Ip_u16
ipmacsec_crypto_get_icvbits(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_crypto_create
*===========================================================================
* Description: Crypto Interface constructor
* Parameters: secy - SecY pointer
* Returns: Pointer to created crypto_if structure upon success, IP_NULL otherwise
*
*/
IPMACSEC_PRIVATE Ipmacsec_crypto_if *
ipmacsec_crypto_create(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_crypto_delete
*===========================================================================
* Description: Crypto Interface desstructor
* Parameters: secy - SecY pointer
* crypto - pointer to crypto_if structure to delete
* Returns: 0 upon success, <0 on error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_crypto_delete(Ipnet_secy *secy, Ipmacsec_crypto_if *crypto);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,187 @@
/* ipmacsec_debug.h - IPMACSEC DEBUG-ONLY header file */
/*
* Copyright (c) 2010 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*
*/
/*
modification history
--------------------
01a,09feb10,mry Created
*/
#ifndef IPMACSEC_DEBUG_H
#define IPMACSEC_DEBUG_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/* This header file is to be included by internal modules for the purpose of
* supporting DEBUG ONLY functionality.
* The following APIs and definitions are to be used for debugging purposes ONLY.
* They are not part of the official macsec APIs and are not intended for production systems.
* Behavior when these APIs are invoked is not guaranteed to be valid
* nor safe for normal operation and may have an impact on performance.
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#ifdef IP_PORT_VWORKS
#include <vsbConfig.h>
#endif
#include "ipmacsec_h.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#ifdef _WRS_CONFIG_IPMACSEC_DEBUG
#ifndef IPMACSEC_DEBUG
#define IPMACSEC_DEBUG
#endif
#endif
#if defined(IP_DEBUG) || defined(IPMACSEC_DEBUG)
#define IPMACSEC_USE_DUMP_PACKET
#endif
#ifdef IPMACSEC_DEBUG
/* Define/Undefine some/all of these do increase/reduce debug output */
#undef IPMACSEC_DEBUG_SECY_INIT
#undef IPMACSEC_DEBUG_SECY_CFG
#undef IPMACSEC_DEBUG_SECY_CTRL
#undef IPMACSEC_DEBUG_SECY_MGMT
#undef IPMACSEC_DEBUG_SECY_MGMT_VERBOSE
#undef IPMACSEC_DEBUG_SECY_IN_PROCESS
#undef IPMACSEC_DEBUG_SECY_IN_PARSE
#undef IPMACSEC_DEBUG_SECY_UCP_OUT
#undef IPMACSEC_DEBUG_SECY_CP_OUT
#undef IPMACSEC_DEBUG_SECY_OUT_PREP
#undef IPMACSEC_DEBUG_IOCTL
#undef IPMACSEC_DEBUG_CRYPTO
#undef IPMACSEC_DEBUG_CRYPTO_PROTECT
#undef IPMACSEC_DEBUG_CRYPTO_VALIDATE
#undef IPMACSEC_DEBUG_CRYPTO_CIPH_GCMAES
#undef IPMACSEC_DEBUG_CRYPTO_CIPH_GCMAES_DETAIL
#undef IPMACSEC_DEBUG_NL
#undef IPMACSEC_DEBUG_NL_VERBOSE
#undef IPMACSEC_DEBUG_NL_BCAST
#define IPMACSEC_DEBUG_CMD /* Recommend that this be kept on for debug builds */
#undef IPMACSEC_DEBUG_CMD_PARSE
#undef IPMACSEC_DEBUG_DUMP_PKT
#else
#undef IPMACSEC_DEBUG_SECY_INIT
#undef IPMACSEC_DEBUG_SECY_CFG
#undef IPMACSEC_DEBUG_SECY_CTRL
#undef IPMACSEC_DEBUG_SECY_MGMT
#undef IPMACSEC_DEBUG_SECY_MGMT_VERBOSE
#undef IPMACSEC_DEBUG_SECY_IN_PROCESS
#undef IPMACSEC_DEBUG_SECY_IN_PARSE
#undef IPMACSEC_DEBUG_SECY_UCP_OUT
#undef IPMACSEC_DEBUG_SECY_CP_OUT
#undef IPMACSEC_DEBUG_SECY_OUT_PREP
#undef IPMACSEC_DEBUG_IOCTL
#undef IPMACSEC_DEBUG_CRYPTO
#undef IPMACSEC_DEBUG_CRYPTO_PROTECT
#undef IPMACSEC_DEBUG_CRYPTO_VALIDATE
#undef IPMACSEC_DEBUG_CRYPTO_CIPH_GCMAES
#undef IPMACSEC_DEBUG_CRYPTO_CIPH_GCMAES_DETAIL
#undef IPMACSEC_DEBUG_NL
#undef IPMACSEC_DEBUG_NL_VERBOSE
#undef IPMACSEC_DEBUG_NL_BCAST
#undef IPMACSEC_DEBUG_CMD
#undef IPMACSEC_DEBUG_CMD_PARSE
#undef IPMACSEC_DEBUG_DUMP_PKT
#endif
#ifdef IPMACSEC_DEBUG_DUMP_PKT
#define IPMACSEC_DUMP_PKT ipmacsec_dump_packet
#else
#define IPMACSEC_DUMP_PKT(...) {}
#endif
#ifdef IPMACSEC_UNIT_TEST
#if !defined(_WRS_CONFIG_IPMACSEC_DEBUG) && !defined(IPMACSEC_DEBUG)
#error Must Select IPMACSEC_DEBUG VSB component or define IPMACSEC_DEBUG to be able to enable IPMACSEC_UNIT_TEST
#endif
#warning IPMACSEC_UNIT_TEST SHOULD ONLY BE TURNED ON FOR UNIT TESTING
#endif
#ifdef IPMACSEC_UNIT_TEST_INLINE_HARDCODED_CONFIG
#ifndef IPMACSEC_UNIT_TEST
#error IPMACSEC_UNIT_TEST must be defined before IPMACSEC_UNIT_TEST_INLINE_HARDCODED_CONFIG can be defined
#endif
#warning IPMACSEC_UNIT_TEST SHOULD ONLY BE TURNED ON FOR DEBUGGING PURPOSES ON NON_PRODUCTION SYSTEMS
#endif
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
IPMACSEC_PRIVATE void ipmacsec_dump_packet(char *desc, Ipcom_pkt *pkt);
IPMACSEC_PRIVATE void ipmacsec_dump_buffer(IP_CONST char *desc, IP_CONST Ip_u8* buf, IP_CONST Ip_u32 len);
#ifdef IPMACSEC_UNIT_TEST
IP_GLOBAL int ipmacsec_netlink_monitor_test(Ip_u32 timeout);
IP_GLOBAL int ipmacsec_secy_monitor_test_start_daemon(char *ifname, Ip_u32 timeout);
IP_GLOBAL int ipmacsec_netlink_test(void);
IP_GLOBAL int ipmacsec_netlink_multi_test(char *ifname);
IP_GLOBAL int ipmacsec_key_test(char *ifname);
IP_GLOBAL int ipmacsec_ctrl_cmd_test(char *ifname);
IP_GLOBAL int ipmacsec_sc_sa_test(char *ifname);
IP_GLOBAL void ipmacsec_counter_format_test(void);
IP_GLOBAL int ipmacsec_parse_sci_string_test(void);
IP_GLOBAL int ipmacsec_secy_ucp_test(char *ifname, Ip_u32 num_expected_pkts, Ip_u32 timeout);
IP_GLOBAL int ipmacsec_secy_ucp_test_start_daemon(char *ifname, Ip_u32 num_expected_pkts, Ip_u32 timeout);
IP_GLOBAL Ip_u32 ipmacsec_secy_ucp_test_daemon_num_rcv_pkts(void);
IP_GLOBAL Ipmacsec_lmi_error ipmacsec_lmi_secy_setup_ut_profile(char *ifname, Ip_u8 ut_profile_index);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,280 @@
/* ipmacsec.h - MACsec Private header file */
/*
* Copyright (c) 2010 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*
*/
/*
modification history
--------------------
01a,09feb10,mry Created
*/
#ifndef IPMACSEC_H_H
#define IPMACSEC_H_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/* This header file is to be included by internal ipmacsec modules. */
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include "ipnet_eth.h"
#include "ipmacsec.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* IPMACSEC_PRIVATE is used to differentiate functions that should ONLY be used
* by other IPMACSEC module functions and not by any external modules.
*/
#define IPMACSEC_PRIVATE IP_GLOBAL
/* Current MACsec Protocol Version number */
#define IPMACSEC_VERSION_NUMBER 0
/* Macros for manipulating the Controlled and Uncontrolled Port statistics */
#define IPMACSEC_UCP_STATS(xvar) netif->uncontrolled_port->stats.xvar
#ifdef IPMACSEC_USE_STATS
#define IPMACSEC_CP_STATS(xvar) netif->controlled_port->stats.xvar
#define IPMACSEC_CP_STATS_SET(xvar,val) netif->controlled_port->stats.xvar = val
#define IPMACSEC_CP_STATS_INC(xvar,inc) netif->controlled_port->stats.xvar +=(inc)
#define IPMACSEC_SECY_STATS(xvar) secy->stats.xvar
#define IPMACSEC_SECY_STAT_VAL(xvar) secy->stats.xvar
#define IPMACSEC_SECY_STATS_INC(xvar,inc) secy->stats.xvar+=(inc)
#define IPMACSEC_SC_STATS(xvar) sc->stats.xvar
#define IPMACSEC_SC_STAT_VAL(xvar) sc->stats.xvar
#define IPMACSEC_SC_STATS_INC(xvar,inc) sc->stats.xvar+=(inc)
#define IPMACSEC_SA_STATS(xvar) sa->stats.xvar
#define IPMACSEC_SA_STAT_VAL(xvar) sa->stats.xvar
#define IPMACSEC_SA_STATS_INC(xvar,inc) sa->stats.xvar+=(inc)
#else
#define IPMACSEC_CP_STATS(xvar) IP_NOOP
#define IPMACSEC_CP_STATS_SET(xvar,val) IP_NOOP
#define IPMACSEC_CP_STATS_INC(xvar,inc) IP_NOOP
#define IPMACSEC_SECY_STATS(xvar) IP_NOOP
#define IPMACSEC_SECY_STAT_VAL(xvar) 0
#define IPMACSEC_SECY_STATS_INC(xvar,inc) IP_NOOP
#define IPMACSEC_SC_STATS(xvar) IP_NOOP
#define IPMACSEC_SC_STAT_VAL(xvar) 0
#define IPMACSEC_SC_STATS_INC(xvar,inc) IP_NOOP
#define IPMACSEC_SA_STATS(xvar) IP_NOOP
#define IPMACSEC_SA_STAT_VAL(xvar) 0
#define IPMACSEC_SA_STATS_INC(xvar,inc) IP_NOOP
#endif
/* Common Length definitions */
#define IPMACSEC_MACADDRS_LEN (2*IPNET_ETH_ADDR_SIZE)
#define IPMACSEC_PN_LEN 4 /* # of octets in the PN field */
#define IPMACSEC_SECTAG_LEN sizeof(Ipnet_sectag)
#define IPMACSEC_SECTAG_NOSCI_LEN (sizeof(Ipnet_sectag)-IPMACSEC_SCI_LEN)
#define IPMACSEC_MIN_ICV_LEN 8
#define IPMACSEC_MIN_MPDU_LEN (IPMACSEC_SECTAG_NOSCI_LEN+1+IPMACSEC_MIN_ICV_LEN)
#define IPMACSEC_0SL_MIN_MSDU_LEN 48 /* Minimum MSDU length when SL == 0 */
#define IPMACSEC_0CBIT_ICV_LEN 16 /* ICV length when C bit == 0 */
/* Default threshold value for PN near exhaustion notification */
#define IPMACSEC_SECY_DEFAULT_PN_THRESHOLD 0xFFFF0000
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
#include "ipcom_align16.h"
/* Actual SecTAG header struct */
typedef IP_PACKED1 struct Ipnet_sectag_struct {
Ip_u16 ethType; /* Ethernet Type. Should be IPNET_ETHFRAME_MACSEC */
Ip_u8 tci_an; /* Tag Control Information (bits8-3) + Association Number (bits2-1) */
Ip_u8 sl; /* Short Length */
Ip_u32 pn; /* Packet Number */
Ip_u8 sci[IPMACSEC_SCI_LEN]; /* Secure Channel Identifier (optionally encoded) */
}
IP_PACKED2 Ipnet_sectag;
#include "ipcom_align16.h"
#include "ipcom_align16.h"
/* MACsec's Header overlay structure */
typedef IP_PACKED1 struct Ipnet_pkt_macsec_struct {
Ip_u8 dst[IPNET_ETH_ADDR_SIZE]; /* Destination address of the frame */
Ip_u8 src[IPNET_ETH_ADDR_SIZE]; /* Source address of the fram */
union {
Ip_u16 ethType;
Ipnet_sectag sectag;
} d;
}
IP_PACKED2 Ipnet_pkt_macsec;
#include "ipcom_align16.h"
/* MACsec's SecTAG representation */
typedef struct Ipmacsec_sectag_struct {
Ip_u16 ethType; /* Ethernet Type. Should be IPNET_ETHFRAME_MACSEC */
Ip_u8 tci; /* Tag Control Information value */
Ip_u8 version; /* Version value */
Ip_bool es_bit; /* End Station bit */
Ip_bool sc_bit; /* Secure Connection bit */
Ip_bool scb_bit; /* Single Copy Broadcast bit */
Ip_bool e_bit; /* Encryption bit */
Ip_bool c_bit; /* Changed text bit */
Ip_u32 pn; /* Packet Number (host order) */
Ip_u8 sl; /* Short Length */
Ip_u8 an; /* Association Number value */
Ip_u8 sci[IPMACSEC_SCI_LEN]; /* Secure Channel Identifier (if sc_bit is TRUE) */
Ip_u8 length; /* actual length of the SecTAG field */
} Ipmacsec_sectag;
/* SAK container */
typedef struct Ipmacsec_secy_sak_struct {
Ip_u8 *buf; /* buffer contaning the SAK binary octets */
Ip_u32 num_octets; /* size of the SAK buffer (# of octets) */
} Ipmacsec_secy_sak;
/* Key structure used to convey the SAK */
typedef struct Ipmacsec_secy_key_struct {
Ipmacsec_secy_key_id key_id; /* Set by KaY. */
Ipmacsec_secy_sak sak;
Ip_bool inUse; /* tracks if key is already in use by an SA */
Ip_bool transmits; /* Read ONLY value */
Ip_bool receives; /* Read ONLY value */
Ipmacsec_time createdTime; /* Read ONLY value */
} Ipmacsec_secy_key;
/* Struct used for TX and RX SAs */
typedef struct Ipmacsec_secy_sa_struct {
Ip_u32 an; /* a value <= IPMACSEC_AN_MAX_VAL */
Ip_bool inUse;
Ip_u32 nextPN;
Ip_u32 lowestPN; /* Applies for Rx SA only */
Ipmacsec_secy_key *key;
struct Ipmacsec_secy_sc_struct *sc; /* pointer back to SC parent of this SA. If not set, then SA is invalid */
Ipmacsec_time createdTime, startedTime, stoppedTime;
Ipmacsec_secy_sa_ref ref; /* A mgmt provided reference (10.7.13; 10.7.21) */
Ipmacsec_secy_sa_ctrl ctrl; /* Set via LMI */
Ip_bool confidentiality; /* Enable encryption (10.7.21) */
Ip_u32 pn_threshold; /* Threshold used for sending notificationfor PN near exhaustion */
Ip_bool pn_near_exhaust_notify; /* Flag used to track if notification was sent for PN near exhaustion */
#ifdef IPMACSEC_USE_STATS
Ipmacsec_secy_sa_stats stats;
#endif
} Ipmacsec_secy_sa; /* section 10.7 of 802.1AE */
/* Struct used for TX and RX SCs */
typedef struct Ipmacsec_secy_sc_struct {
Ip_bool enabled; /* set to TRUE when SC is enabled, otherwise non of the following fields have valid values */
union {
Ip_bool transmitting; /* Set by SecY when a tx SC is transmitting. READ only by external entities */
Ip_bool receiving;/* Set by SecY when a rx SC is receiving. READ only by external entities */
} oper;
Ip_u32 encodingSA; /* a value <= IPMACSEC_AN_MAX_VAL. Used by Tx SC ONLY. (10.5.1) */
Ip_u32 encipheringSA; /* a value <= IPMACSEC_AN_MAX_VAL. Used by Tx SC ONLY. (10.5.4) */
Ipmacsec_dir dir; /* Indicates whether it is a TX or RX SC */
Ipmacsec_time createdTime, startedTime, stoppedTime;
Ip_u8 sci[IPMACSEC_SCI_LEN]; /* Set by KaY or management interface */
Ipmacsec_secy_sa sa[IPMACSEC_MAX_SA];
Ip_u32 numActiveRxSAs; /* Current # of active Rx SAs, i.e. SAs enabled for reception (must be <= maxRxKeys).
* Used for internal tracking ONLY */
#ifdef IPMACSEC_USE_STATS
Ipmacsec_secy_sc_stats stats; /* Note that the "aggr" part of the stats stores only aggregate stats for deleted SAs,
otherwise needs to be added to existing SA stats to determine latest SC stats (10.7.9; 10.7.18)*/
#endif
Ip_u32 oldAN, newAN; /* ANs for tracking interleaved SAs */
Ip_u32 interleave_time; /* Time of reception of 1st interleaved frame in ms */
struct Ipmacsec_crypto_if_struct *crypto; /* per SC crypto if */
} Ipmacsec_secy_sc; /* section 10.7 of 802.1AE */
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipmacsec_secy_enable
*===========================================================================
* Description: Enable a SecY instance.
* Parameters: secy - SecY instance pointer
* Returns: 0 upon success, < 0 upon failure.
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_enable(struct Ipnet_secy_struct *secy);
/*
*===========================================================================
* ipmacsec_secy_disable
*===========================================================================
* Description: Disable a SecY instance.
* Parameters: secy - SecY instance pointer
* Returns: 0 upon success, < 0 upon failure.
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_disable(struct Ipnet_secy_struct *secy);
/*
*===========================================================================
* ipmacsec_sak_copy
*===========================================================================
* Description: Create a copy of an SAK content
* Parameters: to_sak - Valid pointer to SAK to copy to
* from_sak - Valid pointer to SAK to copy from
* Returns: 0 upon success, < 0 upon failure.
*
*/
IPMACSEC_PRIVATE int
ipmacsec_sak_copy(Ipmacsec_secy_sak *to_sak, IP_CONST Ipmacsec_secy_sak *from_sak);
/*
*===========================================================================
* ipmacsec_sak_delete
*===========================================================================
* Description: SAK destructor
* Parameters: sak - Valid pointer to SAK to delete
* Returns: 0 upon success, < 0 upon failure.
*
*/
IPMACSEC_PRIVATE int
ipmacsec_sak_delete(Ipmacsec_secy_sak *sak);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,219 @@
/* ipmacsec_ioctl.c - MACsec Ioctl implementation */
/*
* Copyright (c) 2010 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*
*/
/*
modification history
--------------------
01a,15feb10,mry Created
*/
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
* Implements MACsec Ioctl handlers and interface fns.
* This is provided for legacy reasons only. The main interface to MACsec
* SecY is via Netlink.
*/
/*
****************************************************************************
* 2 INCLUDE FILES
****************************************************************************
*/
#define IPCOM_USE_CLIB_PROTO
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#include <ipcom_clib.h>
#include <ipcom_err.h>
#include <ipcom_sock.h>
#include <ipcom_syslog.h>
#include <ipcom_sysvar.h>
#include <ipcom_errno.h>
#include <ipcom_err.h>
#include <ipcom_os.h>
#include <ipcom_ipd.h>
#include <ipcom_os.h>
#include <ipcom_sock.h>
#include "ipmacsec_debug.h"
#include "ipmacsec_h.h"
#include "ipmacsec.h"
#include "ipmacsec_ioctl.h"
/*
****************************************************************************
* 3 CONFIGURATION
****************************************************************************
*/
#include "ipmacsec_config.h"
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
****************************************************************************
* 6 EXTERN PROTOTYPES
****************************************************************************
*/
/*
****************************************************************************
* 7 LOCAL PROTOTYPES
****************************************************************************
*/
IP_GLOBAL int ipmacsec_ioctl(Ipnet_netif *netif, Ip_u32 request, void *data);
/*
*
****************************************************************************
* 8 DATA
****************************************************************************
*/
/*
****************************************************************************
* 9 STATIC FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* 10 PRIVATE FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipmacsec_ioctl
*===========================================================================
* Description: MACsec Ioctl handler.
* Only supports the SecY Enable/Disable operations
* Parameters:
* Returns: 0 upon success, < 0 upon failure.
*
*/
IPMACSEC_PRIVATE int
ipmacsec_ioctl(Ipnet_netif *netif, Ip_u32 request, void *data) {
struct Ip_secyreq *secyreq;
Ipmacsec_ioctl_cmd cmd;
ip_assert(netif);
if (request != IP_SIOCXSECY) {
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG1(ERR, "ipmacsec_ioctl :: request 0x%x != IP_SIOCXSECY ", request);
#endif
return -1;
}
if (!netif->secy) {
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG1(ERR, "ipmacsec_ioctl :: Null secy for interface %s", netif->ipcom.name);
#endif
return -1;
}
secyreq = (struct Ip_secyreq *)data;
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG6(DEBUG2, "MACSEC-IOCTL: interface %s, command %u, data %.2x %.2x %.2x %.2x",
netif->ipcom.name, secyreq->command, secyreq->data[0], secyreq->data[1], secyreq->data[2], secyreq->data[3]);
#endif
cmd = (Ipmacsec_ioctl_cmd)secyreq->command;
switch (cmd) {
case IPMACSEC_IOCTL_CMD_SECY_ENABLE:
return ipmacsec_secy_enable(netif->secy);
case IPMACSEC_IOCTL_CMD_SECY_DISABLE:
return ipmacsec_secy_disable(netif->secy);
default:
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG1(ERR, "ipmacsec_ioctl ::Unrecognized MACsec Ioctl cmd %u", cmd);
#endif
break;
}
return 0;
}
/*
****************************************************************************
* 11 PUBLIC FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipmacsec_send_ioctl
*===========================================================================
* Description: see "ipmacsec_ioctl.h"
* Parameters:
* Returns:
*
*/
IP_PUBLIC int
ipmacsec_send_ioctl(char *ifname, Ip_u32 command, Ip_u8 *data, Ip_u32 datalen) {
int rc = 0, sock = IP_INVALID_SOCKET;
struct Ip_secyreq secyreq;
if (data && (datalen > sizeof(secyreq.data))) {
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG2(ERR, "ipmacsec_send_ioctl :: datalen too large (%u > %u)\n", datalen, sizeof(secyreq.data));
#endif
return -1;
}
if (datalen && !data) {
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG0(ERR, "ipmacsec_send_ioctl :: Null data");
#endif
return -1;
}
ipcom_memset(&secyreq, 0, sizeof(secyreq));
ipcom_strncpy(secyreq.if_name, ifname, IP_IFNAMSIZ);
secyreq.if_name[IP_IFNAMSIZ-1] = '\0';
secyreq.command = command;
ipcom_memcpy(secyreq.data, data, datalen);
sock = ipcom_socket(IP_PF_PACKET, IP_SOCK_RAW, 0);
if (sock == IP_INVALID_SOCKET) {
#ifdef IPMACSEC_DEBUG_IOCTL
IPCOM_LOG1(ERR, "ipmacsec_send_ioctl :: ipcom_socket() failed, errno: %d\n", ipcom_errno);
#endif
return -1;
}
if ((rc = ipcom_socketioctl(sock, IP_SIOCXSECY, &secyreq)) < 0) {
#ifdef IPMACSEC_DEBUG_IOCTL
int errno = *ipcom_errno_get();
IPCOM_LOG2(ERR, "ipmacsec_send_ioctl :: ioctl(IP_SIOCXSECY) failed (%d: %s)",
errno, ipcom_strerror(errno));
#endif
}
ipcom_socketclose(sock);
return rc;
}
@@ -0,0 +1,99 @@
/* ipmacsec_ioctl.h - IPMACSEC IOCTL header file */
/*
* Copyright (c) 2010 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*
*/
/*
modification history
--------------------
01a,15feb10,mry Created
*/
#ifndef IPMACSEC_IOCTL_H
#define IPMACSEC_IOCTL_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#ifdef IP_PORT_VWORKS
#include <vsbConfig.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
typedef enum {
IPMACSEC_IOCTL_CMD_SECY_DISABLE,
IPMACSEC_IOCTL_CMD_SECY_ENABLE
} Ipmacsec_ioctl_cmd;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipmacsec_send_ioctl
*===========================================================================
* Description: API used by SecY LMI to send MACsec SecY Ioctl commands
* Parameters: ifname - Interface name
* command - Ipmacsec_ioctl_cmd to send
* data - Pointer to associated command data (if any)
* datalen - Length of command data
* Returns: 0 upon success, < 0 upon failure.
*
*/
IP_PUBLIC int
ipmacsec_send_ioctl(char *ifname, Ip_u32 command, Ip_u8 *data, Ip_u32 datalen);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,554 @@
/* ipmacsec_secy_mgmt.h - IPMACSEC SecY Management header file */
/*
* Copyright (c) 2010 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
* of an applicable Wind River license agreement.
*
*/
/*
modification history
--------------------
01a,24feb10,mry Created
*/
#ifndef IPMACSEC_SECY_MGMT_H
#define IPMACSEC_SECY_MGMT_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include <ipcom_cstyle.h>
#ifdef IP_PORT_VWORKS
#include <vsbConfig.h>
#endif
#include "ipmacsec_h.h"
#include "ipmacsec_lmi.h"
#include "ipmacsec_debug.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
#define IPMACSEC_SECY_MAC_OPER_OFF IP_TRUE
#define IPMACSEC_SECY_MAC_OPER_DEFAULT IP_FALSE
#ifndef IP_LOGICAL_XOR
#define IP_LOGICAL_XOR(x,y) (((x) || (y)) && !((x) && (y)))
#endif
/* Compare Controlled or Uncontrolled port status to that of Common Port to determine
* if it may have changed.
*/
#define IPMACSEC_SECY_PORT_STATUS_CHANGED(secy, port) \
(IP_LOGICAL_XOR(port.status.mac_enabled, IP_BIT_ISSET(secy->netif->ipcom.flags, IP_IFF_UP)) || \
IP_LOGICAL_XOR(port.status.mac_oper, IP_BIT_ISSET(secy->netif->ipcom.flags, IP_IFF_RUNNING)))
/* Convenience macro for when notification result is irrelevant and no params are being passed */
#define IPMACSEC_SECY_STATUS_NOTIFY(secy,status) (void)ipmacsec_secy_status_notify((secy), (status), IP_NULL, IP_NULL)
#define IPMACSEC_SECY_INFO_NOTIFY(secy, info) (void)ipmacsec_secy_info_notify((secy), (info), IP_NULL, IP_NULL)
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipmacsec_secy_keydb_init
*===========================================================================
* Description: Initialize the SecY Key database
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_keydb_init(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_keydb_destroy
*===========================================================================
* Description: Destroy the SecY Key database
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_keydb_destroy(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_ucp_update_status_ext
*===========================================================================
* Description: Externally registered API to update the Uncontrolled Port status
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_ucp_update_status_ext(struct Ipnet_netif_struct *netif);
/*
*===========================================================================
* ipmacsec_secy_ucp_update_statistics
*===========================================================================
* Description: Update the Uncontrolled Port Statistics
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_ucp_update_statistics(struct Ipnet_netif_struct *netif);
/*
*===========================================================================
* ipmacsec_secy_ucp_update_status
*===========================================================================
* Description: Update the Uncontrolled Port Status
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_ucp_update_status(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_cp_update_status_ext
*===========================================================================
* Description: Externally registered API to update the Controlled Port Status
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_cp_update_status_ext(struct Ipnet_netif_struct *netif);
/*
*===========================================================================
* ipmacsec_secy_cp_update_statistics
*===========================================================================
* Description: Update Controlled Port Statistics
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_cp_update_statistics(struct Ipnet_netif_struct *netif);
/*
*===========================================================================
* ipmacsec_secy_cp_update_status
*===========================================================================
* Description: Update Controlled Port Status
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_cp_update_status(Ipnet_secy *secy, Ip_bool mac_oper_off);
/*
*===========================================================================
* ipmacsec_secy_create_tx_sc
*===========================================================================
* Description: Create the TX SC
* Parameters:
* Returns: Pointer to the created SC if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sc *
ipmacsec_secy_create_tx_sc(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_delete_tx_sc
*===========================================================================
* Description: Delete the TX SC
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_tx_sc(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_create_tx_sa
*===========================================================================
* Description: Create a TX SA
* Parameters:
* Returns: Pointer to the created SA if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sa *
ipmacsec_secy_create_tx_sa(Ipnet_secy *secy, Ip_u8 an, Ipmacsec_secy_sa_ref ref,
Ip_u32 nextPN, Ipmacsec_confidentiality confidentiality,
Ipmacsec_secy_key *key);
/*
*===========================================================================
* ipmacsec_secy_delete_tx_sa
*===========================================================================
* Description: Delete a TX SA
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_tx_sa(Ipnet_secy *secy, Ipmacsec_secy_sa *sa);
/*
*===========================================================================
* ipmacsec_secy_enable_tx_sa
*===========================================================================
* Description: Enable/Disable Tx SA (set enableTransmit accordingly)
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_enable_tx_sa(Ipnet_secy *secy, Ipmacsec_secy_sa *sa, Ip_bool enableTransmit);
/*
*===========================================================================
* ipmacsec_secy_create_rx_sc
*===========================================================================
* Description: Create an RX SC
* Parameters:
* Returns: Pointer to the created SC if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sc *
ipmacsec_secy_create_rx_sc(Ipnet_secy *secy, IP_CONST Ip_u8 *sci);
/*
*===========================================================================
* ipmacsec_secy_delete_rx_sc
*===========================================================================
* Description: Delete an RX SC
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_rx_sc(Ipnet_secy *secy, Ipmacsec_secy_sc *sc);
/*
*===========================================================================
* ipmacsec_secy_delete_rx_sc_all
*===========================================================================
* Description: Delete all RX SCs for this SecY
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_rx_sc_all(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_create_rx_sa
*===========================================================================
* Description: Create an RX SA
* Parameters:
* Returns: Pointer to the created SA if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sa *
ipmacsec_secy_create_rx_sa(Ipnet_secy *secy, Ipmacsec_secy_sc *sc,
Ip_u8 an, Ipmacsec_secy_sa_ref ref, Ip_u32 nextPN,
Ip_u32 lowestPN, Ipmacsec_secy_key *key);
/*
*===========================================================================
* ipmacsec_secy_delete_rx_sa
*===========================================================================
* Description: Delete an RX SA
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_rx_sa(Ipnet_secy *secy, Ipmacsec_secy_sa *sa);
/*
*===========================================================================
* ipmacsec_secy_enable_rx_sa
*===========================================================================
* Description: Enable/Disable Rx SA (according to enableReceive)
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_enable_rx_sa(Ipnet_secy *secy, Ipmacsec_secy_sa *sa, Ip_bool enableReceive);
/*
*===========================================================================
* ipmacsec_secy_update_rx_sa
*===========================================================================
* Description: Update Rx SA nextPN and/or lowestPN based on provided values.
* Invoked via LMI trigger.
* Parameters: nextPN, lowestPN value of 0 means do not update
* Returns: 0 upon success, <0 upon error.
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_update_rx_sa(Ipnet_secy *secy, Ipmacsec_secy_sa *sa,
Ip_u32 nextPN, Ip_u32 lowestPN);
/*
*===========================================================================
* ipmacsec_secy_create_key
*===========================================================================
* Description: Create an SAK
* Parameters:
* Returns: Pointer to the created key upon success,
* IP_NULL upon failure.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_key *
ipmacsec_secy_create_key(Ipnet_secy *secy, Ipmacsec_secy_sak *sak,
Ipmacsec_secy_key_id *key_id);
/*
*===========================================================================
* ipmacsec_secy_delete_key
*===========================================================================
* Description: Delete an SAK
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_key(Ipnet_secy *secy, Ipmacsec_secy_key *key);
/*
*===========================================================================
* ipmacsec_secy_install_key
*===========================================================================
* Description: Install an SAK
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_install_key(Ipnet_secy *secy,
Ipmacsec_secy_key *key, Ipmacsec_keytype keytype);
/*
*===========================================================================
* ipmacsec_secy_remove_key
*===========================================================================
* Description: Remove an SAK
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_key *
ipmacsec_secy_remove_key(Ipnet_secy *secy, Ipmacsec_secy_key_id *key_id);
/*
*===========================================================================
* ipmacsec_secy_delete_all_keys
*===========================================================================
* Description: Delete all SAKs for this SecY
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_delete_all_keys(Ipnet_secy *secy, Ip_bool ignore_in_use);
/*
*===========================================================================
* ipmacsec_secy_get_tx_sc
*===========================================================================
* Description: Retrieve the TX SC for this SecY
* Parameters:
* Returns: Pointer to the TX SC if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sc *
ipmacsec_secy_get_tx_sc(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_get_tx_sa
*===========================================================================
* Description: Retrieve the current transmit SA
* Parameters:
* Returns: Pointer to the SA if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sa *
ipmacsec_secy_get_tx_sa(Ipnet_secy *secy);
/*
*===========================================================================
* ipmacsec_secy_lookup_tx_sa
*===========================================================================
* Description: Lookup a transmit SA based on the specified AN
* Parameters:
* Returns: Pointer to the SA if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sa *
ipmacsec_secy_lookup_tx_sa(Ipnet_secy *secy, IP_CONST Ip_u8 an);
/*
*===========================================================================
* ipmacsec_secy_lookup_rx_sc
*===========================================================================
* Description: Lookup an RX SC based on the specified SCI
* Parameters:
* Returns: Pointer to the SC if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sc *
ipmacsec_secy_lookup_rx_sc(Ipnet_secy *secy, IP_CONST Ip_u8 *sci);
/*
*===========================================================================
* ipmacsec_secy_lookup_rx_sa
*===========================================================================
* Description: Lookup an RX SA based on the specified SC+AN
* Parameters:
* Returns: Pointer to the SA if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sa *
ipmacsec_secy_lookup_rx_sa(Ipnet_secy *secy, Ipmacsec_secy_sc *sc, IP_CONST Ip_u8 an);
/*
*===========================================================================
* ipmacsec_secy_lookup_rx_sa_sai
*===========================================================================
* Description: Lookup an RX SA based on the specified SAI=SCI+AN
* Parameters:
* Returns: Pointer to the SA if successful,
* IP_NULL otherwise.
*
*/
IPMACSEC_PRIVATE Ipmacsec_secy_sa *
ipmacsec_secy_lookup_rx_sa_sai(Ipnet_secy *secy, IP_CONST Ip_u8 *sci, IP_CONST Ip_u8 an);
/*
*===========================================================================
* ipmacsec_secy_check_rx_sa_interleave
*===========================================================================
* Description: Check whether interleaving is allowed on this RX SA (7.1.3)
* Parameters:
* Returns: 0 if frame should be accepted on this SA, < 0 if frame should be dropped
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_check_rx_sa_interleave(Ipnet_secy *secy, Ipmacsec_secy_sa *sa);
/*
*===========================================================================
* ipmacsec_secy_cp_enable
*===========================================================================
* Description: Enable the SecY Controlled Port.
* Called from LMI trigger
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_cp_enable(Ipnet_secy *secy, Ip_bool enable);
/*
*===========================================================================
* ipmacsec_secy_cp_set_adminP2pMac
*===========================================================================
* Description: Set the SecY Controlled Port AdminPointToPointMAC.
* Called from LMI trigger
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_cp_set_adminP2pMac(Ipnet_secy *secy, Ip_portif_admin_ptp_mac_val admin_p2p_mac);
/*
*===========================================================================
* ipmacsec_secy_status_notify
*===========================================================================
* Description: Notify via LMI of SecY status changes.
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_status_notify(Ipnet_secy *secy, Ipmacsec_secy_status status, void *param, Ip_u32 param_size);
/*
*===========================================================================
* ipmacsec_secy_info_notify
*===========================================================================
* Description: Notify via LMI of SecY informational events
* (Only turned on during debugging).
* Parameters:
* Returns: 0 upon success, <0 upon error
*
*/
IPMACSEC_PRIVATE int
ipmacsec_secy_info_notify(Ipnet_secy *secy, Ipmacsec_secy_info info, void *param, Ip_u32 param_size);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/