xref: /illumos-gate/usr/src/lib/libdladm/common/libdloverlay.h (revision 36589d6bb0cdae89e166b57b0d64ae56d53247d9)
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) 2015 Joyent, Inc.
14  */
15 
16 #ifndef _LIBDLOVERLAY_H
17 #define	_LIBDLOVERLAY_H
18 
19 /*
20  * libdladm Overlay device routines
21  */
22 
23 #include <libdladm.h>
24 #include <libdladm_impl.h>
25 #include <sys/overlay.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define	DLADM_OVERLAY_F_DROP	0x0001
32 #define	DLADM_OVERLAY_F_DEFAULT	0xf000
33 
34 typedef struct dladm_overlay_point {
35 	uint_t			dop_dest;
36 	struct ether_addr	dop_mac;
37 	uint16_t		dop_flags;
38 	struct in6_addr		dop_ip;
39 	uint16_t		dop_port;
40 } dladm_overlay_point_t;
41 
42 typedef struct dladm_overlay_status {
43 	boolean_t	dos_degraded;
44 	char		dos_fmamsg[256];
45 } dladm_overlay_status_t;
46 
47 extern dladm_status_t dladm_overlay_create(dladm_handle_t, const char *,
48     const char *, const char *, uint64_t, dladm_arg_list_t *, dladm_errlist_t *,
49     uint32_t);
50 extern dladm_status_t dladm_overlay_delete(dladm_handle_t, datalink_id_t);
51 
52 typedef void (*dladm_overlay_status_f)(dladm_handle_t, datalink_id_t,
53     dladm_overlay_status_t *, void *);
54 extern dladm_status_t dladm_overlay_status(dladm_handle_t, datalink_id_t,
55     dladm_overlay_status_f, void *);
56 
57 extern dladm_status_t dladm_overlay_cache_flush(dladm_handle_t, datalink_id_t);
58 extern dladm_status_t dladm_overlay_cache_delete(dladm_handle_t, datalink_id_t,
59     const struct ether_addr *);
60 extern dladm_status_t dladm_overlay_cache_set(dladm_handle_t, datalink_id_t,
61     const struct ether_addr *, char *);
62 extern dladm_status_t dladm_overlay_cache_get(dladm_handle_t, datalink_id_t,
63     const struct ether_addr *, dladm_overlay_point_t *);
64 
65 #define	DLADM_OVERLAY_PROP_SIZEMAX	256
66 #define	DLADM_OVERLAY_PROP_NAMELEN	32
67 
68 typedef struct __dladm_overlay_propinfo *dladm_overlay_propinfo_handle_t;
69 
70 extern dladm_status_t dladm_overlay_prop_info(dladm_overlay_propinfo_handle_t,
71     const char **, uint_t *, uint_t *, const void **, uint32_t *,
72     const mac_propval_range_t **);
73 extern dladm_status_t dladm_overlay_get_prop(dladm_handle_t, datalink_id_t,
74     dladm_overlay_propinfo_handle_t, void *buf, size_t *bufsize);
75 
76 typedef int (*dladm_overlay_prop_f)(dladm_handle_t, datalink_id_t,
77     dladm_overlay_propinfo_handle_t, void *);
78 extern dladm_status_t dladm_overlay_walk_prop(dladm_handle_t, datalink_id_t,
79     dladm_overlay_prop_f, void *arg, dladm_errlist_t *);
80 
81 typedef int (*dladm_overlay_cache_f)(dladm_handle_t, datalink_id_t,
82     const struct ether_addr *, const dladm_overlay_point_t *, void *);
83 extern dladm_status_t dladm_overlay_walk_cache(dladm_handle_t, datalink_id_t,
84     dladm_overlay_cache_f, void *);
85 
86 /*
87  * Some day we'll want to support being able to set properties after creation.
88  * If we do, the following strawman API might serve us well.
89  *
90  * extern dladm_status_t dladm_overlay_prop_lookup(dladm_handle_t,
91  *     datalink_id_t, const char *, dladm_overlay_propinfo_handle_t *);
92  * extern void dladm_overlay_prop_handle_free(dladm_handle_t, datalink_id_t,
93  *     dladm_overlay_propinfo_handle_t *);
94  * extern dladm_status_t dladm_overlay_set_prop(dladm_handle_t, datalink_id_t,
95  *     dladm_propinfo_handle_t, void *buf, size_t *bufsize);
96  * extern dladm_status_t dladm_overlay_str_to_buf(dladm_handle_t, datalink_id_t,
97  *     dladm_overlay_propinfo_handle_t *, const char *, void *, size_t *);
98  * extern dladm_status_t dladm_overlay_buf_to_str(dladm_handle_t, datalink_id_t,
99  *     dladm_overlay_propinfo_handle_t *, const void *, const size_t, char *,
100  *     size_t *);
101  */
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* _LIBDLOVERLAY_H */
108