Browse Source

Oh my god! I fixed the tunl0 issues by renaming it to tunl1 and creating tunl1 on my system first, Amongst other things I don't remember.

MissValeska 10 years ago
parent
commit
15baa56a87
4 changed files with 28 additions and 24 deletions
  1. 1
    1
      src/andns.c
  2. 21
    18
      src/iptunnel.c
  3. 5
    5
      src/iptunnel.h
  4. 1
    0
      src/mark.c

+ 1
- 1
src/andns.c View File

603
                 error(err_str);
603
                 error(err_str);
604
 		err_ret(ERR_RSLRSL,-1);
604
 		err_ret(ERR_RSLRSL,-1);
605
         }
605
         }
606
-        fprintf(stderr, "Addr is %p, rdata is %p\n", (void*)addr, (void*) dp->pkt_answ->rdata);
606
+        fprintf(stderr, "Addr is %p, rdata is %p rawr %p hai %p\n", (void*)&addr, (void*) dp->pkt_answ->rdata, (void*) dp->pkt_answ, (void*) dp);
607
         if ((dp == NULL) || (dp->pkt_answ == NULL) || (dp->pkt_answ->rdata == NULL)) return -1;
607
         if ((dp == NULL) || (dp->pkt_answ == NULL) || (dp->pkt_answ->rdata == NULL)) return -1;
608
         memcpy(&addr, dp->pkt_answ->rdata, sizeof(uint32_t));
608
         memcpy(&addr, dp->pkt_answ->rdata, sizeof(uint32_t));
609
         addr=ntohl(addr);
609
         addr=ntohl(addr);

+ 21
- 18
src/iptunnel.c View File

17
  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
  *
18
  *
19
  * --
19
  * --
20
- * This code derives from iproute2/iprule.c, it was modified to fit in 
20
+ * This code derives from iproute2/iprule.c, it was modified to fit in
21
  * Netsukuku.
21
  * Netsukuku.
22
  *
22
  *
23
  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
23
  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
49
 int tunnel_add(inet_prefix *remote, inet_prefix *local, char *dev,
49
 int tunnel_add(inet_prefix *remote, inet_prefix *local, char *dev,
50
 		char *tunl_prefix, int tunl_number)
50
 		char *tunl_prefix, int tunl_number)
51
 {
51
 {
52
-	return do_add(SIOCADDTUNNEL, remote, local, dev, tunl_prefix, 
52
+	return do_add(SIOCADDTUNNEL, remote, local, dev, tunl_prefix,
53
 			tunl_number);
53
 			tunl_number);
54
 }
54
 }
55
 
55
 
56
 int tunnel_change(inet_prefix *remote, inet_prefix *local, char *dev,
56
 int tunnel_change(inet_prefix *remote, inet_prefix *local, char *dev,
57
 		char *tunl_prefix, int tunl_number)
57
 		char *tunl_prefix, int tunl_number)
58
 {
58
 {
59
+	error("The value of siocchgtunnel is: %d", SIOCCHGTUNNEL);
59
 	return do_add(SIOCCHGTUNNEL, remote, local, dev, tunl_prefix,
60
 	return do_add(SIOCCHGTUNNEL, remote, local, dev, tunl_prefix,
60
 			tunl_number);
61
 			tunl_number);
61
 }
62
 }
150
 	ifr.ifr_ifru.ifru_data = (void*)p;
151
 	ifr.ifr_ifru.ifru_data = (void*)p;
151
 	fd = socket(AF_INET, SOCK_DGRAM, 0);
152
 	fd = socket(AF_INET, SOCK_DGRAM, 0);
152
 	err = ioctl(fd, cmd, &ifr);
153
 	err = ioctl(fd, cmd, &ifr);
154
+    error("Socket File Descriptor Is: %i cmd is: %i err is: %i ifr is: %s Errno is: %d", fd, cmd, err, &ifr, errno);
153
 	if (err)
155
 	if (err)
154
 		error(ERROR_MSG "ioctl: %s",ERROR_POS, strerror(errno));
156
 		error(ERROR_MSG "ioctl: %s",ERROR_POS, strerror(errno));
155
 	close(fd);
157
 	close(fd);
