summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cmd-inet/common/conflib.h
blob: a6ad92e964393d5c9ef0352548fef93e93ae1039 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _CONFLIB_H
#define	_CONFLIB_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * conflib.h -- Prototypes and defines for conflib.c
 * WARNING:  This code assumes that an int is 32 bits.
 */

#include <netinet/in.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Static lengths of values. */
#define	MAX_LABEL_LEN 256
#define	MAX_SECTION_LEN 256
#define	MAX_VALUE_LEN 256
#define	MAX_FILENAME_LEN 256

/* Error string readable by external programs */
#define	ERROR_SUBSTRING_LEN 256
#define	ERROR_STRING_LEN (MAX_FILENAME_LEN + ERROR_SUBSTRING_LEN)
extern char ErrorString[];

/*
 * Check if OS has defined true or false.  This code is portable between
 * several OSs.
 */
#ifndef TRUE
#define	TRUE 1
#define	FALSE 0
#endif


/* these are shared between mipagent and mipagentconfig */

/* IPsec flags - what's in place to protect datagrams to/from an agent peer. */
#define	IPSEC_REQUEST_AH		0x01	/* regRequest using AH */
#define	IPSEC_REQUEST_ESP		0x02	/* regRequest using ESP */
#define	IPSEC_REPLY_AH			0x04	/* regReply using AH */
#define	IPSEC_REPLY_ESP			0x08	/* regReply using ESP */
#define	IPSEC_TUNNEL_AH			0x10	/* forward tunnel using AH */
#define	IPSEC_TUNNEL_ESP		0x20	/* forward tunnel using ESP */
#define	IPSEC_REVERSE_TUNNEL_AH		0x40	/* reverse tunnel using AH */
#define	IPSEC_REVERSE_TUNNEL_ESP	0x80	/* reverse tunnel using ESP */

/* useful combinations */
#define	IPSEC_REQUEST_BOTH	(IPSEC_REQUEST_AH | IPSEC_REQUEST_ESP)
#define	IPSEC_REPLY_BOTH	(IPSEC_REPLY_AH | IPSEC_REPLY_ESP)
#define	IPSEC_TUNNEL_BOTH	(IPSEC_TUNNEL_AH | IPSEC_TUNNEL_ESP)
#define	IPSEC_REVERSE_TUNNEL_BOTH \
			(IPSEC_REVERSE_TUNNEL_AH | IPSEC_REVERSE_TUNNEL_ESP)

/* useful for checking if there's a policy that should be invoked */
#define	IPSEC_REQUEST_ANY(x)	((x) & (IPSEC_REQUEST_BOTH))
#define	IPSEC_REPLY_ANY(x)	((x) & (IPSEC_REPLY_BOTH))
#define	IPSEC_TUNNEL_ANY(x)	((x) & (IPSEC_TUNNEL_BOTH))
#define	IPSEC_REVERSE_TUNNEL_ANY(x) ((x) & (IPSEC_REVERSE_TUNNEL_BOTH))

/* useful for checking when user is requesting something that's not offered */
#define	IPSEC_ANY_AH(x)	((x) & (IPSEC_REQUEST_AH |\
				IPSEC_REPLY_AH |\
				IPSEC_TUNNEL_AH |\
				IPSEC_REVERSE_TUNNEL_AH))

#define	IPSEC_ANY_ESP(x)	((x) & (IPSEC_REQUEST_ESP |\
					IPSEC_REPLY_ESP |\
					IPSEC_TUNNEL_ESP |\
					IPSEC_REVERSE_TUNNEL_ESP))

/* how policies are deliniated in CONF_FILE_NAME */
#define	IPSP_SEPARATOR	":"

/* these functions are necessary to share IPsec functionality */
int parseIPsecProps(char *, ipsec_req_t *);
boolean_t isIPsecPolicyValid(char *, ipsec_req_t *);

/* These functions mimic the Windows(tm) equivilants */
int WritePrivateProfileString(char *, char *, char *, char *);
int WritePrivateProfileInt(char *, char *, int, char *);
int GetPrivateProfileString(char *, char *, char *, char *, int, char *);
int GetPrivateProfileInt(char *, char *, int, char *);

/* These functions were necessary for extra usability */
char *IniListSections(char *, int *, int *);
int DeletePrivateProfileLabel(char *, char *, char *);
int DeletePrivateProfileSection(char *, char *);

#ifdef __cplusplus
}
#endif

#endif /* _CONFLIB_H */