1*657a8c20SJan Friedel /* 2*657a8c20SJan Friedel * CDDL HEADER START 3*657a8c20SJan Friedel * 4*657a8c20SJan Friedel * The contents of this file are subject to the terms of the 5*657a8c20SJan Friedel * Common Development and Distribution License (the "License"). 6*657a8c20SJan Friedel * You may not use this file except in compliance with the License. 7*657a8c20SJan Friedel * 8*657a8c20SJan Friedel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*657a8c20SJan Friedel * or http://www.opensolaris.org/os/licensing. 10*657a8c20SJan Friedel * See the License for the specific language governing permissions 11*657a8c20SJan Friedel * and limitations under the License. 12*657a8c20SJan Friedel * 13*657a8c20SJan Friedel * When distributing Covered Code, include this CDDL HEADER in each 14*657a8c20SJan Friedel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*657a8c20SJan Friedel * If applicable, add the following below this CDDL HEADER, with the 16*657a8c20SJan Friedel * fields enclosed by brackets "[]" replaced with your own identifying 17*657a8c20SJan Friedel * information: Portions Copyright [yyyy] [name of copyright owner] 18*657a8c20SJan Friedel * 19*657a8c20SJan Friedel * CDDL HEADER END 20*657a8c20SJan Friedel */ 21*657a8c20SJan Friedel /* 22*657a8c20SJan Friedel * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*657a8c20SJan Friedel * Use is subject to license terms. 24*657a8c20SJan Friedel * 25*657a8c20SJan Friedel */ 26*657a8c20SJan Friedel 27*657a8c20SJan Friedel #ifndef _AUDIT_REMOTE_H 28*657a8c20SJan Friedel #define _AUDIT_REMOTE_H 29*657a8c20SJan Friedel 30*657a8c20SJan Friedel 31*657a8c20SJan Friedel #ifdef __cplusplus 32*657a8c20SJan Friedel extern "C" { 33*657a8c20SJan Friedel #endif 34*657a8c20SJan Friedel 35*657a8c20SJan Friedel #include <stdio.h> 36*657a8c20SJan Friedel #include <security/auditd.h> 37*657a8c20SJan Friedel 38*657a8c20SJan Friedel /* gettext() obfuscation routine for lint */ 39*657a8c20SJan Friedel #ifdef __lint 40*657a8c20SJan Friedel #define gettext(x) x 41*657a8c20SJan Friedel #endif 42*657a8c20SJan Friedel 43*657a8c20SJan Friedel 44*657a8c20SJan Friedel /* send_record() return code */ 45*657a8c20SJan Friedel enum send_record_rc { 46*657a8c20SJan Friedel SEND_RECORD_SUCCESS, 47*657a8c20SJan Friedel SEND_RECORD_NEXT, 48*657a8c20SJan Friedel SEND_RECORD_RETRY, 49*657a8c20SJan Friedel SEND_RECORD_FAIL 50*657a8c20SJan Friedel }; 51*657a8c20SJan Friedel typedef enum send_record_rc send_record_rc_t; 52*657a8c20SJan Friedel 53*657a8c20SJan Friedel /* closing helpers - the reason of connection closure */ 54*657a8c20SJan Friedel enum close_rsn_e { 55*657a8c20SJan Friedel RSN_UNDEFINED, /* reason not defined */ 56*657a8c20SJan Friedel RSN_INIT_POLL, /* poll() initialization failed */ 57*657a8c20SJan Friedel RSN_TOK_RECV_FAILED, /* token receiving failed */ 58*657a8c20SJan Friedel RSN_TOK_TOO_BIG, /* unacceptable token size */ 59*657a8c20SJan Friedel RSN_TOK_UNVERIFIABLE, /* received unverifiable token */ 60*657a8c20SJan Friedel RSN_SOCKET_CLOSE, /* socket closure */ 61*657a8c20SJan Friedel RSN_SOCKET_CREATE, /* socket creation */ 62*657a8c20SJan Friedel RSN_CONNECTION_CREATE, /* connection creation */ 63*657a8c20SJan Friedel RSN_PROTOCOL_NEGOTIATE, /* protocol version negotiation */ 64*657a8c20SJan Friedel RSN_GSS_CTX_ESTABLISH, /* establish GSS-API context */ 65*657a8c20SJan Friedel RSN_GSS_CTX_EXP, /* expiration of the GSS-API context */ 66*657a8c20SJan Friedel RSN_UNKNOWN_AF, /* unknown address family */ 67*657a8c20SJan Friedel RSN_MEMORY_ALLOCATE, /* memory allocation failure */ 68*657a8c20SJan Friedel RSN_OTHER_ERR /* other, not classified error */ 69*657a8c20SJan Friedel }; 70*657a8c20SJan Friedel typedef enum close_rsn_e close_rsn_t; 71*657a8c20SJan Friedel 72*657a8c20SJan Friedel /* linked list of remote audit hosts (servers) */ 73*657a8c20SJan Friedel typedef struct hostlist_s hostlist_t; 74*657a8c20SJan Friedel struct hostlist_s { 75*657a8c20SJan Friedel hostlist_t *next_host; 76*657a8c20SJan Friedel struct hostent *host; 77*657a8c20SJan Friedel in_port_t port; /* TCP port number */ 78*657a8c20SJan Friedel gss_OID mech; /* GSS mechanism - see mech(4) */ 79*657a8c20SJan Friedel }; 80*657a8c20SJan Friedel 81*657a8c20SJan Friedel /* transq_t - single, already sent token in the transmit queue. */ 82*657a8c20SJan Friedel struct transq_node_s { 83*657a8c20SJan Friedel struct transq_node_s *next; 84*657a8c20SJan Friedel struct transq_node_s *prev; 85*657a8c20SJan Friedel gss_buffer_desc seq_token; /* seq num || plain token */ 86*657a8c20SJan Friedel uint64_t seq_num; /* seq number */ 87*657a8c20SJan Friedel }; 88*657a8c20SJan Friedel typedef struct transq_node_s transq_node_t; 89*657a8c20SJan Friedel 90*657a8c20SJan Friedel /* transq_hdr_t - the transmit queue header structure */ 91*657a8c20SJan Friedel struct transq_hdr_s { 92*657a8c20SJan Friedel struct transq_node_s *head; 93*657a8c20SJan Friedel struct transq_node_s *end; 94*657a8c20SJan Friedel long count; /* amount of nodes in the queue */ 95*657a8c20SJan Friedel }; 96*657a8c20SJan Friedel typedef struct transq_hdr_s transq_hdr_t; 97*657a8c20SJan Friedel 98*657a8c20SJan Friedel /* pipe_msg_s - the notification pipe message */ 99*657a8c20SJan Friedel struct pipe_msg_s { 100*657a8c20SJan Friedel int sock_num; /* socket fd to be poll()ed and more */ 101*657a8c20SJan Friedel boolean_t sync; /* call the sync routines */ 102*657a8c20SJan Friedel }; 103*657a8c20SJan Friedel typedef struct pipe_msg_s pipe_msg_t; 104*657a8c20SJan Friedel 105*657a8c20SJan Friedel 106*657a8c20SJan Friedel /* 107*657a8c20SJan Friedel * Cross audit_remote plugin source code shared functions and bool parameters. 108*657a8c20SJan Friedel * 109*657a8c20SJan Friedel * reset_transport() helpers: 110*657a8c20SJan Friedel * arg1) DO_SYNC, DO_NOT_SYNC 111*657a8c20SJan Friedel * arg2) DO_EXIT, DO_CLOSE, DO_NOT_EXIT, DO_NOT_CLOSE 112*657a8c20SJan Friedel */ 113*657a8c20SJan Friedel #define DO_SYNC B_TRUE 114*657a8c20SJan Friedel #define DO_NOT_SYNC B_FALSE 115*657a8c20SJan Friedel #define DO_EXIT B_FALSE 116*657a8c20SJan Friedel #define DO_CLOSE B_TRUE 117*657a8c20SJan Friedel #define DO_NOT_EXIT B_CLOSE 118*657a8c20SJan Friedel #define DO_NOT_CLOSE B_EXIT 119*657a8c20SJan Friedel extern void reset_transport(boolean_t, boolean_t); 120*657a8c20SJan Friedel extern send_record_rc_t send_record(struct hostlist_s *, const char *, size_t, 121*657a8c20SJan Friedel uint64_t, close_rsn_t *); 122*657a8c20SJan Friedel 123*657a8c20SJan Friedel #if DEBUG 124*657a8c20SJan Friedel #define DPRINT(x) { (void) fprintf x; (void) fflush(dfile); } 125*657a8c20SJan Friedel #else 126*657a8c20SJan Friedel #define DPRINT(x) 127*657a8c20SJan Friedel #endif 128*657a8c20SJan Friedel 129*657a8c20SJan Friedel #if DEBUG 130*657a8c20SJan Friedel extern FILE *dfile; 131*657a8c20SJan Friedel #endif 132*657a8c20SJan Friedel 133*657a8c20SJan Friedel 134*657a8c20SJan Friedel #ifdef __cplusplus 135*657a8c20SJan Friedel } 136*657a8c20SJan Friedel #endif 137*657a8c20SJan Friedel 138*657a8c20SJan Friedel #endif /* _AUDIT_REMOTE_H */ 139