http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / userapps / opensource / ipsec-tools / src / racoon / remoteconf.h
1 /* $Id: remoteconf.h,v 1.1.1.1 2006/05/18 10:47:25 michaelc Exp $ */
2
3 /*
4  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5  * All rights reserved.
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the project nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  * 
19  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31
32 #ifndef _REMOTECONF_H
33 #define _REMOTECONF_H
34
35 /* remote configuration */
36
37 #include <sys/queue.h>
38 #include "genlist.h"
39
40 struct proposalspec;
41
42 struct etypes {
43         int type;
44         struct etypes *next;
45 };
46
47 /* Script hooks */
48 #define SCRIPT_PHASE1_UP        0
49 #define SCRIPT_PHASE1_DOWN      1
50 #define SCRIPT_MAX              1
51 char *script_names[SCRIPT_MAX + 1];
52
53 struct remoteconf {
54         struct sockaddr *remote;        /* remote IP address */
55                                         /* if family is AF_UNSPEC, that is
56                                          * for anonymous configuration. */
57
58         struct etypes *etypes;          /* exchange type list. the head
59                                          * is a type to be sent first. */
60         int doitype;                    /* doi type */
61         int sittype;                    /* situation type */
62
63         int idvtype;                    /* my identifier type */
64         vchar_t *idv;                   /* my identifier */
65         vchar_t *key;                   /* my pre-shared key */
66         struct genlist *idvl_p;         /* peer's identifiers list */
67
68         int certtype;                   /* certificate type if need */
69         char *mycertfile;               /* file name of my certificate */
70         char *myprivfile;               /* file name of my private key file */
71         char *peerscertfile;            /* file name of peer's certifcate */
72         int getcert_method;             /* the way to get peer's certificate */
73         int cacerttype;                 /* CA type is needed */
74         char *cacertfile;               /* file name of CA */
75         int getcacert_method;           /* the way to get the CA */
76         int send_cert;                  /* send to CERT or not */
77         int send_cr;                    /* send to CR or not */
78         int verify_cert;                /* verify a CERT strictly */
79         int verify_identifier;          /* vefify the peer's identifier */
80         int nonce_size;                 /* the number of bytes of nonce */
81         int passive;                    /* never initiate */
82         int ike_frag;                   /* IKE fragmentation */
83         int mode_cfg;                   /* Gets config through mode config */
84         int support_proxy;              /* support mip6/proxy */
85         int gen_policy;                 /* generate policy if no policy found */
86         int ini_contact;                /* initial contact */
87         int pcheck_level;               /* level of propocl checking */
88         int nat_traversal;              /* NAT-Traversal */
89         vchar_t *script[SCRIPT_MAX + 1];/* Shell script hooks */
90         int dh_group;                   /* use it when only aggressive mode */
91         struct dhgroup *dhgrp;          /* use it when only aggressive mode */
92                                         /* above two can't be defined by user*/
93
94         int retry_counter;              /* times to retry. */
95         int retry_interval;             /* interval each retry. */
96                                 /* above 2 values are copied from localconf. */
97
98         int dpd;                                /* Negociate DPD support ? */
99         int dpd_retry;                  /* in seconds */
100         int dpd_interval;               /* in seconds */
101         int dpd_maxfails; 
102
103         struct isakmpsa *proposal;      /* proposal list */
104         struct remoteconf *inherited_from;      /* the original rmconf 
105                                                    from which this one 
106                                                    was inherited */
107         struct proposalspec *prhead;
108
109         struct genlist  *rsa_private,   /* lists of PlainRSA keys to use */
110                         *rsa_public;
111         TAILQ_ENTRY(remoteconf) chain;  /* next remote conf */
112 };
113
114 struct dhgroup;
115
116 /* ISAKMP SA specification */
117 struct isakmpsa {
118         int prop_no;
119         int trns_no;
120         time_t lifetime;
121         size_t lifebyte;
122         int enctype;
123         int encklen;
124         int authmethod;
125         int hashtype;
126         int vendorid;
127 #ifdef HAVE_GSSAPI
128         vchar_t *gssid;
129 #endif
130         int dh_group;                   /* don't use it if aggressive mode */
131         struct dhgroup *dhgrp;          /* don't use it if aggressive mode */
132
133         struct isakmpsa *next;          /* next transform */
134         struct remoteconf *rmconf;      /* backpointer to remoteconf */
135 };
136
137 struct idspec {
138         int idtype;                     /* identifier type */
139         vchar_t *id;                    /* identifier */
140 };
141
142 typedef struct remoteconf * (rmconf_func_t)(struct remoteconf *rmconf, void *data);
143
144 extern struct remoteconf *getrmconf __P((struct sockaddr *));
145 extern struct remoteconf *getrmconf_strict
146         __P((struct sockaddr *remote, int allow_anon));
147 extern struct remoteconf *copyrmconf __P((struct sockaddr *));
148 extern struct remoteconf *newrmconf __P((void));
149 extern struct remoteconf *duprmconf __P((struct remoteconf *));
150 extern void delrmconf __P((struct remoteconf *));
151 extern void delisakmpsa __P((struct isakmpsa *));
152 extern void deletypes __P((struct etypes *));
153 extern struct etypes * dupetypes __P((struct etypes *));
154 extern void insrmconf __P((struct remoteconf *));
155 extern void remrmconf __P((struct remoteconf *));
156 extern void flushrmconf __P((void));
157 extern void initrmconf __P((void));
158 extern struct etypes *check_etypeok
159         __P((struct remoteconf *, u_int8_t));
160 extern struct remoteconf *foreachrmconf __P((rmconf_func_t rmconf_func,
161                                              void *data));
162
163 extern struct isakmpsa *newisakmpsa __P((void));
164 extern void insisakmpsa __P((struct isakmpsa *, struct remoteconf *));
165
166 extern void dumprmconf __P((void));
167
168 extern struct idspec *newidspec __P((void));
169
170 #endif /* _REMOTECONF_H */