Home | History | Annotate | Line # | Download | only in net
      1  1.35  knakahar /*	$NetBSD: pfkeyv2.h,v 1.35 2023/01/04 01:58:33 knakahara Exp $	*/
      2  1.14    itojun /*	$KAME: pfkeyv2.h,v 1.36 2003/07/25 09:33:37 itojun Exp $	*/
      3   1.3    itojun 
      4   1.3    itojun /*
      5   1.3    itojun  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      6   1.3    itojun  * All rights reserved.
      7   1.5    itojun  *
      8   1.3    itojun  * Redistribution and use in source and binary forms, with or without
      9   1.3    itojun  * modification, are permitted provided that the following conditions
     10   1.3    itojun  * are met:
     11   1.3    itojun  * 1. Redistributions of source code must retain the above copyright
     12   1.3    itojun  *    notice, this list of conditions and the following disclaimer.
     13   1.3    itojun  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.3    itojun  *    notice, this list of conditions and the following disclaimer in the
     15   1.3    itojun  *    documentation and/or other materials provided with the distribution.
     16   1.3    itojun  * 3. Neither the name of the project nor the names of its contributors
     17   1.3    itojun  *    may be used to endorse or promote products derived from this software
     18   1.3    itojun  *    without specific prior written permission.
     19   1.5    itojun  *
     20   1.3    itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     21   1.3    itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22   1.3    itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23   1.3    itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     24   1.3    itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25   1.3    itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26   1.3    itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27   1.3    itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28   1.3    itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29   1.3    itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30   1.3    itojun  * SUCH DAMAGE.
     31   1.3    itojun  */
     32   1.3    itojun 
     33   1.4    itojun /*
     34   1.4    itojun  * This file has been derived rfc 2367,
     35   1.4    itojun  * And added some flags of SADB_KEY_FLAGS_ as SADB_X_EXT_.
     36   1.4    itojun  *	sakane (at) ydc.co.jp
     37   1.4    itojun  */
     38   1.4    itojun 
     39   1.3    itojun #ifndef _NET_PFKEYV2_H_
     40   1.3    itojun #define _NET_PFKEYV2_H_
     41   1.3    itojun 
     42   1.4    itojun /*
     43   1.4    itojun This file defines structures and symbols for the PF_KEY Version 2
     44   1.4    itojun key management interface. It was written at the U.S. Naval Research
     45   1.4    itojun Laboratory. This file is in the public domain. The authors ask that
     46   1.4    itojun you leave this credit intact on any copies of this file.
     47   1.4    itojun */
     48   1.4    itojun #ifndef __PFKEY_V2_H
     49   1.4    itojun #define __PFKEY_V2_H 1
     50   1.4    itojun 
     51   1.4    itojun #define PF_KEY_V2 2
     52   1.4    itojun #define PFKEYV2_REVISION        199806L
     53   1.4    itojun 
     54   1.4    itojun #define SADB_RESERVED    0
     55   1.4    itojun #define SADB_GETSPI      1
     56   1.4    itojun #define SADB_UPDATE      2
     57   1.4    itojun #define SADB_ADD         3
     58   1.4    itojun #define SADB_DELETE      4
     59   1.4    itojun #define SADB_GET         5
     60   1.4    itojun #define SADB_ACQUIRE     6
     61   1.4    itojun #define SADB_REGISTER    7
     62   1.4    itojun #define SADB_EXPIRE      8
     63   1.4    itojun #define SADB_FLUSH       9
     64   1.4    itojun #define SADB_DUMP        10
     65   1.4    itojun #define SADB_X_PROMISC   11
     66   1.4    itojun #define SADB_X_PCHANGE   12
     67   1.4    itojun 
     68   1.5    itojun #define SADB_X_SPDUPDATE  13
     69   1.4    itojun #define SADB_X_SPDADD     14
     70   1.5    itojun #define SADB_X_SPDDELETE  15	/* by policy index */
     71   1.5    itojun #define SADB_X_SPDGET     16
     72   1.5    itojun #define SADB_X_SPDACQUIRE 17
     73   1.4    itojun #define SADB_X_SPDDUMP    18
     74   1.4    itojun #define SADB_X_SPDFLUSH   19
     75   1.5    itojun #define SADB_X_SPDSETIDX  20
     76   1.4    itojun #define SADB_X_SPDEXPIRE  21	/* not yet */
     77   1.5    itojun #define SADB_X_SPDDELETE2 22	/* by policy id */
     78  1.19      manu #define SADB_X_NAT_T_NEW_MAPPING 23
     79  1.23      yamt #if 0
     80  1.24      yamt #define	SADB_X_MIGRATE    24	/* KAME */
     81  1.23      yamt #endif
     82  1.19      manu #define SADB_MAX          23
     83   1.4    itojun 
     84   1.4    itojun struct sadb_msg {
     85  1.26      matt   uint8_t sadb_msg_version;
     86  1.26      matt   uint8_t sadb_msg_type;
     87  1.26      matt   uint8_t sadb_msg_errno;
     88  1.26      matt   uint8_t sadb_msg_satype;
     89  1.26      matt   uint16_t sadb_msg_len;
     90  1.26      matt   uint16_t sadb_msg_reserved;
     91  1.26      matt   uint32_t sadb_msg_seq;
     92  1.26      matt   uint32_t sadb_msg_pid;
     93   1.4    itojun };
     94   1.4    itojun 
     95   1.4    itojun struct sadb_ext {
     96  1.26      matt   uint16_t sadb_ext_len;
     97  1.26      matt   uint16_t sadb_ext_type;
     98   1.4    itojun };
     99   1.4    itojun 
    100   1.4    itojun struct sadb_sa {
    101  1.26      matt   uint16_t sadb_sa_len;
    102  1.26      matt   uint16_t sadb_sa_exttype;
    103  1.26      matt   uint32_t sadb_sa_spi;
    104  1.26      matt   uint8_t sadb_sa_replay;
    105  1.26      matt   uint8_t sadb_sa_state;
    106  1.26      matt   uint8_t sadb_sa_auth;
    107  1.26      matt   uint8_t sadb_sa_encrypt;
    108  1.26      matt   uint32_t sadb_sa_flags;
    109   1.4    itojun };
    110   1.4    itojun 
    111   1.4    itojun struct sadb_lifetime {
    112  1.26      matt   uint16_t sadb_lifetime_len;
    113  1.26      matt   uint16_t sadb_lifetime_exttype;
    114  1.26      matt   uint32_t sadb_lifetime_allocations;
    115  1.26      matt   uint64_t sadb_lifetime_bytes;
    116  1.26      matt   uint64_t sadb_lifetime_addtime;
    117  1.26      matt   uint64_t sadb_lifetime_usetime;
    118   1.4    itojun };
    119   1.4    itojun 
    120   1.4    itojun struct sadb_address {
    121  1.26      matt   uint16_t sadb_address_len;
    122  1.26      matt   uint16_t sadb_address_exttype;
    123  1.26      matt   uint8_t sadb_address_proto;
    124  1.26      matt   uint8_t sadb_address_prefixlen;
    125  1.26      matt   uint16_t sadb_address_reserved;
    126   1.4    itojun };
    127   1.4    itojun 
    128   1.4    itojun struct sadb_key {
    129  1.26      matt   uint16_t sadb_key_len;
    130  1.26      matt   uint16_t sadb_key_exttype;
    131  1.26      matt   uint16_t sadb_key_bits;
    132  1.26      matt   uint16_t sadb_key_reserved;
    133   1.4    itojun };
    134   1.4    itojun 
    135   1.4    itojun struct sadb_ident {
    136  1.26      matt   uint16_t sadb_ident_len;
    137  1.26      matt   uint16_t sadb_ident_exttype;
    138  1.26      matt   uint16_t sadb_ident_type;
    139  1.26      matt   uint16_t sadb_ident_reserved;
    140  1.26      matt   uint64_t sadb_ident_id;
    141   1.4    itojun };
    142   1.4    itojun 
    143   1.4    itojun struct sadb_sens {
    144  1.26      matt   uint16_t sadb_sens_len;
    145  1.26      matt   uint16_t sadb_sens_exttype;
    146  1.26      matt   uint32_t sadb_sens_dpd;
    147  1.26      matt   uint8_t sadb_sens_sens_level;
    148  1.26      matt   uint8_t sadb_sens_sens_len;
    149  1.26      matt   uint8_t sadb_sens_integ_level;
    150  1.26      matt   uint8_t sadb_sens_integ_len;
    151  1.26      matt   uint32_t sadb_sens_reserved;
    152   1.4    itojun };
    153   1.4    itojun 
    154   1.4    itojun struct sadb_prop {
    155  1.26      matt   uint16_t sadb_prop_len;
    156  1.26      matt   uint16_t sadb_prop_exttype;
    157  1.26      matt   uint8_t sadb_prop_replay;
    158  1.26      matt   uint8_t sadb_prop_reserved[3];
    159   1.4    itojun };
    160   1.4    itojun 
    161   1.4    itojun struct sadb_comb {
    162  1.26      matt   uint8_t sadb_comb_auth;
    163  1.26      matt   uint8_t sadb_comb_encrypt;
    164  1.26      matt   uint16_t sadb_comb_flags;
    165  1.26      matt   uint16_t sadb_comb_auth_minbits;
    166  1.26      matt   uint16_t sadb_comb_auth_maxbits;
    167  1.26      matt   uint16_t sadb_comb_encrypt_minbits;
    168  1.26      matt   uint16_t sadb_comb_encrypt_maxbits;
    169  1.26      matt   uint32_t sadb_comb_reserved;
    170  1.26      matt   uint32_t sadb_comb_soft_allocations;
    171  1.26      matt   uint32_t sadb_comb_hard_allocations;
    172  1.26      matt   uint64_t sadb_comb_soft_bytes;
    173  1.26      matt   uint64_t sadb_comb_hard_bytes;
    174  1.26      matt   uint64_t sadb_comb_soft_addtime;
    175  1.26      matt   uint64_t sadb_comb_hard_addtime;
    176  1.26      matt   uint64_t sadb_comb_soft_usetime;
    177  1.26      matt   uint64_t sadb_comb_hard_usetime;
    178   1.4    itojun };
    179   1.4    itojun 
    180   1.4    itojun struct sadb_supported {
    181  1.26      matt   uint16_t sadb_supported_len;
    182  1.26      matt   uint16_t sadb_supported_exttype;
    183  1.26      matt   uint32_t sadb_supported_reserved;
    184   1.4    itojun };
    185   1.4    itojun 
    186   1.4    itojun struct sadb_alg {
    187  1.26      matt   uint8_t sadb_alg_id;
    188  1.26      matt   uint8_t sadb_alg_ivlen;
    189  1.26      matt   uint16_t sadb_alg_minbits;
    190  1.26      matt   uint16_t sadb_alg_maxbits;
    191  1.26      matt   uint16_t sadb_alg_reserved;
    192   1.4    itojun };
    193   1.4    itojun 
    194   1.4    itojun struct sadb_spirange {
    195  1.26      matt   uint16_t sadb_spirange_len;
    196  1.26      matt   uint16_t sadb_spirange_exttype;
    197  1.26      matt   uint32_t sadb_spirange_min;
    198  1.26      matt   uint32_t sadb_spirange_max;
    199  1.26      matt   uint32_t sadb_spirange_reserved;
    200   1.4    itojun };
    201   1.4    itojun 
    202   1.4    itojun struct sadb_x_kmprivate {
    203  1.26      matt   uint16_t sadb_x_kmprivate_len;
    204  1.26      matt   uint16_t sadb_x_kmprivate_exttype;
    205  1.26      matt   uint32_t sadb_x_kmprivate_reserved;
    206   1.4    itojun };
    207   1.4    itojun 
    208   1.5    itojun /*
    209   1.5    itojun  * XXX Additional SA Extension.
    210   1.5    itojun  * mode: tunnel or transport
    211   1.5    itojun  * reqid: to make SA unique nevertheless the address pair of SA are same.
    212   1.5    itojun  *        Mainly it's for VPN.
    213   1.5    itojun  */
    214   1.5    itojun struct sadb_x_sa2 {
    215  1.26      matt   uint16_t sadb_x_sa2_len;
    216  1.26      matt   uint16_t sadb_x_sa2_exttype;
    217  1.26      matt   uint8_t sadb_x_sa2_mode;
    218  1.26      matt   uint8_t sadb_x_sa2_reserved1;
    219  1.26      matt   uint16_t sadb_x_sa2_reserved2;
    220  1.26      matt   uint32_t sadb_x_sa2_sequence;
    221  1.26      matt   uint32_t sadb_x_sa2_reqid;		/* topmost 16bits are always 0 */
    222   1.5    itojun };
    223   1.5    itojun 
    224   1.4    itojun /* XXX Policy Extension */
    225   1.5    itojun /* sizeof(struct sadb_x_policy) == 16 */
    226   1.4    itojun struct sadb_x_policy {
    227  1.26      matt   uint16_t sadb_x_policy_len;
    228  1.26      matt   uint16_t sadb_x_policy_exttype;
    229  1.26      matt   uint16_t sadb_x_policy_type;		/* See policy type of ipsec.h */
    230  1.26      matt   uint8_t sadb_x_policy_dir;		/* direction, see ipsec.h */
    231  1.34  knakahar   uint8_t sadb_x_policy_flags;
    232  1.34  knakahar #define IPSEC_POLICY_FLAG_ORIGIN_KERNEL 0x80	/* policy is generated by kernel */
    233  1.35  knakahar #define	sadb_x_policy_reserved	sadb_x_policy_flags
    234  1.26      matt   uint32_t sadb_x_policy_id;
    235  1.26      matt   uint32_t sadb_x_policy_reserved2;
    236   1.4    itojun };
    237   1.4    itojun /*
    238   1.4    itojun  * When policy_type == IPSEC, it is followed by some of
    239   1.4    itojun  * the ipsec policy request.
    240   1.4    itojun  * [total length of ipsec policy requests]
    241   1.4    itojun  *	= (sadb_x_policy_len * sizeof(uint64_t) - sizeof(struct sadb_x_policy))
    242   1.4    itojun  */
    243   1.4    itojun 
    244   1.4    itojun /* XXX IPsec Policy Request Extension */
    245   1.4    itojun /*
    246   1.4    itojun  * This structure is aligned 8 bytes.
    247   1.4    itojun  */
    248   1.4    itojun struct sadb_x_ipsecrequest {
    249  1.26      matt   uint16_t sadb_x_ipsecrequest_len;	/* structure length in 64 bits. */
    250  1.26      matt   uint16_t sadb_x_ipsecrequest_proto;	/* See ipsec.h */
    251  1.26      matt   uint8_t sadb_x_ipsecrequest_mode;	/* See IPSEC_MODE_XX in ipsec.h. */
    252  1.26      matt   uint8_t sadb_x_ipsecrequest_level;	/* See IPSEC_LEVEL_XX in ipsec.h */
    253  1.26      matt   uint16_t sadb_x_ipsecrequest_reqid;	/* See ipsec.h */
    254   1.4    itojun 
    255   1.4    itojun   /*
    256   1.4    itojun    * followed by source IP address of SA, and immediately followed by
    257   1.4    itojun    * destination IP address of SA.  These encoded into two of sockaddr
    258   1.4    itojun    * structure without any padding.  Must set each sa_len exactly.
    259   1.4    itojun    * Each of length of the sockaddr structure are not aligned to 64bits,
    260   1.4    itojun    * but sum of x_request and addresses is aligned to 64bits.
    261   1.4    itojun    */
    262   1.4    itojun };
    263   1.4    itojun 
    264  1.19      manu /* NAT traversal type, see draft-ietf-ipsec-udp-encaps-06 */
    265  1.19      manu /* sizeof(struct sadb_x_nat_t_type) == 8 */
    266  1.19      manu struct sadb_x_nat_t_type {
    267  1.26      matt   uint16_t sadb_x_nat_t_type_len;
    268  1.26      matt   uint16_t sadb_x_nat_t_type_exttype;
    269  1.26      matt   uint8_t sadb_x_nat_t_type_type;
    270  1.26      matt   uint8_t sadb_x_nat_t_type_reserved[3];
    271  1.19      manu };
    272  1.19      manu 
    273  1.19      manu /* NAT traversal source or destination port */
    274  1.19      manu /* sizeof(struct sadb_x_nat_t_port) == 8 */
    275  1.20     perry struct sadb_x_nat_t_port {
    276  1.26      matt   uint16_t sadb_x_nat_t_port_len;
    277  1.26      matt   uint16_t sadb_x_nat_t_port_exttype;
    278  1.26      matt   uint16_t sadb_x_nat_t_port_port;
    279  1.26      matt   uint16_t sadb_x_nat_t_port_reserved;
    280  1.19      manu };
    281  1.19      manu 
    282  1.19      manu /* ESP fragmentation size */
    283  1.19      manu /* sizeof(struct sadb_x_nat_t_frag) == 8 */
    284  1.19      manu struct sadb_x_nat_t_frag {
    285  1.26      matt   uint16_t sadb_x_nat_t_frag_len;
    286  1.26      matt   uint16_t sadb_x_nat_t_frag_exttype;
    287  1.26      matt   uint16_t sadb_x_nat_t_frag_fraglen;
    288  1.26      matt   uint16_t sadb_x_nat_t_frag_reserved;
    289  1.19      manu };
    290  1.19      manu 
    291  1.19      manu 
    292   1.4    itojun #define SADB_EXT_RESERVED             0
    293   1.4    itojun #define SADB_EXT_SA                   1
    294   1.4    itojun #define SADB_EXT_LIFETIME_CURRENT     2
    295   1.4    itojun #define SADB_EXT_LIFETIME_HARD        3
    296   1.4    itojun #define SADB_EXT_LIFETIME_SOFT        4
    297   1.4    itojun #define SADB_EXT_ADDRESS_SRC          5
    298   1.4    itojun #define SADB_EXT_ADDRESS_DST          6
    299   1.4    itojun #define SADB_EXT_ADDRESS_PROXY        7
    300   1.4    itojun #define SADB_EXT_KEY_AUTH             8
    301   1.4    itojun #define SADB_EXT_KEY_ENCRYPT          9
    302   1.4    itojun #define SADB_EXT_IDENTITY_SRC         10
    303   1.4    itojun #define SADB_EXT_IDENTITY_DST         11
    304   1.4    itojun #define SADB_EXT_SENSITIVITY          12
    305   1.4    itojun #define SADB_EXT_PROPOSAL             13
    306   1.4    itojun #define SADB_EXT_SUPPORTED_AUTH       14
    307   1.4    itojun #define SADB_EXT_SUPPORTED_ENCRYPT    15
    308   1.4    itojun #define SADB_EXT_SPIRANGE             16
    309   1.4    itojun #define SADB_X_EXT_KMPRIVATE          17
    310   1.4    itojun #define SADB_X_EXT_POLICY             18
    311   1.5    itojun #define SADB_X_EXT_SA2                19
    312  1.19      manu #define SADB_X_EXT_NAT_T_TYPE         20
    313  1.19      manu #define SADB_X_EXT_NAT_T_SPORT        21
    314  1.19      manu #define SADB_X_EXT_NAT_T_DPORT        22
    315  1.27       spz #define SADB_X_EXT_NAT_T_OA           23	/* compat */
    316  1.27       spz #define SADB_X_EXT_NAT_T_OAI          23
    317  1.27       spz #define SADB_X_EXT_NAT_T_OAR          24
    318  1.27       spz #define SADB_X_EXT_NAT_T_FRAG	      25
    319  1.23      yamt #if 0
    320  1.23      yamt #define	SADB_X_EXT_TAG		      25	/* KAME */
    321  1.23      yamt #define	SADB_X_EXT_SA3		      26	/* KAME */
    322  1.23      yamt #define	SADB_X_EXT_PACKET	      27	/* KAME */
    323  1.23      yamt #endif
    324  1.27       spz #define SADB_EXT_MAX                  25
    325   1.4    itojun 
    326   1.4    itojun #define SADB_SATYPE_UNSPEC	0
    327   1.4    itojun #define SADB_SATYPE_AH		2
    328   1.4    itojun #define SADB_SATYPE_ESP		3
    329   1.4    itojun #define SADB_SATYPE_RSVP	5
    330   1.4    itojun #define SADB_SATYPE_OSPFV2	6
    331   1.4    itojun #define SADB_SATYPE_RIPV2	7
    332   1.4    itojun #define SADB_SATYPE_MIP		8
    333   1.4    itojun #define SADB_X_SATYPE_IPCOMP	9
    334  1.12    itojun /*#define SADB_X_SATYPE_POLICY	10	obsolete, do not reuse */
    335  1.16  jonathan #define SADB_X_SATYPE_TCPSIGNATURE	11
    336  1.16  jonathan #define SADB_SATYPE_MAX		12
    337   1.4    itojun 
    338   1.4    itojun #define SADB_SASTATE_LARVAL   0
    339   1.4    itojun #define SADB_SASTATE_MATURE   1
    340   1.4    itojun #define SADB_SASTATE_DYING    2
    341   1.4    itojun #define SADB_SASTATE_DEAD     3
    342   1.4    itojun #define SADB_SASTATE_MAX      3
    343   1.4    itojun 
    344  1.32     ozaki #define SADB_SASTATE_USABLE_P(sav) \
    345  1.32     ozaki     ((sav)->state == SADB_SASTATE_MATURE || (sav)->state == SADB_SASTATE_DYING)
    346  1.32     ozaki 
    347   1.4    itojun #define SADB_SAFLAGS_PFS      1
    348   1.4    itojun 
    349  1.31  christos /*
    350  1.31  christos  * Statistics variable definitions. For ESP/AH/IPCOMP we define
    351  1.31  christos  * indirection arrays of 256 elements indexed by algorithm (which
    352  1.31  christos  * is uint8_t. All unknown/unhandled entries are summed in the 0th
    353  1.31  christos  * element. We provide three variables per protocol:
    354  1.31  christos  * 	1. *_STATS_INIT: a list of initializers
    355  1.31  christos  * 	2. *_STATS_NUM: number of algorithms/statistics including (0/unknown)
    356  1.31  christos  *	3. *_STATS_STR: a list of strings to symbolically print the statistics
    357  1.31  christos  */
    358  1.31  christos 
    359   1.7    itojun /* RFC2367 numbers - meets RFC2407 */
    360   1.7    itojun #define SADB_AALG_NONE		0
    361   1.7    itojun #define SADB_AALG_MD5HMAC	2
    362   1.7    itojun #define SADB_AALG_SHA1HMAC	3
    363   1.7    itojun #define SADB_AALG_MAX		251
    364  1.13    itojun /* private allocations - based on RFC2407/IANA assignment */
    365  1.13    itojun #define SADB_X_AALG_SHA2_256	5
    366  1.13    itojun #define SADB_X_AALG_SHA2_384	6
    367  1.13    itojun #define SADB_X_AALG_SHA2_512	7
    368  1.14    itojun #define SADB_X_AALG_RIPEMD160HMAC 8
    369  1.29  drochner #define SADB_X_AALG_AES_XCBC_MAC 9 /* RFC3566 */
    370  1.29  drochner #define SADB_X_AALG_AES128GMAC	11 /* RFC4543 + Errata1821 */
    371  1.29  drochner #define SADB_X_AALG_AES192GMAC	12
    372  1.29  drochner #define SADB_X_AALG_AES256GMAC	13
    373   1.7    itojun /* private allocations should use 249-255 (RFC2407) */
    374   1.7    itojun #define SADB_X_AALG_MD5		249	/* Keyed MD5 */
    375   1.7    itojun #define SADB_X_AALG_SHA		250	/* Keyed SHA */
    376   1.7    itojun #define SADB_X_AALG_NULL	251	/* null authentication */
    377  1.16  jonathan #define SADB_X_AALG_TCP_MD5	252	/* Keyed TCP-MD5 (RFC2385) */
    378   1.7    itojun 
    379  1.31  christos 
    380  1.31  christos #define SADB_AALG_STATS_INIT \
    381  1.31  christos     [SADB_AALG_NONE] = 1, \
    382  1.31  christos     [SADB_AALG_MD5HMAC] = 2, \
    383  1.31  christos     [SADB_AALG_SHA1HMAC] = 3, \
    384  1.31  christos     [SADB_X_AALG_SHA2_256] = 4, \
    385  1.31  christos     [SADB_X_AALG_SHA2_384] = 5, \
    386  1.31  christos     [SADB_X_AALG_SHA2_512] = 6, \
    387  1.31  christos     [SADB_X_AALG_RIPEMD160HMAC] = 7, \
    388  1.31  christos     [SADB_X_AALG_AES_XCBC_MAC] = 8, \
    389  1.31  christos     [SADB_X_AALG_AES128GMAC] = 9, \
    390  1.31  christos     [SADB_X_AALG_AES192GMAC] = 10, \
    391  1.31  christos     [SADB_X_AALG_AES256GMAC] = 11, \
    392  1.31  christos     [SADB_X_AALG_MD5] = 12, \
    393  1.31  christos     [SADB_X_AALG_SHA] = 13, \
    394  1.31  christos     [SADB_X_AALG_NULL] = 14, \
    395  1.31  christos     [SADB_X_AALG_TCP_MD5] = 15,
    396  1.31  christos 
    397  1.31  christos #define SADB_AALG_STATS_NUM 16
    398  1.31  christos #define SADB_AALG_STATS_STR \
    399  1.31  christos     "*unknown*", \
    400  1.31  christos     "none", \
    401  1.31  christos     "hmac-md5", \
    402  1.31  christos     "hmac-sha1", \
    403  1.31  christos     "hmac-sha2-256", \
    404  1.31  christos     "hmac-sha2-384", \
    405  1.31  christos     "hmac-sha2-512", \
    406  1.31  christos     "hmac-ripe-md160", \
    407  1.31  christos     "aes-xbc-mac", \
    408  1.31  christos     "aes-128-mac", \
    409  1.31  christos     "aes-192-mac", \
    410  1.31  christos     "aes-256-mac", \
    411  1.31  christos     "md5", \
    412  1.31  christos     "sha", \
    413  1.31  christos     "null", \
    414  1.31  christos     "tcp-md5",
    415  1.31  christos 
    416   1.7    itojun /* RFC2367 numbers - meets RFC2407 */
    417   1.7    itojun #define SADB_EALG_NONE		0
    418   1.7    itojun #define SADB_EALG_DESCBC	2
    419   1.7    itojun #define SADB_EALG_3DESCBC	3
    420  1.11    itojun #define SADB_EALG_NULL		11
    421  1.15  jonathan #define SADB_EALG_MAX		250
    422   1.9    itojun /* private allocations - based on RFC2407/IANA assignment */
    423   1.7    itojun #define SADB_X_EALG_CAST128CBC	6
    424   1.8    itojun #define SADB_X_EALG_BLOWFISHCBC	7
    425   1.9    itojun #define SADB_X_EALG_RIJNDAELCBC	12
    426   1.9    itojun #define SADB_X_EALG_AES		12
    427  1.29  drochner #define SADB_X_EALG_AESCTR	13 /* RFC3686 */
    428  1.29  drochner #define SADB_X_EALG_AESGCM8	18 /* RFC4106 */
    429  1.29  drochner #define SADB_X_EALG_AESGCM12	19
    430  1.29  drochner #define SADB_X_EALG_AESGCM16	20
    431  1.29  drochner #define SADB_X_EALG_CAMELLIACBC	22 /* RFC4312 */
    432  1.29  drochner #define SADB_X_EALG_AESGMAC	23 /* RFC4543 + Errata1821 */
    433   1.7    itojun /* private allocations should use 249-255 (RFC2407) */
    434  1.15  jonathan #define SADB_X_EALG_SKIPJACK    250
    435   1.4    itojun 
    436  1.31  christos #define SADB_EALG_STATS_INIT \
    437  1.31  christos     [SADB_EALG_NONE] = 1, \
    438  1.31  christos     [SADB_EALG_DESCBC] = 2, \
    439  1.31  christos     [SADB_EALG_3DESCBC] = 3, \
    440  1.31  christos     [SADB_EALG_NULL] = 4, \
    441  1.31  christos     [SADB_X_EALG_CAST128CBC] = 5, \
    442  1.31  christos     [SADB_X_EALG_BLOWFISHCBC] = 6, \
    443  1.31  christos     [SADB_X_EALG_RIJNDAELCBC] = 7, \
    444  1.31  christos     [SADB_X_EALG_AESCTR] = 8, \
    445  1.31  christos     [SADB_X_EALG_AESGCM8] = 9, \
    446  1.31  christos     [SADB_X_EALG_AESGCM12] = 10, \
    447  1.31  christos     [SADB_X_EALG_AESGCM16] = 11, \
    448  1.31  christos     [SADB_X_EALG_CAMELLIACBC] = 12, \
    449  1.31  christos     [SADB_X_EALG_AESGMAC] = 13, \
    450  1.31  christos     [SADB_X_EALG_SKIPJACK] = 14,
    451  1.31  christos 
    452  1.31  christos #define SADB_EALG_STATS_NUM 15
    453  1.31  christos #define SADB_EALG_STATS_STR \
    454  1.31  christos     "*unknown*", \
    455  1.31  christos     "none", \
    456  1.31  christos     "des-cbc", \
    457  1.31  christos     "3des-cbc", \
    458  1.31  christos     "null", \
    459  1.31  christos     "cast128-cbc", \
    460  1.31  christos     "blowfish-cbc", \
    461  1.31  christos     "aes-cbc", \
    462  1.31  christos     "aes-ctr", \
    463  1.31  christos     "aes-gcm-8", \
    464  1.31  christos     "aes-gcm-12", \
    465  1.31  christos     "aes-gcm-16", \
    466  1.31  christos     "camelia-cbc", \
    467  1.31  christos     "aes-gmac", \
    468  1.31  christos     "skipjack",
    469  1.31  christos 
    470  1.13    itojun /* private allocations - based on RFC2407/IANA assignment */
    471   1.4    itojun #define SADB_X_CALG_NONE	0
    472   1.4    itojun #define SADB_X_CALG_OUI		1
    473   1.4    itojun #define SADB_X_CALG_DEFLATE	2
    474   1.4    itojun #define SADB_X_CALG_LZS		3
    475   1.4    itojun #define SADB_X_CALG_MAX		4
    476   1.4    itojun 
    477  1.31  christos #define SADB_CALG_STATS_INIT \
    478  1.31  christos     [SADB_X_CALG_NONE] = 1, \
    479  1.31  christos     [SADB_X_CALG_OUI] = 2, \
    480  1.31  christos     [SADB_X_CALG_DEFLATE] = 3, \
    481  1.31  christos     [SADB_X_CALG_LZS] = 4,
    482  1.31  christos 
    483  1.31  christos #define SADB_CALG_STATS_NUM 5
    484  1.31  christos 
    485  1.31  christos #define SADB_CALG_STATS_STR \
    486  1.31  christos     "*unknown*", \
    487  1.31  christos     "none", \
    488  1.31  christos     "oui", \
    489  1.31  christos     "deflate", \
    490  1.31  christos     "lzs",
    491  1.31  christos 
    492  1.31  christos 
    493   1.4    itojun #define SADB_IDENTTYPE_RESERVED   0
    494   1.4    itojun #define SADB_IDENTTYPE_PREFIX     1
    495   1.4    itojun #define SADB_IDENTTYPE_FQDN       2
    496   1.4    itojun #define SADB_IDENTTYPE_USERFQDN   3
    497   1.4    itojun #define SADB_X_IDENTTYPE_ADDR     4
    498   1.4    itojun #define SADB_IDENTTYPE_MAX        4
    499   1.4    itojun 
    500   1.4    itojun /* `flags' in sadb_sa structure holds followings */
    501   1.4    itojun #define SADB_X_EXT_NONE		0x0000	/* i.e. new format. */
    502   1.4    itojun #define SADB_X_EXT_OLD		0x0001	/* old format. */
    503   1.4    itojun 
    504   1.4    itojun #define SADB_X_EXT_IV4B		0x0010	/* IV length of 4 bytes in use */
    505   1.4    itojun #define SADB_X_EXT_DERIV	0x0020	/* DES derived */
    506   1.4    itojun #define SADB_X_EXT_CYCSEQ	0x0040	/* allowing to cyclic sequence. */
    507   1.4    itojun 
    508   1.4    itojun 	/* three of followings are exclusive flags each them */
    509  1.33    andvar #define SADB_X_EXT_PSEQ		0x0000	/* sequential padding for ESP */
    510   1.4    itojun #define SADB_X_EXT_PRAND	0x0100	/* random padding for ESP */
    511   1.4    itojun #define SADB_X_EXT_PZERO	0x0200	/* zero padding for ESP */
    512   1.4    itojun #define SADB_X_EXT_PMASK	0x0300	/* mask for padding flag */
    513   1.4    itojun 
    514   1.4    itojun #if 1
    515   1.4    itojun #define SADB_X_EXT_RAWCPI	0x0080	/* use well known CPI (IPComp) */
    516   1.4    itojun #endif
    517   1.4    itojun 
    518   1.4    itojun #define SADB_KEY_FLAGS_MAX	0x0fff
    519   1.4    itojun 
    520   1.4    itojun /* SPI size for PF_KEYv2 */
    521  1.26      matt #define PFKEY_SPI_SIZE	sizeof(uint32_t)
    522   1.4    itojun 
    523   1.4    itojun /* Identifier for menber of lifetime structure */
    524   1.4    itojun #define SADB_X_LIFETIME_ALLOCATIONS	0
    525   1.4    itojun #define SADB_X_LIFETIME_BYTES		1
    526   1.4    itojun #define SADB_X_LIFETIME_ADDTIME		2
    527   1.4    itojun #define SADB_X_LIFETIME_USETIME		3
    528   1.4    itojun 
    529   1.4    itojun /* The rate for SOFT lifetime against HARD one. */
    530   1.4    itojun #define PFKEY_SOFT_LIFETIME_RATE	80
    531   1.4    itojun 
    532   1.4    itojun /* Utilities */
    533   1.4    itojun #define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1)))
    534   1.4    itojun #define	PFKEY_EXTLEN(msg) \
    535  1.30  drochner 	PFKEY_UNUNIT64(((const struct sadb_ext *)(const void *)(msg))->sadb_ext_len)
    536   1.4    itojun #define PFKEY_ADDR_PREFIX(ext) \
    537  1.30  drochner 	(((const struct sadb_address *)(const void *)(ext))->sadb_address_prefixlen)
    538   1.4    itojun #define PFKEY_ADDR_PROTO(ext) \
    539  1.30  drochner 	(((const struct sadb_address *)(const void *)(ext))->sadb_address_proto)
    540   1.4    itojun #define PFKEY_ADDR_SADDR(ext) \
    541  1.22  christos 	((struct sockaddr *)(void *)((char *)(void *)(ext) + \
    542  1.22  christos 	sizeof(struct sadb_address)))
    543   1.4    itojun 
    544   1.4    itojun /* in 64bits */
    545   1.4    itojun #define	PFKEY_UNUNIT64(a)	((a) << 3)
    546   1.4    itojun #define	PFKEY_UNIT64(a)		((a) >> 3)
    547   1.4    itojun 
    548   1.4    itojun #endif /* __PFKEY_V2_H */
    549   1.3    itojun 
    550  1.25      elad #endif /* !_NET_PFKEYV2_H_ */
    551