xref: /illumos-gate/usr/src/cmd/vscan/vscand/vs_incl.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
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 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include <stdio.h>
39 #include <sys/types.h>
40 #include <netdb.h>
41 #include <sys/vscan.h>
42 #include <libvscan.h>
43 
44 /* vscan result code - "vsr_rc" field of vs_result_t */
45 #define	VS_RESULT_SE_ERROR    	-2 /* scan engine i/f error */
46 #define	VS_RESULT_ERROR    	-1
47 #define	VS_RESULT_UNDEFINED	0
48 #define	VS_RESULT_CLEAN		1 /* clean (no infection found) */
49 #define	VS_RESULT_CLEANED	2 /* infections found and cleaned */
50 #define	VS_RESULT_FORBIDDEN	3 /* infected and NOT cleaned */
51 
52 /* "Resolution" field of violation_rec */
53 #define	VS_RES_FILE_NOT_REPAIRED	0
54 #define	VS_RES_FILE_REPAIRED		1
55 #define	VS_RES_POLICY_VIOLATION		2
56 
57 #define	VS_MAX_VIOLATIONS		10
58 #define	VS_DESCRIPTION_MAX		64
59 
60 /* number of retries on failure to communicate with a scan engine */
61 #define	VS_MAX_RETRY			1
62 #define	VS_ENG_WAIT_DFLT		30 /* seconds */
63 
64 /* flags */
65 #define	VS_NO_REPAIR	0x01
66 
67 
68 /* vscan daemon state */
69 typedef enum {
70 	VS_STATE_INIT, VS_STATE_RUNNING, VS_STATE_SHUTDOWN
71 } vs_daemon_state_t;
72 
73 
74 /* violation record - populated as part of result returned from vs_icap.c */
75 typedef struct vs_vrec {
76 	int vr_id;
77 	int vr_res;
78 	char vr_desc[VS_DESCRIPTION_MAX];
79 } vs_vrec_t;
80 
81 
82 /* scan result - populate by vs_icap.c */
83 typedef struct vs_result {
84 	int vsr_rc;
85 	vs_scanstamp_t vsr_scanstamp;
86 	int vsr_nviolations;
87 	vs_vrec_t vsr_vrec[VS_MAX_VIOLATIONS];
88 } vs_result_t;
89 
90 
91 /* scan engine connection context */
92 typedef struct vs_eng_ctx {
93 	int vse_eidx;	/* engine index */
94 	int vse_cidx;	/* connection index */
95 	char vse_engid[VS_SE_NAME_LEN];
96 	char vse_host[MAXHOSTNAMELEN];
97 	int vse_port;
98 	int vse_sockfd;
99 } vs_eng_ctx_t;
100 
101 
102 /* Function Prototypes */
103 vs_daemon_state_t vscand_get_state(void);
104 char *vscand_viruslog(void);
105 int vscand_kernel_result(vs_scan_rsp_t *);
106 
107 int vs_door_init(void);
108 void vs_door_fini(void);
109 
110 int vs_svc_init(uint32_t);
111 void vs_svc_fini(void);
112 int vs_svc_queue_scan_req(vs_scan_req_t *);
113 void vs_svc_terminate(void);
114 
115 void vs_eng_init(void);
116 void vs_eng_fini(void);
117 void vs_eng_config(vs_props_all_t *);
118 void vs_eng_set_error(vs_eng_ctx_t *, int);
119 int vs_eng_get(vs_eng_ctx_t *, boolean_t);
120 void vs_eng_release(const vs_eng_ctx_t *);
121 void vs_eng_close_connections(void);
122 int vs_eng_scanstamp_current(vs_scanstamp_t);
123 
124 void vs_icap_init(void);
125 void vs_icap_fini(void);
126 void vs_icap_config(int, char *, int);
127 int vs_icap_scan_file(vs_eng_ctx_t *, char *, char *, uint64_t,
128     int, vs_result_t *);
129 void vs_icap_print_options(int);
130 int vs_icap_compare_scanstamp(int, vs_scanstamp_t);
131 
132 int vs_stats_init();
133 void vs_stats_fini();
134 void vs_stats_set(int);
135 void vs_stats_eng_err(char *);
136 void vs_stats_config(vs_props_all_t *);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* _VS_INCL_H */
143