summaryrefslogtreecommitdiff
path: root/usr/src/lib/varpd/libvarpd/common/libvarpd_client.h
blob: 459711b38548c993e29640039879551e3f0aa926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2015 Joyent, Inc.
 */

#ifndef _LIBVARPD_CLIENT_H
#define	_LIBVARPD_CLIENT_H

/*
 * varpd interfaces
 */

#include <sys/types.h>
#include <stdint.h>
#include <sys/mac.h>
#include <sys/overlay_target.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct __varpd_client_handle varpd_client_handle_t;
typedef struct __varpd_client_prop_handle varpd_client_prop_handle_t;

typedef struct varpd_client_cache_entry {
	struct ether_addr	vcp_mac;
	uint16_t		vcp_flags;
	struct in6_addr		vcp_ip;
	uint16_t		vcp_port;
} varpd_client_cache_entry_t;

/*
 * We just use the values from the kernel for now.
 */
#define	LIBVARPD_PROP_SIZEMAX	OVERLAY_PROP_SIZEMAX
#define	LIBVARPD_PROP_NAMELEN	OVERLAY_PROP_NAMELEN

extern int libvarpd_c_create(varpd_client_handle_t **, const char *);
extern void libvarpd_c_destroy(varpd_client_handle_t *);
extern int libvarpd_c_instance_create(varpd_client_handle_t *, datalink_id_t,
    const char *, uint64_t *);
extern int libvarpd_c_instance_activate(varpd_client_handle_t *, uint64_t);
extern int libvarpd_c_instance_destroy(varpd_client_handle_t *, uint64_t);

extern int libvarpd_c_prop_nprops(varpd_client_handle_t *, uint64_t, uint_t *);
extern int libvarpd_c_prop_handle_alloc(varpd_client_handle_t *, uint64_t,
    varpd_client_prop_handle_t **);
extern void libvarpd_c_prop_handle_free(varpd_client_prop_handle_t *);
extern int libvarpd_c_prop_info_fill(varpd_client_prop_handle_t *, uint_t);
extern int libvarpd_c_prop_info_fill_by_name(varpd_client_prop_handle_t *,
    const char *);
extern int libvarpd_c_prop_info(varpd_client_prop_handle_t *, const char **,
    uint_t *, uint_t *, const void **, uint32_t *,
    const mac_propval_range_t **);
extern int libvarpd_c_prop_get(varpd_client_prop_handle_t *, void *,
    uint32_t *);
extern int libvarpd_c_prop_set(varpd_client_prop_handle_t *, const void *,
    uint32_t);

extern int libvarpd_c_instance_lookup(varpd_client_handle_t *, datalink_id_t,
    uint64_t *);
extern int libvarpd_c_instance_target_mode(varpd_client_handle_t *, uint64_t,
    uint_t *, uint_t *);
extern int libvarpd_c_instance_cache_flush(varpd_client_handle_t *, uint64_t);
extern int libvarpd_c_instance_cache_delete(varpd_client_handle_t *, uint64_t,
    const struct ether_addr *);
extern int libvarpd_c_instance_cache_get(varpd_client_handle_t *, uint64_t,
    const struct ether_addr *, varpd_client_cache_entry_t *);
extern int libvarpd_c_instance_cache_set(varpd_client_handle_t *, uint64_t,
    const struct ether_addr *, const varpd_client_cache_entry_t *);

typedef int (*varpd_client_cache_f)(varpd_client_handle_t *, uint64_t,
    const struct ether_addr *, const varpd_client_cache_entry_t *, void *);
extern int libvarpd_c_instance_cache_walk(varpd_client_handle_t *, uint64_t,
    varpd_client_cache_f, void *);


#ifdef __cplusplus
}
#endif

#endif /* _LIBVARPD_CLIENT_H */