179
  * fill_tunnel_parm: fills the `p' struct.
181
  * fill_tunnel_parm: fills the `p' struct.
180
  * `remote' and `local' must be in host order
182
  * `remote' and `local' must be in host order
181
  */
183
  */
182
-static int fill_tunnel_parm(int cmd, inet_prefix *remote, inet_prefix *local, 
184
+static int fill_tunnel_parm(int cmd, inet_prefix *remote, inet_prefix *local,
183
 		char *dev, char *tunl_prefix, int tunl_number,
185
 		char *dev, char *tunl_prefix, int tunl_number,
184
 		struct ip_tunnel_parm *p)
186
 		struct ip_tunnel_parm *p)
185
 {
187
 {
229
 	return 0;
231
 	return 0;
230
 }
232
 }
231
 
233
 
232
-/* 
234
+/*
233
  * do_get: returns 1 if the tunnel named `dev' exists.
235
  * do_get: returns 1 if the tunnel named `dev' exists.
234
  */
236
  */
235
 int do_get(char *dev)
237
 int do_get(char *dev)
246
 static int do_add(int cmd, inet_prefix *remote, inet_prefix *local, char *dev,
248
 static int do_add(int cmd, inet_prefix *remote, inet_prefix *local, char *dev,
247
 		char *tunl_prefix, int tunl_number)
249
 		char *tunl_prefix, int tunl_number)
248
 {
250
 {
251
+    error("This is the do_add function.");
249
 	struct ip_tunnel_parm p;
252
 	struct ip_tunnel_parm p;
250
 
253
 
251
-	if (fill_tunnel_parm(cmd, remote, local, dev, tunl_prefix, 
254
+	if (fill_tunnel_parm(cmd, remote, local, dev, tunl_prefix,
252
 				tunl_number, &p) < 0)
255
 				tunl_number, &p) < 0)
253
 		return -1;
256
 		return -1;
254
 
257
 
258
 	switch (p.iph.protocol) {
261
 	switch (p.iph.protocol) {
259
 		case IPPROTO_IPIP:
262
 		case IPPROTO_IPIP:
260
 			return do_add_ioctl(cmd, DEFAULT_TUNL_IF, &p);
263
 			return do_add_ioctl(cmd, DEFAULT_TUNL_IF, &p);
261
-		default:	
264
+		default:
262
 			fatal("cannot determine tunnel mode (ipip, gre or sit)\n");
265
 			fatal("cannot determine tunnel mode (ipip, gre or sit)\n");
263
 	}
266
 	}
264
 	return -1;
267
 	return -1;
276
 	switch (p.iph.protocol) {
279
 	switch (p.iph.protocol) {
277
 		case IPPROTO_IPIP:
280
 		case IPPROTO_IPIP:
278
 			return do_del_ioctl(DEFAULT_TUNL_IF, &p);
281
 			return do_del_ioctl(DEFAULT_TUNL_IF, &p);
279
-		default:	
282
+		default:
280
 			return do_del_ioctl(p.name, &p);
283
 			return do_del_ioctl(p.name, &p);
281
 	}
284
 	}
282
 	return -1;
285
 	return -1;
283
 }
286
 }
284
 
287
 
285
 /*
288
 /*
286
- * tun_add_tunl: it adds in the `ifs' array a new struct which refers to 
289
+ * tun_add_tunl: it adds in the `ifs' array a new struct which refers to
287
  * the tunnel "tunlX", where X is a number equal to `tunl'.
290
  * the tunnel "tunlX", where X is a number equal to `tunl'.
288
  */
291
  */
289
 int tun_add_tunl(interface *ifs, char *tunl_prefix, u_char tunl_number)
292
 int tun_add_tunl(interface *ifs, char *tunl_prefix, u_char tunl_number)
298
 	return 0;
301
 	return 0;
299
 }
302
 }
300
 
303
 
