* localaddr.c (krb5_os_localaddr): Raise buffer size to 10K. Handle INET6
authorKen Raeburn <raeburn@mit.edu>
Sun, 17 Oct 1999 07:16:32 +0000 (07:16 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sun, 17 Oct 1999 07:16:32 +0000 (07:16 +0000)
addresses.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11863 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/ChangeLog
src/lib/krb5/os/localaddr.c

index 208125a8dccf306bf92cb971fdf3bd4fe247c2b3..fb24615966174a264a6f9ed483051a4a00cef4f2 100644 (file)
@@ -1,3 +1,8 @@
+1999-10-17  Ken Raeburn  <raeburn@raeburn.org>
+
+       * localaddr.c (krb5_os_localaddr): Raise buffer size to 10K.
+       Handle INET6 addresses.
+
 1999-09-28  Ken Raeburn  <raeburn@mit.edu>
 
        * changepw.c (krb5_locate_kpasswd): Declare local variable i even
index 5c5a27334274b8c9e169d5115593929d59580e6f..c4d4986e37c0e29affa1923832541de446e24f9d 100644 (file)
 #include <netinet/in.h>
 
 #ifndef USE_AF
+#ifdef AF_INET6
+#define USE_AF AF_INET6
+#else
 #define USE_AF AF_INET
+#endif
 #define USE_TYPE SOCK_DGRAM
 #define USE_PROTO 0
 #endif
@@ -115,8 +119,8 @@ krb5_os_localaddr(context, addr)
     struct ifreq *ifr, ifreq;
     struct ifconf ifc;
     int s, code, n, i;
-    char buf[1024];
-    krb5_address *addr_temp [ 1024/sizeof(struct ifreq) ];
+    char buf[1024*10];
+    krb5_address *addr_temp [ sizeof(buf)/sizeof(struct ifreq) ];
     int n_found;
     int mem_err = 0;
     
@@ -181,9 +185,39 @@ n_found = 0;
                    }
                } else mem_err++;
            }
-#endif
+#ifdef AF_INET6
+       case AF_INET6:
+           {
+               struct sockaddr_in6 *in =
+                   (struct sockaddr_in6 *)&ifr->ifr_addr;
+
+               if (IN6_IS_ADDR_LINKLOCAL (&in->sin6_addr))
+                   continue;
+
+               address = (krb5_address *)
+                   malloc (sizeof(krb5_address));
+               if (address) {
+                   address->magic = KV5M_ADDRESS;
+                   address->addrtype = ADDRTYPE_INET6;
+                   address->length = sizeof(struct in6_addr);
+                   address->contents = (unsigned char *)malloc(address->length);
+                   if (!address->contents) {
+                       krb5_xfree(address);
+                       address = 0;
+                       mem_err++;
+                   } else {
+                       memcpy ((char *)address->contents,
+                               (char *)&in->sin6_addr,
+                               address->length);
+                       break;
+                   }
+               } else mem_err++;
+           }
+#endif /* AF_INET6 */
+#endif /* netinet/in.h */
+
 #ifdef KRB5_USE_NS
-           case AF_XNS:
+       case AF_XNS:
            {  
                struct sockaddr_ns *ns =
                    (struct sockaddr_ns *)&ifr->ifr_addr;