xref: /freebsd-src/lib/libtacplus/taclib.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
12c195535SJohn Polstra /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni  *
41a61aeb8SPaul Traina  * Copyright (c) 1998, 2001, Juniper Networks, Inc.
52c195535SJohn Polstra  * All rights reserved.
62c195535SJohn Polstra  *
72c195535SJohn Polstra  * Redistribution and use in source and binary forms, with or without
82c195535SJohn Polstra  * modification, are permitted provided that the following conditions
92c195535SJohn Polstra  * are met:
102c195535SJohn Polstra  * 1. Redistributions of source code must retain the above copyright
112c195535SJohn Polstra  *    notice, this list of conditions and the following disclaimer.
122c195535SJohn Polstra  * 2. Redistributions in binary form must reproduce the above copyright
132c195535SJohn Polstra  *    notice, this list of conditions and the following disclaimer in the
142c195535SJohn Polstra  *    documentation and/or other materials provided with the distribution.
152c195535SJohn Polstra  *
162c195535SJohn Polstra  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
172c195535SJohn Polstra  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
182c195535SJohn Polstra  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
192c195535SJohn Polstra  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
202c195535SJohn Polstra  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
212c195535SJohn Polstra  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
222c195535SJohn Polstra  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
232c195535SJohn Polstra  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242c195535SJohn Polstra  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
252c195535SJohn Polstra  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
262c195535SJohn Polstra  * SUCH DAMAGE.
272c195535SJohn Polstra  */
282c195535SJohn Polstra 
292c195535SJohn Polstra #ifndef _TACLIB_H_
302c195535SJohn Polstra #define _TACLIB_H_
312c195535SJohn Polstra 
322c195535SJohn Polstra #include <sys/types.h>
332c195535SJohn Polstra 
342c195535SJohn Polstra struct tac_handle;
352c195535SJohn Polstra 
362c195535SJohn Polstra /* Flags for tac_add_server(). */
372c195535SJohn Polstra #define TAC_SRVR_SINGLE_CONNECT	0x04	/* Keep connection open for multiple
382c195535SJohn Polstra 					   sessions. */
392c195535SJohn Polstra 
402c195535SJohn Polstra /* Disassembly of tac_send_authen() return value. */
412c195535SJohn Polstra #define	TAC_AUTHEN_STATUS(s)	((s) & 0xff)
422c195535SJohn Polstra #define TAC_AUTHEN_NOECHO(s)	((s) & (1<<8))
432c195535SJohn Polstra 
441a61aeb8SPaul Traina /* Disassembly of tac_send_author() return value. */
451a61aeb8SPaul Traina #define	TAC_AUTHOR_STATUS(s)	((s) & 0xff)
461a61aeb8SPaul Traina #define TAC_AUTHEN_AV_COUNT(s)	(((s)>>8) & 0xff)
471a61aeb8SPaul Traina 
482c195535SJohn Polstra /* Privilege levels */
492c195535SJohn Polstra #define TAC_PRIV_LVL_MIN	0x00
502c195535SJohn Polstra #define TAC_PRIV_LVL_USER	0x01
512c195535SJohn Polstra #define TAC_PRIV_LVL_ROOT	0x0f
522c195535SJohn Polstra #define TAC_PRIV_LVL_MAX	0x0f
532c195535SJohn Polstra 
542c195535SJohn Polstra /* Authentication actions */
552c195535SJohn Polstra #define TAC_AUTHEN_LOGIN	0x01
562c195535SJohn Polstra #define TAC_AUTHEN_CHPASS	0x02
572c195535SJohn Polstra #define TAC_AUTHEN_SENDPASS	0x03
582c195535SJohn Polstra #define TAC_AUTHEN_SENDAUTH	0x04
592c195535SJohn Polstra 
602c195535SJohn Polstra /* Authentication types */
61*951beab1SDag-Erling Smørgrav #define TAC_AUTHEN_TYPE_NOT_SET	0x00
622c195535SJohn Polstra #define TAC_AUTHEN_TYPE_ASCII	0x01
632c195535SJohn Polstra #define TAC_AUTHEN_TYPE_PAP	0x02
642c195535SJohn Polstra #define TAC_AUTHEN_TYPE_CHAP	0x03
652c195535SJohn Polstra #define TAC_AUTHEN_TYPE_ARAP	0x04
662c195535SJohn Polstra #define TAC_AUTHEN_TYPE_MSCHAP	0x05
672c195535SJohn Polstra 
682c195535SJohn Polstra /* Authentication services */
692c195535SJohn Polstra #define TAC_AUTHEN_SVC_NONE	0x00
702c195535SJohn Polstra #define TAC_AUTHEN_SVC_LOGIN	0x01
712c195535SJohn Polstra #define TAC_AUTHEN_SVC_ENABLE	0x02
722c195535SJohn Polstra #define TAC_AUTHEN_SVC_PPP	0x03
732c195535SJohn Polstra #define TAC_AUTHEN_SVC_ARAP	0x04
742c195535SJohn Polstra #define TAC_AUTHEN_SVC_PT	0x05
752c195535SJohn Polstra #define TAC_AUTHEN_SVC_RCMD	0x06
762c195535SJohn Polstra #define TAC_AUTHEN_SVC_X25	0x07
772c195535SJohn Polstra #define TAC_AUTHEN_SVC_NASI	0x08
782c195535SJohn Polstra #define TAC_AUTHEN_SVC_FWPROXY	0x09
792c195535SJohn Polstra 
802c195535SJohn Polstra /* Authentication reply status codes */
812c195535SJohn Polstra #define TAC_AUTHEN_STATUS_PASS		0x01
822c195535SJohn Polstra #define TAC_AUTHEN_STATUS_FAIL		0x02
832c195535SJohn Polstra #define TAC_AUTHEN_STATUS_GETDATA	0x03
842c195535SJohn Polstra #define TAC_AUTHEN_STATUS_GETUSER	0x04
852c195535SJohn Polstra #define TAC_AUTHEN_STATUS_GETPASS	0x05
862c195535SJohn Polstra #define TAC_AUTHEN_STATUS_RESTART	0x06
872c195535SJohn Polstra #define TAC_AUTHEN_STATUS_ERROR		0x07
882c195535SJohn Polstra #define TAC_AUTHEN_STATUS_FOLLOW	0x21
892c195535SJohn Polstra 
901a61aeb8SPaul Traina /* Authorization authenticatication methods */
911a61aeb8SPaul Traina #define TAC_AUTHEN_METH_NOT_SET         0x00
921a61aeb8SPaul Traina #define TAC_AUTHEN_METH_NONE            0x01
931a61aeb8SPaul Traina #define TAC_AUTHEN_METH_KRB5            0x02
941a61aeb8SPaul Traina #define TAC_AUTHEN_METH_LINE            0x03
951a61aeb8SPaul Traina #define TAC_AUTHEN_METH_ENABLE          0x04
961a61aeb8SPaul Traina #define TAC_AUTHEN_METH_LOCAL           0x05
971a61aeb8SPaul Traina #define TAC_AUTHEN_METH_TACACSPLUS      0x06
981a61aeb8SPaul Traina #define TAC_AUTHEN_METH_RCMD            0x20
991a61aeb8SPaul Traina /* If adding more, see comments in protocol_version() in taclib.c */
1001a61aeb8SPaul Traina 
1011a61aeb8SPaul Traina /* Authorization status */
1021a61aeb8SPaul Traina #define TAC_AUTHOR_STATUS_PASS_ADD      0x01
1031a61aeb8SPaul Traina #define TAC_AUTHOR_STATUS_PASS_REPL     0x02
1041a61aeb8SPaul Traina #define TAC_AUTHOR_STATUS_FAIL          0x10
1051a61aeb8SPaul Traina #define TAC_AUTHOR_STATUS_ERROR         0x11
1061a61aeb8SPaul Traina 
107db3a20a5SShteryana Shopova /* Accounting actions */
108db3a20a5SShteryana Shopova #define TAC_ACCT_MORE			0x1
109db3a20a5SShteryana Shopova #define TAC_ACCT_START			0x2
110db3a20a5SShteryana Shopova #define TAC_ACCT_STOP			0x4
111db3a20a5SShteryana Shopova #define TAC_ACCT_WATCHDOG		0x8
112db3a20a5SShteryana Shopova 
113db3a20a5SShteryana Shopova /* Accounting status */
114db3a20a5SShteryana Shopova #define TAC_ACCT_STATUS_SUCCESS		0x1
115db3a20a5SShteryana Shopova #define TAC_ACCT_STATUS_ERROR		0x2
116db3a20a5SShteryana Shopova #define TAC_ACCT_STATUS_FOLLOW		0x21
117db3a20a5SShteryana Shopova 
1182c195535SJohn Polstra __BEGIN_DECLS
1192c195535SJohn Polstra int			 tac_add_server(struct tac_handle *,
1202c195535SJohn Polstra 			    const char *, int, const char *, int, int);
1212c195535SJohn Polstra void			 tac_close(struct tac_handle *);
1222c195535SJohn Polstra int			 tac_config(struct tac_handle *, const char *);
1232c195535SJohn Polstra int			 tac_create_authen(struct tac_handle *, int, int, int);
1242c195535SJohn Polstra void			*tac_get_data(struct tac_handle *, size_t *);
1252c195535SJohn Polstra char			*tac_get_msg(struct tac_handle *);
1262c195535SJohn Polstra struct tac_handle	*tac_open(void);
1272c195535SJohn Polstra int			 tac_send_authen(struct tac_handle *);
1282c195535SJohn Polstra int			 tac_set_data(struct tac_handle *,
1292c195535SJohn Polstra 			    const void *, size_t);
1302c195535SJohn Polstra int			 tac_set_msg(struct tac_handle *, const char *);
1312c195535SJohn Polstra int			 tac_set_port(struct tac_handle *, const char *);
1322c195535SJohn Polstra int			 tac_set_priv(struct tac_handle *, int);
1332c195535SJohn Polstra int			 tac_set_rem_addr(struct tac_handle *, const char *);
1342c195535SJohn Polstra int			 tac_set_user(struct tac_handle *, const char *);
1352c195535SJohn Polstra const char		*tac_strerror(struct tac_handle *);
1361a61aeb8SPaul Traina int			 tac_send_author(struct tac_handle *);
1371a61aeb8SPaul Traina int			 tac_create_author(struct tac_handle *, int, int, int);
1381a61aeb8SPaul Traina int			 tac_set_av(struct tac_handle *, u_int, const char *);
1391a61aeb8SPaul Traina char			*tac_get_av(struct tac_handle *, u_int);
1401a61aeb8SPaul Traina char			*tac_get_av_value(struct tac_handle *, const char *);
1411a61aeb8SPaul Traina void			 tac_clear_avs(struct tac_handle *);
142db3a20a5SShteryana Shopova int			 tac_create_acct(struct tac_handle *, int, int, int, int);
143db3a20a5SShteryana Shopova int			 tac_send_acct(struct tac_handle *);
1442c195535SJohn Polstra __END_DECLS
1452c195535SJohn Polstra 
1462c195535SJohn Polstra #endif /* _TACLIB_H_ */
147