net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 1 | /* $USAGI: $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (C)2004 USAGI/WIDE Project |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | /* |
| 21 | * Authors: |
| 22 | * Masahide NAKAMURA @USAGI |
| 23 | */ |
| 24 | |
| 25 | #ifndef __XFRM_H__ |
| 26 | #define __XFRM_H__ 1 |
| 27 | |
| 28 | #include <stdio.h> |
| 29 | #include <sys/socket.h> |
| 30 | #include <linux/xfrm.h> |
osdl.net!shemminger | 63d91b4 | 2004-10-20 23:22:30 +0000 | [diff] [blame] | 31 | |
| 32 | #ifndef IPPROTO_SCTP |
| 33 | # define IPPROTO_SCTP 132 |
| 34 | #endif |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 35 | |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 36 | #define XFRMS_RTA(x) ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_usersa_info)))) |
| 37 | #define XFRMS_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_usersa_info)) |
| 38 | |
| 39 | #define XFRMP_RTA(x) ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_info)))) |
| 40 | #define XFRMP_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_userpoilcy_info)) |
| 41 | |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 42 | #define XFRM_FLAG_PRINT(fp, flags, f, s) \ |
| 43 | do { \ |
| 44 | if (flags & f) { \ |
| 45 | flags &= ~f; \ |
| 46 | fprintf(fp, s "%s", (flags ? " " : "")); \ |
| 47 | } \ |
| 48 | } while(0) |
| 49 | |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 50 | struct xfrm_buffer { |
| 51 | char *buf; |
| 52 | int size; |
| 53 | int offset; |
| 54 | |
| 55 | int nlmsg_count; |
| 56 | struct rtnl_handle *rth; |
| 57 | }; |
| 58 | |
| 59 | struct xfrm_filter { |
| 60 | int use; |
| 61 | |
| 62 | struct xfrm_usersa_info xsinfo; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 63 | __u8 id_src_mask; |
| 64 | __u8 id_dst_mask; |
| 65 | __u8 id_proto_mask; |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 66 | __u32 id_spi_mask; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 67 | __u8 mode_mask; |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 68 | __u32 reqid_mask; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 69 | __u8 state_flags_mask; |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 70 | |
| 71 | struct xfrm_userpolicy_info xpinfo; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 72 | __u8 dir_mask; |
| 73 | __u8 sel_src_mask; |
| 74 | __u8 sel_dst_mask; |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 75 | __u32 sel_dev_mask; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 76 | __u8 upspec_proto_mask; |
| 77 | __u16 upspec_sport_mask; |
| 78 | __u16 upspec_dport_mask; |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 79 | __u32 index_mask; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 80 | __u8 action_mask; |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 81 | __u32 priority_mask; |
| 82 | }; |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 83 | #define XFRM_FILTER_MASK_FULL (~0) |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 84 | |
| 85 | extern struct xfrm_filter filter; |
| 86 | |
| 87 | int do_xfrm_state(int argc, char **argv); |
| 88 | int do_xfrm_policy(int argc, char **argv); |
| 89 | |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 90 | int xfrm_addr_match(xfrm_address_t *x1, xfrm_address_t *x2, int bits); |
org[shemminger]!nakam | 29aa4dd | 2004-09-28 18:40:49 +0000 | [diff] [blame] | 91 | int xfrm_xfrmproto_getbyname(char *name); |
net[shemminger]!shemminger | 7809c61 | 2004-08-11 23:41:38 +0000 | [diff] [blame] | 92 | int xfrm_algotype_getbyname(char *name); |
org[shemminger]!nakam | 29aa4dd | 2004-09-28 18:40:49 +0000 | [diff] [blame] | 93 | const char *strxf_xfrmproto(__u8 proto); |
net[shemminger]!shemminger | 7809c61 | 2004-08-11 23:41:38 +0000 | [diff] [blame] | 94 | const char *strxf_algotype(int type); |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 95 | const char *strxf_mask8(__u8 mask); |
| 96 | const char *strxf_mask32(__u32 mask); |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 97 | const char *strxf_share(__u8 share); |
net[shemminger]!shemminger | 30ff508 | 2004-07-30 20:26:15 +0000 | [diff] [blame] | 98 | const char *strxf_proto(__u8 proto); |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 99 | void xfrm_id_info_print(xfrm_address_t *saddr, struct xfrm_id *id, |
net[shemminger]!shemminger | eaa34ee | 2005-01-17 23:29:39 +0000 | [diff] [blame] | 100 | __u8 mode, __u32 reqid, __u16 family, int force_spi, |
| 101 | FILE *fp, const char *prefix); |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 102 | void xfrm_stats_print(struct xfrm_stats *s, FILE *fp, const char *prefix); |
| 103 | void xfrm_lifetime_print(struct xfrm_lifetime_cfg *cfg, |
| 104 | struct xfrm_lifetime_cur *cur, |
| 105 | FILE *fp, const char *prefix); |
| 106 | void xfrm_selector_print(struct xfrm_selector *sel, __u16 family, |
| 107 | FILE *fp, const char *prefix); |
7!tgraf | 43d9d2d | 2005-01-18 22:11:58 +0000 | [diff] [blame] | 108 | void xfrm_xfrma_print(struct rtattr *tb[], __u16 family, |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 109 | FILE *fp, const char *prefix); |
| 110 | int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family, |
net[shemminger]!shemminger | 7809c61 | 2004-08-11 23:41:38 +0000 | [diff] [blame] | 111 | int loose, int *argcp, char ***argvp); |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 112 | int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp); |
osdl.net!shemminger | 5cf576d | 2005-03-10 19:04:00 +0000 | [diff] [blame] | 113 | int xfrm_encap_type_parse(__u16 *type, int *argcp, char ***argvp); |
net[shemminger]!shemminger | c769987 | 2004-07-07 17:05:56 +0000 | [diff] [blame] | 114 | int xfrm_reqid_parse(__u32 *reqid, int *argcp, char ***argvp); |
| 115 | int xfrm_selector_parse(struct xfrm_selector *sel, int *argcp, char ***argvp); |
| 116 | int xfrm_lifetime_cfg_parse(struct xfrm_lifetime_cfg *lft, |
| 117 | int *argcp, char ***argvp); |
| 118 | |
| 119 | #endif |