xref: /titanic_51/usr/src/lib/libtnfctl/kernel.c (revision 06e46062ef4f5f4b687cbafb4518fb123fe23920)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1994, by Sun Microsytems, Inc.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * Published kernel specific interfaces for libtnfctl.
30  * After doing some error checking, these just turn around and call
31  * internal interfaces that do the real work.
32  */
33 
34 #include <stdio.h>
35 #include <errno.h>
36 
37 #include "tnfctl_int.h"
38 #include "kernel_int.h"
39 
40 tnfctl_errcode_t
41 tnfctl_trace_state_set(tnfctl_handle_t *hdl, boolean_t mode)
42 {
43 	if (hdl->mode != KERNEL_MODE)
44 		return (TNFCTL_ERR_BADARG);
45 
46 	/* KERNEL_MODE */
47 	return (_tnfctl_prbk_set_tracing(hdl, mode));
48 }
49 
50 tnfctl_errcode_t
51 tnfctl_filter_state_set(tnfctl_handle_t *hdl, boolean_t mode)
52 {
53 	if (hdl->mode != KERNEL_MODE)
54 		return (TNFCTL_ERR_BADARG);
55 
56 	/* KERNEL_MODE */
57 	return (_tnfctl_prbk_set_pfilter_mode(hdl, mode));
58 }
59 
60 tnfctl_errcode_t
61 tnfctl_filter_list_get(tnfctl_handle_t *hdl, pid_t **pid_list, int *pid_count)
62 {
63 	if (hdl->mode != KERNEL_MODE)
64 		return (TNFCTL_ERR_BADARG);
65 
66 	/* KERNEL_MODE */
67 	return (_tnfctl_prbk_get_pfilter_list(hdl, pid_list, pid_count));
68 }
69 
70 tnfctl_errcode_t
71 tnfctl_filter_list_add(tnfctl_handle_t *hdl, pid_t pid)
72 {
73 	if (hdl->mode != KERNEL_MODE)
74 		return (TNFCTL_ERR_BADARG);
75 
76 	/* KERNEL_MODE */
77 	return (_tnfctl_prbk_pfilter_add(hdl, pid));
78 }
79 
80 tnfctl_errcode_t
81 tnfctl_filter_list_delete(tnfctl_handle_t *hdl, pid_t pid)
82 {
83 	if (hdl->mode != KERNEL_MODE)
84 		return (TNFCTL_ERR_BADARG);
85 
86 	/* KERNEL_MODE */
87 	return (_tnfctl_prbk_pfilter_delete(hdl, pid));
88 }
89