xref: /openbsd/sbin/isakmpd/util.h (revision 4516ba27)
1 /* $OpenBSD: util.h,v 1.19 2004/05/23 16:14:22 deraadt 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  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /*
30  * This code was written under funding by Ericsson Radio Systems.
31  */
32 
33 #ifndef _UTIL_H_
34 #define _UTIL_H_
35 
36 #include <sys/types.h>
37 
38 extern int      allow_name_lookups;
39 extern int      regrand;
40 extern unsigned long seed;
41 
42 struct message;
43 struct sockaddr;
44 
45 extern int      check_file_secrecy(char *, size_t *);
46 extern int      check_file_secrecy_fd(int, char *, size_t *);
47 extern u_int16_t decode_16(u_int8_t *);
48 extern u_int32_t decode_32(u_int8_t *);
49 extern u_int64_t decode_64(u_int8_t *);
50 #if 0
51 extern void     decode_128(u_int8_t *, u_int8_t *);
52 #endif
53 extern void     encode_16(u_int8_t *, u_int16_t);
54 extern void     encode_32(u_int8_t *, u_int32_t);
55 extern void     encode_64(u_int8_t *, u_int64_t);
56 #if 0
57 extern void     encode_128(u_int8_t *, u_int8_t *);
58 #endif
59 extern u_int8_t *getrandom(u_int8_t *, size_t);
60 extern int      hex2raw(char *, u_int8_t *, size_t);
61 extern int      ones_test(const u_int8_t *, size_t);
62 extern int      sockaddr2text(struct sockaddr *, char **, int);
63 extern u_int8_t *sockaddr_addrdata(struct sockaddr *);
64 extern int      sockaddr_addrlen(struct sockaddr *);
65 extern in_port_t sockaddr_port(struct sockaddr *);
66 extern int      text2sockaddr(char *, char *, struct sockaddr **);
67 extern void     util_ntoa(char **, int, u_int8_t *);
68 extern int      zero_test(const u_int8_t *, size_t);
69 
70 #endif				/* _UTIL_H_ */
71