Blame ip/xfrm.h

Packit Service 3880ab
/* $USAGI: $ */
Packit Service 3880ab
Packit Service 3880ab
/*
Packit Service 3880ab
 * Copyright (C)2004 USAGI/WIDE Project
Packit Service 3880ab
 *
Packit Service 3880ab
 * This program is free software; you can redistribute it and/or modify
Packit Service 3880ab
 * it under the terms of the GNU General Public License as published by
Packit Service 3880ab
 * the Free Software Foundation; either version 2 of the License, or
Packit Service 3880ab
 * (at your option) any later version.
Packit Service 3880ab
 *
Packit Service 3880ab
 * This program is distributed in the hope that it will be useful,
Packit Service 3880ab
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 3880ab
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 3880ab
 * GNU General Public License for more details.
Packit Service 3880ab
 *
Packit Service 3880ab
 * You should have received a copy of the GNU General Public License
Packit Service 3880ab
 * along with this program; if not, see <http://www.gnu.org/licenses>.
Packit Service 3880ab
 */
Packit Service 3880ab
/*
Packit Service 3880ab
 * Authors:
Packit Service 3880ab
 *	Masahide NAKAMURA @USAGI
Packit Service 3880ab
 */
Packit Service 3880ab
Packit Service 3880ab
#ifndef __XFRM_H__
Packit Service 3880ab
#define __XFRM_H__ 1
Packit Service 3880ab
Packit Service 3880ab
#include <stdio.h>
Packit Service 3880ab
#include <sys/socket.h>
Packit Service 3880ab
#include <linux/in.h>
Packit Service 3880ab
#include <linux/xfrm.h>
Packit Service 3880ab
#include <linux/ipsec.h>
Packit Service 3880ab
Packit Service 3880ab
#ifndef IPPROTO_MH
Packit Service 3880ab
#define IPPROTO_MH              135
Packit Service 3880ab
#endif
Packit Service 3880ab
Packit Service 3880ab
#define XFRMS_RTA(x)  ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_usersa_info))))
Packit Service 3880ab
#define XFRMS_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_usersa_info))
Packit Service 3880ab
Packit Service 3880ab
#define XFRMP_RTA(x)  ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_info))))
Packit Service 3880ab
#define XFRMP_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_userpoilcy_info))
Packit Service 3880ab
Packit Service 3880ab
#define XFRMSID_RTA(x)  ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_usersa_id))))
Packit Service 3880ab
#define XFRMSID_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_usersa_id))
Packit Service 3880ab
Packit Service 3880ab
#define XFRMPID_RTA(x)  ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_id))))
Packit Service 3880ab
#define XFRMPID_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_userpoilcy_id))
Packit Service 3880ab
Packit Service 3880ab
#define XFRMACQ_RTA(x)	((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_user_acquire))))
Packit Service 3880ab
#define XFRMEXP_RTA(x)	((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_user_expire))))
Packit Service 3880ab
#define XFRMPEXP_RTA(x)	((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_user_polexpire))))
Packit Service 3880ab
Packit Service 3880ab
#define XFRMREP_RTA(x)	((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_user_report))))
Packit Service 3880ab
Packit Service 3880ab
#define XFRMSAPD_RTA(x)	((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(__u32))))
Packit Service 3880ab
#define XFRM_FLAG_PRINT(fp, flags, f, s) \
Packit Service 3880ab
	do { \
Packit Service 3880ab
		if (flags & f) { \
Packit Service 3880ab
			flags &= ~f; \
Packit Service 3880ab
			fprintf(fp, s "%s", (flags ? " " : "")); \
Packit Service 3880ab
		} \
Packit Service 3880ab
	} while(0)
