xref: /titanic_50/usr/src/cmd/vscan/vscand/vs_incl.h (revision f8919bdadda3ebb97bd55cc14a16e0271ed57615)
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 2007 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 - "scan_ret_code" 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 */
94 typedef struct vs_eng_conn {
95 	int vsc_idx;
96 	char vsc_engid[VS_SE_NAME_LEN];
97 	char vsc_host[MAXHOSTNAMELEN];
98 	int vsc_port;
99 	int vsc_sockfd;
100 	struct vs_eng_conn *vsc_next;
101 	struct vs_eng_conn *vsc_prev;
102 }vs_eng_conn_t;
103 
104 
105 /* file attributes used by virus scanning */
106 typedef struct vs_attr {
107 	int vsa_modified;
108 	int vsa_quarantined;
109 	uint64_t vsa_size;
110 	vs_scanstamp_t vsa_scanstamp;
111 }vs_attr_t;
112 
113 
114 /* Function Prototypes */
115 vs_daemon_state_t vscand_get_state(void);
116 char *vscand_viruslog(void);
117 
118 int vs_door_init(void);
119 void vs_door_fini(void);
120 
121 void vs_svc_init(void);
122 void vs_svc_fini(void);
123 int vs_svc_scan_file(char *, char *, vs_attr_t *, int);
124 
125 void vs_eng_init(void);
126 void vs_eng_fini(void);
127 void vs_eng_config(vs_props_all_t *);
128 void vs_eng_set_error(vs_eng_conn_t *, int);
129 int vs_eng_get(vs_eng_conn_t *, int);
130 int vs_eng_connect(vs_eng_conn_t *);
131 void vs_eng_release(vs_eng_conn_t *);
132 int vs_eng_scanstamp_current(vs_scanstamp_t);
133 
134 void vs_icap_init(void);
135 void vs_icap_fini(void);
136 void vs_icap_config(int, char *, int);
137 int vs_icap_scan_file(vs_eng_conn_t *, char *, char *, uint64_t,
138     int, vs_result_t *);
139 void vs_icap_print_options(int);
140 int vs_icap_compare_scanstamp(int, vs_scanstamp_t);
141 
142 int vs_stats_init();
143 void vs_stats_fini();
144 void vs_stats_set(int);
145 void vs_stats_eng_err(char *);
146 void vs_stats_config(vs_props_all_t *);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* _VS_INCL_H */
153