xref: /titanic_41/usr/src/lib/libipd/common/libipd.h (revision 1a95defd9ad2425f3c74030860dd9eb24a3e7930)
1*bfb211e0SRobert Mustacchi /*
2*bfb211e0SRobert Mustacchi  * This file and its contents are supplied under the terms of the
3*bfb211e0SRobert Mustacchi  * Common Development and Distribution License ("CDDL"), version 1.0.
4*bfb211e0SRobert Mustacchi  * You may only use this file in accordance with the terms of version
5*bfb211e0SRobert Mustacchi  * 1.0 of the CDDL.
6*bfb211e0SRobert Mustacchi  *
7*bfb211e0SRobert Mustacchi  * A full copy of the text of the CDDL should have accompanied this
8*bfb211e0SRobert Mustacchi  * source.  A copy of the CDDL is also available via the Internet at
9*bfb211e0SRobert Mustacchi  * http://www.illumos.org/license/CDDL.
10*bfb211e0SRobert Mustacchi  */
11*bfb211e0SRobert Mustacchi 
12*bfb211e0SRobert Mustacchi /*
13*bfb211e0SRobert Mustacchi  * Copyright (c) 2012 Joyent, Inc.  All rights reserved.
14*bfb211e0SRobert Mustacchi  * Use is subject to license terms.
15*bfb211e0SRobert Mustacchi  */
16*bfb211e0SRobert Mustacchi 
17*bfb211e0SRobert Mustacchi #ifndef	_LIBIPD_H
18*bfb211e0SRobert Mustacchi #define	_LIBIPD_H
19*bfb211e0SRobert Mustacchi 
20*bfb211e0SRobert Mustacchi #include <sys/types.h>
21*bfb211e0SRobert Mustacchi 
22*bfb211e0SRobert Mustacchi #ifdef	__cplusplus
23*bfb211e0SRobert Mustacchi extern "C" {
24*bfb211e0SRobert Mustacchi #endif
25*bfb211e0SRobert Mustacchi 
26*bfb211e0SRobert Mustacchi /*
27*bfb211e0SRobert Mustacchi  * Bitmask values for ic_mask.
28*bfb211e0SRobert Mustacchi  */
29*bfb211e0SRobert Mustacchi #define	IPDM_CORRUPT	0x1000
30*bfb211e0SRobert Mustacchi #define	IPDM_DELAY	0x2000
31*bfb211e0SRobert Mustacchi #define	IPDM_DROP	0x4000
32*bfb211e0SRobert Mustacchi 
33*bfb211e0SRobert Mustacchi typedef enum ipd_errno {
34*bfb211e0SRobert Mustacchi 	EIPD_NOERROR = 0,
35*bfb211e0SRobert Mustacchi 	EIPD_NOMEM,
36*bfb211e0SRobert Mustacchi 	EIPD_ZC_NOENT,
37*bfb211e0SRobert Mustacchi 	EIPD_RANGE,
38*bfb211e0SRobert Mustacchi 	EIPD_PERM,
39*bfb211e0SRobert Mustacchi 	EIPD_FAULT,
40*bfb211e0SRobert Mustacchi 	EIPD_INTERNAL,
41*bfb211e0SRobert Mustacchi 	EIPD_UNKNOWN
42*bfb211e0SRobert Mustacchi } ipd_errno_t;
43*bfb211e0SRobert Mustacchi 
44*bfb211e0SRobert Mustacchi typedef struct ipd_config {
45*bfb211e0SRobert Mustacchi 	uint32_t ic_mask;
46*bfb211e0SRobert Mustacchi 	uint32_t ic_corrupt;
47*bfb211e0SRobert Mustacchi 	uint32_t ic_drop;
48*bfb211e0SRobert Mustacchi 	uint32_t ic_delay;
49*bfb211e0SRobert Mustacchi } ipd_config_t;
50*bfb211e0SRobert Mustacchi 
51*bfb211e0SRobert Mustacchi struct ipd_stat;
52*bfb211e0SRobert Mustacchi typedef struct ipd_stat *ipd_stathdl_t;
53*bfb211e0SRobert Mustacchi 
54*bfb211e0SRobert Mustacchi typedef void (*ipd_status_cb_f)(zoneid_t, const ipd_config_t *, void *);
55*bfb211e0SRobert Mustacchi 
56*bfb211e0SRobert Mustacchi extern __thread ipd_errno_t ipd_errno;
57*bfb211e0SRobert Mustacchi extern __thread char ipd_errmsg[];
58*bfb211e0SRobert Mustacchi 
59*bfb211e0SRobert Mustacchi extern const char *ipd_strerror(ipd_errno_t);
60*bfb211e0SRobert Mustacchi extern int ipd_open(const char *);
61*bfb211e0SRobert Mustacchi extern int ipd_close(int);
62*bfb211e0SRobert Mustacchi extern int ipd_status_read(int, ipd_stathdl_t *);
63*bfb211e0SRobert Mustacchi extern void ipd_status_foreach_zone(const ipd_stathdl_t,
64*bfb211e0SRobert Mustacchi     ipd_status_cb_f, void *);
65*bfb211e0SRobert Mustacchi extern int ipd_status_get_config(const ipd_stathdl_t,
66*bfb211e0SRobert Mustacchi     zoneid_t, ipd_config_t **);
67*bfb211e0SRobert Mustacchi extern void ipd_status_free(ipd_stathdl_t);
68*bfb211e0SRobert Mustacchi extern int ipd_ctl(int, zoneid_t, const ipd_config_t *);
69*bfb211e0SRobert Mustacchi 
70*bfb211e0SRobert Mustacchi #ifdef	__cplusplus
71*bfb211e0SRobert Mustacchi }
72*bfb211e0SRobert Mustacchi #endif
73*bfb211e0SRobert Mustacchi 
74*bfb211e0SRobert Mustacchi #endif	/* _LIBIPD_H */
75