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