]> git.ozlabs.org Git - ppp.git/commitdiff
Added Linux support for the ipv6cp-use-persistent option.
authorRussell Coker <russell@coker.com.au>
Sat, 14 Sep 2002 08:10:11 +0000 (08:10 +0000)
committerRussell Coker <russell@coker.com.au>
Sat, 14 Sep 2002 08:10:11 +0000 (08:10 +0000)
pppd/ipv6cp.c
pppd/ipv6cp.h
pppd/sys-linux.c

index 3a370a0caa96fe55a5486c9a4c6730aeb2f8efc2..0026f54562e77e3c8b622f8147090fe550385c61 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: ipv6cp.c,v 1.15 2001/03/22 00:42:33 paulus Exp $ 
+ * $Id: ipv6cp.c,v 1.16 2002/09/14 08:10:11 etbe Exp $ 
  */
 
-#define RCSID  "$Id: ipv6cp.c,v 1.15 2001/03/22 00:42:33 paulus Exp $"
+#define RCSID  "$Id: ipv6cp.c,v 1.16 2002/09/14 08:10:11 etbe Exp $"
 
 /*
  * TODO: 
@@ -193,7 +193,7 @@ static option_t ipv6cp_option_list[] = {
     { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip,
       "Use (default) IPv4 address as interface identifier", 1 },
 
-#if defined(SOL2)
+#if defined(SOL2) || defined(__linux__)
     { "ipv6cp-use-persistent", o_bool, &ipv6cp_wantoptions[0].use_persistent,
       "Use uniquely-available persistent value for link local address", 1 },
 #endif /* defined(SOL2) */
@@ -330,6 +330,8 @@ setifaceid(argv)
     return 1;
 }
 
+char *llv6_ntoa(eui64_t ifaceid);
+
 static void
 printifaceid(opt, printer, arg)
     option_t *opt;
@@ -1027,7 +1029,7 @@ ipv6_check_options()
     if (!ipv6cp_protent.enabled_flag)
        return;
 
-#if defined(SOL2)
+#if defined(SOL2) || defined(__linux__)
     /*
      * Persistent link-local id is only used when user has not explicitly
      * configure/hard-code the id
index d0ac3d6483009787dd96e316d8a0ebd5e7230ffc..bcdd0d57eb1d72b3b96d50cc313e59c9ac8a87cf 100644 (file)
@@ -90,7 +90,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: ipv6cp.h,v 1.5 2000/08/05 06:46:47 paulus Exp $
+ * $Id: ipv6cp.h,v 1.6 2002/09/14 08:10:11 etbe Exp $
  */
 
 /*
@@ -109,7 +109,7 @@ typedef struct ipv6cp_options {
     int opt_local;             /* ourtoken set by option */
     int opt_remote;            /* histoken set by option */
     int use_ip;                        /* use IP as interface identifier */
-#if defined(SOL2)
+#if defined(SOL2) || defined(__linux__)
     int use_persistent;                /* use uniquely persistent value for address */
 #endif /* defined(SOL2) */
     int neg_vj;                        /* Van Jacobson Compression? */
index d630bca14fab4f864aa2599701bb15619a9f6c61..c86a516f0aad475be0818e6cd167798a4fd1ad49 100644 (file)
@@ -2778,3 +2778,51 @@ sys_check_options(void)
     }
     return 1;
 }
+
+#ifdef INET6
+/*
+ * ether_to_eui64 - Convert 48-bit Ethernet address into 64-bit EUI
+ *
+ * convert the 48-bit MAC address of eth0 into EUI 64. caller also assumes
+ * that the system has a properly configured Ethernet interface for this
+ * function to return non-zero.
+ */
+int
+ether_to_eui64(eui64_t *p_eui64)
+{
+    struct ifreq ifr;
+    int skfd;
+    const unsigned char *ptr;
+
+    skfd = socket(PF_INET6, SOCK_DGRAM, 0);
+    if(skfd == -1)
+    {
+        warn("could not open IPv6 socket");
+        return 0;
+    }
+
+    strcpy(ifr.ifr_name, "eth0");
+    if(ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
+    {
+        close(skfd);
+        warn("could not obtain hardware address for eth0");
+        return 0;
+    }
+    close(skfd);
+
+    /*
+     * And convert the EUI-48 into EUI-64, per RFC 2472 [sec 4.1]
+     */
+    ptr = ifr.ifr_hwaddr.sa_data;
+    p_eui64->e8[0] = ptr[0] | 0x02;
+    p_eui64->e8[1] = ptr[1];
+    p_eui64->e8[2] = ptr[2];
+    p_eui64->e8[3] = 0xFF;
+    p_eui64->e8[4] = 0xFE;
+    p_eui64->e8[5] = ptr[3];
+    p_eui64->e8[6] = ptr[4];
+    p_eui64->e8[7] = ptr[5];
+
+    return 1;
+}
+#endif