17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5f4b3ec61Sdh155122 * Common Development and Distribution License (the "License"). 6f4b3ec61Sdh155122 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22bd670b35SErik Nordmark * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _INET_IPSECAH_H 277c478bd9Sstevel@tonic-gate #define _INET_IPSECAH_H 287c478bd9Sstevel@tonic-gate 29f4b3ec61Sdh155122 #include <inet/ip.h> 30f4b3ec61Sdh155122 #include <inet/ipdrop.h> 31f4b3ec61Sdh155122 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 36f4b3ec61Sdh155122 #include <sys/note.h> 37f4b3ec61Sdh155122 387c478bd9Sstevel@tonic-gate #ifdef _KERNEL 397c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 40f4b3ec61Sdh155122 typedef struct ipsecahparam_s { 417c478bd9Sstevel@tonic-gate uint_t ipsecah_param_min; 427c478bd9Sstevel@tonic-gate uint_t ipsecah_param_max; 437c478bd9Sstevel@tonic-gate uint_t ipsecah_param_value; 447c478bd9Sstevel@tonic-gate char *ipsecah_param_name; 457c478bd9Sstevel@tonic-gate } ipsecahparam_t; 467c478bd9Sstevel@tonic-gate 47f4b3ec61Sdh155122 /* 48f4b3ec61Sdh155122 * Stats. This may eventually become a full-blown SNMP MIB once that spec 49f4b3ec61Sdh155122 * stabilizes. 50f4b3ec61Sdh155122 */ 51f4b3ec61Sdh155122 typedef struct ah_kstats_s 52f4b3ec61Sdh155122 { 53f4b3ec61Sdh155122 kstat_named_t ah_stat_num_aalgs; 54f4b3ec61Sdh155122 kstat_named_t ah_stat_good_auth; 55f4b3ec61Sdh155122 kstat_named_t ah_stat_bad_auth; 56f4b3ec61Sdh155122 kstat_named_t ah_stat_replay_failures; 57f4b3ec61Sdh155122 kstat_named_t ah_stat_replay_early_failures; 58f4b3ec61Sdh155122 kstat_named_t ah_stat_keysock_in; 59f4b3ec61Sdh155122 kstat_named_t ah_stat_out_requests; 60f4b3ec61Sdh155122 kstat_named_t ah_stat_acquire_requests; 61f4b3ec61Sdh155122 kstat_named_t ah_stat_bytes_expired; 62f4b3ec61Sdh155122 kstat_named_t ah_stat_out_discards; 63f4b3ec61Sdh155122 kstat_named_t ah_stat_crypto_sync; 64f4b3ec61Sdh155122 kstat_named_t ah_stat_crypto_async; 65f4b3ec61Sdh155122 kstat_named_t ah_stat_crypto_failures; 66f4b3ec61Sdh155122 } ah_kstats_t; 67f4b3ec61Sdh155122 68f4b3ec61Sdh155122 /* 69f4b3ec61Sdh155122 * ahstack->ah_kstats is equal to ahstack->ah_ksp->ks_data if 70f4b3ec61Sdh155122 * kstat_create_netstack for ahstack->ah_ksp succeeds, but when it 71f4b3ec61Sdh155122 * fails, it will be NULL. Note this is done for all stack instances, 72f4b3ec61Sdh155122 * so it *could* fail. hence a non-NULL checking is done for 73f4b3ec61Sdh155122 * AH_BUMP_STAT and AH_DEBUMP_STAT 74f4b3ec61Sdh155122 */ 75f4b3ec61Sdh155122 #define AH_BUMP_STAT(ahstack, x) \ 76f4b3ec61Sdh155122 do { \ 77f4b3ec61Sdh155122 if (ahstack->ah_kstats != NULL) \ 78f4b3ec61Sdh155122 (ahstack->ah_kstats->ah_stat_ ## x).value.ui64++; \ 79f4b3ec61Sdh155122 _NOTE(CONSTCOND) \ 80f4b3ec61Sdh155122 } while (0) 81f4b3ec61Sdh155122 #define AH_DEBUMP_STAT(ahstack, x) \ 82f4b3ec61Sdh155122 do { \ 83f4b3ec61Sdh155122 if (ahstack->ah_kstats != NULL) \ 84f4b3ec61Sdh155122 (ahstack->ah_kstats->ah_stat_ ## x).value.ui64--; \ 85f4b3ec61Sdh155122 _NOTE(CONSTCOND) \ 86f4b3ec61Sdh155122 } while (0) 87f4b3ec61Sdh155122 88f4b3ec61Sdh155122 /* 89f4b3ec61Sdh155122 * IPSECAH stack instances 90f4b3ec61Sdh155122 */ 91f4b3ec61Sdh155122 struct ipsecah_stack { 92f4b3ec61Sdh155122 netstack_t *ipsecah_netstack; /* Common netstack */ 93f4b3ec61Sdh155122 94f4b3ec61Sdh155122 caddr_t ipsecah_g_nd; 95f4b3ec61Sdh155122 ipsecahparam_t *ipsecah_params; 96f4b3ec61Sdh155122 kmutex_t ipsecah_param_lock; /* Protects params */ 97f4b3ec61Sdh155122 98f4b3ec61Sdh155122 sadbp_t ah_sadb; 99f4b3ec61Sdh155122 100f4b3ec61Sdh155122 /* Packet dropper for AH drops. */ 101f4b3ec61Sdh155122 ipdropper_t ah_dropper; 102f4b3ec61Sdh155122 103f4b3ec61Sdh155122 kstat_t *ah_ksp; 104f4b3ec61Sdh155122 ah_kstats_t *ah_kstats; 105f4b3ec61Sdh155122 106f4b3ec61Sdh155122 /* 107f4b3ec61Sdh155122 * Keysock instance of AH. There can be only one per stack instance. 108*75d94465SJosef 'Jeff' Sipek * Use atomic_cas_ptr() on this because I don't set it until 109*75d94465SJosef 'Jeff' Sipek * KEYSOCK_HELLO comes down. 110f4b3ec61Sdh155122 * Paired up with the ah_pfkey_q is the ah_event, which will age SAs. 111f4b3ec61Sdh155122 */ 112f4b3ec61Sdh155122 queue_t *ah_pfkey_q; 113f4b3ec61Sdh155122 timeout_id_t ah_event; 114f4b3ec61Sdh155122 }; 115f4b3ec61Sdh155122 typedef struct ipsecah_stack ipsecah_stack_t; 116f4b3ec61Sdh155122 1177c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * For now, only provide "aligned" version of header. 1217c478bd9Sstevel@tonic-gate * If aligned version is needed, we'll go with the naming conventions then. 1227c478bd9Sstevel@tonic-gate */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate typedef struct ah { 1257c478bd9Sstevel@tonic-gate uint8_t ah_nexthdr; 1267c478bd9Sstevel@tonic-gate uint8_t ah_length; 1277c478bd9Sstevel@tonic-gate uint16_t ah_reserved; 1287c478bd9Sstevel@tonic-gate uint32_t ah_spi; 1297c478bd9Sstevel@tonic-gate uint32_t ah_replay; 1307c478bd9Sstevel@tonic-gate } ah_t; 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #define AH_BASELEN 12 1337c478bd9Sstevel@tonic-gate #define AH_TOTAL_LEN(ah) (((ah)->ah_length << 2) + AH_BASELEN - \ 1347c478bd9Sstevel@tonic-gate sizeof ((ah)->ah_replay)) 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* "Old" AH, without replay. For 1827-29 compatibility. */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate typedef struct ahold { 1397c478bd9Sstevel@tonic-gate uint8_t ah_nexthdr; 1407c478bd9Sstevel@tonic-gate uint8_t ah_length; 1417c478bd9Sstevel@tonic-gate uint16_t ah_reserved; 1427c478bd9Sstevel@tonic-gate uint32_t ah_spi; 1437c478bd9Sstevel@tonic-gate } ahold_t; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #define AHOLD_BASELEN 8 1467c478bd9Sstevel@tonic-gate #define AHOLD_TOTAL_LEN(ah) (((ah)->ah_length << 2) + AH_BASELEN) 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate #endif 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #endif /* _INET_IPSECAH_H */ 153