vscan.h revision 53c110294d8b1410cabc201a52f94b03ae2ef448
1N/A/*
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License (the "License").
1N/A * You may not use this file except in compliance with the License.
1N/A *
1N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * When distributing Covered Code, include this CDDL HEADER in each
1N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A * If applicable, add the following below this CDDL HEADER, with the
1N/A * fields enclosed by brackets "[]" replaced with your own identifying
1N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1N/A *
1N/A * CDDL HEADER END
1N/A */
1N/A/*
1N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1N/A * Use is subject to license terms.
1N/A */
1N/A
1N/A#ifndef _VSCAN_H
1N/A#define _VSCAN_H
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#ifdef __cplusplus
1N/Aextern "C" {
1N/A#endif
1N/A
1N/A#include <sys/param.h>
1N/A#include <sys/vnode.h>
1N/A
1N/A/*
1N/A * vscan.h provides definitions for vscan kernel module
1N/A */
1N/A
1N/A#define VS_DRV_MAX_FILES 1024 /* max concurent file scans */
1N/A#define VS_DRV_PATH "/devices/pseudo/vscan@0:vscan"
1N/A#define VS_DRV_IOCTL_ENABLE 0x0001 /* door rendezvous */
1N/A#define VS_DRV_IOCTL_DISABLE 0x0002 /* vscand shutting down */
1N/A#define VS_DRV_IOCTL_CONFIG 0x0004 /* vscand config data update */
1N/A
1N/A/* Scan Result - vsr_result */
1N/A#define VS_STATUS_UNDEFINED 0
1N/A#define VS_STATUS_NO_SCAN 1 /* scan not required */
1N/A#define VS_STATUS_ERROR 2 /* scan failed */
1N/A#define VS_STATUS_CLEAN 3 /* scan successful, file clean */
1N/A#define VS_STATUS_INFECTED 4 /* scan successful, file infected */
1N/A
1N/A#define VS_TYPES_LEN 4096 /* vs_config_t - types buffer */
1N/A
1N/A/*
1N/A * AV_SCANSTAMP_SZ is the size of the scanstamp stored in the
1N/A * filesystem. vs_scanstamp_t is 1 character longer to allow
1N/A * a null terminated string to be used within vscan
1N/A */
1N/Atypedef char vs_scanstamp_t[AV_SCANSTAMP_SZ + 1];
1N/A
1N/A/* used for both request to and response from vscand */
1N/Atypedef struct vs_scan_req {
1N/A uint32_t vsr_id;
1N/A uint32_t vsr_flags;
1N/A uint64_t vsr_size;
1N/A uint8_t vsr_modified;
1N/A uint8_t vsr_quarantined;
1N/A char vsr_path[MAXPATHLEN];
1N/A vs_scanstamp_t vsr_scanstamp;
1N/A uint32_t vsr_result;
1N/A} vs_scan_req_t;
1N/A
1N/A
1N/A/* passed in VS_DRV_IOCTL_CONFIG */
1N/Atypedef struct vs_config {
1N/A char vsc_types[VS_TYPES_LEN];
1N/A uint64_t vsc_types_len;
1N/A uint64_t vsc_max_size; /* files > max size (bytes) not scan */
1N/A uint64_t vsc_allow; /* allow access to file exceeding max_size? */
1N/A} vs_config_t;
1N/A
1N/A
1N/A#ifdef _KERNEL
1N/A
1N/A/*
1N/A * max no of types in vs_config_t.vsc_types
* used as dimention for array of pointers to types
*/
#define VS_TYPES_MAX VS_TYPES_LEN / 2
/*
* seconds to wait for daemon to reconnect before unregistering from VFS
* during this time, the kernel will:
* - allow access to files that have not been modified since last scanned
* - deny access to files which have been modified since last scanned
*/
#define VS_DAEMON_WAIT_SEC 60
/* access derived from scan result (VS_STATUS_XXX) and file attributes */
#define VS_ACCESS_UNDEFINED 0
#define VS_ACCESS_ALLOW 1
#define VS_ACCESS_DENY 2
int vscan_svc_init(void);
void vscan_svc_fini(void);
void vscan_svc_enable(void);
void vscan_svc_disable(void);
int vscan_svc_configure(vs_config_t *);
boolean_t vscan_svc_is_enabled(void);
boolean_t vscan_svc_in_use(void);
vnode_t *vscan_svc_get_vnode(int);
int vscan_door_init(void);
void vscan_door_fini(void);
int vscan_door_open(int);
void vscan_door_close(void);
int vscan_door_scan_file(vs_scan_req_t *);
boolean_t vscan_drv_create_node(int);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _VSCAN_H */