xref: /illumos-gate/usr/src/cmd/tsol/tnd/tnd.h (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_TND_H_
28 #define	_TND_H_
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * TSOL Messages have the following header
36  */
37 
38 typedef struct {
39 	uchar_t tnd_version; /* protocol version number */
40 	uchar_t tnd_message; /* message type. */
41 	uchar_t tnd_error_code; /* Error return for a reply. */
42 } tsol_tnd_hdr_t;
43 
44 /*
45  * TND TSOL messages
46  */
47 
48 #define	TND_DEBUG_REQ	127
49 #define	TND_POLL_REQ	128
50 #define	TND_REPLY	129
51 
52 /*
53  * TND errors
54  */
55 
56 #define	TND_SUCCESS 1
57 #define	TND_FAIL_LOG	2
58 #define	TND_FAIL_DEBUG_LEVEL 4
59 #define	TND_NOT_SUPPORTED 8
60 #define	TND_DENIED	16
61 
62 /* TND door files */
63 #define	TND_DOORFILE	"/etc/.tnd_door"
64 #define	TND_DOORFILE2	"/etc/.tnd_door2"
65 
66 /*
67  * tnd request messages have the following format
68  */
69 
70 struct tsol_tnd_msg {
71 	tsol_tnd_hdr_t ttm_hdr; /* message header */
72 	uint_t ttm_int; /* debug level or poll interval(in seconds) */
73 };
74 
75 #define	TNDLOG "/var/tsol/tndlog"
76 #define	MAX_TND_DEBUG 2
77 #define	DEF_TND_DEBUG 1
78 
79 #define	HNAMELEN 64
80 
81 /*
82  * polling default (seconds)
83  */
84 #define	TND_DEF_POLL_TIME 1800 /* 30 minutes */
85 
86 /* tnrhtp_c cache structure */
87 struct tnd_tnrhtp_c {
88 	tsol_tpent_t tp_ent;
89 	struct tnd_tnrhtp_c *tp_next;
90 };
91 
92 /* tnrhdb_c cache structure */
93 typedef struct tnd_tnrhdb_c {
94 	tsol_rhent_t	rh_ent;
95 	int		visited;	/* Flag to handle deletions */
96 	struct tnd_tnrhdb_c	*rh_next;
97 } tnd_tnrhdb_t;
98 
99 /* tnrhdb lookup table */
100 typedef struct tnrh_tlb {
101 	in_addr_t	addr;
102 	char		template_name[TNTNAMSIZ];
103 	int		reload;		/* flag to reload/delete */
104 	int		masklen_used;	/* Which mask did we use */
105 	tnd_tnrhdb_t	*src;		/* Which table entry is our source */
106 	struct tnrh_tlb	*next;		/* Next in the hash chain */
107 } tnrh_tlb_t;
108 
109 /* tnrhdb IPv6 address lookup table */
110 typedef struct tnrh_tlb_ipv6 {
111 	in6_addr_t	addr;
112 	char		template_name[TNTNAMSIZ];
113 	int		reload;		/* flag to reload/delete */
114 	int		masklen_used;	/* Which mask did we use */
115 	tnd_tnrhdb_t	*src;		/* Which table entry is our source */
116 	struct tnrh_tlb_ipv6	*next;	/* Next in the hash chain */
117 } tnrh_tlb_ipv6_t;
118 
119 /* Clients of tnd can use this structure */
120 typedef struct {
121 	struct tsol_rhent rh;
122 	union {
123 		in_addr_t _v4addr;
124 		in6_addr_t _v6addr;
125 	} _addr_un;
126 	sa_family_t af;
127 	int flag;	/* flag to reload/delete */
128 } tndclnt_arg_t;
129 #define	v4addr _addr_un._v4addr
130 #define	v6addr _addr_un._v6addr
131 
132 #ifdef	__cplusplus
133 }
134 #endif
135 
136 #endif	/* _TND_H_ */
137