1 /**********************************************************
2 SixXS - Automatic IPv6 Connectivity Configuration Utility
3 ***********************************************************
4 Copyright 2003-2005 SixXS - http://www.sixxs.net
5 ***********************************************************
6 common/aiccu_linux.c - AICCU Linux Abstracted functions
7 ***********************************************************
9 $Id: aiccu_linux.c,v 1.15 2007-01-15 12:18:58 jeroen Exp $
10 $Date: 2007-01-15 12:18:58 $
11 **********************************************************/
15 bool aiccu_os_install(void)
17 /* Check if IPv6 support is available */
18 if (access("/proc/net/if_inet6", F_OK
))
20 /* Doing the modprobe doesn't guarantee success unfortunately */
21 (void)system("modprobe -q ipv6 2>/dev/null >/dev/null");
23 /* Thus test it again */
24 if (access("/proc/net/if_inet6", F_OK
))
26 dolog(LOG_ERR
, "No IPv6 Stack found! Please check your kernel and module configuration\n");
31 /* Try to load modules (SIT tunnel, TUN/TAP)
32 * They can be kernel builtins and there is no easy
33 * way to check if they are loaded/built except for
34 * trying to use them and fail at that point
36 (void)system("modprobe -q sit 2>/dev/null >/dev/null");
37 (void)system("modprobe -q tun 2>/dev/null >/dev/null");
42 bool aiccu_os_setup(struct TIC_Tunnel
*hTunnel
)
44 if (hTunnel
->uses_tundev
== 0)
47 "ip tunnel add %s mode sit %s%s remote %s",
48 g_aiccu
->ipv6_interface
,
49 strcmp(hTunnel
->sIPv4_Local
, "heartbeat") == 0 ? "" : "local ",
50 strcmp(hTunnel
->sIPv4_Local
, "heartbeat") == 0 ? "" : hTunnel
->sIPv4_Local
,
56 g_aiccu
->ipv6_interface
);
59 "ip link set mtu %u dev %s",
61 g_aiccu
->ipv6_interface
);
63 if (hTunnel
->uses_tundev
== 0)
66 "ip tunnel change %s ttl 64",
67 g_aiccu
->ipv6_interface
);
71 /* Add a LinkLocal address for AYIYA tunnels */
73 "ip -6 addr add %s/%u dev %s",
74 hTunnel
->sIPv6_LinkLocal
,
76 g_aiccu
->ipv6_interface
);
80 "ip -6 addr add %s/%u dev %s",
82 hTunnel
->nIPv6_PrefixLength
,
83 g_aiccu
->ipv6_interface
);
85 if (g_aiccu
->defaultroute
)
88 "ip -6 ro add %s via %s dev %s",
91 g_aiccu
->ipv6_interface
);
97 void aiccu_os_reconfig(struct TIC_Tunnel
*hTunnel
)
99 if (hTunnel
->uses_tundev
== 0)
102 "ip tunnel change %s local %s",
103 g_aiccu
->ipv6_interface
,
104 hTunnel
->sIPv4_Local
);
108 void aiccu_os_delete(struct TIC_Tunnel
*hTunnel
)
112 "ip link set %s down",
113 g_aiccu
->ipv6_interface
);
115 if (hTunnel
->uses_tundev
== 0)
119 g_aiccu
->ipv6_interface
);