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 45 extern "C" { 46 #endif 47 48 struct xfrmnl_sp; 49 50 extern struct xfrmnl_sp* xfrmnl_sp_alloc(void); 51 extern void xfrmnl_sp_put(struct xfrmnl_sp *); 52 53 extern int xfrmnl_sp_alloc_cache(struct nl_sock *, struct nl_cache **); 54 extern struct xfrmnl_sp* xfrmnl_sp_get(struct nl_cache*, unsigned int, unsigned int); 55 56 extern int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result); 57 58 extern int xfrmnl_sp_build_get_request(unsigned int, unsigned int, unsigned int, 59 unsigned int, struct nl_msg **); 60 extern int xfrmnl_sp_get_kernel(struct nl_sock*, unsigned int, unsigned int, 61 unsigned int, unsigned int, struct xfrmnl_sp**); 62 63 extern int xfrmnl_sp_add(struct nl_sock*, struct xfrmnl_sp*, int); 64 extern int xfrmnl_sp_build_add_request(struct xfrmnl_sp*, int, struct nl_msg **); 65 66 extern int xfrmnl_sp_update(struct nl_sock*, struct xfrmnl_sp*, int); 67 extern int xfrmnl_sp_build_update_request(struct xfrmnl_sp*, int, struct nl_msg **); 68 69 extern int xfrmnl_sp_delete(struct nl_sock*, struct xfrmnl_sp*, int); 70 extern int xfrmnl_sp_build_delete_request(struct xfrmnl_sp*, int, struct nl_msg **); 71 72 extern struct xfrmnl_sel* xfrmnl_sp_get_sel (struct xfrmnl_sp*); 73 extern int xfrmnl_sp_set_sel (struct xfrmnl_sp*, struct xfrmnl_sel*); 74 75 extern struct xfrmnl_ltime_cfg* xfrmnl_sp_get_lifetime_cfg (struct xfrmnl_sp*); 76 extern int xfrmnl_sp_set_lifetime_cfg (struct xfrmnl_sp*, struct xfrmnl_ltime_cfg*); 77 78 extern 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 82 extern int xfrmnl_sp_get_priority (struct xfrmnl_sp*); 83 extern int xfrmnl_sp_set_priority (struct xfrmnl_sp*, unsigned int); 84 85 extern int xfrmnl_sp_get_index (struct xfrmnl_sp*); 86 extern int xfrmnl_sp_set_index (struct xfrmnl_sp*, unsigned int); 87 88 extern int xfrmnl_sp_get_dir (struct xfrmnl_sp*); 89 extern int xfrmnl_sp_set_dir (struct xfrmnl_sp*, unsigned int); 90 91 extern int xfrmnl_sp_get_action (struct xfrmnl_sp*); 92 extern int xfrmnl_sp_set_action (struct xfrmnl_sp*, unsigned int); 93 94 extern int xfrmnl_sp_get_flags (struct xfrmnl_sp*); 95 extern int xfrmnl_sp_set_flags (struct xfrmnl_sp*, unsigned int); 96 97 extern int xfrmnl_sp_get_share (struct xfrmnl_sp*); 98 extern int xfrmnl_sp_set_share (struct xfrmnl_sp*, unsigned int); 99 100 extern int xfrmnl_sp_get_sec_ctx (struct xfrmnl_sp*, unsigned int*, unsigned int*, 101 unsigned int*, unsigned int*, unsigned int*, char*); 102 extern int xfrmnl_sp_set_sec_ctx (struct xfrmnl_sp*, unsigned int, unsigned int, 103 unsigned int, unsigned int, unsigned int, char*); 104 105 extern int xfrmnl_sp_get_userpolicy_type (struct xfrmnl_sp*); 106 extern int xfrmnl_sp_set_userpolicy_type (struct xfrmnl_sp*, unsigned int); 107 108 extern void xfrmnl_sp_add_usertemplate(struct xfrmnl_sp*, struct xfrmnl_user_tmpl*); 109 extern void xfrmnl_sp_remove_usertemplate(struct xfrmnl_sp*, struct xfrmnl_user_tmpl*); 110 extern struct nl_list_head* xfrmnl_sp_get_usertemplates(struct xfrmnl_sp*); 111 extern int xfrmnl_sp_get_nusertemplates(struct xfrmnl_sp*); 112 extern void xfrmnl_sp_foreach_usertemplate(struct xfrmnl_sp*, 113 void (*cb)(struct xfrmnl_user_tmpl*, void *), 114 void *arg); 115 extern struct xfrmnl_user_tmpl* xfrmnl_sp_usertemplate_n(struct xfrmnl_sp*, int); 116 117 extern int xfrmnl_sp_get_mark (struct xfrmnl_sp*, unsigned int*, unsigned int*); 118 extern int xfrmnl_sp_set_mark (struct xfrmnl_sp*, unsigned int, unsigned int); 119 120 extern char* xfrmnl_sp_action2str(int, char *, size_t); 121 extern int xfrmnl_sp_str2action(const char *); 122 123 extern char* xfrmnl_sp_flags2str(int, char *, size_t); 124 extern int xfrmnl_sp_str2flag(const char *); 125 126 extern char* xfrmnl_sp_type2str(int, char *, size_t); 127 extern int xfrmnl_sp_str2type(const char *); 128 129 extern char* xfrmnl_sp_dir2str(int, char *, size_t); 130 extern int xfrmnl_sp_str2dir(const char *); 131 132 extern char* xfrmnl_sp_share2str(int, char *, size_t); 133 extern int xfrmnl_sp_str2share(const char *); 134 135 extern int xfrmnl_sp_index2dir (unsigned int); 136 137 138 #ifdef __cplusplus 139 } 140 #endif 141 142 #endif 143