301
-/* 
304
+/*
302
  * tun_del_tunl: it removes from the `ifs' array, which must have at least
305
  * tun_del_tunl: it removes from the `ifs' array, which must have at least
303
  * MAX_TUNNEL_IFS members, the struct which refers the tunnel "tunlX", where X
306
  * MAX_TUNNEL_IFS members, the struct which refers the tunnel "tunlX", where X
304
  * is a number equal to `tunl'.
307
  * is a number equal to `tunl'.
308
 {
311
 {
309
 	char tunl_name[IFNAMSIZ];
312
 	char tunl_name[IFNAMSIZ];
310
 	int i;
313
 	int i;
311
-	
314
+
312
 	sprintf(tunl_name, TUNL_STRING, TUNL_N(tunl_prefix, tunl_number));
315
 	sprintf(tunl_name, TUNL_STRING, TUNL_N(tunl_prefix, tunl_number));
313
 
316
 
314
 	for(i=0; i<MAX_TUNNEL_IFS; i++)
317
 	for(i=0; i<MAX_TUNNEL_IFS; i++)
316
 			memset(&ifs[i], 0, sizeof(interface));
319
 			memset(&ifs[i], 0, sizeof(interface));
317
 			return 0;
320
 			return 0;
318
 		}
321
 		}
319
-	
322
+
320
 	return -1;
323
 	return -1;
321
 }
324
 }
322
 
325
 
328
 }
331
 }
329
 
332
 
330
 /*
333
 /*
331
- * first_free_tunnel_if: returns the position of the first member of the 
334
+ * first_free_tunnel_if: returns the position of the first member of the
332
  * `tunnel_ifs' array which isn't used yet.
335
  * `tunnel_ifs' array which isn't used yet.
333
  * If the whole array is full, -1 is returned.
336
  * If the whole array is full, -1 is returned.
334
  */
337
  */
369
 		char *tunl_prefix, int tunl_number, inet_prefix *tunl_ip)
372
 		char *tunl_prefix, int tunl_number, inet_prefix *tunl_ip)
