taclib.h revision 200399
1218885Sdim/*- 2218885Sdim * Copyright (c) 1998, 2001, Juniper Networks, Inc. 3218885Sdim * All rights reserved. 4218885Sdim * 5218885Sdim * Redistribution and use in source and binary forms, with or without 6218885Sdim * modification, are permitted provided that the following conditions 7218885Sdim * are met: 8218885Sdim * 1. Redistributions of source code must retain the above copyright 9218885Sdim * notice, this list of conditions and the following disclaimer. 10218885Sdim * 2. Redistributions in binary form must reproduce the above copyright 11218885Sdim * notice, this list of conditions and the following disclaimer in the 12218885Sdim * documentation and/or other materials provided with the distribution. 13218885Sdim * 14218885Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15218885Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16249423Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17218885Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18221345Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19221345Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20218885Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21249423Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22218885Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23218885Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24218885Sdim * SUCH DAMAGE. 25218885Sdim * 26218885Sdim * $FreeBSD: head/lib/libtacplus/taclib.h 200399 2009-12-11 07:53:44Z syrinx $ 27218885Sdim */ 28218885Sdim 29234353Sdim#ifndef _TACLIB_H_ 30249423Sdim#define _TACLIB_H_ 31218885Sdim 32263508Sdim#include <sys/types.h> 33218885Sdim 34218885Sdimstruct tac_handle; 35218885Sdim 36218885Sdim/* Flags for tac_add_server(). */ 37218885Sdim#define TAC_SRVR_SINGLE_CONNECT 0x04 /* Keep connection open for multiple 38249423Sdim sessions. */ 39249423Sdim 40226633Sdim/* Disassembly of tac_send_authen() return value. */ 41218885Sdim#define TAC_AUTHEN_STATUS(s) ((s) & 0xff) 42218885Sdim#define TAC_AUTHEN_NOECHO(s) ((s) & (1<<8)) 43249423Sdim 44218885Sdim/* Disassembly of tac_send_author() return value. */ 45219077Sdim#define TAC_AUTHOR_STATUS(s) ((s) & 0xff) 46219077Sdim#define TAC_AUTHEN_AV_COUNT(s) (((s)>>8) & 0xff) 47218885Sdim 48218885Sdim/* Privilege levels */ 49218885Sdim#define TAC_PRIV_LVL_MIN 0x00 50218885Sdim#define TAC_PRIV_LVL_USER 0x01 51218885Sdim#define TAC_PRIV_LVL_ROOT 0x0f 52218885Sdim#define TAC_PRIV_LVL_MAX 0x0f 53226633Sdim 54226633Sdim/* Authentication actions */ 55226633Sdim#define TAC_AUTHEN_LOGIN 0x01 56226633Sdim#define TAC_AUTHEN_CHPASS 0x02 57226633Sdim#define TAC_AUTHEN_SENDPASS 0x03 58226633Sdim#define TAC_AUTHEN_SENDAUTH 0x04 59226633Sdim 60226633Sdim/* Authentication types */ 61226633Sdim#define TAC_AUTHEN_TYPE_ASCII 0x01 62218885Sdim#define TAC_AUTHEN_TYPE_PAP 0x02 63218885Sdim#define TAC_AUTHEN_TYPE_CHAP 0x03 64218885Sdim#define TAC_AUTHEN_TYPE_ARAP 0x04 65218885Sdim#define TAC_AUTHEN_TYPE_MSCHAP 0x05 66221345Sdim 67221345Sdim/* Authentication services */ 68221345Sdim#define TAC_AUTHEN_SVC_NONE 0x00 69221345Sdim#define TAC_AUTHEN_SVC_LOGIN 0x01 70218885Sdim#define TAC_AUTHEN_SVC_ENABLE 0x02 71218885Sdim#define TAC_AUTHEN_SVC_PPP 0x03 72218885Sdim#define TAC_AUTHEN_SVC_ARAP 0x04 73218885Sdim#define TAC_AUTHEN_SVC_PT 0x05 74218885Sdim#define TAC_AUTHEN_SVC_RCMD 0x06 75263508Sdim#define TAC_AUTHEN_SVC_X25 0x07 76218885Sdim#define TAC_AUTHEN_SVC_NASI 0x08 77218885Sdim#define TAC_AUTHEN_SVC_FWPROXY 0x09 78218885Sdim 79218885Sdim/* Authentication reply status codes */ 80223017Sdim#define TAC_AUTHEN_STATUS_PASS 0x01 81218885Sdim#define TAC_AUTHEN_STATUS_FAIL 0x02 82218885Sdim#define TAC_AUTHEN_STATUS_GETDATA 0x03 83251662Sdim#define TAC_AUTHEN_STATUS_GETUSER 0x04 84219077Sdim#define TAC_AUTHEN_STATUS_GETPASS 0x05 85224145Sdim#define TAC_AUTHEN_STATUS_RESTART 0x06 86218885Sdim#define TAC_AUTHEN_STATUS_ERROR 0x07 87221345Sdim#define TAC_AUTHEN_STATUS_FOLLOW 0x21 88221345Sdim 89221345Sdim/* Authorization authenticatication methods */ 90221345Sdim#define TAC_AUTHEN_METH_NOT_SET 0x00 91221345Sdim#define TAC_AUTHEN_METH_NONE 0x01 92221345Sdim#define TAC_AUTHEN_METH_KRB5 0x02 93221345Sdim#define TAC_AUTHEN_METH_LINE 0x03 94221345Sdim#define TAC_AUTHEN_METH_ENABLE 0x04 95221345Sdim#define TAC_AUTHEN_METH_LOCAL 0x05 96221345Sdim#define TAC_AUTHEN_METH_TACACSPLUS 0x06 97221345Sdim#define TAC_AUTHEN_METH_RCMD 0x20 98221345Sdim/* If adding more, see comments in protocol_version() in taclib.c */ 99221345Sdim 100221345Sdim/* Authorization status */ 101226633Sdim#define TAC_AUTHOR_STATUS_PASS_ADD 0x01 102226633Sdim#define TAC_AUTHOR_STATUS_PASS_REPL 0x02 103226633Sdim#define TAC_AUTHOR_STATUS_FAIL 0x10 104226633Sdim#define TAC_AUTHOR_STATUS_ERROR 0x11 105226633Sdim 106226633Sdim/* Accounting actions */ 107226633Sdim#define TAC_ACCT_MORE 0x1 108226633Sdim#define TAC_ACCT_START 0x2 109226633Sdim#define TAC_ACCT_STOP 0x4 110226633Sdim#define TAC_ACCT_WATCHDOG 0x8 111226633Sdim 112226633Sdim/* Accounting status */ 113226633Sdim#define TAC_ACCT_STATUS_SUCCESS 0x1 114226633Sdim#define TAC_ACCT_STATUS_ERROR 0x2 115226633Sdim#define TAC_ACCT_STATUS_FOLLOW 0x21 116226633Sdim 117226633Sdim__BEGIN_DECLS 118226633Sdimint tac_add_server(struct tac_handle *, 119226633Sdim const char *, int, const char *, int, int); 120226633Sdimvoid tac_close(struct tac_handle *); 121221345Sdimint tac_config(struct tac_handle *, const char *); 122221345Sdimint tac_create_authen(struct tac_handle *, int, int, int); 123263508Sdimvoid *tac_get_data(struct tac_handle *, size_t *); 124223017Sdimchar *tac_get_msg(struct tac_handle *); 125263508Sdimstruct tac_handle *tac_open(void); 126223017Sdimint tac_send_authen(struct tac_handle *); 127224145Sdimint tac_set_data(struct tac_handle *, 128224145Sdim const void *, size_t); 129224145Sdimint tac_set_msg(struct tac_handle *, const char *); 130221345Sdimint tac_set_port(struct tac_handle *, const char *); 131224145Sdimint tac_set_priv(struct tac_handle *, int); 132224145Sdimint tac_set_rem_addr(struct tac_handle *, const char *); 133224145Sdimint tac_set_user(struct tac_handle *, const char *); 134224145Sdimconst char *tac_strerror(struct tac_handle *); 135224145Sdimint tac_send_author(struct tac_handle *); 136224145Sdimint tac_create_author(struct tac_handle *, int, int, int); 137224145Sdimint tac_set_av(struct tac_handle *, u_int, const char *); 138224145Sdimchar *tac_get_av(struct tac_handle *, u_int); 139221345Sdimchar *tac_get_av_value(struct tac_handle *, const char *); 140224145Sdimvoid tac_clear_avs(struct tac_handle *); 141221345Sdimint tac_create_acct(struct tac_handle *, int, int, int, int); 142221345Sdimint tac_send_acct(struct tac_handle *); 143224145Sdim__END_DECLS 144224145Sdim 145224145Sdim#endif /* _TACLIB_H_ */ 146224145Sdim