1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2014 Jason King.
  24  */
  25 
  26 #ifndef _IKEV1_H
  27 #define _IKEV1_H
  28 
  29 #include <sys/types.h>
  30 #include "ike.h"
  31 
  32 #ifdef __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 #define IKEV1_MAJOR_VERSION     1
  37 #define IKEV1_MINOR_VERSION     0
  38 #define IKEV1_VERSION           0x10
  39 
  40 typedef struct ike_header ikev1_header_t;
  41 
  42 enum ikev1_exch {
  43         IKEV1_EXCH_BASE                 = 1,
  44         IKEV1_EXCH_IDPROT               = 2,
  45         IKEV1_EXCH_AUTH_ONLY            = 3,
  46         IKEV1_EXCH_AGGRESSIVE           = 4,
  47         IKEV1_EXCH_INFORMATIONAL        = 5,
  48 };
  49 #define IKEV1_VALID_EXCH(exch) \
  50         (((exch) >= IKEV1_EXCH_BASE) && (exch) <= ((IKEV1_EXCH_INFORMATIONAL)))
  51 typedef enum ikev1_exch ikev1_exch_t;
  52 
  53 #define IKEV1_FLAG_ENCR         (1 << 0)
  54 #define IKEV1_FLAG_COMMIT       (1 << 1)
  55 #define IKEV1_FLAG_AUTH_ONLY    (1 << 2)
  56 #define IKEV1_FLAGS \
  57         (IKEV1_FLAG_ENCR|IKEV1_FLAG_COMMIT|IKEV1_FLAG_AUTH_ONLY)
  58 
  59 typedef struct ike_payload ikev1_payload_t;
  60 
  61 enum ikev1_pay_type {
  62         IKEV1_PAYLOAD_SA        = 1,
  63         IKEV1_PAYLOAD_PROP      = 2,
  64         IKEV1_PAYLOAD_XFORM     = 3,
  65         IKEV1_PAYLOAD_KE        = 4,
  66         IKEV1_PAYLOAD_ID        = 5,
  67         IKEV1_PAYLOAD_CERT      = 6,
  68         IKEV1_PAYLOAD_CREQ      = 7,
  69         IKEV1_PAYLOAD_HASH      = 8,
  70         IKEV1_PAYLOAD_SIG       = 9,
  71         IKEV1_PAYLOAD_NONCE     = 10,
  72         IKEV1_PAYLOAD_NOTIFY    = 11,
  73         IKEV1_PAYLOAD_DELETE    = 12,
  74         IKEV1_PAYLOAD_VENDOR    = 13,
  75 };
  76 typedef enum ikev1_pay_type ikev1_pay_t;
  77 #define IKEV1_VALID_PAYLOAD(p) \
  78         (((p) >= IKEV1_PAYLOAD_SA) && ((p) <= IKEV1_PAYLOAD_VENDOR))
  79 
  80 #define IKEV1_SIT_IDENTITY_ONLY (0x01)
  81 #define IKEV1_SIT_SECRECY       (0x02)
  82 #define IKEV1_SIT_INTEGRITY     (0x04)
  83 
  84 typedef enum ikev1_spi_proto_e {
  85         IKEV1_SPI_PROTO_ISAKMP          = 1,
  86         IKEv1_SPI_PROTO_IPSEC_AH        = 2,
  87         IKEV1_SPI_PROTO_IPSEC_ESP       = 3,
  88         IKEV1_SPI_PROTO_IPCOMP          = 4
  89 } ikev1_spi_proto_t;
  90 
  91 typedef struct ike_prop ikev1_prop_t;
  92 #define IKEV1_PROP_LAST 0
  93 #define IKEV1_PROP_MORE 2
  94 
  95 typedef struct ike_xform ikev1_xform_t;
  96 #define IKEV1_XFORM_LAST        0
  97 #define IKEV1_XFORM_MORE        3
  98 
  99 enum ikev1_xf_type {
 100         IKEV1_XF_ENCR           = 1,
 101         IKEV1_XF_HASH           = 2,
 102         IKEV1_XF_AUTH           = 3,
 103         IKEV1_XF_GROUP_DESC     = 4,
 104         IKEV1_XF_GROUP_TYPE     = 5,
 105         IKEV1_XF_GROUP_PRIME    = 6,
 106         IKEV1_XF_GROUP_GEN_1    = 7,
 107         IKEV1_XF_GROUP_GEN_2    = 8,
 108         IKEV1_XF_GROUP_CURVE_A  = 9,
 109         IKEV1_XF_GROUP_CURVE_B  = 10,
 110         IKEV1_XF_LIFE_TYPE      = 11,
 111         IKEV1_XF_LIFE_DUR       = 12,
 112         IKEV1_XF_PRF            = 13,
 113         IKEV1_XF_KEYLEN         = 14,
 114         IKEV1_XF_FIELD_SIZE     = 15,
 115         IKEV1_XF_GROUP_ORDER    = 16
 116 };
 117 typedef enum ikev1_xf_type ikev1_xf_type_t;
 118 
 119 typedef struct ike_xf_attr ikev1_xf_attr_t;
 120 #define IKEV1_ATTR_TV                   IKE_ATTR_TV
 121 #define IKEV1_ATTR_TLV                  IKE_ATTR_TLV
 122 #define IKEV1_ATTR_GET_TYPE(t)          IKE_GET_TYPE(t)
 123 #define IKEV1_ATTR_GET_FORMAT(t)        IKE_GET_FORMAT(t)
 124 #define IKEV1_ATTR_TYPE(f, t)           IKE_ATTR_TYPE(f, t)
 125 
 126 #ifdef __cplusplus
 127 }
 128 #endif
 129 
 130 #endif /* _IKEV1_H */