370
 {
373
 {
371
 	char tunl_name[IFNAMSIZ];
374
 	char tunl_name[IFNAMSIZ];
372
-	
373
-	/* 
375
+
376
+	/*
374
 	 * tunl0 zero is a special tunnel, it cannot be created nor destroyed.
377
 	 * tunl0 zero is a special tunnel, it cannot be created nor destroyed.
375
 	 * It's pure energy.
378
 	 * It's pure energy.
376
 	 */
379
 	 */
377
 	if(!strcmp(tunl_prefix, DEFAULT_TUNL_PREFIX) && !tunl_number)
380
 	if(!strcmp(tunl_prefix, DEFAULT_TUNL_PREFIX) && !tunl_number)
378
 		goto skip_krnl_add_tunl;
381
 		goto skip_krnl_add_tunl;
379
-	
382
+
380
 	if(tunnel_add(remote, local, dev, tunl_prefix, tunl_number) < 0) {
383
 	if(tunnel_add(remote, local, dev, tunl_prefix, tunl_number) < 0) {
381
 		error("Cannot add the \"" TUNL_STRING "\" tunnel",
384
 		error("Cannot add the \"" TUNL_STRING "\" tunnel",
382
 				TUNL_N(tunl_prefix, tunl_number));
385
 				TUNL_N(tunl_prefix, tunl_number));
396
 		if(set_tunnel_ip(tunl_prefix, tunl_number, tunl_ip) < 0)
399
 		if(set_tunnel_ip(tunl_prefix, tunl_number, tunl_ip) < 0)
397
 			return -1;
400
 			return -1;
398
 
401
 
399
-		
402
+
400
 		/*
403
 		/*
401
 		 *  ip route append tunl_ip_subnet dev tunnel  proto kernel \
404
 		 *  ip route append tunl_ip_subnet dev tunnel  proto kernel \
402
 		 *  scope link  src `tunl_ip'
405
 		 *  scope link  src `tunl_ip'
403
 		 */
406
 		 */
404
 		sprintf(tunl_name, TUNL_STRING, TUNL_N(tunl_prefix, tunl_number));
407
 		sprintf(tunl_name, TUNL_STRING, TUNL_N(tunl_prefix, tunl_number));
405
 		rt_append_subnet_src(tunl_ip, tunl_name);
408
 		rt_append_subnet_src(tunl_ip, tunl_name);
406
-				
409
+
407
 		if(route_rp_filter_all_dev(my_family, &tunnel_ifs[tunl_number],
410
 		if(route_rp_filter_all_dev(my_family, &tunnel_ifs[tunl_number],
408
 				1, 0) < 0)
411
 				1, 0) < 0)
409
 			return -1;
412
 			return -1;
434
 	return 0;
437
 	return 0;
435
 }
438
 }
436
 
439
 
437
-void del_all_tunnel_ifs(inet_prefix *remote, inet_prefix *local, char *dev, 
440
+void del_all_tunnel_ifs(inet_prefix *remote, inet_prefix *local, char *dev,
438
 		char *tunl_prefix)
441
 		char *tunl_prefix)
439
 {
442
 {
440
 	char tunl_name[IFNAMSIZ];
443
 	char tunl_name[IFNAMSIZ];

+ 5
- 5
src/iptunnel.h View File

22
 #include "if.h"
22
 #include "if.h"
23
 
23
 
24
 #define DEFAULT_TUNL_PREFIX	"tunl"
24
 #define DEFAULT_TUNL_PREFIX	"tunl"
25
-#define DEFAULT_TUNL_NUMBER	0	/* The permanent tunl0 device */
26
-#define DEFAULT_TUNL_IF		"tunl0"
25
+#define DEFAULT_TUNL_NUMBER	1	/* The permanent tunl0 device */
26
+#define DEFAULT_TUNL_IF		"tunl1"
27
 #define NTK_TUNL_PREFIX		"ntk_tunl"
27
 #define NTK_TUNL_PREFIX		"ntk_tunl"
28
 
28
 
29
 /* Usage: printf(TUNL_STRING, TUNL_NUMBER("tunl", x)); */
29
 /* Usage: printf(TUNL_STRING, TUNL_NUMBER("tunl", x)); */
31
 #define TUNL_N(prefix, x)	prefix, x
31
 #define TUNL_N(prefix, x)	prefix, x
32
 
32
 
33
 #define MAX_TUNNEL_IFS		24	/* it must be >= MAX_MULTIPATH_ROUTES,
33
 #define MAX_TUNNEL_IFS		24	/* it must be >= MAX_MULTIPATH_ROUTES,
34
-					   since in igs.c we are using a tunnel 
34
+					   since in igs.c we are using a tunnel
35
 					   for each nexthop inet-gw */
35
 					   for each nexthop inet-gw */
36
 
36
 
37
 /*
37
 /*
41
 interface tunnel_ifs[MAX_TUNNEL_IFS];
41
 interface tunnel_ifs[MAX_TUNNEL_IFS];
42
 
42
 
43
 
43
 
44
-/* 
44
+/*
45
  * Functions declaration
45
  * Functions declaration
46
  */
46
  */
47
 
47
 
63
 		char *tunl_prefix, int tunl_number, inet_prefix *tunl_ip);
63
 		char *tunl_prefix, int tunl_number, inet_prefix *tunl_ip);
64
 int del_tunnel_if(inet_prefix *remote, inet_prefix *local, char *dev,
64
 int del_tunnel_if(inet_prefix *remote, inet_prefix *local, char *dev,
65
 		char *tunl_prefix, int tunl_number);
65
 		char *tunl_prefix, int tunl_number);
66
-void del_all_tunnel_ifs(inet_prefix *remote, inet_prefix *local, char *dev, 
66
+void del_all_tunnel_ifs(inet_prefix *remote, inet_prefix *local, char *dev,
67
 		char *tunl_prefix);
67
 		char *tunl_prefix);
68
 #endif /* IPTUNNEL_H */
68
 #endif /* IPTUNNEL_H */

+ 1
- 0
src/mark.c View File

105
 {
105
 {
106
 	int res;
106
 	int res;
107
 	res=iptc_commit(t);
107
 	res=iptc_commit(t);
108
+	error("This is the value of res: %i This is the value of t is: %s", res, t);
108
 	if (!res) {
109
 	if (!res) {
109
 		error("In commit_rules: %s.",iptc_strerror(errno));
110
 		error("In commit_rules: %s.",iptc_strerror(errno));
110
 		err_ret(ERR_NETCOM,-1);
111
 		err_ret(ERR_NETCOM,-1);

Loading…
Cancel
Save