fixed compiler warnings issued by:
[strongswan.git] / src / starter / klips.c
1 /* strongSwan KLIPS starter
2 * Copyright (C) 2001-2002 Mathieu Lafon - Arkoon Network Security
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * RCSID $Id$
15 */
16
17 #include <sys/types.h>
18 #include <sys/stat.h>
19 #include <stdlib.h>
20
21 #include <freeswan.h>
22
23 #include "../pluto/constants.h"
24 #include "../pluto/defs.h"
25 #include "../pluto/log.h"
26
27 #include "files.h"
28
29 bool
30 starter_klips_init(void)
31 {
32 struct stat stb;
33
34 if (stat(PROC_KLIPS, &stb) != 0)
35 {
36 /* ipsec module makes the pf_key proc interface visible */
37 if (stat(PROC_MODULES, &stb) == 0)
38 {
39 ignore_result(system("modprobe -qv ipsec"));
40 }
41
42 /* now test again */
43 if (stat(PROC_KLIPS, &stb) != 0)
44 {
45 DBG(DBG_CONTROL,
46 DBG_log("kernel appears to lack the KLIPS IPsec stack")
47 )
48 return FALSE;
49 }
50 }
51
52 /* load crypto algorithm modules */
53 ignore_result(system("modprobe -qv ipsec_aes"));
54 ignore_result(system("modprobe -qv ipsec_blowfish"));
55 ignore_result(system("modprobe -qv ipsec_sha2"));
56
57 DBG(DBG_CONTROL,
58 DBG_log("Found KLIPS IPsec stack")
59 )
60
61 return TRUE;
62 }
63
64 void
65 starter_klips_cleanup(void)
66 {
67 if (system("type eroute > /dev/null 2>&1") == 0)
68 {
69 ignore_result(system("spi --clear"));
70 ignore_result(system("eroute --clear"));
71 }
72 else if (system("type setkey > /dev/null 2>&1") == 0)
73 {
74 ignore_result(system("setkey -F"));
75 ignore_result(system("setkey -FP"));
76 }
77 else
78 {
79 plog("WARNING: cannot flush IPsec state/policy database");
80 }
81 }
82