1c91307af2622f6625525f3c1f9c954376df950adChia-chi Yeh/*	$NetBSD: sainfo.h,v 1.5 2006/10/03 08:01:56 vanhu Exp $	*/
20a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
30a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang/* Id: sainfo.h,v 1.5 2006/07/09 17:19:38 manubsd Exp */
40a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
50a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang/*
60a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
70a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * All rights reserved.
80a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *
90a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * Redistribution and use in source and binary forms, with or without
100a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * modification, are permitted provided that the following conditions
110a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * are met:
120a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * 1. Redistributions of source code must retain the above copyright
130a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *    notice, this list of conditions and the following disclaimer.
140a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * 2. Redistributions in binary form must reproduce the above copyright
150a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *    notice, this list of conditions and the following disclaimer in the
160a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *    documentation and/or other materials provided with the distribution.
170a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * 3. Neither the name of the project nor the names of its contributors
180a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *    may be used to endorse or promote products derived from this software
190a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *    without specific prior written permission.
200a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang *
210a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
220a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
230a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
240a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
250a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
260a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
270a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
280a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
290a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
300a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
310a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang * SUCH DAMAGE.
320a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang */
330a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
340a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang#ifndef _SAINFO_H
350a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang#define _SAINFO_H
360a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
370a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang#include <sys/queue.h>
380a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
390a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang/* SA info */
400a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangstruct sainfo {
410a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	vchar_t *idsrc;
420a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	vchar_t *iddst;
430a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang		/*
440a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang		 * idsrc and iddst are constructed body of ID payload.
450a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang		 * that is (struct ipsecdoi_id_b) + ID value.
460a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang		 * If idsrc == NULL, that is anonymous entry.
470a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang		 */
480a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
490a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang#ifdef ENABLE_HYBRID
500a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	vchar_t *group;
510a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang#endif
520a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
530a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	time_t lifetime;
540a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	int lifebyte;
550a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	int pfs_group;		/* only use when pfs is required. */
560a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	vchar_t *id_i;		/* identifier of the authorized initiator */
570a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	struct sainfoalg *algs[MAXALGCLASS];
580a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
59c91307af2622f6625525f3c1f9c954376df950adChia-chi Yeh	int remoteid;
600a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
610a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	LIST_ENTRY(sainfo) chain;
620a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang};
630a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
640a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang/* algorithm type */
650a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangstruct sainfoalg {
660a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	int alg;
670a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	int encklen;			/* key length if encryption algorithm */
680a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang	struct sainfoalg *next;
690a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang};
700a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
710a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern struct sainfo *getsainfo __P((const vchar_t *,
72c91307af2622f6625525f3c1f9c954376df950adChia-chi Yeh	const vchar_t *, const vchar_t *, int));
730a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern struct sainfo *newsainfo __P((void));
740a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void delsainfo __P((struct sainfo *));
750a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void inssainfo __P((struct sainfo *));
760a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void remsainfo __P((struct sainfo *));
770a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void flushsainfo __P((void));
780a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void initsainfo __P((void));
790a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern struct sainfoalg *newsainfoalg __P((void));
800a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void delsainfoalg __P((struct sainfoalg *));
810a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void inssainfoalg __P((struct sainfoalg **, struct sainfoalg *));
820a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern const char * sainfo2str __P((const struct sainfo *));
830a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
84c91307af2622f6625525f3c1f9c954376df950adChia-chi Yehextern void save_sainfotree __P((void));
85c91307af2622f6625525f3c1f9c954376df950adChia-chi Yehextern void save_sainfotree_flush __P((void));
860a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wangextern void save_sainfotree_restore __P((void));
870a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang
880a1907d434839af6a9cb6329bbde60b237bf53dcChung-yih Wang#endif /* _SAINFO_H */
89