/* * All-in-one program to set Security Association parameters * Copyright (C) 1996 John Ioannidis. * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Richard Guy Briggs. * Copyright (C) 2005-2007 Michael Richardson * Copyright (C) 2007-2010 Paul Wouters * Copyright (C) 2013 Paul Wouters * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. See . * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ #include #include #include /* #include */ #include /* #include */ /* new */ #include #include #include #include /* #include */ #include #include /* #include */ #include #include #include #include #include #include #include #include #include #if 0 #include /* CONFIG_IPSEC_PFKEYv2 */ #endif #include #include #include #include #include "constants.h" #include "libreswan/radij.h" #include "libreswan/ipsec_encap.h" #include "libreswan/ipsec_xform.h" #include "libreswan/ipsec_ipe4.h" #include "libreswan/ipsec_ah.h" #include "libreswan/ipsec_esp.h" #include "libreswan/ipsec_sa.h" /* IPSEC_SAREF_NULL */ #include /* PF_KEY_DEBUG_PARSE_MAX */ #include "lswlog.h" #include "alg_info.h" #include "kernel_alg.h" #include "pfkey_help.h" #include "lsw_select.h" struct encap_msghdr *em; char *progname; bool debug = FALSE; int dumpsaref = 0; int saref_him = 0; int saref_me = 0; char *command; char scratch[2]; unsigned char *iv = NULL, *enckey = NULL, *authkey = NULL; size_t ivlen = 0, enckeylen = 0, authkeylen = 0; ip_address edst, dst, src; int address_family = 0; unsigned char proto = 0; int alg = 0; /* * Manual connection support for modular algos (ipsec_alg) --Juanjo. */ #define XF_OTHER_ALG (XF_CLR - 1) /* define magic XF_ symbol for alg_info's */ #include const char *alg_string = NULL; /* algorithm string */ struct esp_info *esp_info = NULL; /* esp info from 1st (only) element */ int proc_read_ok = 0; /* /proc/net/pf_key_support read ok */ unsigned long replay_window = 0; char sa[SATOT_BUF]; int pfkey_sock; uint32_t pfkey_seq = 0; enum life_severity { life_soft = 0, life_hard = 1, life_maxsever = 2 }; enum life_type { life_alloc = 0, life_bytes = 1, life_addtime = 2, life_usetime = 3, life_packets = 4, life_maxtype = 5 }; static const char *usage_string = "Usage:\n" " in the following, is: --af --edst --spi --proto \n" " OR: --said <.|:>@\n" " is: --life -=[,...]\n" "spi --clear\n" "spi --help\n" "spi --version\n" "spi\n" "spi --del \n" "spi --ip4 --src --dst \n" "spi --ip6 --src --dst \n" "spi --ah [ ][ --replay_window ] --authkey \n" " where is one of: hmac-md5-96 | hmac-sha1-96 | something-loaded \n" "spi --esp [ ][ --replay_window ] --enckey --authkey \n" " where is one of: 3des-md5-96 | 3des-sha1-96\n | something-loaded" " also, --natt will enable UDP encapsulation, and --sport/--dport will set\n" " the source/destination UDP ports.\n" "spi --esp [ ][ --replay_window ] --enckey \n" " where is: 3des\n" "spi --comp \n" " where is: deflate | lzs\n" "[ --sarefme=XXX ] set the saref to use for this SA\n" "[ --sarefhim=XXX ] set the saref to use for paired SA\n" "[ --dumpsaref ] show the saref allocated\n" "[ --outif=XXX ] set the outgoing interface to use \n" "[ --debug ] is optional to any spi command.\n" "[ --label