Packit Service 3880ab
Packit Service 3880ab
struct xfrm_buffer {
Packit Service 3880ab
	char *buf;
Packit Service 3880ab
	int size;
Packit Service 3880ab
	int offset;
Packit Service 3880ab
Packit Service 3880ab
	int nlmsg_count;
Packit Service 3880ab
	struct rtnl_handle *rth;
Packit Service 3880ab
};
Packit Service 3880ab
Packit Service 3880ab
struct xfrm_filter {
Packit Service 3880ab
	int use;
Packit Service 3880ab
Packit Service 3880ab
	struct xfrm_usersa_info xsinfo;
Packit Service 3880ab
	__u8 id_src_mask;
Packit Service 3880ab
	__u8 id_dst_mask;
Packit Service 3880ab
	__u8 id_proto_mask;
Packit Service 3880ab
	__u32 id_spi_mask;
Packit Service 3880ab
	__u8 mode_mask;
Packit Service 3880ab
	__u32 reqid_mask;
Packit Service 3880ab
	__u8 state_flags_mask;
Packit Service 3880ab
Packit Service 3880ab
	struct xfrm_userpolicy_info xpinfo;
Packit Service 3880ab
	__u8 dir_mask;
Packit Service 3880ab
	__u8 sel_src_mask;
Packit Service 3880ab
	__u8 sel_dst_mask;
Packit Service 3880ab
	__u32 sel_dev_mask;
Packit Service 3880ab
	__u8 upspec_proto_mask;
Packit Service 3880ab
	__u16 upspec_sport_mask;
Packit Service 3880ab
	__u16 upspec_dport_mask;
Packit Service 3880ab
	__u32 index_mask;
Packit Service 3880ab
	__u8 action_mask;
Packit Service 3880ab
	__u32 priority_mask;
Packit Service 3880ab
	__u8 policy_flags_mask;
Packit Service 3880ab
	__u8 filter_socket;
Packit Service 3880ab
Packit Service 3880ab
	__u8 ptype;
Packit Service 3880ab
	__u8 ptype_mask;
Packit Service 3880ab
Packit Service 3880ab
};
Packit Service 3880ab
#define XFRM_FILTER_MASK_FULL (~0)
Packit Service 3880ab
Packit Service 3880ab
extern struct xfrm_filter filter;
Packit Service 3880ab
Packit Service 3880ab
int xfrm_state_print(struct nlmsghdr *n, void *arg);
Packit Service 3880ab
int xfrm_state_print_nokeys(struct nlmsghdr *n, void *arg);
Packit Service 3880ab
int xfrm_policy_print(struct nlmsghdr *n, void *arg);
Packit Service 3880ab
int do_xfrm_state(int argc, char **argv);
Packit Service 3880ab
int do_xfrm_policy(int argc, char **argv);
Packit Service 3880ab
int do_xfrm_monitor(int argc, char **argv);
Packit Service 3880ab
Packit Service 3880ab
int xfrm_addr_match(xfrm_address_t *x1, xfrm_address_t *x2, int bits);
Packit Service 3880ab
int xfrm_xfrmproto_is_ipsec(__u8 proto);
Packit Service 3880ab
int xfrm_xfrmproto_is_ro(__u8 proto);
Packit Service 3880ab
int xfrm_xfrmproto_getbyname(char *name);
Packit Service 3880ab
int xfrm_algotype_getbyname(char *name);
Packit Service 3880ab
int xfrm_parse_mark(struct xfrm_mark *mark, int *argcp, char ***argvp);
Packit Service 3880ab
const char *strxf_xfrmproto(__u8 proto);
Packit Service 3880ab
const char *strxf_algotype(int type);
Packit Service 3880ab
const char *strxf_mask32(__u32 mask);
Packit Service 3880ab
const char *strxf_proto(__u8 proto);
Packit Service 3880ab
const char *strxf_ptype(__u8 ptype);
Packit Service 3880ab
void xfrm_selector_print(struct xfrm_selector *sel, __u16 family,
Packit Service 3880ab
			 FILE *fp, const char *prefix);
Packit Service 3880ab
void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,
Packit Service 3880ab
		      FILE *fp, const char *prefix, bool nokeys);
Packit Service 3880ab
void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,
Packit Service 3880ab
			    struct rtattr *tb[], FILE *fp, const char *prefix,
Packit Service 3880ab
			   const char *title, bool nokeys);
Packit Service 3880ab
void xfrm_policy_info_print(struct xfrm_userpolicy_info *xpinfo,
Packit Service 3880ab
			    struct rtattr *tb[], FILE *fp, const char *prefix,
Packit Service 3880ab
			    const char *title);
Packit Service 3880ab
int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family,
Packit Service 3880ab
		  int loose, int *argcp, char ***argvp);
Packit Service 3880ab
int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp);
Packit Service 3880ab
int xfrm_encap_type_parse(__u16 *type, int *argcp, char ***argvp);
Packit Service 3880ab
int xfrm_reqid_parse(__u32 *reqid, int *argcp, char ***argvp);
Packit Service 3880ab
int xfrm_selector_parse(struct xfrm_selector *sel, int *argcp, char ***argvp);
Packit Service 3880ab
int xfrm_lifetime_cfg_parse(struct xfrm_lifetime_cfg *lft,
Packit Service 3880ab
			    int *argcp, char ***argvp);
Packit Service 3880ab
int xfrm_sctx_parse(char *ctxstr, char *context,
Packit Service 3880ab
		    struct xfrm_user_sec_ctx *sctx);
Packit Service 3880ab
#endif