555 lines
19 KiB
C
555 lines
19 KiB
C
/* 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
|
|
****************************************************************************
|
|
*/
|