void turn_connection_on (char *name, char *type) {
char command[STRING_SIZE];
- safe_system("/usr/sbin/ipsec whack --rereadall >/dev/null");
- memset(command, 0, STRING_SIZE);
- snprintf(command, STRING_SIZE - 1,
- "/usr/sbin/ipsec down %s >/dev/null", name);
- safe_system(command);
+ safe_system("/usr/sbin/ipsec reload >/dev/null");
memset(command, 0, STRING_SIZE);
+ /* give ipsec time to be ready */
+ safe_system("/bin/sleep 2");
snprintf(command, STRING_SIZE - 1,
"/usr/sbin/ipsec up %s >/dev/null", name);
safe_system(command);
char command[STRING_SIZE];
memset(command, 0, STRING_SIZE);
snprintf(command, STRING_SIZE - 1,
- "/usr/sbin/ipsec down %s >/dev/null", name);
+ "/usr/sbin/ipsec whack --delete --name %s >/dev/null", name);
safe_system(command);
+ safe_system("/usr/sbin/ipsec whack --rereadall >/dev/null");
}
FILE *file = NULL;
+
+ if (strcmp(argv[1], "I") == 0) {
+ safe_system("/usr/sbin/ipsec whack --status");
+ exit(0);
+ }
+
+ if (strcmp(argv[1], "R") == 0) {
+ safe_system("/usr/sbin/ipsec whack --rereadall >/dev/null");
+ exit(0);
+ }
+
/* Get vpnwatch pid */
if ( (argc == 2) && (file = fopen("/var/run/vpn-watch.pid", "r"))) {
exit(0);
}
- if (strcmp(argv[1], "R") == 0) {
- safe_system("/usr/sbin/ipsec whack --rereadall");
- exit(0);
- }
-
- if (strcmp(argv[1], "I") == 0) {
- safe_system("/usr/sbin/ipsec whack --status");
- exit(0);
- }
-
}
/* clear iptables vpn rules */