Fixed shell-script-fails-syntax-check ./etc/pm/sleep.d/60aiccu
[aiccu.git] / common / aiccu_kame.c
blobc6d1ea3a28b435cbf18756613e55de7436654c38
1 /**********************************************************
2 SixXS - Automatic IPv6 Connectivity Configuration Utility
3 ***********************************************************
4 Copyright 2003-2005 SixXS - http://www.sixxs.net
5 ***********************************************************
6 common/aiccu_kame.c - NetBSD + FreeBSD 5.x+
7 ***********************************************************
8 $Author: jeroen $
9 $Id: aiccu_kame.c,v 1.15 2007-01-11 15:11:27 jeroen Exp $
10 $Date: 2007-01-11 15:11:27 $
11 **********************************************************/
13 #include "aiccu.h"
15 bool aiccu_os_install(void)
17 return true;
20 bool aiccu_os_setup(struct TIC_Tunnel *hTunnel)
22 if (hTunnel->uses_tundev == 0)
24 aiccu_exec(
25 "/sbin/ifconfig %s create",
26 g_aiccu->ipv6_interface);
28 aiccu_exec(
29 "/sbin/ifconfig %s tunnel %s %s",
30 g_aiccu->ipv6_interface,
31 strcmp(hTunnel->sIPv4_Local, "heartbeat") == 0 ? "0.0.0.0" : hTunnel->sIPv4_Local,
32 hTunnel->sIPv4_POP);
35 aiccu_exec(
36 "ifconfig %s up",
37 g_aiccu->ipv6_interface);
39 aiccu_exec(
40 "ifconfig %s mtu %u",
41 g_aiccu->ipv6_interface,
42 hTunnel->nMTU);
44 if (hTunnel->uses_tundev == 1)
46 /* Configure a generated linklocal address */
47 aiccu_exec(
48 "ifconfig %s inet6 %s prefixlen 64 alias",
49 g_aiccu->ipv6_interface,
50 hTunnel->sIPv6_LinkLocal);
53 /* PtP link, so we can use the PtP syntax */
54 aiccu_exec(
55 "ifconfig %s inet6 %s %s prefixlen 128 alias",
56 g_aiccu->ipv6_interface,
57 hTunnel->sIPv6_Local,
58 hTunnel->sIPv6_POP);
60 if (g_aiccu->defaultroute)
62 aiccu_exec(
63 "route add -inet6 %s %s",
64 "default",
65 hTunnel->sIPv6_POP);
68 return true;
71 void aiccu_os_reconfig(struct TIC_Tunnel *hTunnel)
73 if (hTunnel->uses_tundev == 0)
75 aiccu_exec(
76 "/sbin/ifconfig %s tunnel %s %s",
77 g_aiccu->ipv6_interface,
78 hTunnel->sIPv4_Local,
79 hTunnel->sIPv4_POP);
83 void aiccu_os_delete(struct TIC_Tunnel *hTunnel)
85 hTunnel = hTunnel;
86 aiccu_exec(
87 "ifconfig %s down",
88 g_aiccu->ipv6_interface);
90 if (hTunnel->uses_tundev == 0)
92 aiccu_exec(
93 "ifconfig %s deletetunnel",
94 g_aiccu->ipv6_interface);