/* * manipulate eroutes * Copyright (C) 1996 John Ioannidis. * Copyright (C) 1997, 1998, 1999, 2000, 2001 Richard Guy Briggs. * * 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. */ char eroute_c_version[] = "RCSID $Id: eroute.c,v 1.3 2005/02/24 20:03:46 as Exp $"; #include #include /* new */ #include #include #include /* system(), strtoul() */ #include #include #include #include #include #include #include #include #if 0 #include /* CONFIG_IPSEC_PFKEYv2 */ #endif /* permanently turn it on since netlink support has been disabled */ #include #include #include #include "freeswan/radij.h" #include "freeswan/ipsec_encap.h" #include #include char *program_name; char me[] = "ipsec eroute"; extern char *optarg; extern int optind, opterr, optopt; char *eroute_af_opt, *said_af_opt, *edst_opt, *spi_opt, *proto_opt, *said_opt, *dst_opt, *src_opt; char *transport_proto_opt, *src_port_opt, *dst_port_opt; int action_type = 0; int pfkey_sock; fd_set pfkey_socks; uint32_t pfkey_seq = 0; #define EMT_IFADDR 1 /* set enc if addr */ #define EMT_SETSPI 2 /* Set SPI properties */ #define EMT_DELSPI 3 /* Delete an SPI */ #define EMT_GRPSPIS 4 /* Group SPIs (output order) */ #define EMT_SETEROUTE 5 /* set an extended route */ #define EMT_DELEROUTE 6 /* del an extended route */ #define EMT_TESTROUTE 7 /* try to find route, print to console */ #define EMT_SETDEBUG 8 /* set debug level if active */ #define EMT_UNGRPSPIS 9 /* UnGroup SPIs (output order) */ #define EMT_CLREROUTE 10 /* clear the extended route table */ #define EMT_CLRSPIS 11 /* clear the spi table */ #define EMT_REPLACEROUTE 12 /* set an extended route */ #define EMT_GETDEBUG 13 /* get debug level if active */ #define EMT_INEROUTE 14 /* set incoming policy for IPIP on a chain */ static void add_port(int af, ip_address * addr, short port) { switch (af) { case AF_INET: addr->u.v4.sin_port = port; break; case AF_INET6: addr->u.v6.sin6_port = port; break; } } static void usage(char* arg) { fprintf(stdout, "usage: %s --{add,addin,replace} --eraf --src /| --dst /| [ --transport-proto ] [ --src-port ] [ --dst-port ] \n", arg); fprintf(stdout, " where is '--af --edst --spi --proto '\n"); fprintf(stdout, " OR '--said '\n"); fprintf(stdout, " OR '--said <%%passthrough | %%passthrough4 | %%passthrough6 | %%drop | %%reject | %%trap | %%hold | %%pass>'.\n"); fprintf(stdout, " %s --del --eraf --src /| --dst /| [ --transport-proto ] [ --src-port ] [ --dst-port ]\n", arg); fprintf(stdout, " %s --clear\n", arg); fprintf(stdout, " %s --help\n", arg); fprintf(stdout, " %s --version\n", arg); fprintf(stdout, " %s\n", arg); fprintf(stdout, " [ --debug ] is optional to any %s command.\n", arg); fprintf(stdout, " [ --label