From 358530e1d3b52c514dd2511e64e0976d5a9d0fb1 Mon Sep 17 00:00:00 2001 From: David Kopf Date: Fri, 2 Mar 2012 15:28:26 -0500 Subject: [PATCH] Add higher baud rates, option for link-local address assignment --- tools/tunslip6.c | 57 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/tools/tunslip6.c b/tools/tunslip6.c index 4192dae4f..3b6a51601 100644 --- a/tools/tunslip6.c +++ b/tools/tunslip6.c @@ -29,7 +29,6 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: tunslip6.c,v 1.6 2010/11/29 18:14:54 joxe Exp $ * */ @@ -596,6 +595,49 @@ ifconf(const char *tundev, const char *ipaddr) ssystem("ifconfig %s inet `hostname` up", tundev); if (timestamp) stamptime(); ssystem("ifconfig %s add %s", tundev, ipaddr); + +/* radvd needs a link local address for routing */ +#if 0 +/* fe80::1/64 is good enough */ + ssystem("ifconfig %s add fe80::1/64", tundev); +#elif 1 +/* Generate a link local address a la sixxs/aiccu */ +/* First a full parse, stripping off the prefix length */ +{ +char lladdr[40]; +char c,*ptr=(char *)ipaddr; +uint16_t digit,ai,a[8],cc,scc,i; + for(ai=0;ai<8;ai++) a[ai]=0; + ai=0;cc=scc=0; + while(c=*ptr++) { + if(c=='/') break; + if(c==':') { + if(cc) scc = ai; + cc = 1; + if (++ai>7) break; + } else { + cc=0; + digit = c-'0'; if (digit > 9) digit = 10 + (c & 0xdf) - 'A'; + a[ai] = (a[ai] << 4) + digit; + } + } + /* Get # elided and shift what's after to the end */ + cc=8-ai; + for(i=0;i