1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _NET_PFPOLICY_H 28*0Sstevel@tonic-gate #define _NET_PFPOLICY_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Definitions and structures for PF_POLICY version 1. 34*0Sstevel@tonic-gate * 35*0Sstevel@tonic-gate * This local protocol provides an interface allowing utilities to 36*0Sstevel@tonic-gate * manage a system's IPsec System Policy Database; see RFC2401 for a 37*0Sstevel@tonic-gate * conceptual overview of the SPD. 38*0Sstevel@tonic-gate * The basic encoding is modelled on PF_KEY version 2; see pfkeyv2.h 39*0Sstevel@tonic-gate * and RFC2367 for more information. 40*0Sstevel@tonic-gate */ 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #ifdef __cplusplus 43*0Sstevel@tonic-gate extern "C" { 44*0Sstevel@tonic-gate #endif 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate #define PF_POLICY_V1 1 47*0Sstevel@tonic-gate #define PF_POLICY_REVISION 200304L 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate /* 50*0Sstevel@tonic-gate * Base PF_POLICY message header. Each request/response starts with 51*0Sstevel@tonic-gate * one of these, followed by some number of extensions. Each 52*0Sstevel@tonic-gate * extension type appears at most once in a message. spd_msg_len 53*0Sstevel@tonic-gate * contains the total length of the message including header. 54*0Sstevel@tonic-gate */ 55*0Sstevel@tonic-gate typedef struct spd_msg 56*0Sstevel@tonic-gate { 57*0Sstevel@tonic-gate uint8_t spd_msg_version; /* PF_POLICY_V1 */ 58*0Sstevel@tonic-gate uint8_t spd_msg_type; /* ADD, DELETE, QUERY, ... */ 59*0Sstevel@tonic-gate uint8_t spd_msg_errno; /* Unix errno space; mbz on request */ 60*0Sstevel@tonic-gate uint8_t spd_msg_spdid; /* which policy db instance */ 61*0Sstevel@tonic-gate uint16_t spd_msg_len; /* in 64-bit words */ 62*0Sstevel@tonic-gate uint16_t spd_msg_diagnostic; /* additional error reason */ 63*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 64*0Sstevel@tonic-gate union { 65*0Sstevel@tonic-gate struct { 66*0Sstevel@tonic-gate uint32_t spd_msg_useq; /* set by sender */ 67*0Sstevel@tonic-gate uint32_t spd_msg_upid; /* set by sender */ 68*0Sstevel@tonic-gate } spd_msg_actual; 69*0Sstevel@tonic-gate uint64_t spd_msg_alignment; 70*0Sstevel@tonic-gate } spd_msg_u; 71*0Sstevel@tonic-gate #define spd_msg_seq spd_msg_u.spd_msg_actual.spd_msg_useq 72*0Sstevel@tonic-gate #define spd_msg_pid spd_msg_u.spd_msg_actual.spd_msg_upid 73*0Sstevel@tonic-gate } spd_msg_t; 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* 76*0Sstevel@tonic-gate * Command numbers, found in spd_msg_type. 77*0Sstevel@tonic-gate */ 78*0Sstevel@tonic-gate #define SPD_RESERVED 0 79*0Sstevel@tonic-gate #define SPD_MIN 1 80*0Sstevel@tonic-gate #define SPD_FLUSH 1 81*0Sstevel@tonic-gate #define SPD_ADDRULE 2 82*0Sstevel@tonic-gate #define SPD_DELETERULE 3 83*0Sstevel@tonic-gate #define SPD_FLIP 4 84*0Sstevel@tonic-gate #define SPD_LOOKUP 5 85*0Sstevel@tonic-gate #define SPD_DUMP 6 86*0Sstevel@tonic-gate #define SPD_CLONE 7 87*0Sstevel@tonic-gate #define SPD_ALGLIST 8 88*0Sstevel@tonic-gate #define SPD_DUMPALGS 9 89*0Sstevel@tonic-gate #define SPD_UPDATEALGS 10 90*0Sstevel@tonic-gate #define SPD_MAX 10 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* 93*0Sstevel@tonic-gate * Well-known policy db instances, found in spd_msg_spdid 94*0Sstevel@tonic-gate */ 95*0Sstevel@tonic-gate #define SPD_ACTIVE 0 /* The currently active instance */ 96*0Sstevel@tonic-gate #define SPD_STANDBY 1 /* "on deck" standby SPD */ 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* 99*0Sstevel@tonic-gate * The spd_msg_t is followed by extensions, which start with the 100*0Sstevel@tonic-gate * following header; each extension structure includes the length and 101*0Sstevel@tonic-gate * type fields internally as an overlay to simplify parsing and 102*0Sstevel@tonic-gate * construction. 103*0Sstevel@tonic-gate */ 104*0Sstevel@tonic-gate typedef struct spd_ext 105*0Sstevel@tonic-gate { 106*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 107*0Sstevel@tonic-gate union { 108*0Sstevel@tonic-gate struct { 109*0Sstevel@tonic-gate uint16_t spd_ext_ulen; /* in 64-bit words */ 110*0Sstevel@tonic-gate uint16_t spd_ext_utype; /* 0 is reserved */ 111*0Sstevel@tonic-gate } spd_ext_actual; 112*0Sstevel@tonic-gate uint64_t spd_ext_alignment; 113*0Sstevel@tonic-gate } spd_ext_u; 114*0Sstevel@tonic-gate #define spd_ext_len spd_ext_u.spd_ext_actual.spd_ext_ulen 115*0Sstevel@tonic-gate #define spd_ext_type spd_ext_u.spd_ext_actual.spd_ext_utype 116*0Sstevel@tonic-gate } spd_ext_t; 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * Extension numbers, found in spd_ext_type. 120*0Sstevel@tonic-gate */ 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate #define SPD_EXT_LCLPORT 1 123*0Sstevel@tonic-gate #define SPD_EXT_REMPORT 2 124*0Sstevel@tonic-gate #define SPD_EXT_PROTO 3 125*0Sstevel@tonic-gate #define SPD_EXT_LCLADDR 4 126*0Sstevel@tonic-gate #define SPD_EXT_REMADDR 5 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate #define SPD_EXT_ACTION 6 129*0Sstevel@tonic-gate #define SPD_EXT_RULE 7 130*0Sstevel@tonic-gate #define SPD_EXT_RULESET 8 131*0Sstevel@tonic-gate #define SPD_EXT_ICMP_TYPECODE 9 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate #define SPD_EXT_MAX 9 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate /* 136*0Sstevel@tonic-gate * base policy rule (attributes which every rule has) 137*0Sstevel@tonic-gate * 138*0Sstevel@tonic-gate * spd_rule_index MBZ on a SPD_ADD, and is assigned by the kernel. 139*0Sstevel@tonic-gate * subsequent deletes can operate either by specifying selectors or by 140*0Sstevel@tonic-gate * specifying a non-zero rule index. 141*0Sstevel@tonic-gate */ 142*0Sstevel@tonic-gate struct spd_rule 143*0Sstevel@tonic-gate { 144*0Sstevel@tonic-gate uint16_t spd_rule_len; 145*0Sstevel@tonic-gate uint16_t spd_rule_type; /* SPD_EXT_RULE */ 146*0Sstevel@tonic-gate uint32_t spd_rule_priority; 147*0Sstevel@tonic-gate uint32_t spd_rule_flags; /* INBOUND, OUTBOUND, ... */ 148*0Sstevel@tonic-gate uint32_t spd_rule_unused; 149*0Sstevel@tonic-gate uint64_t spd_rule_index; /* unique rule identifier. */ 150*0Sstevel@tonic-gate }; 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate /* 153*0Sstevel@tonic-gate * Flags for spd_rule.spd_rule_flags 154*0Sstevel@tonic-gate */ 155*0Sstevel@tonic-gate #define SPD_RULE_FLAG_INBOUND 0x0001 156*0Sstevel@tonic-gate #define SPD_RULE_FLAG_OUTBOUND 0x0002 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate /* 159*0Sstevel@tonic-gate * Address selectors. Different from PF_KEY because we want a 160*0Sstevel@tonic-gate * more precise format for wildcards on ports/protocol. 161*0Sstevel@tonic-gate */ 162*0Sstevel@tonic-gate typedef struct spd_address { 163*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 164*0Sstevel@tonic-gate union { 165*0Sstevel@tonic-gate struct { 166*0Sstevel@tonic-gate uint16_t spd_address_ulen; 167*0Sstevel@tonic-gate uint16_t spd_address_uexttype; /* SRC, DST */ 168*0Sstevel@tonic-gate uint8_t spd_address_uaf; /* address family. */ 169*0Sstevel@tonic-gate uint8_t spd_address_uprefixlen; /* Prefix len (bits). */ 170*0Sstevel@tonic-gate uint16_t spd_address_ureserved2; /* Padding */ 171*0Sstevel@tonic-gate } spd_address_actual; 172*0Sstevel@tonic-gate uint64_t spd_address_alignment; 173*0Sstevel@tonic-gate } spd_address_u; 174*0Sstevel@tonic-gate /* 175*0Sstevel@tonic-gate * .. followed by 4 bytes of IPv4 or 16 bytes of IPv6 address, 176*0Sstevel@tonic-gate * padded up to next uint64_t 177*0Sstevel@tonic-gate */ 178*0Sstevel@tonic-gate #define spd_address_len \ 179*0Sstevel@tonic-gate spd_address_u.spd_address_actual.spd_address_ulen 180*0Sstevel@tonic-gate #define spd_address_exttype \ 181*0Sstevel@tonic-gate spd_address_u.spd_address_actual.spd_address_uexttype 182*0Sstevel@tonic-gate #define spd_address_af \ 183*0Sstevel@tonic-gate spd_address_u.spd_address_actual.spd_address_uaf 184*0Sstevel@tonic-gate #define spd_address_prefixlen \ 185*0Sstevel@tonic-gate spd_address_u.spd_address_actual.spd_address_uprefixlen 186*0Sstevel@tonic-gate #define spd_address_reserved2 \ 187*0Sstevel@tonic-gate spd_address_u.spd_address_actual.spd_address_ureserved2 188*0Sstevel@tonic-gate } spd_address_t; 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate /* 191*0Sstevel@tonic-gate * Protocol selector 192*0Sstevel@tonic-gate */ 193*0Sstevel@tonic-gate struct spd_proto 194*0Sstevel@tonic-gate { 195*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 196*0Sstevel@tonic-gate union { 197*0Sstevel@tonic-gate struct { 198*0Sstevel@tonic-gate uint16_t spd_proto_ulen; 199*0Sstevel@tonic-gate uint16_t spd_proto_uexttype; /* PROTO */ 200*0Sstevel@tonic-gate uint8_t spd_proto_unumber; /* IPPROTO_* */ 201*0Sstevel@tonic-gate uint8_t spd_proto_ureserved1; /* pad */ 202*0Sstevel@tonic-gate uint16_t spd_proto_ureserved2; /* pad */ 203*0Sstevel@tonic-gate } spd_proto_actual; 204*0Sstevel@tonic-gate uint64_t spd_proto_alignment; 205*0Sstevel@tonic-gate } spd_proto_u; 206*0Sstevel@tonic-gate #define spd_proto_len spd_proto_u.spd_proto_actual.spd_proto_ulen 207*0Sstevel@tonic-gate #define spd_proto_exttype spd_proto_u.spd_proto_actual.spd_proto_uexttype 208*0Sstevel@tonic-gate #define spd_proto_number spd_proto_u.spd_proto_actual.spd_proto_unumber 209*0Sstevel@tonic-gate #define spd_proto_reserved1 spd_proto_u.spd_proto_actual.spd_proto_ureserved1 210*0Sstevel@tonic-gate #define spd_proto_reserved2 spd_proto_u.spd_proto_actual.spd_proto_ureserved2 211*0Sstevel@tonic-gate }; 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate /* 214*0Sstevel@tonic-gate * Port selector. We only support minport==maxport at present. 215*0Sstevel@tonic-gate */ 216*0Sstevel@tonic-gate struct spd_portrange 217*0Sstevel@tonic-gate { 218*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 219*0Sstevel@tonic-gate union { 220*0Sstevel@tonic-gate struct { 221*0Sstevel@tonic-gate uint16_t spd_ports_ulen; 222*0Sstevel@tonic-gate uint16_t spd_ports_uexttype; /* LCLPORT, REMPORT */ 223*0Sstevel@tonic-gate uint16_t spd_ports_uminport; /* min port */ 224*0Sstevel@tonic-gate uint16_t spd_ports_umaxport; /* max port */ 225*0Sstevel@tonic-gate } spd_ports_actual; 226*0Sstevel@tonic-gate uint64_t spd_ports_alignment; 227*0Sstevel@tonic-gate } spd_ports_u; 228*0Sstevel@tonic-gate #define spd_ports_len spd_ports_u.spd_ports_actual.spd_ports_ulen 229*0Sstevel@tonic-gate #define spd_ports_exttype spd_ports_u.spd_ports_actual.spd_ports_uexttype 230*0Sstevel@tonic-gate #define spd_ports_minport spd_ports_u.spd_ports_actual.spd_ports_uminport 231*0Sstevel@tonic-gate #define spd_ports_maxport spd_ports_u.spd_ports_actual.spd_ports_umaxport 232*0Sstevel@tonic-gate }; 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate /* 235*0Sstevel@tonic-gate * ICMP type selector. 236*0Sstevel@tonic-gate */ 237*0Sstevel@tonic-gate struct spd_typecode 238*0Sstevel@tonic-gate { 239*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 240*0Sstevel@tonic-gate union { 241*0Sstevel@tonic-gate struct { 242*0Sstevel@tonic-gate uint16_t spd_typecode_ulen; 243*0Sstevel@tonic-gate uint16_t spd_typecode_uexttype; /* ICMP_TYPECODE */ 244*0Sstevel@tonic-gate uint8_t spd_typecode_utype; 245*0Sstevel@tonic-gate uint8_t spd_typecode_utype_end; 246*0Sstevel@tonic-gate uint8_t spd_typecode_ucode; 247*0Sstevel@tonic-gate uint8_t spd_typecode_ucode_end; 248*0Sstevel@tonic-gate } spd_typecode_actual; 249*0Sstevel@tonic-gate uint64_t spd_typecode_alignment; 250*0Sstevel@tonic-gate } spd_typecode_u; 251*0Sstevel@tonic-gate #define spd_typecode_len \ 252*0Sstevel@tonic-gate spd_typecode_u.spd_typecode_actual.spd_typecode_ulen 253*0Sstevel@tonic-gate #define spd_typecode_exttype \ 254*0Sstevel@tonic-gate spd_typecode_u.spd_typecode_actual.spd_typecode_uexttype 255*0Sstevel@tonic-gate #define spd_typecode_type \ 256*0Sstevel@tonic-gate spd_typecode_u.spd_typecode_actual.spd_typecode_utype 257*0Sstevel@tonic-gate #define spd_typecode_type_end \ 258*0Sstevel@tonic-gate spd_typecode_u.spd_typecode_actual.spd_typecode_utype_end 259*0Sstevel@tonic-gate #define spd_typecode_code \ 260*0Sstevel@tonic-gate spd_typecode_u.spd_typecode_actual.spd_typecode_ucode 261*0Sstevel@tonic-gate #define spd_typecode_code_end \ 262*0Sstevel@tonic-gate spd_typecode_u.spd_typecode_actual.spd_typecode_ucode_end 263*0Sstevel@tonic-gate }; 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate /* 267*0Sstevel@tonic-gate * Actions, specifying what happens to packets which match selectors. 268*0Sstevel@tonic-gate * This extension is followed by some number of spd_attribute tag-value pairs 269*0Sstevel@tonic-gate * which encode one or more alternative policies; see below for 270*0Sstevel@tonic-gate * the encoding used. 271*0Sstevel@tonic-gate */ 272*0Sstevel@tonic-gate struct spd_ext_actions 273*0Sstevel@tonic-gate { 274*0Sstevel@tonic-gate /* Union is for guaranteeing 64-bit alignment. */ 275*0Sstevel@tonic-gate union { 276*0Sstevel@tonic-gate struct { 277*0Sstevel@tonic-gate uint16_t spd_actions_ulen; 278*0Sstevel@tonic-gate uint16_t spd_actions_uexttype; /* ACTION */ 279*0Sstevel@tonic-gate uint16_t spd_actions_ucount; /* # of alternatives */ 280*0Sstevel@tonic-gate uint16_t spd_actions_ureserved; 281*0Sstevel@tonic-gate } spd_actions_actual; 282*0Sstevel@tonic-gate uint64_t spd_actions_alignment; 283*0Sstevel@tonic-gate } spd_actions_u; 284*0Sstevel@tonic-gate #define spd_actions_len \ 285*0Sstevel@tonic-gate spd_actions_u.spd_actions_actual.spd_actions_ulen 286*0Sstevel@tonic-gate #define spd_actions_exttype \ 287*0Sstevel@tonic-gate spd_actions_u.spd_actions_actual.spd_actions_uexttype 288*0Sstevel@tonic-gate #define spd_actions_count \ 289*0Sstevel@tonic-gate spd_actions_u.spd_actions_actual.spd_actions_ucount 290*0Sstevel@tonic-gate #define spd_actions_reserved \ 291*0Sstevel@tonic-gate spd_actions_u.spd_actions_actual.spd_actions_ureserved 292*0Sstevel@tonic-gate }; 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate /* 295*0Sstevel@tonic-gate * Extensible encoding for requested SA attributes. 296*0Sstevel@tonic-gate * To allow additional attributes to be added, we use a simple-to-interpret 297*0Sstevel@tonic-gate * (tag, value) encoding to fill in attributes in a list of alternatives. 298*0Sstevel@tonic-gate * 299*0Sstevel@tonic-gate * We fill in alternatives one at a time, starting with most-preferred, 300*0Sstevel@tonic-gate * proceeding to least-preferred. 301*0Sstevel@tonic-gate * 302*0Sstevel@tonic-gate * Conceptually, we are filling in attributes of a "template", and 303*0Sstevel@tonic-gate * then copying that template value into the list of alternatives when 304*0Sstevel@tonic-gate * we see a SPD_ATTR_END or SPD_ATTR_NEXT. 305*0Sstevel@tonic-gate * 306*0Sstevel@tonic-gate * The template is not changed by SPD_ATTR_NEXT, so that attributes common to 307*0Sstevel@tonic-gate * all alternatives need only be mentioned once. 308*0Sstevel@tonic-gate * 309*0Sstevel@tonic-gate * spd_actions_count is the maximum number of alternatives present; it 310*0Sstevel@tonic-gate * should be one greater than the number of SPD_ATTR_NEXT opcodes 311*0Sstevel@tonic-gate * present in the sequence. 312*0Sstevel@tonic-gate */ 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate struct spd_attribute 315*0Sstevel@tonic-gate { 316*0Sstevel@tonic-gate union { 317*0Sstevel@tonic-gate struct { 318*0Sstevel@tonic-gate uint32_t spd_attr_utag; 319*0Sstevel@tonic-gate uint32_t spd_attr_uvalue; 320*0Sstevel@tonic-gate } spd_attribute_actual; 321*0Sstevel@tonic-gate uint64_t spd_attribute_alignment; 322*0Sstevel@tonic-gate } spd_attribute_u; 323*0Sstevel@tonic-gate #define spd_attr_tag spd_attribute_u.spd_attribute_actual.spd_attr_utag 324*0Sstevel@tonic-gate #define spd_attr_value spd_attribute_u.spd_attribute_actual.spd_attr_uvalue 325*0Sstevel@tonic-gate }; 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate #define SPD_ATTR_NOP 0x00000000 /* space filler */ 328*0Sstevel@tonic-gate #define SPD_ATTR_END 0x00000001 /* end of description */ 329*0Sstevel@tonic-gate #define SPD_ATTR_EMPTY 0x00000002 /* reset template to default */ 330*0Sstevel@tonic-gate #define SPD_ATTR_NEXT 0x00000003 /* start filling next alternative */ 331*0Sstevel@tonic-gate 332*0Sstevel@tonic-gate #define SPD_ATTR_TYPE 0x00000100 333*0Sstevel@tonic-gate #define SPD_ATTR_FLAGS 0x00000101 334*0Sstevel@tonic-gate #define SPD_ATTR_AH_AUTH 0x00000102 335*0Sstevel@tonic-gate #define SPD_ATTR_ESP_ENCR 0x00000103 336*0Sstevel@tonic-gate #define SPD_ATTR_ESP_AUTH 0x00000104 337*0Sstevel@tonic-gate #define SPD_ATTR_ENCR_MINBITS 0x00000105 338*0Sstevel@tonic-gate #define SPD_ATTR_ENCR_MAXBITS 0x00000106 339*0Sstevel@tonic-gate #define SPD_ATTR_AH_MINBITS 0x00000107 340*0Sstevel@tonic-gate #define SPD_ATTR_AH_MAXBITS 0x00000108 341*0Sstevel@tonic-gate #define SPD_ATTR_LIFE_SOFT_TIME 0x00000109 342*0Sstevel@tonic-gate #define SPD_ATTR_LIFE_HARD_TIME 0x0000010a 343*0Sstevel@tonic-gate #define SPD_ATTR_LIFE_SOFT_BYTES 0x0000010b 344*0Sstevel@tonic-gate #define SPD_ATTR_LIFE_HARD_BYTES 0x0000010c 345*0Sstevel@tonic-gate #define SPD_ATTR_KM_PROTO 0x0000010d 346*0Sstevel@tonic-gate #define SPD_ATTR_KM_COOKIE 0x0000010e 347*0Sstevel@tonic-gate #define SPD_ATTR_REPLAY_DEPTH 0x0000010f 348*0Sstevel@tonic-gate #define SPD_ATTR_ESPA_MINBITS 0x00000110 349*0Sstevel@tonic-gate #define SPD_ATTR_ESPA_MAXBITS 0x00000111 350*0Sstevel@tonic-gate #define SPD_ATTR_ENCR_DEFBITS 0x00000112 351*0Sstevel@tonic-gate #define SPD_ATTR_ENCR_INCRBITS 0x00000113 352*0Sstevel@tonic-gate #define SPD_ATTR_AH_DEFBITS 0x00000114 353*0Sstevel@tonic-gate #define SPD_ATTR_AH_INCRBITS 0x00000115 354*0Sstevel@tonic-gate #define SPD_ATTR_ESPA_DEFBITS 0x00000116 355*0Sstevel@tonic-gate #define SPD_ATTR_ESPA_INCRBITS 0x00000117 356*0Sstevel@tonic-gate #define SPD_ATTR_ALG_ID 0x00000118 357*0Sstevel@tonic-gate #define SPD_ATTR_ALG_PROTO 0x00000119 358*0Sstevel@tonic-gate #define SPD_ATTR_ALG_INCRBITS 0x0000011a 359*0Sstevel@tonic-gate #define SPD_ATTR_ALG_NKEYSIZES 0x0000011b 360*0Sstevel@tonic-gate #define SPD_ATTR_ALG_KEYSIZE 0x0000011c 361*0Sstevel@tonic-gate #define SPD_ATTR_ALG_NBLOCKSIZES 0x0000011d 362*0Sstevel@tonic-gate #define SPD_ATTR_ALG_BLOCKSIZE 0x0000011e 363*0Sstevel@tonic-gate #define SPD_ATTR_ALG_MECHNAME 0x0000011f 364*0Sstevel@tonic-gate #define SPD_ATTR_PROTO_ID 0x00000120 365*0Sstevel@tonic-gate #define SPD_ATTR_PROTO_EXEC_MODE 0x00000121 366*0Sstevel@tonic-gate 367*0Sstevel@tonic-gate /* 368*0Sstevel@tonic-gate * Minimum, maximum key lengths in bits. 369*0Sstevel@tonic-gate */ 370*0Sstevel@tonic-gate #define SPD_MIN_MINBITS 0x0000 371*0Sstevel@tonic-gate #define SPD_MAX_MAXBITS 0xffff 372*0Sstevel@tonic-gate 373*0Sstevel@tonic-gate /* 374*0Sstevel@tonic-gate * IPsec action types (in SPD_ATTR_TYPE attribute) 375*0Sstevel@tonic-gate */ 376*0Sstevel@tonic-gate #define SPD_ACTTYPE_DROP 0x0001 377*0Sstevel@tonic-gate #define SPD_ACTTYPE_PASS 0x0002 378*0Sstevel@tonic-gate #define SPD_ACTTYPE_IPSEC 0x0003 379*0Sstevel@tonic-gate 380*0Sstevel@tonic-gate /* 381*0Sstevel@tonic-gate * Action flags (in SPD_ATTR_FLAGS attribute) 382*0Sstevel@tonic-gate */ 383*0Sstevel@tonic-gate #define SPD_APPLY_AH 0x0001 384*0Sstevel@tonic-gate #define SPD_APPLY_ESP 0x0002 385*0Sstevel@tonic-gate #define SPD_APPLY_SE 0x0004 /* self-encapsulation */ 386*0Sstevel@tonic-gate #define SPD_APPLY_COMP 0x0008 /* compression; NYI */ 387*0Sstevel@tonic-gate #define SPD_APPLY_UNIQUE 0x0010 /* unique per-flow SA */ 388*0Sstevel@tonic-gate #define SPD_APPLY_BYPASS 0x0020 /* bypass policy */ 389*0Sstevel@tonic-gate #define SPD_APPLY_ESPA 0x0040 /* ESP authentication */ 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gate /* 392*0Sstevel@tonic-gate * SW crypto execution modes. 393*0Sstevel@tonic-gate */ 394*0Sstevel@tonic-gate #define SPD_ALG_EXEC_MODE_SYNC 1 /* synchronous */ 395*0Sstevel@tonic-gate #define SPD_ALG_EXEC_MODE_ASYNC 2 /* asynchronous */ 396*0Sstevel@tonic-gate 397*0Sstevel@tonic-gate /* 398*0Sstevel@tonic-gate * SPD_DUMP protocol: 399*0Sstevel@tonic-gate * 400*0Sstevel@tonic-gate * We do not want to force an stack to have to read-lock the entire 401*0Sstevel@tonic-gate * SPD for the duration of the dump, but we want management apps to be 402*0Sstevel@tonic-gate * able to get a consistent snapshot of the SPD. 403*0Sstevel@tonic-gate * 404*0Sstevel@tonic-gate * Therefore, we make optimistic locking assumptions. 405*0Sstevel@tonic-gate * 406*0Sstevel@tonic-gate * The response to a SPD_DUMP request consists of multiple spd_msg 407*0Sstevel@tonic-gate * records, all with spd_msg_type == SPD_DUMP and spd_msg_{seq,pid} 408*0Sstevel@tonic-gate * matching the request. 409*0Sstevel@tonic-gate * 410*0Sstevel@tonic-gate * There is one header, then a sequence of policy rule records (one 411*0Sstevel@tonic-gate * rule per record), then a trailer. 412*0Sstevel@tonic-gate * 413*0Sstevel@tonic-gate * The header and trailer both contain a single SPD_EXT_RULESET 414*0Sstevel@tonic-gate * containing a version number and rule count. The dump was "good" if 415*0Sstevel@tonic-gate * header version == trailer version, and the number of rules read by 416*0Sstevel@tonic-gate * the application matches the rule count in the trailer. The rule 417*0Sstevel@tonic-gate * count in the header is unused and should be set to zero. 418*0Sstevel@tonic-gate * 419*0Sstevel@tonic-gate * In between, each rule record contains a set of extensions which, if 420*0Sstevel@tonic-gate * used in an SPD_ADD request, would recreate an equivalent rule. 421*0Sstevel@tonic-gate * 422*0Sstevel@tonic-gate * If rules were added to the SPD during the dump, the dump may be 423*0Sstevel@tonic-gate * truncated or otherwise incomplete; the management application 424*0Sstevel@tonic-gate * should re-try the dump in this case. 425*0Sstevel@tonic-gate */ 426*0Sstevel@tonic-gate 427*0Sstevel@tonic-gate /* 428*0Sstevel@tonic-gate * Ruleset extension, used at the start and end of a SPD_DUMP. 429*0Sstevel@tonic-gate */ 430*0Sstevel@tonic-gate typedef struct spd_ruleset_ext 431*0Sstevel@tonic-gate { 432*0Sstevel@tonic-gate uint16_t spd_ruleset_len; /* 2 x 64 bits */ 433*0Sstevel@tonic-gate uint16_t spd_ruleset_type; /* SPD_EXT_RULESET */ 434*0Sstevel@tonic-gate uint32_t spd_ruleset_count; /* only valid in trailer */ 435*0Sstevel@tonic-gate uint64_t spd_ruleset_version; /* version number */ 436*0Sstevel@tonic-gate } spd_ruleset_ext_t; 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gate /* 439*0Sstevel@tonic-gate * Diagnostic codes. These supplement error messages. Be sure to 440*0Sstevel@tonic-gate * update libipsecutil's spdsock_diag() if you change any of these. 441*0Sstevel@tonic-gate */ 442*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_NONE 0 443*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNKNOWN_EXT 1 444*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_BAD_EXTLEN 2 445*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_NO_RULE_EXT 3 446*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_BAD_ADDR_LEN 4 447*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MIXED_AF 5 448*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ADD_NO_MEM 6 449*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ADD_WRONG_ACT_COUNT 7 450*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ADD_BAD_TYPE 8 451*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ADD_BAD_FLAGS 9 452*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ADD_INCON_FLAGS 10 453*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_LCLPORT 11 454*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_LCLPORT 12 455*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_REMPORT 13 456*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_REMPORT 14 457*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_PROTO 15 458*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_PROTO 16 459*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_LCLADDR 17 460*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_LCLADDR 18 461*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_REMADDR 19 462*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_REMADDR 20 463*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_ACTION 21 464*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_ACTION 22 465*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_RULE 23 466*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_RULE 24 467*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_RULESET 25 468*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_RULESET 26 469*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_INVALID_RULE_INDEX 27 470*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_BAD_SPDID 28 471*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_BAD_MSG_TYPE 29 472*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNSUPP_AH_ALG 30 473*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNSUPP_ESP_ENCR_ALG 31 474*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNSUPP_ESP_AUTH_ALG 32 475*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNSUPP_AH_KEYSIZE 33 476*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNSUPP_ESP_ENCR_KEYSIZE 34 477*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_UNSUPP_ESP_AUTH_KEYSIZE 35 478*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_NO_ACTION_EXT 36 479*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ALG_ID_RANGE 37 480*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ALG_NUM_KEY_SIZES 38 481*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ALG_NUM_BLOCK_SIZES 39 482*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ALG_MECH_NAME_LEN 40 483*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_ALG_IPSEC_NOT_LOADED 41 484*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_MALFORMED_ICMP_TYPECODE 42 485*0Sstevel@tonic-gate #define SPD_DIAGNOSTIC_DUPLICATE_ICMP_TYPECODE 43 486*0Sstevel@tonic-gate 487*0Sstevel@tonic-gate /* 488*0Sstevel@tonic-gate * Helper macros. 489*0Sstevel@tonic-gate */ 490*0Sstevel@tonic-gate #define SPD_64TO8(x) ((x) << 3) 491*0Sstevel@tonic-gate #define SPD_8TO64(x) ((x) >> 3) 492*0Sstevel@tonic-gate #define SPD_8TO1(x) ((x) << 3) 493*0Sstevel@tonic-gate #define SPD_1TO8(x) ((x) >> 3) 494*0Sstevel@tonic-gate 495*0Sstevel@tonic-gate #ifdef __cplusplus 496*0Sstevel@tonic-gate } 497*0Sstevel@tonic-gate #endif 498*0Sstevel@tonic-gate 499*0Sstevel@tonic-gate #endif /* _NET_PFPOLICY_H */ 500