Home | History | Annotate | Line # | Download | only in racoon
      1 /*	$NetBSD: isakmp_var.h,v 1.20 2025/03/08 16:39:08 christos Exp $	*/
      2 
      3 /* Id: isakmp_var.h,v 1.12 2005/05/07 14:45:31 manubsd Exp */
      4 
      5 /*
      6  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. Neither the name of the project nor the names of its contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  * SUCH DAMAGE.
     32  */
     33 
     34 #ifndef _ISAKMP_VAR_H
     35 #define _ISAKMP_VAR_H
     36 
     37 #include "vmbuf.h"
     38 #include "policy.h"
     39 
     40 #define PORT_ISAKMP 500
     41 #define PORT_ISAKMP_NATT 4500
     42 
     43 #define DEFAULT_NONCE_SIZE	16
     44 
     45 typedef u_char cookie_t[8];
     46 typedef u_char msgid_t[4];
     47 
     48 typedef struct { /* i_cookie + r_cookie */
     49 	cookie_t i_ck;
     50 	cookie_t r_ck;
     51 } isakmp_index;
     52 
     53 struct isakmp_gen;
     54 struct sched;
     55 
     56 struct sockaddr;
     57 struct ph1handle;
     58 struct ph2handle;
     59 struct remoteconf;
     60 struct ipsecdoi_pl_id;	/* XXX */
     61 struct isakmp_pl_ke;	/* XXX */
     62 struct isakmp_pl_nonce;	/* XXX */
     63 
     64 extern struct ph1handle *isakmp_ph1begin_i(struct remoteconf *,
     65     struct sockaddr *, struct sockaddr *);
     66 
     67 extern vchar_t *isakmp_parsewoh(int, struct isakmp_gen *, int);
     68 extern vchar_t *isakmp_parse(vchar_t *);
     69 
     70 extern int isakmp_init(void);
     71 extern const char *isakmp_pindex(const isakmp_index *, const uint32_t);
     72 extern int isakmp_open(struct sockaddr *, int);
     73 extern void isakmp_close(int fd);
     74 extern int isakmp_send(struct ph1handle *, vchar_t *);
     75 
     76 extern int isakmp_ph1send(struct ph1handle *);
     77 extern int isakmp_ph2send(struct ph2handle *);
     78 extern void isakmp_ph1dying_stub(struct sched *);
     79 extern void isakmp_ph1dying(struct ph1handle *);
     80 extern void isakmp_ph1expire_stub(struct sched *);
     81 extern void isakmp_ph1expire(struct ph1handle *);
     82 extern void isakmp_ph1delete_stub(struct sched *);
     83 extern void isakmp_ph1delete(struct ph1handle *);
     84 extern void isakmp_ph2expire_stub(struct sched *);
     85 extern void isakmp_ph2expire(struct ph2handle *);
     86 extern void isakmp_ph2delete_stub(struct sched *);
     87 extern void isakmp_ph2delete(struct ph2handle *);
     88 
     89 extern int isakmp_get_sainfo(struct ph2handle *, struct secpolicy *, struct secpolicy *);
     90 extern int isakmp_post_acquire(struct ph2handle *, struct ph1handle *, int);
     91 extern int isakmp_post_getspi(struct ph2handle *);
     92 extern void isakmp_chkph1there_stub(struct sched *);
     93 extern void isakmp_chkph1there(struct ph2handle *);
     94 
     95 extern caddr_t isakmp_set_attr_v(caddr_t, int, caddr_t, int);
     96 extern caddr_t isakmp_set_attr_l(caddr_t, int, uint32_t);
     97 extern vchar_t *isakmp_add_attr_v(vchar_t *, int, caddr_t, int);
     98 extern vchar_t *isakmp_add_attr_l(vchar_t *, int, uint32_t);
     99 
    100 extern int isakmp_newcookie(caddr_t, struct sockaddr *, struct sockaddr *);
    101 
    102 extern int isakmp_p2ph(vchar_t **, struct isakmp_gen *);
    103 
    104 extern uint32_t isakmp_newmsgid2(struct ph1handle *);
    105 extern caddr_t set_isakmp_header1(vchar_t *, struct ph1handle *, int);
    106 extern caddr_t set_isakmp_header2(vchar_t *, struct ph2handle *, int);
    107 extern caddr_t set_isakmp_payload(caddr_t, vchar_t *, int);
    108 
    109 extern struct payload_list *isakmp_plist_append_full(
    110     struct payload_list *, vchar_t *, uint8_t, uint8_t);
    111 
    112 static inline struct payload_list *
    113 isakmp_plist_append(struct payload_list *plist, vchar_t *payload, uint8_t payload_type)
    114 {
    115 	return isakmp_plist_append_full(plist, payload, payload_type, 0);
    116 }
    117 
    118 
    119 extern vchar_t *isakmp_plist_set_all(struct payload_list **plist,
    120 	struct ph1handle *iph1);
    121 
    122 #ifdef HAVE_PRINT_ISAKMP_C
    123 extern void isakmp_printpacket(vchar_t *, struct sockaddr *,
    124 	struct sockaddr *, int);
    125 #endif
    126 
    127 extern int copy_ph1addresses( struct ph1handle *,
    128 	struct remoteconf *, struct sockaddr *, struct sockaddr *);
    129 extern void log_ph1established(const struct ph1handle *);
    130 
    131 extern void script_hook(struct ph1handle *, int);
    132 extern int script_env_append(char ***, int *, const char *, char *);
    133 extern int script_exec(char *, int, char * const *);
    134 
    135 void purge_remote(struct ph1handle *);
    136 void delete_spd(struct ph2handle *, u_int64_t);
    137 #ifdef INET6
    138 uint32_t setscopeid(struct sockaddr *, struct sockaddr *);
    139 #endif
    140 
    141 #endif /* _ISAKMP_VAR_H */
    142