Fixed shell-script-fails-syntax-check ./etc/pm/sleep.d/60aiccu
[aiccu.git] / common / aiccu_freebsd4.c
blob95a655461f6b7e08e3cc3d5262e5d504b3c99aac
1 /**********************************************************
2 SixXS - Automatic IPv6 Connectivity Configuration Utility
3 ***********************************************************
4 Copyright 2003-2005 SixXS - http://www.sixxs.net
5 ***********************************************************
6 common/aiccu_freebsd4.c - FreeBSD 3.x/4.x
7 ***********************************************************
8 $Author: jeroen $
9 $Id: aiccu_freebsd4.c,v 1.11 2007-01-07 17:05:23 jeroen Exp $
10 $Date: 2007-01-07 17:05:23 $
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 /* Create the tunnel device */
25 aiccu_exec(
26 "/sbin/ifconfig %s create",
27 g_aiccu->ipv6_interface);
29 /* Configure the endpoint */
30 aiccu_exec(
31 "/sbin/ifconfig %s tunnel %s %s",
32 g_aiccu->ipv6_interface,
33 strcmp(hTunnel->sIPv4_Local, "heartbeat") == 0 ? "0.0.0.0" : hTunnel->sIPv4_Local,
34 hTunnel->sIPv4_POP);
37 /* Mark the interface up */
38 aiccu_exec(
39 "ifconfig %s up",
40 g_aiccu->ipv6_interface);
42 /* Configure the MTU */
43 aiccu_exec(
44 "ifconfig %s mtu %u",
45 g_aiccu->ipv6_interface,
46 hTunnel->nMTU);
48 if (hTunnel->uses_tundev == 1)
50 /* Give it a link local address */
51 aiccu_exec(
52 "ifconfig %s inet6 %s prefixlen 64 alias",
53 g_aiccu->ipv6_interface,
54 hTunnel->sIPv6_LinkLocal);
57 /* Local side of the tunnel */
58 aiccu_exec(
59 "ifconfig %s inet6 %s prefixlen 128 alias",
60 g_aiccu->ipv6_interface,
61 hTunnel->sIPv6_Local);
63 /* Route to the remote side of the tunnel */
64 aiccu_exec(
65 "route add -inet6 %s -prefixlen 128 %s",
66 hTunnel->sIPv6_POP,
67 hTunnel->sIPv6_Local);
69 if (g_aiccu->defaultroute)
71 /* Add a default route */
72 aiccu_exec(
73 "route add -inet6 %s %s",
74 "default",
75 hTunnel->sIPv6_POP);
78 return true;
81 void aiccu_os_reconfig(struct TIC_Tunnel *hTunnel)
83 if (hTunnel->uses_tundev == 0)
85 /* Change the endpoints of the tunnel */
86 aiccu_exec(
87 "/sbin/ifconfig %s tunnel %s %s",
88 g_aiccu->ipv6_interface,
89 hTunnel->sIPv4_Local,
90 hTunnel->sIPv4_POP);
94 void aiccu_os_delete(struct TIC_Tunnel *hTunnel)
96 hTunnel = hTunnel;
98 /* Mark the interface down */
99 aiccu_exec(
100 "ifconfig %s down",
101 g_aiccu->ipv6_interface);
103 if (hTunnel->uses_tundev == 0)
105 /* Destroy the tunnel */
106 aiccu_exec(
107 "ifconfig %s destroy",
108 g_aiccu->ipv6_interface);