start merging Jonathan's IPv6 patches (01-defines, 02-ipv6-cli)
authorBrendan O'Dea <bod@optus.net>
Sat, 18 Dec 2004 01:20:05 +0000 (01:20 +0000)
committerBrendan O'Dea <bod@optus.net>
Sat, 18 Dec 2004 01:20:05 +0000 (01:20 +0000)
Changes
cli.c
l2tpns.c
l2tpns.h
l2tpns.spec

diff --git a/Changes b/Changes
index 32e9a2b..2431686 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+* Sat Dec 18 2004 Brendan O'Dea <bod@optusnet.com.au> 2.1.0
+- Add IPv6 support from Jonathan McDowell (work in progress).
+
 * Fri Dec 17 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.13
 - Better cluster master collision resolution: keep a counter of state
   changes, propagated in the heartbeats; the master with the highest #
diff --git a/cli.c b/cli.c
index cce14bf..26e91b4 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -2,7 +2,7 @@
 // vim: sw=8 ts=8
 
 char const *cvs_name = "$Name:  $";
-char const *cvs_id_cli = "$Id: cli.c,v 1.43 2004-12-17 00:28:00 bodea Exp $";
+char const *cvs_id_cli = "$Id: cli.c,v 1.44 2004-12-18 01:20:05 bodea Exp $";
 
 #include <stdio.h>
 #include <stdarg.h>
@@ -98,6 +98,7 @@ static int cmd_set(struct cli_def *cli, char *command, char **argv, int argc);
 static int cmd_load_plugin(struct cli_def *cli, char *command, char **argv, int argc);
 static int cmd_remove_plugin(struct cli_def *cli, char *command, char **argv, int argc);
 static int cmd_uptime(struct cli_def *cli, char *command, char **argv, int argc);
+
 static int regular_stuff(struct cli_def *cli);
 static void parsemac(char *string, char mac[6]);
 
