]>
Commit | Line | Data |
---|---|---|
c7699875 | 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> | |
31 | #include "utils.h" | |
32 | ||
33 | #define XFRM_MAX_DEPTH 6 | |
34 | ||
35 | #define XFRMS_RTA(x) ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_usersa_info)))) | |
36 | #define XFRMS_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_usersa_info)) | |
37 | ||
38 | #define XFRMP_RTA(x) ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_info)))) | |
39 | #define XFRMP_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_userpoilcy_info)) | |
40 | ||
41 | struct xfrm_buffer { | |
42 | char *buf; | |
43 | int size; | |
44 | int offset; | |
45 | ||
46 | int nlmsg_count; | |
47 | struct rtnl_handle *rth; | |
48 | }; | |
49 | ||
50 | struct xfrm_filter { | |
51 | int use; | |
52 | ||
53 | struct xfrm_usersa_info xsinfo; | |
54 | __u32 id_src_mask; | |
55 | __u32 id_dst_mask; | |
56 | __u32 id_proto_mask; | |
57 | __u32 id_spi_mask; | |
58 | __u32 mode_mask; | |
59 | __u32 reqid_mask; | |
60 | __u32 state_flags_mask; | |
61 | ||
62 | struct xfrm_userpolicy_info xpinfo; | |
63 | __u32 dir_mask; | |
64 | __u32 sel_src_mask; | |
65 | __u32 sel_dst_mask; | |
66 | __u32 sel_dev_mask; | |
67 | __u32 upspec_proto_mask; | |
68 | __u32 upspec_sport_mask; | |
69 | __u32 upspec_dport_mask; | |
70 | __u32 index_mask; | |
71 | __u32 action_mask; | |
72 | __u32 priority_mask; | |
73 | }; | |
74 | #define XFRM_FILTER_MASK_FULL (~(__u32)0) | |
75 | ||
76 | extern struct xfrm_filter filter; | |
77 | ||
78 | int do_xfrm_state(int argc, char **argv); | |
79 | int do_xfrm_policy(int argc, char **argv); | |
80 | ||
81 | const char *strxf_flags(__u8 flags); | |
82 | const char *strxf_share(__u8 share); | |
83 | void xfrm_id_info_print(xfrm_address_t *saddr, struct xfrm_id *id, | |
84 | __u8 mode, __u32 reqid, __u16 family, FILE *fp, | |
85 | const char *prefix); | |
86 | void xfrm_stats_print(struct xfrm_stats *s, FILE *fp, const char *prefix); | |
87 | void xfrm_lifetime_print(struct xfrm_lifetime_cfg *cfg, | |
88 | struct xfrm_lifetime_cur *cur, | |
89 | FILE *fp, const char *prefix); | |
90 | void xfrm_selector_print(struct xfrm_selector *sel, __u16 family, | |
91 | FILE *fp, const char *prefix); | |
92 | void xfrm_xfrma_print(struct rtattr *tb[], int ntb, __u16 family, | |
93 | FILE *fp, const char *prefix); | |
94 | int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family, | |
95 | int *argcp, char ***argvp); | |
96 | int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp); | |
97 | int xfrm_reqid_parse(__u32 *reqid, int *argcp, char ***argvp); | |
98 | int xfrm_selector_parse(struct xfrm_selector *sel, int *argcp, char ***argvp); | |
99 | int xfrm_lifetime_cfg_parse(struct xfrm_lifetime_cfg *lft, | |
100 | int *argcp, char ***argvp); | |
101 | ||
102 | #endif |