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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <netinet/in.h>
38 /* Property IDs - general property group */
39 #define VS_PROPID_MAXSIZE 0x01LL
40 #define VS_PROPID_MAXSIZE_ACTION 0x02LL
41 #define VS_PROPID_TYPES 0x04LL
42 #define VS_PROPID_VLOG 0x08LL
44 #define VS_PROPID_GEN_ALL (VS_PROPID_MAXSIZE | \
45 VS_PROPID_MAXSIZE_ACTION | VS_PROPID_TYPES | VS_PROPID_VLOG)
47 #define VS_PROPID_VALUE_AUTH 0x010LL
49 /* Property IDs - scan engine property groups */
50 #define VS_PROPID_SE_ENABLE 0x100LL
51 #define VS_PROPID_SE_HOST 0x200LL
52 #define VS_PROPID_SE_PORT 0x400LL
53 #define VS_PROPID_SE_MAXCONN 0x800LL
55 #define VS_PROPID_SE_ALL (VS_PROPID_SE_ENABLE | \
56 VS_PROPID_SE_HOST | VS_PROPID_SE_PORT | VS_PROPID_SE_MAXCONN)
58 /* Check for whether a property id is a scan engine id */
59 #define VS_PROPID_IS_SE(id) ((id & VS_PROPID_SE_ALL) ? 1 : 0)
61 /* The maximum property id value - across all property groups */
62 #define VS_PROPID_MAX VS_PROPID_SE_MAXCONN
64 /* The number of properties in the largest property group */
65 #define VS_NUM_PROPIDS 5
67 /* Range of scan engine IDs and max number of scan engines supported */
69 #define VS_SE_NAME_LEN 64
71 /* Min & Max scan engine connections per engine */
72 #define VS_VAL_SE_MAXCONN_MIN 1
73 #define VS_VAL_SE_MAXCONN_MAX 512
75 /* Can accommodate a string-ified ULONG_MAX plus unit specifier */
76 #define VS_VAL_MAXSIZE_LEN 32
78 #define VS_VAL_TYPES_LEN 4096
79 #define VS_VAL_TYPES_INVALID_CHARS "."
81 /* libvscan error codes */
83 #define VS_ERR_INVALID_PROPERTY 1
84 #define VS_ERR_INVALID_VALUE 2
85 #define VS_ERR_INVALID_HOST 3
86 #define VS_ERR_INVALID_SE 4
87 #define VS_ERR_MAX_SE 5
89 #define VS_ERR_DAEMON_COMM 10
94 /* RBAC authorizations */
95 #define VS_VALUE_AUTH "solaris.smf.value.vscan"
96 #define VS_ACTION_AUTH "solaris.smf.manage.vscan"
97 #define VS_MODIFY_AUTH "solaris.smf.modify.application"
99 /* statistics door interface */
100 #define VS_STATS_DOOR_NAME "/var/run/vscan_stats_door"
101 #define VS_STATS_DOOR_VERSION 1
102 #define VS_STATS_DOOR_MAGIC 0x56535354 /* VSST - VScanStats */
104 /* scan statistics door request type */
108 } vs_stats_req_type_t
;
110 typedef struct vs_stats_req
{
112 vs_stats_req_type_t vsr_id
;
115 typedef struct vs_stats
{
116 uint64_t vss_scanned
;
117 uint64_t vss_infected
;
118 uint64_t vss_cleaned
;
121 char vss_engid
[VS_SE_NAME_LEN
];
123 } vss_eng
[VS_SE_MAX
];
126 typedef struct vs_stats_rsp
{
128 vs_stats_t vsr_stats
;
134 * General service configuration properties
136 typedef struct vs_props
{
137 char vp_maxsize
[VS_VAL_MAXSIZE_LEN
];
138 boolean_t vp_maxsize_action
;
139 char vp_types
[VS_VAL_TYPES_LEN
];
140 char vp_vlog
[MAXPATHLEN
];
144 * Scan engine configuration properties. These are defined
147 typedef struct vs_props_se
{
148 char vep_engid
[VS_SE_NAME_LEN
];
149 boolean_t vep_enable
;
150 char vep_host
[MAXHOSTNAMELEN
];
152 uint64_t vep_maxconn
;
155 typedef struct vs_props_all
{
157 vs_props_se_t va_se
[VS_SE_MAX
];
162 * General service configuration properties API
163 * These functions return VS_ERR_XXX error codes.
165 int vs_props_get_all(vs_props_all_t
*);
166 int vs_props_set(const vs_props_t
*, uint64_t);
167 int vs_props_get(vs_props_t
*, uint64_t);
168 int vs_props_validate(const vs_props_t
*, uint64_t);
172 * Scan engine configuration properties API
173 * These functions return VS_ERR_XXX error codes.
175 int vs_props_se_create(char *, const vs_props_se_t
*, uint64_t);
176 int vs_props_se_set(char *, const vs_props_se_t
*, uint64_t);
177 int vs_props_se_get(char *, vs_props_se_t
*, uint64_t);
178 int vs_props_se_validate(const vs_props_se_t
*, uint64_t);
179 int vs_props_se_delete(const char *);
182 /* Get error string for error code */
183 const char *vs_strerror(int);
185 /* Functions to access/reset scan statistics in service daemon */
186 int vs_statistics(vs_stats_t
*);
187 int vs_statistics_reset(void);
190 /* Utility functions */
193 * Replace comma separators with '\0'.
195 * Types contains comma separated rules each beginning with +|-
196 * - embedded commas are escaped by backslash
197 * - backslash is escaped by backslash
198 * - a single backslash not followed by comma is illegal
200 * On entry to the function len must contain the length of
201 * the buffer. On sucecssful exit len will contain the length
202 * of the parsed data within the buffer.
204 * Returns 0 on success, -1 on failure
206 int vs_parse_types(const char *, char *, uint32_t *);
210 * Converts a size string in the format into an integer.
212 * A size string is a numeric value followed by an optional unit
213 * specifier which is used as a multiplier to calculate a raw
215 * The size string format is: N[.N][KMGTP][B]
217 * The numeric value can contain a decimal portion. Unit specifiers
218 * are either a one-character or two-character string; i.e. "K" or
219 * "KB" for kilobytes. Unit specifiers must follow the numeric portion
220 * immediately, and are not case-sensitive.
222 * If either "B" is specified, or there is no unit specifier portion
223 * in the string, the numeric value is calculated with no multiplier
224 * (assumes a basic unit of "bytes").
226 * Returns: -1: Failure; errno set to specify the error.
229 int vs_strtonum(const char *, uint64_t *);
235 #endif /* __LIBVS_H__ */