xref: /titanic_52/usr/src/cmd/tsol/tnd/tnd.h (revision 940d71d237794874e18a0eb72f6564821a823517)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * TSOL Messages have the following header
38  */
39 
40 typedef struct {
41 	uchar_t tnd_version; /* protocol version number */
42 	uchar_t tnd_message; /* message type. */
43 	uchar_t tnd_error_code; /* Error return for a reply. */
44 } tsol_tnd_hdr_t;
45 
46 /*
47  * TND TSOL messages
48  */
49 
50 #define	TND_DEBUG_REQ	127
51 #define	TND_POLL_REQ	128
52 #define	TND_REPLY	129
53 
54 /*
55  * TND errors
56  */
57 
58 #define	TND_SUCCESS 1
59 #define	TND_FAIL_LOG	2
60 #define	TND_FAIL_DEBUG_LEVEL 4
61 #define	TND_NOT_SUPPORTED 8
62 #define	TND_DENIED	16
63 
64 /* TND door files */
65 #define	TND_DOORFILE	"/etc/.tnd_door"
66 #define	TND_DOORFILE2	"/etc/.tnd_door2"
67 
68 /*
69  * tnd request messages have the following format
70  */
71 
72 struct tsol_tnd_msg {
73 	tsol_tnd_hdr_t ttm_hdr; /* message header */
74 	uint_t ttm_int; /* debug level or poll interval(in seconds) */
75 };
76 
77 #define	TNDLOG "/var/tsol/tndlog"
78 #define	MAX_TND_DEBUG 2
79 #define	DEF_TND_DEBUG 1
80 
81 #define	HNAMELEN 64
82 
83 /*
84  * polling default (seconds)
85  */
86 #define	TND_DEF_POLL_TIME 1800 /* 30 minutes */
87 
88 /* tnrhtp_c cache structure */
89 struct tnd_tnrhtp_c {
90 	tsol_tpent_t tp_ent;
91 	struct tnd_tnrhtp_c *tp_next;
92 };
93 
94 /* tnrhdb_c cache structure */
95 typedef struct tnd_tnrhdb_c {
96 	tsol_rhent_t	rh_ent;
97 	int		visited;	/* Flag to handle deletions */
98 	struct tnd_tnrhdb_c	*rh_next;
99 } tnd_tnrhdb_t;
100 
101 /* tnrhdb lookup table */
102 typedef struct tnrh_tlb {
103 	in_addr_t	addr;
104 	char		template_name[TNTNAMSIZ];
105 	int		reload;		/* flag to reload/delete */
106 	int		masklen_used;	/* Which mask did we use */
107 	tnd_tnrhdb_t	*src;		/* Which table entry is our source */
108 	struct tnrh_tlb	*next;		/* Next in the hash chain */
109 } tnrh_tlb_t;
110 
111 /* tnrhdb IPv6 address lookup table */
112 typedef struct tnrh_tlb_ipv6 {
113 	in6_addr_t	addr;
114 	char		template_name[TNTNAMSIZ];
115 	int		reload;		/* flag to reload/delete */
116 	int		masklen_used;	/* Which mask did we use */
117 	tnd_tnrhdb_t	*src;		/* Which table entry is our source */
118 	struct tnrh_tlb_ipv6	*next;	/* Next in the hash chain */
119 } tnrh_tlb_ipv6_t;
120 
121 /* Clients of tnd can use this structure */
122 typedef struct {
123 	struct tsol_rhent rh;
124 	union {
125 		in_addr_t _v4addr;
126 		in6_addr_t _v6addr;
127 	} _addr_un;
128 	sa_family_t af;
129 	int flag;	/* flag to reload/delete */
130 } tndclnt_arg_t;
131 #define	v4addr _addr_un._v4addr
132 #define	v6addr _addr_un._v6addr
133 
134 #ifdef	__cplusplus
135 }
136 #endif
137 
138 #endif	/* _TND_H_ */
139