#ifndef TACLIB_PRIVATE_H
#define TACLIB_PRIVATE_H
#include "taclib.h"
#define PATH_TACPLUS_CONF "/etc/tacplus.conf"
#define TACPLUS_PORT 49
#define TIMEOUT 3
#define BODYSIZE 8150
#define ERRSIZE 128
#define MAXCONFLINE 1024
#define MAXSERVERS 10
#define MAXAVPAIRS 255
#define HDRSIZE 12
#define TAC_VER_MAJOR 0xc
#define TAC_AUTHEN 0x01
#define TAC_AUTHOR 0x02
#define TAC_ACCT 0x03
#define TAC_UNENCRYPTED 0x01
#define TAC_SINGLE_CONNECT 0x04
struct tac_str {
char *data;
size_t len;
};
struct tac_authen_start {
u_int8_t action;
u_int8_t priv_lvl;
u_int8_t authen_type;
u_int8_t service;
u_int8_t user_len;
u_int8_t port_len;
u_int8_t rem_addr_len;
u_int8_t data_len;
unsigned char rest[1];
};
struct tac_authen_reply {
u_int8_t status;
u_int8_t flags;
u_int16_t msg_len;
u_int16_t data_len;
unsigned char rest[1];
};
struct tac_authen_cont {
u_int16_t user_msg_len;
u_int16_t data_len;
u_int8_t flags;
unsigned char rest[1];
};
struct tac_author_request {
u_int8_t authen_meth;
u_int8_t priv_lvl;
u_int8_t authen_type;
u_int8_t service;
u_int8_t user_len;
u_int8_t port_len;
u_int8_t rem_addr_len;
u_int8_t av_cnt;
unsigned char rest[1];
};
struct tac_author_response {
u_int8_t status;
u_int8_t av_cnt;
u_int16_t msg_len;
u_int16_t data_len;
unsigned char rest[1];
};
struct tac_acct_start {
u_int8_t action;
u_int8_t authen_action;
u_int8_t priv_lvl;
u_int8_t authen_type;
u_int8_t authen_service;
u_int8_t user_len;
u_int8_t port_len;
u_int8_t rem_addr_len;
u_int8_t av_cnt;
unsigned char rest[1];
};
struct tac_acct_reply {
u_int16_t msg_len;
u_int16_t data_len;
u_int8_t status;
unsigned char rest[1];
};
struct tac_msg {
u_int8_t version;
u_int8_t type;
u_int8_t seq_no;
u_int8_t flags;
u_int8_t session_id[4];
u_int32_t length;
union {
struct tac_authen_start authen_start;
struct tac_authen_reply authen_reply;
struct tac_authen_cont authen_cont;
struct tac_author_request author_request;
struct tac_author_response author_response;
struct tac_acct_start acct_start;
struct tac_acct_reply acct_reply;
unsigned char body[BODYSIZE];
} u;
};
struct tac_server {
struct sockaddr_in addr;
char *secret;
int timeout;
int flags;
unsigned int navs;
struct tac_str avs[MAXAVPAIRS];
};
struct tac_handle {
int fd;
struct tac_server servers[MAXSERVERS];
int num_servers;
int cur_server;
int single_connect;
int last_seq_no;
char errmsg[ERRSIZE];
struct tac_str user;
struct tac_str port;
struct tac_str rem_addr;
struct tac_str data;
struct tac_str user_msg;
struct tac_str avs[MAXAVPAIRS];
struct tac_msg request;
struct tac_msg response;
int srvr_pos;
unsigned int srvr_navs;
struct tac_str srvr_msg;
struct tac_str srvr_data;
struct tac_str srvr_avs[MAXAVPAIRS];
};
#define is_alpha(ch) \
(((ch) >= 'A' && (ch) <= 'Z') || ((ch) >= 'a' && (ch) <= 'z'))
#define is_num(ch) \
((ch) >= '0' && (ch) <= '9')
#define is_alnum(ch) \
(is_alpha(ch) || is_num(ch))
#define is_arg(ch) \
(is_alnum(ch) || (ch) == '_' || (ch) == '-')
#endif