1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * Includes private to the vscan daemon. 28 * vs_icap.c also has its own private include file: vs_icap.h 29 */ 30 31 #ifndef _VS_INCL_H 32 #define _VS_INCL_H 33 34 #pragma ident "%Z%%M% %I% %E% SMI" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 #include <stdio.h> 41 #include <sys/types.h> 42 #include <netdb.h> 43 #include <sys/vscan.h> 44 #include <libvscan.h> 45 46 /* vscan result code - "vsr_rc" field of vs_result_t */ 47 #define VS_RESULT_SE_ERROR -2 /* scan engine i/f error */ 48 #define VS_RESULT_ERROR -1 49 #define VS_RESULT_UNDEFINED 0 50 #define VS_RESULT_CLEAN 1 /* clean (no infection found) */ 51 #define VS_RESULT_CLEANED 2 /* infections found and cleaned */ 52 #define VS_RESULT_FORBIDDEN 3 /* infected and NOT cleaned */ 53 54 /* "Resolution" field of violation_rec */ 55 #define VS_RES_FILE_NOT_REPAIRED 0 56 #define VS_RES_FILE_REPAIRED 1 57 #define VS_RES_POLICY_VIOLATION 2 58 59 #define VS_MAX_VIOLATIONS 10 60 #define VS_DESCRIPTION_MAX 64 61 62 /* number of retries on failure to communicate with a scan engine */ 63 #define VS_MAX_RETRY 1 64 #define VS_ENG_WAIT_DFLT 30 /* seconds */ 65 66 /* flags */ 67 #define VS_NO_REPAIR 0x01 68 69 70 /* vscan daemon state */ 71 typedef enum { 72 VS_STATE_INIT, VS_STATE_RUNNING, VS_STATE_SHUTDOWN 73 } vs_daemon_state_t; 74 75 76 /* violation record - populated as part of result returned from vs_icap.c */ 77 typedef struct vs_vrec { 78 int vr_id; 79 int vr_res; 80 char vr_desc[VS_DESCRIPTION_MAX]; 81 } vs_vrec_t; 82 83 84 /* scan result - populate by vs_icap.c */ 85 typedef struct vs_result { 86 int vsr_rc; 87 vs_scanstamp_t vsr_scanstamp; 88 int vsr_nviolations; 89 vs_vrec_t vsr_vrec[VS_MAX_VIOLATIONS]; 90 } vs_result_t; 91 92 93 /* scan engine connection context */ 94 typedef struct vs_eng_ctx { 95 int vse_eidx; /* engine index */ 96 int vse_cidx; /* connection index */ 97 char vse_engid[VS_SE_NAME_LEN]; 98 char vse_host[MAXHOSTNAMELEN]; 99 int vse_port; 100 int vse_sockfd; 101 } vs_eng_ctx_t; 102 103 104 /* Function Prototypes */ 105 vs_daemon_state_t vscand_get_state(void); 106 char *vscand_viruslog(void); 107 int vscand_kernel_result(vs_scan_rsp_t *); 108 109 int vs_door_init(void); 110 void vs_door_fini(void); 111 112 int vs_svc_init(uint32_t); 113 void vs_svc_fini(void); 114 int vs_svc_queue_scan_req(vs_scan_req_t *); 115 void vs_svc_terminate(void); 116 117 void vs_eng_init(void); 118 void vs_eng_fini(void); 119 void vs_eng_config(vs_props_all_t *); 120 void vs_eng_set_error(vs_eng_ctx_t *, int); 121 int vs_eng_get(vs_eng_ctx_t *, boolean_t); 122 void vs_eng_release(const vs_eng_ctx_t *); 123 void vs_eng_close_connections(void); 124 int vs_eng_scanstamp_current(vs_scanstamp_t); 125 126 void vs_icap_init(void); 127 void vs_icap_fini(void); 128 void vs_icap_config(int, char *, int); 129 int vs_icap_scan_file(vs_eng_ctx_t *, char *, char *, uint64_t, 130 int, vs_result_t *); 131 void vs_icap_print_options(int); 132 int vs_icap_compare_scanstamp(int, vs_scanstamp_t); 133 134 int vs_stats_init(); 135 void vs_stats_fini(); 136 void vs_stats_set(int); 137 void vs_stats_eng_err(char *); 138 void vs_stats_config(vs_props_all_t *); 139 140 #ifdef __cplusplus 141 } 142 #endif 143 144 #endif /* _VS_INCL_H */ 145