ipsec.h (3569B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_IPSEC_H__ 11 #define __BCM_IPSEC_H__ 12 13 #include <bcm/types.h> 14 15 typedef struct bcm_ipsec_config_s { 16 uint32 num_of_ipsec_channels; 17 uint32 num_of_bfd_channels; 18 } bcm_ipsec_config_t; 19 20 #ifndef BCM_HIDE_DISPATCHABLE 21 22 /* configure the IPSEC feature. */ 23 extern int bcm_ipsec_config_set( 24 int unit, 25 bcm_ipsec_config_t *config); 26 27 #endif /* BCM_HIDE_DISPATCHABLE */ 28 29 typedef struct bcm_ipsec_tunnel_info_s { 30 uint32 context_id; 31 bcm_ipv4_ipv6_addr_t local_ip; /* Local tunnel endpoint; IPV4 or IPV6 */ 32 bcm_ipv4_ipv6_addr_t remote_ip; /* Remote tunnel endpoint; IPV4 or IPV6 */ 33 uint32 protocol; /* Tunnel protocol; IPV4 or IPV6 */ 34 uint8 ttl; 35 uint8 dscp; 36 bcm_port_t port; /* Port id will determine the lif port for 37 ipsec output packets */ 38 } bcm_ipsec_tunnel_info_t; 39 40 #ifndef BCM_HIDE_DISPATCHABLE 41 42 /* Add IPSEC tunnel */ 43 extern int bcm_ipsec_tunnel_create( 44 int unit, 45 uint32 flags, 46 uint32 *tunnel_id, 47 bcm_ipsec_tunnel_info_t *tunnel_info); 48 49 /* Delete IPSEC tunnel */ 50 extern int bcm_ipsec_tunnel_delete( 51 int unit, 52 uint32 flags, 53 uint32 tunnel_id); 54 55 #endif /* BCM_HIDE_DISPATCHABLE */ 56 57 typedef enum bcm_ipsec_algo_type_e { 58 bcmEncNone = 0, 59 bcmAES128 = 1, 60 bcmAES256 = 2 61 } bcm_ipsec_algo_type_t; 62 63 typedef enum bcm_ipsec_auth_type_e { 64 bcmAuthNone = 0, 65 bcmSHA1 = 1, 66 bcmSHA256 = 2 67 } bcm_ipsec_auth_type_t; 68 69 typedef enum bcm_ipsec_direction_e { 70 bcmENCRYPTION = 0, 71 bcmDECRYPTION = 1 72 } bcm_ipsec_direction_t; 73 74 typedef struct bcm_ipsec_sa_info_s { 75 uint32 initial_seq_num; 76 uint32 mtu; 77 uint8 fragmentation_enable; 78 bcm_ipsec_algo_type_t encrypt_type; 79 bcm_ipsec_auth_type_t auth_type; 80 bcm_ipsec_direction_t sa_direction; 81 uint32 spi; 82 } bcm_ipsec_sa_info_t; 83 84 #ifndef BCM_HIDE_DISPATCHABLE 85 86 /* Add IPSEC SA */ 87 extern int bcm_ipsec_sa_create( 88 int unit, 89 uint32 flags, 90 uint32 *sa_id, 91 bcm_ipsec_sa_info_t *sa); 92 93 #endif /* BCM_HIDE_DISPATCHABLE */ 94 95 #define BCM_IPSEC_MAX_ENCR_KEY_LEN 256 96 97 #define BCM_IPSEC_MAX_AUTH_KEY_LEN 256 98 99 #define BCM_IPSEC_ENCR_KEY_MAX_NUM_WORDS 8 100 #define BCM_IPSEC_AUTH_KEY_MAX_NUM_WORDS 8 101 102 #define BCM_IPSEC_SA_CREATE_WITH_ID 1 << 0 /* IPSEC SA create API optional 103 flags. */ 104 105 #define BCM_IPSEC_TUNNEL_CREATE_WITH_ID 1 << 0 /* IPSEC TUNNEL create API 106 optional flags. */ 107 108 typedef struct bcm_ipsec_sa_keys_s { 109 uint32 enc_key[BCM_IPSEC_ENCR_KEY_MAX_NUM_WORDS]; 110 uint32 auth_key[BCM_IPSEC_AUTH_KEY_MAX_NUM_WORDS]; 111 } bcm_ipsec_sa_keys_t; 112 113 #ifndef BCM_HIDE_DISPATCHABLE 114 115 /* Add IPSEC SA Keys */ 116 extern int bcm_ipsec_sa_key_update( 117 int unit, 118 uint32 flags, 119 uint32 sa_id, 120 bcm_ipsec_sa_keys_t *sa_keys); 121 122 /* Delete IPSEC SA */ 123 extern int bcm_ipsec_sa_delete( 124 int unit, 125 uint32 flags, 126 uint32 sa_id); 127 128 /* Map IPSEC SA to tunnel */ 129 extern int bcm_ipsec_sa_to_tunnel_map_set( 130 int unit, 131 uint32 tunnel_id, 132 uint32 sa_id); 133 134 /* Map IPSEC SA to tunnel */ 135 extern int bcm_ipsec_sa_to_tunnel_map_get( 136 int unit, 137 uint32 sa_id, 138 uint32 *tunnel_id); 139 140 #endif /* BCM_HIDE_DISPATCHABLE */ 141 142 #endif /* __BCM_IPSEC_H__ */