#ifndef _INET_IPSEC_IMPL_H
#define _INET_IPSEC_IMPL_H
#include <inet/ip.h>
#include <inet/ipdrop.h>
#ifdef __cplusplus
extern "C" {
#endif
#define IPSEC_CONF_SRC_ADDRESS 0
#define IPSEC_CONF_SRC_PORT 1
#define IPSEC_CONF_DST_ADDRESS 2
#define IPSEC_CONF_DST_PORT 3
#define IPSEC_CONF_SRC_MASK 4
#define IPSEC_CONF_DST_MASK 5
#define IPSEC_CONF_ULP 6
#define IPSEC_CONF_IPSEC_PROT 7
#define IPSEC_CONF_IPSEC_AALGS 8
#define IPSEC_CONF_IPSEC_EALGS 9
#define IPSEC_CONF_IPSEC_EAALGS 10
#define IPSEC_CONF_IPSEC_SA 11
#define IPSEC_CONF_IPSEC_DIR 12
#define IPSEC_CONF_ICMP_TYPE 13
#define IPSEC_CONF_ICMP_CODE 14
#define IPSEC_CONF_NEGOTIATE 15
#define IPSEC_CONF_TUNNEL 16
#define IPSEC_NTYPES 0x02
#define IPSEC_TYPE_OUTBOUND 0x00
#define IPSEC_TYPE_INBOUND 0x01
#define IPSEC_POLICY_APPLY 0x01
#define IPSEC_POLICY_DISCARD 0x02
#define IPSEC_POLICY_BYPASS 0x03
#define IPSEC_SHARED_SA 0x01
#define IPSEC_UNIQUE_SA 0x02
#define IPSEC_AH_ONLY 0x01
#define IPSEC_ESP_ONLY 0x02
#define IPSEC_AH_ESP 0x03
#define SADB_AALG_ANY 255
#ifdef _KERNEL
#include <inet/common.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <net/pfkeyv2.h>
#include <inet/ip.h>
#include <inet/sadb.h>
#include <inet/ipsecah.h>
#include <inet/ipsecesp.h>
#include <sys/crypto/common.h>
#include <sys/crypto/api.h>
#include <sys/avl.h>
#define MAX_AALGS 256
#define IPSEC_TASKQ_MIN 10
#define IPSEC_TASKQ_MAX 20
extern boolean_t keysock_extended_reg(netstack_t *);
extern uint32_t keysock_next_seq(netstack_t *);
extern void keysock_spdsock_wput_iocdata(queue_t *, mblk_t *, sa_family_t);
#define HASH_LOCK(table, hash) \
mutex_enter(&(table)[hash].hash_lock)
#define HASH_UNLOCK(table, hash) \
mutex_exit(&(table)[hash].hash_lock)
#define HASH_LOCKED(table, hash) \
MUTEX_HELD(&(table)[hash].hash_lock)
#define HASH_ITERATE(var, field, table, hash) \
var = table[hash].hash_head; var != NULL; var = var->field.hash_next
#define HASH_NEXT(var, field) \
(var)->field.hash_next
#define HASH_INSERT(var, field, table, hash) \
{ \
ASSERT(HASH_LOCKED(table, hash)); \
(var)->field.hash_next = (table)[hash].hash_head; \
(var)->field.hash_pp = &(table)[hash].hash_head; \
(table)[hash].hash_head = var; \
if ((var)->field.hash_next != NULL) \
(var)->field.hash_next->field.hash_pp = \
&((var)->field.hash_next); \
}
#define HASH_UNCHAIN(var, field, table, hash) \
{ \
ASSERT(MUTEX_HELD(&(table)[hash].hash_lock)); \
HASHLIST_UNCHAIN(var, field); \
}
#define HASHLIST_INSERT(var, field, head) \
{ \
(var)->field.hash_next = head; \
(var)->field.hash_pp = &(head); \
head = var; \
if ((var)->field.hash_next != NULL) \
(var)->field.hash_next->field.hash_pp = \
&((var)->field.hash_next); \
}
#define HASHLIST_UNCHAIN(var, field) \
{ \
*var->field.hash_pp = var->field.hash_next; \
if (var->field.hash_next) \
var->field.hash_next->field.hash_pp = \
var->field.hash_pp; \
HASH_NULL(var, field); \
}
#define HASH_NULL(var, field) \
{ \
var->field.hash_next = NULL; \
var->field.hash_pp = NULL; \
}
#define HASH_LINK(fieldname, type) \
struct { \
type *hash_next; \
type **hash_pp; \
} fieldname
#define HASH_HEAD(tag) \
struct { \
struct tag *hash_head; \
kmutex_t hash_lock; \
}
typedef struct ipsec_policy_s ipsec_policy_t;
typedef HASH_HEAD(ipsec_policy_s) ipsec_policy_hash_t;
typedef struct ipsec_prot
{
unsigned int
ipp_use_ah : 1,
ipp_use_esp : 1,
ipp_use_se : 1,
ipp_use_unique : 1,
ipp_use_espa : 1,
ipp_pad : 27;
uint8_t ipp_auth_alg;
uint8_t ipp_encr_alg;
uint8_t ipp_esp_auth_alg;
uint16_t ipp_ah_minbits;
uint16_t ipp_ah_maxbits;
uint16_t ipp_espe_minbits;
uint16_t ipp_espe_maxbits;
uint16_t ipp_espa_minbits;
uint16_t ipp_espa_maxbits;
uint32_t ipp_km_proto;
uint64_t ipp_km_cookie;
uint32_t ipp_replay_depth;
} ipsec_prot_t;
#define IPSEC_MAX_KEYBITS (0xffff)
typedef struct ipsec_act
{
uint8_t ipa_type;
uint8_t ipa_log;
union
{
ipsec_prot_t ipau_apply;
uint8_t ipau_reject_type;
uint32_t ipau_resolve_id;
uint8_t ipau_log_type;
} ipa_u;
#define ipa_apply ipa_u.ipau_apply
#define ipa_reject_type ipa_u.ipau_reject_type
#define ipa_log_type ipa_u.ipau_log_type
#define ipa_resolve_type ipa_u.ipau_resolve_type
} ipsec_act_t;
#define IPSEC_ACT_APPLY 0x01
#define IPSEC_ACT_DISCARD 0x02
#define IPSEC_ACT_BYPASS 0x03
#define IPSEC_ACT_REJECT 0x04
#define IPSEC_ACT_CLEAR 0x05
typedef struct ipsec_action_s
{
HASH_LINK(ipa_hash, struct ipsec_action_s);
struct ipsec_action_s *ipa_next;
uint32_t ipa_refs;
ipsec_act_t ipa_act;
unsigned int
ipa_hval: 8,
ipa_allow_clear:1,
ipa_want_ah:1,
ipa_want_esp:1,
ipa_want_se:1,
ipa_want_unique:1,
ipa_pad:19;
uint32_t ipa_ovhd;
} ipsec_action_t;
#define IPACT_REFHOLD(ipa) { \
atomic_inc_32(&(ipa)->ipa_refs); \
ASSERT((ipa)->ipa_refs != 0); \
}
#define IPACT_REFRELE(ipa) { \
ASSERT((ipa)->ipa_refs != 0); \
membar_exit(); \
if (atomic_dec_32_nv(&(ipa)->ipa_refs) == 0) \
ipsec_action_free(ipa); \
(ipa) = 0; \
}
#define IPSEC_ACTION_HASH_SIZE 1
typedef union ipsec_addr
{
in6_addr_t ipsad_v6;
in_addr_t ipsad_v4;
} ipsec_addr_t;
typedef struct ipsec_selkey
{
uint32_t ipsl_valid;
#define IPSL_REMOTE_ADDR 0x00000001
#define IPSL_LOCAL_ADDR 0x00000002
#define IPSL_REMOTE_PORT 0x00000004
#define IPSL_LOCAL_PORT 0x00000008
#define IPSL_PROTOCOL 0x00000010
#define IPSL_ICMP_TYPE 0x00000020
#define IPSL_ICMP_CODE 0x00000040
#define IPSL_IPV6 0x00000080
#define IPSL_IPV4 0x00000100
#define IPSL_WILDCARD 0x0000007f
ipsec_addr_t ipsl_local;
ipsec_addr_t ipsl_remote;
uint16_t ipsl_lport;
uint16_t ipsl_rport;
uint8_t ipsl_icmp_type;
uint8_t ipsl_icmp_type_end;
uint8_t ipsl_icmp_code;
uint8_t ipsl_icmp_code_end;
uint8_t ipsl_proto;
uint8_t ipsl_local_pfxlen;
uint8_t ipsl_remote_pfxlen;
uint8_t ipsl_mbz;
uint32_t ipsl_pol_hval;
uint32_t ipsl_sel_hval;
} ipsec_selkey_t;
typedef struct ipsec_sel
{
HASH_LINK(ipsl_hash, struct ipsec_sel);
uint32_t ipsl_refs;
ipsec_selkey_t ipsl_key;
} ipsec_sel_t;
struct ipsec_policy_s
{
HASH_LINK(ipsp_hash, struct ipsec_policy_s);
avl_node_t ipsp_byid;
uint64_t ipsp_index;
uint32_t ipsp_prio;
uint32_t ipsp_refs;
ipsec_sel_t *ipsp_sel;
ipsec_action_t *ipsp_act;
netstack_t *ipsp_netstack;
};
#define IPPOL_REFHOLD(ipp) { \
atomic_inc_32(&(ipp)->ipsp_refs); \
ASSERT((ipp)->ipsp_refs != 0); \
}
#define IPPOL_REFRELE(ipp) { \
ASSERT((ipp)->ipsp_refs != 0); \
membar_exit(); \
if (atomic_dec_32_nv(&(ipp)->ipsp_refs) == 0) \
ipsec_policy_free(ipp); \
(ipp) = 0; \
}
#define IPPOL_UNCHAIN(php, ip) \
HASHLIST_UNCHAIN((ip), ipsp_hash); \
avl_remove(&(php)->iph_rulebyid, (ip)); \
IPPOL_REFRELE(ip);
#define IPSEC_AF_V4 0
#define IPSEC_AF_V6 1
#define IPSEC_NAF 2
typedef struct ipsec_policy_root_s
{
ipsec_policy_t *ipr_nonhash[IPSEC_NAF];
int ipr_nchains;
ipsec_policy_hash_t *ipr_hash;
} ipsec_policy_root_t;
typedef struct ipsec_policy_head_s
{
uint32_t iph_refs;
krwlock_t iph_lock;
uint64_t iph_gen;
ipsec_policy_root_t iph_root[IPSEC_NTYPES];
avl_tree_t iph_rulebyid;
} ipsec_policy_head_t;
#define IPPH_REFHOLD(iph) { \
atomic_inc_32(&(iph)->iph_refs); \
ASSERT((iph)->iph_refs != 0); \
}
#define IPPH_REFRELE(iph, ns) { \
ASSERT((iph)->iph_refs != 0); \
membar_exit(); \
if (atomic_dec_32_nv(&(iph)->iph_refs) == 0) \
ipsec_polhead_free(iph, ns); \
(iph) = 0; \
}
typedef struct ipsec_fragcache_entry {
struct ipsec_fragcache_entry *itpfe_next;
mblk_t *itpfe_fraglist;
time_t itpfe_exp;
int itpfe_depth;
ipsec_addr_t itpfe_frag_src;
ipsec_addr_t itpfe_frag_dst;
#define itpfe_src itpfe_frag_src.ipsad_v4
#define itpfe_src6 itpfe_frag_src.ipsad_v6
#define itpfe_dst itpfe_frag_dst.ipsad_v4
#define itpfe_dst6 itpfe_frag_dst.ipsad_v6
uint32_t itpfe_id;
uint8_t itpfe_proto;
uint8_t itpfe_last;
} ipsec_fragcache_entry_t;
typedef struct ipsec_fragcache {
kmutex_t itpf_lock;
struct ipsec_fragcache_entry **itpf_ptr;
struct ipsec_fragcache_entry *itpf_freelist;
time_t itpf_expire_hint;
} ipsec_fragcache_t;
typedef struct ipsec_tun_pol_s {
avl_node_t itp_node;
kmutex_t itp_lock;
uint64_t itp_next_policy_index;
ipsec_policy_head_t *itp_policy;
ipsec_policy_head_t *itp_inactive;
uint32_t itp_flags;
uint32_t itp_refcnt;
char itp_name[LIFNAMSIZ];
ipsec_fragcache_t itp_fragcache;
} ipsec_tun_pol_t;
#define ITPF_P_ACTIVE 0x1
#define ITPF_P_TUNNEL 0x2
#define ITPF_P_PER_PORT_SECURITY 0x4
#define ITPF_PFLAGS 0x7
#define ITPF_SHIFT 3
#define ITPF_I_ACTIVE 0x8
#define ITPF_I_TUNNEL 0x10
#define ITPF_I_PER_PORT_SECURITY 0x20
#define ITPF_IFLAGS 0x38
#define ITPF_CLONE(f) (f) = (((f) & ITPF_PFLAGS) | \
(((f) & ITPF_PFLAGS) << ITPF_SHIFT));
#define ITPF_SWAP(f) (f) = ((((f) & ITPF_PFLAGS) << ITPF_SHIFT) | \
(((f) & ITPF_IFLAGS) >> ITPF_SHIFT))
#define ITP_P_ISACTIVE(itp, iph) ((itp)->itp_flags & \
(((itp)->itp_policy == (iph)) ? ITPF_P_ACTIVE : ITPF_I_ACTIVE))
#define ITP_P_ISTUNNEL(itp, iph) ((itp)->itp_flags & \
(((itp)->itp_policy == (iph)) ? ITPF_P_TUNNEL : ITPF_I_TUNNEL))
#define ITP_P_ISPERPORT(itp, iph) ((itp)->itp_flags & \
(((itp)->itp_policy == (iph)) ? ITPF_P_PER_PORT_SECURITY : \
ITPF_I_PER_PORT_SECURITY))
#define ITP_REFHOLD(itp) { \
atomic_inc_32(&((itp)->itp_refcnt)); \
ASSERT((itp)->itp_refcnt != 0); \
}
#define ITP_REFRELE(itp, ns) { \
ASSERT((itp)->itp_refcnt != 0); \
membar_exit(); \
if (atomic_dec_32_nv(&((itp)->itp_refcnt)) == 0) \
itp_free(itp, ns); \
}
typedef struct ipsid_s
{
struct ipsid_s *ipsid_next;
struct ipsid_s **ipsid_ptpn;
uint32_t ipsid_refcnt;
int ipsid_type;
char *ipsid_cid;
} ipsid_t;
#define IPSID_REFHOLD(ipsid) { \
atomic_inc_32(&(ipsid)->ipsid_refcnt); \
ASSERT((ipsid)->ipsid_refcnt != 0); \
}
#define IPSID_REFRELE(ipsid) { \
membar_exit(); \
atomic_dec_32(&(ipsid)->ipsid_refcnt); \
}
#define IPSEC_MAX_AH_HDR_SIZE (44)
#define IPSEC_MAX_ESP_HDR_SIZE (70)
#include <inet/ipsecesp.h>
#define IPSEC_BASE_ESP_HDR_SIZE(sa) \
(sizeof (esph_t) + ((sa)->ipsa_iv_len << 1) - 2 + (sa)->ipsa_mac_len)
#define IPSID_HASHSIZE 64
typedef struct ipsif_s
{
ipsid_t *ipsif_head;
kmutex_t ipsif_lock;
} ipsif_t;
typedef struct ipsec_crypto_s {
size_t ic_skip_len;
crypto_data_t ic_crypto_data;
crypto_dual_data_t ic_crypto_dual_data;
crypto_data_t ic_crypto_mac;
ipsa_cm_mech_t ic_cmm;
} ipsec_crypto_t;
struct ipsec_stack {
netstack_t *ipsec_netstack;
ipdropper_t ipsec_dropper;
uint64_t ipsec_next_policy_index;
HASH_HEAD(ipsec_action_s) ipsec_action_hash[IPSEC_ACTION_HASH_SIZE];
HASH_HEAD(ipsec_sel) *ipsec_sel_hash;
uint32_t ipsec_spd_hashsize;
ipsif_t ipsec_ipsid_buckets[IPSID_HASHSIZE];
ipsec_policy_head_t ipsec_system_policy;
ipsec_policy_head_t ipsec_inactive_policy;
ipdropper_t ipsec_spd_dropper;
kstat_t *ipsec_ip_drop_kstat;
struct ip_dropstats *ipsec_ip_drop_types;
uint32_t ipsec_policy_failure_count[IPSEC_POLICY_MAX];
hrtime_t ipsec_policy_failure_last;
kstat_t *ipsec_ksp;
struct ipsec_kstats_s *ipsec_kstats;
ipdropper_t ipsec_sadb_dropper;
boolean_t ipsec_inbound_v4_policy_present;
boolean_t ipsec_outbound_v4_policy_present;
boolean_t ipsec_inbound_v6_policy_present;
boolean_t ipsec_outbound_v6_policy_present;
krwlock_t ipsec_alg_lock;
uint8_t ipsec_nalgs[IPSEC_NALGTYPES];
ipsec_alginfo_t *ipsec_alglists[IPSEC_NALGTYPES][IPSEC_MAX_ALGS];
uint8_t ipsec_sortlist[IPSEC_NALGTYPES][IPSEC_MAX_ALGS];
int ipsec_algs_exec_mode[IPSEC_NALGTYPES];
uint32_t ipsec_tun_spd_hashsize;
krwlock_t ipsec_tunnel_policy_lock;
uint64_t ipsec_tunnel_policy_gen;
avl_tree_t ipsec_tunnel_policies;
kmutex_t ipsec_loader_lock;
int ipsec_loader_state;
int ipsec_loader_sig;
kt_did_t ipsec_loader_tid;
kcondvar_t ipsec_loader_sig_cv;
};
typedef struct ipsec_stack ipsec_stack_t;
#define DROPPER(_ipss, _dropper) \
(((_ipss)->ipsec_ip_drop_types == NULL) ? NULL : \
&((_ipss)->ipsec_ip_drop_types->_dropper))
#define IPSEC_LOADER_WAIT 0
#define IPSEC_LOADER_FAILED -1
#define IPSEC_LOADER_SUCCEEDED 1
extern void ipsec_loader_init(ipsec_stack_t *);
extern void ipsec_loader_start(ipsec_stack_t *);
extern void ipsec_loader_destroy(ipsec_stack_t *);
extern void ipsec_loader_loadnow(ipsec_stack_t *);
extern boolean_t ipsec_loader_wait(queue_t *q, ipsec_stack_t *);
extern boolean_t ipsec_loaded(ipsec_stack_t *);
extern boolean_t ipsec_failed(ipsec_stack_t *);
extern void ipsec_policy_g_destroy(void);
extern void ipsec_policy_g_init(void);
extern mblk_t *ipsec_add_crypto_data(mblk_t *, ipsec_crypto_t **);
extern mblk_t *ipsec_remove_crypto_data(mblk_t *, ipsec_crypto_t **);
extern mblk_t *ipsec_free_crypto_data(mblk_t *);
extern int ipsec_alloc_table(ipsec_policy_head_t *, int, int, boolean_t,
netstack_t *);
extern void ipsec_polhead_init(ipsec_policy_head_t *, int);
extern void ipsec_polhead_destroy(ipsec_policy_head_t *);
extern void ipsec_polhead_free_table(ipsec_policy_head_t *);
extern mblk_t *ipsec_check_global_policy(mblk_t *, conn_t *, ipha_t *,
ip6_t *, ip_recv_attr_t *, netstack_t *ns);
extern mblk_t *ipsec_check_inbound_policy(mblk_t *, conn_t *, ipha_t *, ip6_t *,
ip_recv_attr_t *);
extern boolean_t ipsec_in_to_out(ip_recv_attr_t *, ip_xmit_attr_t *,
mblk_t *, ipha_t *, ip6_t *);
extern void ipsec_in_release_refs(ip_recv_attr_t *);
extern void ipsec_out_release_refs(ip_xmit_attr_t *);
extern void ipsec_log_policy_failure(int, char *, ipha_t *, ip6_t *, boolean_t,
netstack_t *);
extern boolean_t ipsec_inbound_accept_clear(mblk_t *, ipha_t *, ip6_t *);
extern int ipsec_conn_cache_policy(conn_t *, boolean_t);
extern void ipsec_cache_outbound_policy(const conn_t *, const in6_addr_t *,
const in6_addr_t *, in_port_t, ip_xmit_attr_t *);
extern boolean_t ipsec_outbound_policy_current(ip_xmit_attr_t *);
extern ipsec_action_t *ipsec_in_to_out_action(ip_recv_attr_t *);
extern void ipsec_latch_inbound(conn_t *connp, ip_recv_attr_t *ira);
extern void ipsec_policy_free(ipsec_policy_t *);
extern void ipsec_action_free(ipsec_action_t *);
extern void ipsec_polhead_free(ipsec_policy_head_t *, netstack_t *);
extern ipsec_policy_head_t *ipsec_polhead_split(ipsec_policy_head_t *,
netstack_t *);
extern ipsec_policy_head_t *ipsec_polhead_create(void);
extern ipsec_policy_head_t *ipsec_system_policy(netstack_t *);
extern ipsec_policy_head_t *ipsec_inactive_policy(netstack_t *);
extern void ipsec_swap_policy(ipsec_policy_head_t *, ipsec_policy_head_t *,
netstack_t *);
extern void ipsec_swap_global_policy(netstack_t *);
extern int ipsec_clone_system_policy(netstack_t *);
extern ipsec_policy_t *ipsec_policy_create(ipsec_selkey_t *,
const ipsec_act_t *, int, int, uint64_t *, netstack_t *);
extern boolean_t ipsec_policy_delete(ipsec_policy_head_t *,
ipsec_selkey_t *, int, netstack_t *);
extern int ipsec_policy_delete_index(ipsec_policy_head_t *, uint64_t,
netstack_t *);
extern boolean_t ipsec_polhead_insert(ipsec_policy_head_t *, ipsec_act_t *,
uint_t, int, int, netstack_t *);
extern void ipsec_polhead_flush(ipsec_policy_head_t *, netstack_t *);
extern int ipsec_copy_polhead(ipsec_policy_head_t *, ipsec_policy_head_t *,
netstack_t *);
extern void ipsec_actvec_from_req(const ipsec_req_t *, ipsec_act_t **, uint_t *,
netstack_t *);
extern void ipsec_actvec_free(ipsec_act_t *, uint_t);
extern int ipsec_req_from_head(ipsec_policy_head_t *, ipsec_req_t *, int);
extern mblk_t *ipsec_construct_inverse_acquire(sadb_msg_t *, sadb_ext_t **,
netstack_t *);
extern ipsec_policy_t *ipsec_find_policy(int, const conn_t *,
ipsec_selector_t *, netstack_t *);
extern ipsid_t *ipsid_lookup(int, char *, netstack_t *);
extern boolean_t ipsid_equal(ipsid_t *, ipsid_t *);
extern void ipsid_gc(netstack_t *);
extern void ipsec_latch_ids(ipsec_latch_t *, ipsid_t *, ipsid_t *);
extern void ipsec_config_flush(netstack_t *);
extern boolean_t ipsec_check_policy(ipsec_policy_head_t *, ipsec_policy_t *,
int);
extern void ipsec_enter_policy(ipsec_policy_head_t *, ipsec_policy_t *, int,
netstack_t *);
extern boolean_t ipsec_check_action(ipsec_act_t *, int *, netstack_t *);
extern void iplatch_free(ipsec_latch_t *);
extern ipsec_latch_t *iplatch_create(void);
extern int ipsec_set_req(cred_t *, conn_t *, ipsec_req_t *);
extern void ipsec_insert_always(avl_tree_t *tree, void *new_node);
extern int32_t ipsec_act_ovhd(const ipsec_act_t *act);
extern mblk_t *sadb_whack_label(mblk_t *, ipsa_t *, ip_xmit_attr_t *,
kstat_named_t *, ipdropper_t *);
extern mblk_t *sadb_whack_label_v4(mblk_t *, ipsa_t *, kstat_named_t *,
ipdropper_t *);
extern mblk_t *sadb_whack_label_v6(mblk_t *, ipsa_t *, kstat_named_t *,
ipdropper_t *);
extern boolean_t update_iv(uint8_t *, queue_t *, ipsa_t *, ipsecesp_stack_t *);
struct iptun_s;
extern mblk_t *ipsec_tun_inbound(ip_recv_attr_t *, mblk_t *, ipsec_tun_pol_t *,
ipha_t *, ip6_t *, ipha_t *, ip6_t *, int, netstack_t *);
extern mblk_t *ipsec_tun_outbound(mblk_t *, struct iptun_s *, ipha_t *,
ip6_t *, ipha_t *, ip6_t *, int, ip_xmit_attr_t *);
extern void itp_free(ipsec_tun_pol_t *, netstack_t *);
extern ipsec_tun_pol_t *create_tunnel_policy(char *, int *, uint64_t *,
netstack_t *);
extern ipsec_tun_pol_t *get_tunnel_policy(char *, netstack_t *);
extern void itp_unlink(ipsec_tun_pol_t *, netstack_t *);
extern void itp_walk(void (*)(ipsec_tun_pol_t *, void *, netstack_t *),
void *, netstack_t *);
extern ipsec_tun_pol_t *itp_get_byaddr(uint32_t *, uint32_t *, int,
ip_stack_t *);
extern void ipsecah_in_assocfailure(mblk_t *, char, ushort_t, char *,
uint32_t, void *, int, ip_recv_attr_t *ira);
extern void ipsecesp_in_assocfailure(mblk_t *, char, ushort_t, char *,
uint32_t, void *, int, ip_recv_attr_t *ira);
extern void ipsecesp_send_keepalive(ipsa_t *);
extern boolean_t ipsec_valid_key_size(uint16_t, ipsec_alginfo_t *);
#define IPSEC_PRIO_SOCKET 0x1000000
extern boolean_t ipsecesp_ddi_init(void);
extern boolean_t ipsecah_ddi_init(void);
extern boolean_t keysock_ddi_init(void);
extern boolean_t spdsock_ddi_init(void);
extern void ipsecesp_ddi_destroy(void);
extern void ipsecah_ddi_destroy(void);
extern void keysock_ddi_destroy(void);
extern void spdsock_ddi_destroy(void);
extern void ipsecah_fill_defs(struct sadb_x_ecomb *, netstack_t *);
extern void ipsecesp_fill_defs(struct sadb_x_ecomb *, netstack_t *);
extern void ipsecah_algs_changed(netstack_t *);
extern void ipsecesp_algs_changed(netstack_t *);
extern void ipsecesp_init_funcs(ipsa_t *);
extern void ipsecah_init_funcs(ipsa_t *);
extern mblk_t *ipsecah_icmp_error(mblk_t *, ip_recv_attr_t *);
extern mblk_t *ipsecesp_icmp_error(mblk_t *, ip_recv_attr_t *);
extern void spdsock_update_pending_algs(netstack_t *);
extern boolean_t ipsec_outbound_sa(mblk_t *, ip_xmit_attr_t *, uint_t);
extern mblk_t *ipsec_inbound_esp_sa(mblk_t *, ip_recv_attr_t *, esph_t **);
extern mblk_t *ipsec_inbound_ah_sa(mblk_t *, ip_recv_attr_t *, ah_t **);
extern ipsec_policy_t *ipsec_find_policy_head(ipsec_policy_t *,
ipsec_policy_head_t *, int, ipsec_selector_t *);
void ip_drop_init(ipsec_stack_t *);
void ip_drop_destroy(ipsec_stack_t *);
extern boolean_t ip_addr_match(uint8_t *, int, in6_addr_t *);
extern boolean_t ipsec_label_match(ts_label_t *, ts_label_t *);
typedef uint32_t ah_counter;
typedef uint32_t esp_counter;
#endif
#ifdef __cplusplus
}
#endif
#endif