1911106dfSjm199354 /* 2911106dfSjm199354 * CDDL HEADER START 3911106dfSjm199354 * 4911106dfSjm199354 * The contents of this file are subject to the terms of the 5911106dfSjm199354 * Common Development and Distribution License (the "License"). 6911106dfSjm199354 * You may not use this file except in compliance with the License. 7911106dfSjm199354 * 8911106dfSjm199354 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9911106dfSjm199354 * or http://www.opensolaris.org/os/licensing. 10911106dfSjm199354 * See the License for the specific language governing permissions 11911106dfSjm199354 * and limitations under the License. 12911106dfSjm199354 * 13911106dfSjm199354 * When distributing Covered Code, include this CDDL HEADER in each 14911106dfSjm199354 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15911106dfSjm199354 * If applicable, add the following below this CDDL HEADER, with the 16911106dfSjm199354 * fields enclosed by brackets "[]" replaced with your own identifying 17911106dfSjm199354 * information: Portions Copyright [yyyy] [name of copyright owner] 18911106dfSjm199354 * 19911106dfSjm199354 * CDDL HEADER END 20911106dfSjm199354 */ 21911106dfSjm199354 /* 2253c11029Sjm199354 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23911106dfSjm199354 * Use is subject to license terms. 24911106dfSjm199354 */ 25911106dfSjm199354 26911106dfSjm199354 /* 27911106dfSjm199354 * Includes private to the vscan daemon. 28911106dfSjm199354 * vs_icap.c also has its own private include file: vs_icap.h 29911106dfSjm199354 */ 30911106dfSjm199354 31911106dfSjm199354 #ifndef _VS_INCL_H 32911106dfSjm199354 #define _VS_INCL_H 33911106dfSjm199354 34911106dfSjm199354 #pragma ident "%Z%%M% %I% %E% SMI" 35911106dfSjm199354 36911106dfSjm199354 #ifdef __cplusplus 37911106dfSjm199354 extern "C" { 38911106dfSjm199354 #endif 39911106dfSjm199354 40911106dfSjm199354 #include <stdio.h> 41911106dfSjm199354 #include <sys/types.h> 42911106dfSjm199354 #include <netdb.h> 43911106dfSjm199354 #include <sys/vscan.h> 44911106dfSjm199354 #include <libvscan.h> 45911106dfSjm199354 4653c11029Sjm199354 /* vscan result code - "vsr_rc" field of vs_result_t */ 47911106dfSjm199354 #define VS_RESULT_SE_ERROR -2 /* scan engine i/f error */ 48911106dfSjm199354 #define VS_RESULT_ERROR -1 49911106dfSjm199354 #define VS_RESULT_UNDEFINED 0 50911106dfSjm199354 #define VS_RESULT_CLEAN 1 /* clean (no infection found) */ 51911106dfSjm199354 #define VS_RESULT_CLEANED 2 /* infections found and cleaned */ 52911106dfSjm199354 #define VS_RESULT_FORBIDDEN 3 /* infected and NOT cleaned */ 53911106dfSjm199354 54911106dfSjm199354 /* "Resolution" field of violation_rec */ 55911106dfSjm199354 #define VS_RES_FILE_NOT_REPAIRED 0 56911106dfSjm199354 #define VS_RES_FILE_REPAIRED 1 57911106dfSjm199354 #define VS_RES_POLICY_VIOLATION 2 58911106dfSjm199354 59911106dfSjm199354 #define VS_MAX_VIOLATIONS 10 60911106dfSjm199354 #define VS_DESCRIPTION_MAX 64 61911106dfSjm199354 62911106dfSjm199354 /* number of retries on failure to communicate with a scan engine */ 63911106dfSjm199354 #define VS_MAX_RETRY 1 64911106dfSjm199354 #define VS_ENG_WAIT_DFLT 30 /* seconds */ 65911106dfSjm199354 66911106dfSjm199354 /* flags */ 67911106dfSjm199354 #define VS_NO_REPAIR 0x01 68911106dfSjm199354 69911106dfSjm199354 70911106dfSjm199354 /* vscan daemon state */ 71911106dfSjm199354 typedef enum { 72911106dfSjm199354 VS_STATE_INIT, VS_STATE_RUNNING, VS_STATE_SHUTDOWN 73911106dfSjm199354 } vs_daemon_state_t; 74911106dfSjm199354 75911106dfSjm199354 76911106dfSjm199354 /* violation record - populated as part of result returned from vs_icap.c */ 77911106dfSjm199354 typedef struct vs_vrec { 78911106dfSjm199354 int vr_id; 79911106dfSjm199354 int vr_res; 80911106dfSjm199354 char vr_desc[VS_DESCRIPTION_MAX]; 81911106dfSjm199354 } vs_vrec_t; 82911106dfSjm199354 83911106dfSjm199354 84911106dfSjm199354 /* scan result - populate by vs_icap.c */ 85911106dfSjm199354 typedef struct vs_result { 86911106dfSjm199354 int vsr_rc; 87911106dfSjm199354 vs_scanstamp_t vsr_scanstamp; 88911106dfSjm199354 int vsr_nviolations; 89911106dfSjm199354 vs_vrec_t vsr_vrec[VS_MAX_VIOLATIONS]; 90911106dfSjm199354 } vs_result_t; 91911106dfSjm199354 92911106dfSjm199354 93*bfc848c6Sjm199354 /* scan engine connection context */ 94*bfc848c6Sjm199354 typedef struct vs_eng_ctx { 95*bfc848c6Sjm199354 int vse_eidx; /* engine index */ 96*bfc848c6Sjm199354 int vse_cidx; /* connection index */ 97*bfc848c6Sjm199354 char vse_engid[VS_SE_NAME_LEN]; 98*bfc848c6Sjm199354 char vse_host[MAXHOSTNAMELEN]; 99*bfc848c6Sjm199354 int vse_port; 100*bfc848c6Sjm199354 int vse_sockfd; 101*bfc848c6Sjm199354 } vs_eng_ctx_t; 102911106dfSjm199354 103911106dfSjm199354 104911106dfSjm199354 /* Function Prototypes */ 105911106dfSjm199354 vs_daemon_state_t vscand_get_state(void); 106911106dfSjm199354 char *vscand_viruslog(void); 107*bfc848c6Sjm199354 int vscand_kernel_result(vs_scan_rsp_t *); 108911106dfSjm199354 109911106dfSjm199354 int vs_door_init(void); 110911106dfSjm199354 void vs_door_fini(void); 111911106dfSjm199354 112*bfc848c6Sjm199354 int vs_svc_init(uint32_t); 113911106dfSjm199354 void vs_svc_fini(void); 114*bfc848c6Sjm199354 int vs_svc_queue_scan_req(vs_scan_req_t *); 115*bfc848c6Sjm199354 void vs_svc_terminate(void); 116911106dfSjm199354 117911106dfSjm199354 void vs_eng_init(void); 118911106dfSjm199354 void vs_eng_fini(void); 119911106dfSjm199354 void vs_eng_config(vs_props_all_t *); 120*bfc848c6Sjm199354 void vs_eng_set_error(vs_eng_ctx_t *, int); 121*bfc848c6Sjm199354 int vs_eng_get(vs_eng_ctx_t *, boolean_t); 122*bfc848c6Sjm199354 void vs_eng_release(const vs_eng_ctx_t *); 123*bfc848c6Sjm199354 void vs_eng_close_connections(void); 124911106dfSjm199354 int vs_eng_scanstamp_current(vs_scanstamp_t); 125911106dfSjm199354 126911106dfSjm199354 void vs_icap_init(void); 127911106dfSjm199354 void vs_icap_fini(void); 128911106dfSjm199354 void vs_icap_config(int, char *, int); 129*bfc848c6Sjm199354 int vs_icap_scan_file(vs_eng_ctx_t *, char *, char *, uint64_t, 130911106dfSjm199354 int, vs_result_t *); 131911106dfSjm199354 void vs_icap_print_options(int); 132911106dfSjm199354 int vs_icap_compare_scanstamp(int, vs_scanstamp_t); 133911106dfSjm199354 134911106dfSjm199354 int vs_stats_init(); 135911106dfSjm199354 void vs_stats_fini(); 136911106dfSjm199354 void vs_stats_set(int); 137911106dfSjm199354 void vs_stats_eng_err(char *); 138911106dfSjm199354 void vs_stats_config(vs_props_all_t *); 139911106dfSjm199354 140911106dfSjm199354 #ifdef __cplusplus 141911106dfSjm199354 } 142911106dfSjm199354 #endif 143911106dfSjm199354 144911106dfSjm199354 #endif /* _VS_INCL_H */ 145