]>
git.ipfire.org Git - people/stevee/aiccu.git/blob - common/aiccu_linux.c
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
)
46 if (hTunnel
->uses_tundev
== 0)
49 "ip tunnel add %s mode sit %s%s remote %s",
50 g_aiccu
->ipv6_interface
,
51 strcmp(hTunnel
->sIPv4_Local
, "heartbeat") == 0 ? "" : "local ",
52 strcmp(hTunnel
->sIPv4_Local
, "heartbeat") == 0 ? "" : hTunnel
->sIPv4_Local
,
58 g_aiccu
->ipv6_interface
);
61 "ip link set mtu %u dev %s",
63 g_aiccu
->ipv6_interface
);
65 if (hTunnel
->uses_tundev
== 0)
68 "ip tunnel change %s ttl 64",
69 g_aiccu
->ipv6_interface
);
73 /* Add a LinkLocal address for AYIYA tunnels */
75 "ip -6 addr add %s/%u dev %s",
76 hTunnel
->sIPv6_LinkLocal
,
78 g_aiccu
->ipv6_interface
);
82 "ip -6 addr add %s/%u dev %s",
84 hTunnel
->nIPv6_PrefixLength
,
85 g_aiccu
->ipv6_interface
);
87 if (g_aiccu
->defaultroute
)
90 "ip -6 ro add %s via %s dev %s",
93 g_aiccu
->ipv6_interface
);
96 if (g_aiccu
->setupscript
)
98 setenv("ACTION", "up", 1);
99 setenv("TUNNEL_TYPE", hTunnel
->sType
, 1);
100 setenv("INTERFACE", g_aiccu
->ipv6_interface
, 1);
101 setenv("REMOTE_ADDRESS", hTunnel
->sIPv6_POP
, 1);
103 snprintf(buffer
, sizeof(buffer
), "%s/%u",
104 hTunnel
->sIPv6_Local
, hTunnel
->nIPv6_PrefixLength
);
105 setenv("LOCAL_ADDRESS", buffer
, 1);
106 setenv("LINK_LOCAL_ADDRESS", hTunnel
->sIPv6_LinkLocal
, 1);
108 snprintf(buffer
, sizeof(buffer
), "%u", hTunnel
->nMTU
);
109 setenv("MTU", buffer
, 1);
111 aiccu_exec("%s", g_aiccu
->setupscript
);
117 void aiccu_os_reconfig(struct TIC_Tunnel
*hTunnel
)
119 if (hTunnel
->uses_tundev
== 0)
122 "ip tunnel change %s local %s",
123 g_aiccu
->ipv6_interface
,
124 hTunnel
->sIPv4_Local
);
128 void aiccu_os_delete(struct TIC_Tunnel
*hTunnel
)
132 "ip link set %s down",
133 g_aiccu
->ipv6_interface
);
135 if (hTunnel
->uses_tundev
== 0)
139 g_aiccu
->ipv6_interface
);
143 setenv("ACTION", "down", 1);
144 setenv("INTERFACE", g_aiccu
->ipv6_interface
, 1);
146 aiccu_exec("%s", g_aiccu
->setupscript
);