xref: /freebsd/lib/libtacplus/taclib.h (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 1998, 2001, Juniper Networks, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  *	$FreeBSD$
29  */
30 
31 #ifndef _TACLIB_H_
32 #define _TACLIB_H_
33 
34 #include <sys/types.h>
35 
36 struct tac_handle;
37 
38 /* Flags for tac_add_server(). */
39 #define TAC_SRVR_SINGLE_CONNECT	0x04	/* Keep connection open for multiple
40 					   sessions. */
41 
42 /* Disassembly of tac_send_authen() return value. */
43 #define	TAC_AUTHEN_STATUS(s)	((s) & 0xff)
44 #define TAC_AUTHEN_NOECHO(s)	((s) & (1<<8))
45 
46 /* Disassembly of tac_send_author() return value. */
47 #define	TAC_AUTHOR_STATUS(s)	((s) & 0xff)
48 #define TAC_AUTHEN_AV_COUNT(s)	(((s)>>8) & 0xff)
49 
50 /* Privilege levels */
51 #define TAC_PRIV_LVL_MIN	0x00
52 #define TAC_PRIV_LVL_USER	0x01
53 #define TAC_PRIV_LVL_ROOT	0x0f
54 #define TAC_PRIV_LVL_MAX	0x0f
55 
56 /* Authentication actions */
57 #define TAC_AUTHEN_LOGIN	0x01
58 #define TAC_AUTHEN_CHPASS	0x02
59 #define TAC_AUTHEN_SENDPASS	0x03
60 #define TAC_AUTHEN_SENDAUTH	0x04
61 
62 /* Authentication types */
63 #define TAC_AUTHEN_TYPE_ASCII	0x01
64 #define TAC_AUTHEN_TYPE_PAP	0x02
65 #define TAC_AUTHEN_TYPE_CHAP	0x03
66 #define TAC_AUTHEN_TYPE_ARAP	0x04
67 #define TAC_AUTHEN_TYPE_MSCHAP	0x05
68 
69 /* Authentication services */
70 #define TAC_AUTHEN_SVC_NONE	0x00
71 #define TAC_AUTHEN_SVC_LOGIN	0x01
72 #define TAC_AUTHEN_SVC_ENABLE	0x02
73 #define TAC_AUTHEN_SVC_PPP	0x03
74 #define TAC_AUTHEN_SVC_ARAP	0x04
75 #define TAC_AUTHEN_SVC_PT	0x05
76 #define TAC_AUTHEN_SVC_RCMD	0x06
77 #define TAC_AUTHEN_SVC_X25	0x07
78 #define TAC_AUTHEN_SVC_NASI	0x08
79 #define TAC_AUTHEN_SVC_FWPROXY	0x09
80 
81 /* Authentication reply status codes */
82 #define TAC_AUTHEN_STATUS_PASS		0x01
83 #define TAC_AUTHEN_STATUS_FAIL		0x02
84 #define TAC_AUTHEN_STATUS_GETDATA	0x03
85 #define TAC_AUTHEN_STATUS_GETUSER	0x04
86 #define TAC_AUTHEN_STATUS_GETPASS	0x05
87 #define TAC_AUTHEN_STATUS_RESTART	0x06
88 #define TAC_AUTHEN_STATUS_ERROR		0x07
89 #define TAC_AUTHEN_STATUS_FOLLOW	0x21
90 
91 /* Authorization authenticatication methods */
92 #define TAC_AUTHEN_METH_NOT_SET         0x00
93 #define TAC_AUTHEN_METH_NONE            0x01
94 #define TAC_AUTHEN_METH_KRB5            0x02
95 #define TAC_AUTHEN_METH_LINE            0x03
96 #define TAC_AUTHEN_METH_ENABLE          0x04
97 #define TAC_AUTHEN_METH_LOCAL           0x05
98 #define TAC_AUTHEN_METH_TACACSPLUS      0x06
99 #define TAC_AUTHEN_METH_RCMD            0x20
100 /* If adding more, see comments in protocol_version() in taclib.c */
101 
102 /* Authorization status */
103 #define TAC_AUTHOR_STATUS_PASS_ADD      0x01
104 #define TAC_AUTHOR_STATUS_PASS_REPL     0x02
105 #define TAC_AUTHOR_STATUS_FAIL          0x10
106 #define TAC_AUTHOR_STATUS_ERROR         0x11
107 
108 /* Accounting actions */
109 #define TAC_ACCT_MORE			0x1
110 #define TAC_ACCT_START			0x2
111 #define TAC_ACCT_STOP			0x4
112 #define TAC_ACCT_WATCHDOG		0x8
113 
114 /* Accounting status */
115 #define TAC_ACCT_STATUS_SUCCESS		0x1
116 #define TAC_ACCT_STATUS_ERROR		0x2
117 #define TAC_ACCT_STATUS_FOLLOW		0x21
118 
119 __BEGIN_DECLS
120 int			 tac_add_server(struct tac_handle *,
121 			    const char *, int, const char *, int, int);
122 void			 tac_close(struct tac_handle *);
123 int			 tac_config(struct tac_handle *, const char *);
124 int			 tac_create_authen(struct tac_handle *, int, int, int);
125 void			*tac_get_data(struct tac_handle *, size_t *);
126 char			*tac_get_msg(struct tac_handle *);
127 struct tac_handle	*tac_open(void);
128 int			 tac_send_authen(struct tac_handle *);
129 int			 tac_set_data(struct tac_handle *,
130 			    const void *, size_t);
131 int			 tac_set_msg(struct tac_handle *, const char *);
132 int			 tac_set_port(struct tac_handle *, const char *);
133 int			 tac_set_priv(struct tac_handle *, int);
134 int			 tac_set_rem_addr(struct tac_handle *, const char *);
135 int			 tac_set_user(struct tac_handle *, const char *);
136 const char		*tac_strerror(struct tac_handle *);
137 int			 tac_send_author(struct tac_handle *);
138 int			 tac_create_author(struct tac_handle *, int, int, int);
139 int			 tac_set_av(struct tac_handle *, u_int, const char *);
140 char			*tac_get_av(struct tac_handle *, u_int);
141 char			*tac_get_av_value(struct tac_handle *, const char *);
142 void			 tac_clear_avs(struct tac_handle *);
143 int			 tac_create_acct(struct tac_handle *, int, int, int, int);
144 int			 tac_send_acct(struct tac_handle *);
145 __END_DECLS
146 
147 #endif /* _TACLIB_H_ */
148