xref: /openbsd-src/sbin/isakmpd/util.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: util.h,v 1.11 2001/07/05 12:36:59 ho Exp $	*/
2 /*	$EOM: util.h,v 1.10 2000/10/24 13:33:39 niklas Exp $	*/
3 
4 /*
5  * Copyright (c) 1998 Niklas Hallqvist.  All rights reserved.
6  * Copyright (c) 2001 H�kan Olsson.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by Ericsson Radio Systems.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * This code was written under funding by Ericsson Radio Systems.
36  */
37 
38 #ifndef _UTIL_H_
39 #define _UTIL_H_
40 
41 #include <sys/types.h>
42 
43 #define ROUNDUP_32(x) (((x) + 3) & ~4)
44 
45 extern int allow_name_lookups;
46 extern int regrand;
47 extern unsigned long seed;
48 
49 struct message;
50 struct sockaddr;
51 
52 extern u_int16_t decode_16 (u_int8_t *);
53 extern u_int32_t decode_32 (u_int8_t *);
54 extern u_int64_t decode_64 (u_int8_t *);
55 #if 0
56 extern void decode_128 (u_int8_t *, u_int8_t *);
57 #endif
58 extern void encode_16 (u_int8_t *, u_int16_t);
59 extern void encode_32 (u_int8_t *, u_int32_t);
60 extern void encode_64 (u_int8_t *, u_int64_t);
61 #if 0
62 extern void encode_128 (u_int8_t *, u_int8_t *);
63 #endif
64 extern u_int8_t *getrandom (u_int8_t *, size_t);
65 extern int hex2raw (char *, u_int8_t *, size_t);
66 extern int sockaddr2text (struct sockaddr *, char **, int);
67 extern void util_ntoa (char **, int, u_int8_t *);
68 extern int text2sockaddr (char *, char *, struct sockaddr **);
69 extern int sockaddr_len (struct sockaddr *);
70 extern u_int8_t *sockaddr_data (struct sockaddr *);
71 extern int zero_test (const u_int8_t *, size_t);
72 extern int ones_test (const u_int8_t *, size_t);
73 extern int check_file_secrecy (char *, off_t *);
74 
75 #endif /* _UTIL_H_ */
76