Merge branch 'starter-kernel-flush'
[strongswan.git] / src / starter / netkey.c
1 /* strongSwan netkey 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
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <stdlib.h>
18
19 #include <library.h>
20 #include <hydra.h>
21 #include <utils/debug.h>
22
23 #include "files.h"
24
25 bool starter_netkey_init(void)
26 {
27 struct stat stb;
28
29 if (stat(PROC_NETKEY, &stb) != 0)
30 {
31 /* af_key module makes the netkey proc interface visible */
32 if (stat(PROC_MODULES, &stb) == 0)
33 {
34 ignore_result(system("modprobe -qv af_key"));
35 }
36
37 /* now test again */
38 if (stat(PROC_NETKEY, &stb) != 0)
39 {
40 DBG2(DBG_APP, "kernel appears to lack the native netkey IPsec stack");
41 return FALSE;
42 }
43 }
44
45 /* make sure that all required IPsec modules are loaded */
46 if (stat(PROC_MODULES, &stb) == 0)
47 {
48 ignore_result(system("modprobe -qv ah4"));
49 ignore_result(system("modprobe -qv esp4"));
50 ignore_result(system("modprobe -qv ipcomp"));
51 ignore_result(system("modprobe -qv xfrm4_tunnel"));
52 ignore_result(system("modprobe -qv xfrm_user"));
53 }
54
55 DBG2(DBG_APP, "found netkey IPsec stack");
56 return TRUE;
57 }