ipsec up|down|route|delete require a connection name
This commit is contained in:
@@ -96,6 +96,11 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
down)
|
down)
|
||||||
shift
|
shift
|
||||||
|
if [ "$#" -ne 1 ]
|
||||||
|
then
|
||||||
|
echo "Usage: ipsec down <connection name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if test -e $IPSEC_PLUTO_PID
|
if test -e $IPSEC_PLUTO_PID
|
||||||
then
|
then
|
||||||
$IPSEC_WHACK --name "$1" --terminate
|
$IPSEC_WHACK --name "$1" --terminate
|
||||||
@@ -160,6 +165,11 @@ restart)
|
|||||||
route|unroute)
|
route|unroute)
|
||||||
op="$1"
|
op="$1"
|
||||||
shift
|
shift
|
||||||
|
if [ "$#" -ne 1 ]
|
||||||
|
then
|
||||||
|
echo "Usage: ipsec $op <connection name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if test -e $IPSEC_PLUTO_PID
|
if test -e $IPSEC_PLUTO_PID
|
||||||
then
|
then
|
||||||
$IPSEC_WHACK --name "$1" "--$op"
|
$IPSEC_WHACK --name "$1" "--$op"
|
||||||
@@ -223,6 +233,11 @@ stop)
|
|||||||
;;
|
;;
|
||||||
up)
|
up)
|
||||||
shift
|
shift
|
||||||
|
if [ "$#" -ne 1 ]
|
||||||
|
then
|
||||||
|
echo "Usage: ipsec up <connection name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if test -e $IPSEC_PLUTO_PID
|
if test -e $IPSEC_PLUTO_PID
|
||||||
then
|
then
|
||||||
$IPSEC_WHACK --name "$1" --initiate
|
$IPSEC_WHACK --name "$1" --initiate
|
||||||
|
|||||||
+53
-19
@@ -12,7 +12,7 @@
|
|||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* RCSID $Id: rcv_whack.c,v 1.17 2005/12/25 12:41:23 as Exp $
|
* RCSID $Id: rcv_whack.c,v 1.18 2006/05/25 11:33:57 as Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -557,7 +557,14 @@ whack_handle(int whackctlfd)
|
|||||||
if (msg.whack_route)
|
if (msg.whack_route)
|
||||||
{
|
{
|
||||||
if (!listening)
|
if (!listening)
|
||||||
|
{
|
||||||
whack_log(RC_DEAF, "need --listen before --route");
|
whack_log(RC_DEAF, "need --listen before --route");
|
||||||
|
}
|
||||||
|
if (msg.name == NULL)
|
||||||
|
{
|
||||||
|
whack_log(RC_UNKNOWN_NAME
|
||||||
|
, "whack --route requires a connection name");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct connection *c = con_by_name(msg.name, TRUE);
|
struct connection *c = con_by_name(msg.name, TRUE);
|
||||||
@@ -579,37 +586,54 @@ whack_handle(int whackctlfd)
|
|||||||
|
|
||||||
if (msg.whack_unroute)
|
if (msg.whack_unroute)
|
||||||
{
|
{
|
||||||
struct connection *c = con_by_name(msg.name, TRUE);
|
if (msg.name == NULL)
|
||||||
|
|
||||||
if (c != NULL)
|
|
||||||
{
|
{
|
||||||
struct spd_route *sr;
|
whack_log(RC_UNKNOWN_NAME
|
||||||
int fail = 0;
|
, "whack --unroute requires a connection name");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct connection *c = con_by_name(msg.name, TRUE);
|
||||||
|
|
||||||
set_cur_connection(c);
|
if (c != NULL)
|
||||||
|
|
||||||
for (sr = &c->spd; sr != NULL; sr = sr->next)
|
|
||||||
{
|
{
|
||||||
if (sr->routing >= RT_ROUTED_TUNNEL)
|
struct spd_route *sr;
|
||||||
fail++;
|
int fail = 0;
|
||||||
|
|
||||||
|
set_cur_connection(c);
|
||||||
|
|
||||||
|
for (sr = &c->spd; sr != NULL; sr = sr->next)
|
||||||
|
{
|
||||||
|
if (sr->routing >= RT_ROUTED_TUNNEL)
|
||||||
|
fail++;
|
||||||
|
}
|
||||||
|
if (fail > 0)
|
||||||
|
whack_log(RC_RTBUSY, "cannot unroute: route busy");
|
||||||
|
else if (c->policy & POLICY_GROUP)
|
||||||
|
unroute_group(c);
|
||||||
|
else
|
||||||
|
unroute_connection(c);
|
||||||
|
reset_cur_connection();
|
||||||
}
|
}
|
||||||
if (fail > 0)
|
|
||||||
whack_log(RC_RTBUSY, "cannot unroute: route busy");
|
|
||||||
else if (c->policy & POLICY_GROUP)
|
|
||||||
unroute_group(c);
|
|
||||||
else
|
|
||||||
unroute_connection(c);
|
|
||||||
reset_cur_connection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.whack_initiate)
|
if (msg.whack_initiate)
|
||||||
{
|
{
|
||||||
if (!listening)
|
if (!listening)
|
||||||
|
{
|
||||||
whack_log(RC_DEAF, "need --listen before --initiate");
|
whack_log(RC_DEAF, "need --listen before --initiate");
|
||||||
|
}
|
||||||
|
else if (msg.name == NULL)
|
||||||
|
{
|
||||||
|
whack_log(RC_UNKNOWN_NAME
|
||||||
|
, "whack --initiate requires a connection name");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
initiate_connection(msg.name
|
initiate_connection(msg.name
|
||||||
, msg.whack_async? NULL_FD : dup_any(whackfd));
|
, msg.whack_async? NULL_FD : dup_any(whackfd));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.whack_oppo_initiate)
|
if (msg.whack_oppo_initiate)
|
||||||
@@ -623,7 +647,17 @@ whack_handle(int whackctlfd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msg.whack_terminate)
|
if (msg.whack_terminate)
|
||||||
terminate_connection(msg.name);
|
{
|
||||||
|
if (msg.name == NULL)
|
||||||
|
{
|
||||||
|
whack_log(RC_UNKNOWN_NAME
|
||||||
|
, "whack --terminate requires a connection name");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
terminate_connection(msg.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (msg.whack_status)
|
if (msg.whack_status)
|
||||||
show_status(msg.whack_statusall, msg.name);
|
show_status(msg.whack_statusall, msg.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user