]> git.ipfire.org Git - people/stevee/aiccu.git/blame - common/aiccu_test.c
spelling error
[people/stevee/aiccu.git] / common / aiccu_test.c
CommitLineData
d98f6a46
SS
1/**********************************************************
2 SixXS - Automatic IPv6 Connectivity Configuration Utility
3***********************************************************
4 Copyright 2003-2005 SixXS - http://www.sixxs.net
5***********************************************************
6 common/aiccu_test.c - AICCU Test function
7***********************************************************
8 $Author: jeroen $
9 $Id: aiccu_test.c,v 1.9 2007-01-15 12:00:46 jeroen Exp $
10 $Date: 2007-01-15 12:00:46 $
11**********************************************************/
12
13#include "aiccu.h"
14
15#ifndef _WIN32
16#define PING4 "ping -c %d -v %s 2>&1"
17#define PING6 "ping6 -c %d -v %s 2>&1"
18#define TRACEROUTE4 "traceroute %s 2>&1"
19#define TRACEROUTE6 "traceroute6 %s 2>&1"
20#else
21#define PING4 "ping -4 -n %d %s"
22#define PING6 "ping -6 -n %d %s"
23#define TRACEROUTE4 "tracert %s"
24#define TRACEROUTE6 "tracert6 %s"
25#endif
26
27void system_arg(const char *fmt, ...);
28void system_arg(const char *fmt, ...)
29{
30 char buf[1024];
31 int ret;
32 va_list ap;
33
34 va_start(ap, fmt);
35 vsnprintf(buf, sizeof(buf), fmt, ap);
36 va_end(ap);
37
38 fflush(stdout);
39 ret = system(buf);
40 if (ret == -1) dolog(LOG_WARNING, "Execution of \"%s\" failed!? (Please check if the command is available)\n", buf);
41}
42
43#define PINGCOUNT 3
44
45bool test_ask(bool automatic);
46bool test_ask(bool automatic)
47{
48 char buf[100];
49
50 if (!g_aiccu->running) return false;
51
52 printf("\n######\n");
53 printf("\n");
54
55 if (automatic) return true;
56
57 printf("Did this work? [Y/n] ");
58
59 if (fgets(buf, sizeof(buf), stdin) == NULL) return false;
60
61 printf("\n");
62
63 return (buf[0] == 'N' || buf[0] == 'n' ? false : true);
64}
65
66void aiccu_os_test(struct TIC_Tunnel *hTunnel, bool automatic)
67{
68 unsigned int t = 1;
69 unsigned int tottests = 8;
70
71 /* Make sure we have a correct local IPv4 address for some tests */
72 if (strcmp(hTunnel->sType, "6in4-static") != 0)
73 {
74 heartbeat_socket(NULL, 0, "",
75 &hTunnel->sIPv4_Local,
76 hTunnel->sIPv4_POP,
77 NULL);
78 }
79
80 if (!g_aiccu->running) return;
81
82 printf("#######\n");
83 printf("####### AICCU Quick Connectivity Test\n");
84 printf("#######\n\n");
85
86 printf("####### [%u/%u] Ping the IPv4 Local/Your Outer Endpoint (%s)\n",
87 t++, tottests, hTunnel->sIPv4_Local);
88 printf("### This should return so called 'echo replies'\n");
89 printf("### If it doesn't then check your firewall settings\n");
90 printf("### Your local endpoint should always be pingable\n");
91 printf("### It could also indicate problems with your IPv4 stack\n");
92 printf("\n");
93 system_arg(PING4, PINGCOUNT, hTunnel->sIPv4_Local);
94 if (!test_ask(automatic) || !g_aiccu->running) return;
95
96 printf("####### [%u/%u] Ping the IPv4 Remote/PoP Outer Endpoint (%s)\n",
97 t++, tottests, hTunnel->sIPv4_POP);
98 printf("### These pings should reach the PoP and come back to you\n");
99 printf("### In case there are problems along the route between your\n");
100 printf("### host and the PoP this could not return replies\n");
101 printf("### Check your firewall settings if problems occur\n");
102 printf("\n");
103 system_arg(PING4, PINGCOUNT, hTunnel->sIPv4_POP);
104 if (!test_ask(automatic) || !g_aiccu->running) return;
105
106 printf("####### [%u/%u] Traceroute to the PoP (%s) over IPv4\n",
107 t++, tottests, hTunnel->sIPv4_POP);
108 printf("### This traceroute should reach the PoP\n");
109 printf("### In case this traceroute fails then you have no connectivity\n");
110 printf("### to the PoP and this is most probably the problem\n");
111 printf("\n");
112 system_arg(TRACEROUTE4, hTunnel->sIPv4_POP);
113 if (!test_ask(automatic) || !g_aiccu->running) return;
114
115 printf("###### [%u/%u] Checking if we can ping IPv6 localhost (::1)\n",
116 t++, tottests);
117 printf("### This confirms if your IPv6 is working\n");
118 printf("### If ::1 doesn't reply then something is wrong with your IPv6 stack\n");
119 printf("\n");
120 system_arg(PING6, PINGCOUNT, "::1");
121 if (!test_ask(automatic) || !g_aiccu->running) return;
122
123 printf("###### [%u/%u] Ping the IPv6 Local/Your Inner Tunnel Endpoint (%s)\n",
124 t++, tottests, hTunnel->sIPv6_Local);
125 printf("### This confirms that your tunnel is configured\n");
126 printf("### If it doesn't reply then check your interface and routing tables\n");
127 printf("\n");
128 system_arg(PING6, PINGCOUNT, hTunnel->sIPv6_Local);
129 if (!test_ask(automatic) || !g_aiccu->running) return;
130
131 printf("###### [%u/%u] Ping the IPv6 Remote/PoP Inner Tunnel Endpoint (%s)\n",
132 t++, tottests, hTunnel->sIPv6_POP);
133 printf("### This confirms the reachability of the other side of the tunnel\n");
134 printf("### If it doesn't reply then check your interface and routing tables\n");
135 printf("### Don't forget to check your firewall of course\n");
ddeba48a 136 printf("### If the previous test was successful then this could be both\n");
d98f6a46
SS
137 printf("### a firewalling and a routing/interface problem\n");
138 printf("\n");
139 system_arg(PING6, PINGCOUNT, hTunnel->sIPv6_POP);
140 if (!test_ask(automatic) || !g_aiccu->running) return;
141
142 printf("###### [%u/%u] Traceroute6 to the central SixXS machine (noc.sixxs.net)\n",
143 t++, tottests);
144 printf("### This confirms that you can reach the central machine of SixXS\n");
145 printf("### If that one is reachable you should be able to reach most IPv6 destinations\n");
146 printf("### Also check http://www.sixxs.net/ipv6calc/ which should show an IPv6 connection\n");
147 printf("### If your browser supports IPv6 and uses it of course.\n");
148 printf("\n");
149 system_arg(TRACEROUTE6, "noc.sixxs.net");
150 if (!test_ask(automatic) || !g_aiccu->running) return;
151
152 printf("###### [%u/%u] Traceroute6 to (www.kame.net)\n",
153 t++, tottests);
154 printf("### This confirms that you can reach a Japanese IPv6 destination\n");
155 printf("### If that one is reachable you should be able to reach most IPv6 destinations\n");
156 printf("### You should also check http://www.kame.net which should display\n");
157 printf("### a animated kame (turtle), of course only when your browser supports and uses IPv6\n");
158 printf("\n");
159 system_arg(TRACEROUTE6, "www.kame.net");
160 if (!test_ask(automatic) || !g_aiccu->running) return;
161
162 printf("###### ACCU Quick Connectivity Test (done)\n\n");
163
164 printf("### Either the above all works and gives no problems\n");
165 printf("### or it shows you where what goes wrong\n");
166 printf("### Check the SixXS FAQ (http://www.sixxs.net/faq/\n");
167 printf("### for more information and possible solutions or hints\n");
168 printf("### Don't forget to check the Forums (http://www.sixxs.net/forum/)\n");
169 printf("### for a helping hand.\n");
170 printf("### Passing the output of 'aiccu autotest >aiccu.log' is a good idea.\n");
171
172 if (!automatic)
173 {
174 /* Wait for a keypress */
175 printf("\n\n*** press a key to continue ***\n");
176 getchar();
177 }
178}
179