libnl 3.7.0
sp.h
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34#ifndef NETLINK_XFRM_SP_H_
35#define NETLINK_XFRM_SP_H_
36
37#include <netlink/netlink.h>
38#include <netlink/cache.h>
39#include <netlink/addr.h>
40#include <netlink/xfrm/template.h>
41#include <netlink/xfrm/lifetime.h>
42#include <linux/xfrm.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48struct xfrmnl_sp;
49
50extern struct xfrmnl_sp* xfrmnl_sp_alloc(void);
51extern void xfrmnl_sp_put(struct xfrmnl_sp *);
52
53extern int xfrmnl_sp_alloc_cache(struct nl_sock *, struct nl_cache **);
54extern struct xfrmnl_sp* xfrmnl_sp_get(struct nl_cache*, unsigned int, unsigned int);
55
56extern int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result);
57
58extern int xfrmnl_sp_build_get_request(unsigned int, unsigned int, unsigned int,
59 unsigned int, struct nl_msg **);
60extern int xfrmnl_sp_get_kernel(struct nl_sock*, unsigned int, unsigned int,
61 unsigned int, unsigned int, struct xfrmnl_sp**);
62
63extern int xfrmnl_sp_add(struct nl_sock*, struct xfrmnl_sp*, int);
64extern int xfrmnl_sp_build_add_request(struct xfrmnl_sp*, int, struct nl_msg **);
65
66extern int xfrmnl_sp_update(struct nl_sock*, struct xfrmnl_sp*, int);
67extern int xfrmnl_sp_build_update_request(struct xfrmnl_sp*, int, struct nl_msg **);
68
69extern int xfrmnl_sp_delete(struct nl_sock*, struct xfrmnl_sp*, int);
70extern int xfrmnl_sp_build_delete_request(struct xfrmnl_sp*, int, struct nl_msg **);
71
72extern struct xfrmnl_sel* xfrmnl_sp_get_sel (struct xfrmnl_sp*);
73extern int xfrmnl_sp_set_sel (struct xfrmnl_sp*, struct xfrmnl_sel*);
74
75extern struct xfrmnl_ltime_cfg* xfrmnl_sp_get_lifetime_cfg (struct xfrmnl_sp*);
76extern int xfrmnl_sp_set_lifetime_cfg (struct xfrmnl_sp*, struct xfrmnl_ltime_cfg*);
77
78extern int xfrmnl_sp_get_curlifetime (struct xfrmnl_sp*, unsigned long long int*,
79 unsigned long long int*, unsigned long long int*,
80 unsigned long long int*);
81
82extern int xfrmnl_sp_get_priority (struct xfrmnl_sp*);
83extern int xfrmnl_sp_set_priority (struct xfrmnl_sp*, unsigned int);
84
85extern int xfrmnl_sp_get_index (struct xfrmnl_sp*);
86extern int xfrmnl_sp_set_index (struct xfrmnl_sp*, unsigned int);
87
88extern int xfrmnl_sp_get_dir (struct xfrmnl_sp*);
89extern int xfrmnl_sp_set_dir (struct xfrmnl_sp*, unsigned int);
90
91extern int xfrmnl_sp_get_action (struct xfrmnl_sp*);
92extern int xfrmnl_sp_set_action (struct xfrmnl_sp*, unsigned int);
93
94extern int xfrmnl_sp_get_flags (struct xfrmnl_sp*);
95extern int xfrmnl_sp_set_flags (struct xfrmnl_sp*, unsigned int);
96
97extern int xfrmnl_sp_get_share (struct xfrmnl_sp*);
98extern int xfrmnl_sp_set_share (struct xfrmnl_sp*, unsigned int);
99
100extern int xfrmnl_sp_get_sec_ctx (struct xfrmnl_sp*, unsigned int*, unsigned int*,
101 unsigned int*, unsigned int*, unsigned int*, char*);
102extern int xfrmnl_sp_set_sec_ctx (struct xfrmnl_sp*, unsigned int, unsigned int,
103 unsigned int, unsigned int, unsigned int, char*);
104
105extern int xfrmnl_sp_get_userpolicy_type (struct xfrmnl_sp*);
106extern int xfrmnl_sp_set_userpolicy_type (struct xfrmnl_sp*, unsigned int);
107
108extern void xfrmnl_sp_add_usertemplate(struct xfrmnl_sp*, struct xfrmnl_user_tmpl*);
109extern void xfrmnl_sp_remove_usertemplate(struct xfrmnl_sp*, struct xfrmnl_user_tmpl*);
110extern struct nl_list_head* xfrmnl_sp_get_usertemplates(struct xfrmnl_sp*);
111extern int xfrmnl_sp_get_nusertemplates(struct xfrmnl_sp*);
112extern void xfrmnl_sp_foreach_usertemplate(struct xfrmnl_sp*,
113 void (*cb)(struct xfrmnl_user_tmpl*, void *),
114 void *arg);
115extern struct xfrmnl_user_tmpl* xfrmnl_sp_usertemplate_n(struct xfrmnl_sp*, int);
116
117extern int xfrmnl_sp_get_mark (struct xfrmnl_sp*, unsigned int*, unsigned int*);
118extern int xfrmnl_sp_set_mark (struct xfrmnl_sp*, unsigned int, unsigned int);
119
120extern char* xfrmnl_sp_action2str(int, char *, size_t);
121extern int xfrmnl_sp_str2action(const char *);
122
123extern char* xfrmnl_sp_flags2str(int, char *, size_t);
124extern int xfrmnl_sp_str2flag(const char *);
125
126extern char* xfrmnl_sp_type2str(int, char *, size_t);
127extern int xfrmnl_sp_str2type(const char *);
128
129extern char* xfrmnl_sp_dir2str(int, char *, size_t);
130extern int xfrmnl_sp_str2dir(const char *);
131
132extern char* xfrmnl_sp_share2str(int, char *, size_t);
133extern int xfrmnl_sp_str2share(const char *);
134
135extern int xfrmnl_sp_index2dir (unsigned int);
136
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif