| 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_SA_H_ |
| 35 |
#define NETLINK_XFRM_SA_H_ |
| 36 |
|
| 37 |
#include <netlink/netlink.h> |
| 38 |
#include <netlink/cache.h> |
| 39 |
#include <netlink/addr.h> |
| 40 |
#include <linux/xfrm.h> |
| 41 |
|
| 42 |
#ifdef __cplusplus |
| 43 |
extern "C" { |
| 44 |
#endif |
| 45 |
|
| 46 |
struct xfrmnl_sa; |
| 47 |
|
| 48 |
extern struct xfrmnl_sa* xfrmnl_sa_alloc(void); |
| 49 |
extern void xfrmnl_sa_put(struct xfrmnl_sa *); |
| 50 |
|
| 51 |
extern int xfrmnl_sa_alloc_cache(struct nl_sock *, struct nl_cache **); |
| 52 |
extern struct xfrmnl_sa* xfrmnl_sa_get(struct nl_cache*, struct nl_addr*, unsigned int, unsigned int); |
| 53 |
|
| 54 |
extern int xfrmnl_sa_parse(struct nlmsghdr *n, struct xfrmnl_sa **result); |
| 55 |
|
| 56 |
extern int xfrmnl_sa_build_get_request(struct nl_addr*, unsigned int, unsigned int, |
| 57 |
unsigned int, unsigned int, struct nl_msg **); |
| 58 |
extern int xfrmnl_sa_get_kernel(struct nl_sock*, struct nl_addr*, unsigned int, |
| 59 |
unsigned int, unsigned int, unsigned int, struct xfrmnl_sa**); |
| 60 |
|
| 61 |
extern int xfrmnl_sa_build_add_request(struct xfrmnl_sa*, int, struct nl_msg **); |
| 62 |
extern int xfrmnl_sa_add(struct nl_sock*, struct xfrmnl_sa*, int); |
| 63 |
|
| 64 |
extern int xfrmnl_sa_build_update_request(struct xfrmnl_sa*, int, struct nl_msg **); |
| 65 |
extern int xfrmnl_sa_update(struct nl_sock*, struct xfrmnl_sa*, int); |
| 66 |
|
| 67 |
extern int xfrmnl_sa_build_delete_request(struct xfrmnl_sa*, int, struct nl_msg **); |
| 68 |
extern int xfrmnl_sa_delete(struct nl_sock*, struct xfrmnl_sa*, int); |
| 69 |
|
| 70 |
extern struct xfrmnl_sel* xfrmnl_sa_get_sel (struct xfrmnl_sa*); |
| 71 |
extern int xfrmnl_sa_set_sel (struct xfrmnl_sa*, struct xfrmnl_sel*); |
| 72 |
|
| 73 |
extern struct nl_addr* xfrmnl_sa_get_daddr (struct xfrmnl_sa*); |
| 74 |
extern int xfrmnl_sa_set_daddr (struct xfrmnl_sa*, struct nl_addr*); |
| 75 |
|
| 76 |
extern int xfrmnl_sa_get_spi (struct xfrmnl_sa*); |
| 77 |
extern int xfrmnl_sa_set_spi (struct xfrmnl_sa*, unsigned int); |
| 78 |
|
| 79 |
extern int xfrmnl_sa_get_proto (struct xfrmnl_sa*); |
| 80 |
extern int xfrmnl_sa_set_proto (struct xfrmnl_sa*, unsigned int); |
| 81 |
|
| 82 |
extern struct nl_addr* xfrmnl_sa_get_saddr (struct xfrmnl_sa*); |
| 83 |
extern int xfrmnl_sa_set_saddr (struct xfrmnl_sa*, struct nl_addr*); |
| 84 |
|
| 85 |
extern struct xfrmnl_ltime_cfg* xfrmnl_sa_get_lifetime_cfg (struct xfrmnl_sa*); |
| 86 |
extern int xfrmnl_sa_set_lifetime_cfg (struct xfrmnl_sa*, struct xfrmnl_ltime_cfg*); |
| 87 |
|
| 88 |
extern int xfrmnl_sa_get_curlifetime (struct xfrmnl_sa*, unsigned long long int*, |
| 89 |
unsigned long long int*, unsigned long long int*, |
| 90 |
unsigned long long int*); |
| 91 |
|
| 92 |
extern int xfrmnl_sa_get_stats (struct xfrmnl_sa*, unsigned long long int*, |
| 93 |
unsigned long long int*, unsigned long long int*); |
| 94 |
|
| 95 |
extern int xfrmnl_sa_get_seq (struct xfrmnl_sa*); |
| 96 |
|
| 97 |
extern int xfrmnl_sa_get_reqid (struct xfrmnl_sa*); |
| 98 |
extern int xfrmnl_sa_set_reqid (struct xfrmnl_sa*, unsigned int); |
| 99 |
|
| 100 |
extern int xfrmnl_sa_get_family (struct xfrmnl_sa*); |
| 101 |
extern int xfrmnl_sa_set_family (struct xfrmnl_sa*, unsigned int); |
| 102 |
|
| 103 |
extern int xfrmnl_sa_get_mode (struct xfrmnl_sa*); |
| 104 |
extern int xfrmnl_sa_set_mode (struct xfrmnl_sa*, unsigned int); |
| 105 |
|
| 106 |
extern int xfrmnl_sa_get_replay_window (struct xfrmnl_sa*); |
| 107 |
extern int xfrmnl_sa_set_replay_window (struct xfrmnl_sa*, unsigned int); |
| 108 |
|
| 109 |
extern int xfrmnl_sa_get_flags (struct xfrmnl_sa*); |
| 110 |
extern int xfrmnl_sa_set_flags (struct xfrmnl_sa*, unsigned int); |
| 111 |
|
| 112 |
extern int xfrmnl_sa_get_aead_params (struct xfrmnl_sa*, char*, unsigned int*, |
| 113 |
unsigned int*, char*); |
| 114 |
extern int xfrmnl_sa_set_aead_params (struct xfrmnl_sa*, const char*, unsigned int, |
| 115 |
unsigned int, const char*); |
| 116 |
|
| 117 |
extern int xfrmnl_sa_get_auth_params (struct xfrmnl_sa*, char*, unsigned int*, |
| 118 |
unsigned int*, char*); |
| 119 |
extern int xfrmnl_sa_set_auth_params (struct xfrmnl_sa*, const char*, unsigned int, |
| 120 |
unsigned int, const char*); |
| 121 |
|
| 122 |
extern int xfrmnl_sa_get_crypto_params (struct xfrmnl_sa*, char*, unsigned int*, char*); |
| 123 |
extern int xfrmnl_sa_set_crypto_params (struct xfrmnl_sa*, const char*, unsigned int, |
| 124 |
const char*); |
| 125 |
|
| 126 |
extern int xfrmnl_sa_get_comp_params (struct xfrmnl_sa*, char*, unsigned int*, char*); |
| 127 |
extern int xfrmnl_sa_set_comp_params (struct xfrmnl_sa*, const char*, unsigned int, |
| 128 |
const char*); |
| 129 |
|
| 130 |
extern int xfrmnl_sa_get_encap_tmpl (struct xfrmnl_sa*, unsigned int*, unsigned int*, |
| 131 |
unsigned int*, struct nl_addr**); |
| 132 |
extern int xfrmnl_sa_set_encap_tmpl (struct xfrmnl_sa*, unsigned int, unsigned int, |
| 133 |
unsigned int, struct nl_addr*); |
| 134 |
|
| 135 |
extern int xfrmnl_sa_get_tfcpad (struct xfrmnl_sa*); |
| 136 |
extern int xfrmnl_sa_set_tfcpad (struct xfrmnl_sa*, unsigned int); |
| 137 |
|
| 138 |
extern struct nl_addr* xfrmnl_sa_get_coaddr (struct xfrmnl_sa*); |
| 139 |
extern int xfrmnl_sa_set_coaddr (struct xfrmnl_sa*, struct nl_addr*); |
| 140 |
|
| 141 |
extern int xfrmnl_sa_get_mark (struct xfrmnl_sa*, unsigned int*, unsigned int*); |
| 142 |
extern int xfrmnl_sa_set_mark (struct xfrmnl_sa*, unsigned int, unsigned int); |
| 143 |
|
| 144 |
extern int xfrmnl_sa_get_if_id (struct xfrmnl_sa*, uint32_t*); |
| 145 |
extern int xfrmnl_sa_set_if_id (struct xfrmnl_sa*, uint32_t); |
| 146 |
|
| 147 |
extern int xfrmnl_sa_get_sec_ctx (struct xfrmnl_sa*, unsigned int*, unsigned int*, |
| 148 |
unsigned int*, unsigned int*, char*); |
| 149 |
extern int xfrmnl_sa_set_sec_ctx (struct xfrmnl_sa*, unsigned int, unsigned int, |
| 150 |
unsigned int, unsigned int, const char*); |
| 151 |
|
| 152 |
extern int xfrmnl_sa_get_replay_maxage (struct xfrmnl_sa*); |
| 153 |
extern int xfrmnl_sa_set_replay_maxage (struct xfrmnl_sa*, unsigned int); |
| 154 |
|
| 155 |
extern int xfrmnl_sa_get_replay_maxdiff (struct xfrmnl_sa*); |
| 156 |
extern int xfrmnl_sa_set_replay_maxdiff (struct xfrmnl_sa*, unsigned int); |
| 157 |
|
| 158 |
extern int xfrmnl_sa_get_replay_state (struct xfrmnl_sa*, unsigned int*, |
| 159 |
unsigned int*, unsigned int*); |
| 160 |
extern int xfrmnl_sa_set_replay_state (struct xfrmnl_sa*, unsigned int, |
| 161 |
unsigned int, unsigned int); |
| 162 |
|
| 163 |
extern int xfrmnl_sa_get_replay_state_esn (struct xfrmnl_sa*, unsigned int*, unsigned int*, |
| 164 |
unsigned int*, unsigned int*, unsigned int*, |
| 165 |
unsigned int*, unsigned int*); |
| 166 |
extern int xfrmnl_sa_set_replay_state_esn (struct xfrmnl_sa*, unsigned int, unsigned int, |
| 167 |
unsigned int, unsigned int, unsigned int, |
| 168 |
unsigned int, unsigned int*); |
| 169 |
|
| 170 |
extern int xfrmnl_sa_get_user_offload (struct xfrmnl_sa*, int*, uint8_t *); |
| 171 |
extern int xfrmnl_sa_set_user_offload (struct xfrmnl_sa*, int, uint8_t); |
| 172 |
|
| 173 |
extern int xfrmnl_sa_is_expiry_reached (struct xfrmnl_sa*); |
| 174 |
extern int xfrmnl_sa_is_hardexpiry_reached (struct xfrmnl_sa*); |
| 175 |
|
| 176 |
extern char* xfrmnl_sa_flags2str(int, char *, size_t); |
| 177 |
extern int xfrmnl_sa_str2flag(const char *); |
| 178 |
|
| 179 |
extern char* xfrmnl_sa_mode2str(int, char *, size_t); |
| 180 |
extern int xfrmnl_sa_str2mode(const char *); |
| 181 |
|
| 182 |
#ifdef __cplusplus |
| 183 |
} |
| 184 |
#endif |
| 185 |
|
| 186 |
#endif |