@@ -889,6 +890,7 @@ static char const *show_access_list_rule(int extended, ip_filter_rulet *rule);
 static int cmd_show_run(struct cli_def *cli, char *command, char **argv, int argc)
 {
        int i;
+       char ipv6addr[INET6_ADDRSTRLEN];
 
        if (CLI_HELP_REQUESTED)
                return CLI_HELP_NO_ARGS;
@@ -899,25 +901,27 @@ static int cmd_show_run(struct cli_def *cli, char *command, char **argv, int arg
        {
                void *value = ((void *)config) + config_values[i].offset;
                if (config_values[i].type == STRING)
-                       cli_print(cli, "set %s \"%.*s\"", config_values[i].key, config_values[i].size, (char *)value);
-               else if (config_values[i].type == IP)
-                       cli_print(cli, "set %s %s", config_values[i].key, fmtaddr(*(unsigned *)value, 0));
+                       cli_print(cli, "set %s \"%.*s\"", config_values[i].key, config_values[i].size, (char *) value);
+               else if (config_values[i].type == IPv4)
+                       cli_print(cli, "set %s %s", config_values[i].key, fmtaddr(*(in_addr_t *) value, 0));
+               else if (config_values[i].type == IPv6)
+                       cli_print(cli, "set %s %s", config_values[i].key, inet_ntop(AF_INET6, value, ipv6addr, INET6_ADDRSTRLEN));
                else if (config_values[i].type == SHORT)
-                       cli_print(cli, "set %s %hu", config_values[i].key, *(short *)value);
+                       cli_print(cli, "set %s %hu", config_values[i].key, *(short *) value);
                else if (config_values[i].type == BOOL)
-                       cli_print(cli, "set %s %s", config_values[i].key, (*(int *)value) ? "yes" : "no");
+                       cli_print(cli, "set %s %s", config_values[i].key, (*(int *) value) ? "yes" : "no");
                else if (config_values[i].type == INT)
-                       cli_print(cli, "set %s %d", config_values[i].key, *(int *)value);
+                       cli_print(cli, "set %s %d", config_values[i].key, *(int *) value);
                else if (config_values[i].type == UNSIGNED_LONG)
-                       cli_print(cli, "set %s %lu", config_values[i].key, *(unsigned long *)value);
+                       cli_print(cli, "set %s %lu", config_values[i].key, *(unsigned long *) value);
                else if (config_values[i].type == MAC)
                        cli_print(cli, "set %s %02x%02x.%02x%02x.%02x%02x", config_values[i].key,
-                                       *(unsigned short *)(value + 0),
-                                       *(unsigned short *)(value + 1),
-                                       *(unsigned short *)(value + 2),
-                                       *(unsigned short *)(value + 3),
-                                       *(unsigned short *)(value + 4),
-                                       *(unsigned short *)(value + 5));
+                                       *(unsigned short *) (value + 0),
+                                       *(unsigned short *) (value + 1),
+                                       *(unsigned short *) (value + 2),
+                                       *(unsigned short *) (value + 3),
+                                       *(unsigned short *) (value + 4),
+                                       *(unsigned short *) (value + 5));
        }
 
        cli_print(cli, "# Plugins");
@@ -1826,28 +1830,31 @@ static int cmd_set(struct cli_def *cli, char *command, char **argv, int argc)
                        switch (config_values[i].type)
                        {
                        case STRING:
-                               strncpy((char *)value, argv[1], config_values[i].size - 1);
+                               strncpy((char *) value, argv[1], config_values[i].size - 1);
                                break;
                        case INT:
-                               *(int *)value = atoi(argv[1]);
+                               *(int *) value = atoi(argv[1]);
                                break;
                        case UNSIGNED_LONG:
-                               *(unsigned long *)value = atol(argv[1]);
+                               *(unsigned long *) value = atol(argv[1]);
                                break;
                        case SHORT:
-                               *(short *)value = atoi(argv[1]);
+                               *(short *) value = atoi(argv[1]);
+                               break;
+                       case IPv4:
+                               *(in_addr_t *) value = inet_addr(argv[1]);
                                break;
-                       case IP:
-                               *(unsigned *)value = inet_addr(argv[1]);
+                       case IPv6:
+                               inet_pton(AF_INET6, argv[1], value);
                                break;
                        case MAC:
                                parsemac(argv[1], (char *)value);
                                break;
                        case BOOL:
                                if (strcasecmp(argv[1], "yes") == 0 || strcasecmp(argv[1], "true") == 0 || strcasecmp(argv[1], "1") == 0)
-                                       *(int *)value = 1;
+                                       *(int *) value = 1;
                                else
-                                       *(int *)value = 0;
+                                       *(int *) value = 0;
                                break;
                        default:
                                cli_print(cli, "Unknown variable type");
index 779112e..d2db89c 100644 (file)
--- a/l2tpns.c
+++ b/l2tpns.c
@@ -4,7 +4,7 @@
 // Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
 // vim: sw=8 ts=8
 
-char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.73 2004-12-17 00:28:00 bodea Exp $";
+char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.74 2004-12-18 01:20:05 bodea Exp $";
 
 #include <arpa/inet.h>
 #include <assert.h>
@@ -95,17 +95,17 @@ config_descriptt config_values[] = {
        CONFIG("log_file", log_filename, STRING),
        CONFIG("pid_file", pid_file, STRING),
        CONFIG("l2tp_secret", l2tpsecret, STRING),
-       CONFIG("primary_dns", default_dns1, IP),
-       CONFIG("secondary_dns", default_dns2, IP),
+       CONFIG("primary_dns", default_dns1, IPv4),
+       CONFIG("secondary_dns", default_dns2, IPv4),
        CONFIG("save_state", save_state, BOOL),
-       CONFIG("primary_radius", radiusserver[0], IP),
-       CONFIG("secondary_radius", radiusserver[1], IP),
+       CONFIG("primary_radius", radiusserver[0], IPv4),
+       CONFIG("secondary_radius", radiusserver[1], IPv4),
        CONFIG("primary_radius_port", radiusport[0], SHORT),
        CONFIG("secondary_radius_port", radiusport[1], SHORT),
        CONFIG("radius_accounting", radius_accounting, BOOL),
        CONFIG("radius_secret", radiussecret, STRING),
-       CONFIG("bind_address", bind_address, IP),
-       CONFIG("peer_address", peer_address, IP),
+       CONFIG("bind_address", bind_address, IPv4),
+       CONFIG("peer_address", peer_address, IPv4),
        CONFIG("send_garp", send_garp, BOOL),
        CONFIG("throttle_speed", rl_rate, UNSIGNED_LONG),
        CONFIG("throttle_buckets", num_tbfs, INT),
@@ -117,7 +117,7 @@ config_descriptt config_values[] = {
        CONFIG("scheduler_fifo", scheduler_fifo, BOOL),
        CONFIG("lock_pages", lock_pages, BOOL),
        CONFIG("icmp_rate", icmp_rate, INT),
-       CONFIG("cluster_address", cluster_address, IP),
+       CONFIG("cluster_address", cluster_address, IPv4),
        CONFIG("cluster_interface", cluster_interface, STRING),
        CONFIG("cluster_hb_interval", cluster_hb_interval, INT),
        CONFIG("cluster_hb_timeout", cluster_hb_timeout, INT),
@@ -1993,7 +1993,7 @@ static void processtun(uint8_t * buf, int len)
                return;
        }
 
-       if (*(uint16_t *) (buf + 2) == htons(PKTIP)) // IP
+       if (*(uint16_t *) (buf + 2) == htons(PKTIP)) // IPv4
                processipout(buf, len);
        // Else discard.
 }
index 756484a..e7584f9 100644 (file)
--- a/l2tpns.h
+++ b/l2tpns.h
@@ -1,5 +1,5 @@
 // L2TPNS Global Stuff
-// $Id: l2tpns.h,v 1.49 2004-12-17 00:28:00 bodea Exp $
+// $Id: l2tpns.h,v 1.50 2004-12-18 01:20:05 bodea Exp $
 
 #ifndef __L2TPNS_H__
 #define __L2TPNS_H__
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 #include <libcli.h>
 
-#define VERSION        "2.0.13"
+#define VERSION        "2.1.0"
 
 // Limits
 #define MAXTUNNEL      500             // could be up to 65535
 #define        L2TPPORT        1701            // L2TP port
 #define RADPORT                1645            // old radius port...
 #define        PKTARP          0x0806          // ARP packet type
-#define        PKTIP           0x0800          // IP packet type
-#define PSEUDOMAC      0x0200          // pseudo MAC prefix (local significant MAC)
+#define        PKTIP           0x0800          // IPv4 packet type
+#define        PKTIPV6         0x86DD          // IPv6 packet type
 #define        PPPPAP          0xC023
 #define        PPPCHAP         0xC223
 #define        PPPLCP          0xC021
 #define        PPPIPCP         0x8021
+#define        PPPIPV6CP       0x8057
 #define        PPPCCP          0x80FD
 #define PPPIP          0x0021
+#define PPPIPV6                0x0057
 #define PPPMP          0x003D
 #define MIN_IP_SIZE    0x19
 enum
@@ -208,6 +210,8 @@ sessiont;
 #define SF_IPCP_ACKED  1       // Has this session seen an IPCP Ack?
 #define SF_LCP_ACKED   2       // LCP negotiated
 #define SF_CCP_ACKED   4       // CCP negotiated
+#define SF_IPV6CP_ACKED        8       // IPv6 negotiated
+#define SF_IPV6_NACKED 16      // IPv6 rejected
 
 typedef struct
 {
@@ -480,7 +484,7 @@ typedef struct
 #endif
 } configt;
 
-enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IP, MAC };
+enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6, MAC };
 typedef struct
 {
        char *key;
index 3cb0c8b..dd382cb 100644 (file)
@@ -1,6 +1,6 @@
 Summary: A high-speed clustered L2TP LNS
 Name: l2tpns
-Version: 2.0.13
+Version: 2.1.0
 Release: 1
 Copyright: GPL
 Group: System Environment/Daemons
@@ -43,5 +43,5 @@ rm -rf %{buildroot}
 %attr(644,root,root) /usr/share/man/man[58]/*
 
 %changelog
-* Fri Dec 17 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.13-1
-- 2.0.13 release, see /usr/share/doc/l2tpns-2.0.13/Changes
+* Sat Dec 18 2004 Brendan O'Dea <bod@optusnet.com.au> 2.1.0-1
+- 2.1.0 release, see /usr/share/doc/l2tpns-2.1.0/Changes