PPP, IPv6, reduce size of llv6_ntoa() function

Reduced static buffer to the strict necessary (26 bytes), removed
call to eui64_ntoa(), merged eui64_ntoa() into llv6_ntoa().

272 bytes (code + static buffers) to 140 bytes on x86_64.

Improved eui64_ntoa() as well, we don't need it anymore but I'd
like to keep all eui64_* helpers functions.
This commit is contained in:
Sylvain Rochet 2015-03-08 13:33:55 +01:00
parent 7fce9346dc
commit af722a2978
2 changed files with 7 additions and 4 deletions

View File

@ -45,9 +45,9 @@
* eui64_ntoa - Make an ascii representation of an interface identifier
*/
char *eui64_ntoa(eui64_t e) {
static char buf[32];
static char buf[20];
snprintf(buf, 32, "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
e.e8[0], e.e8[1], e.e8[2], e.e8[3],
e.e8[4], e.e8[5], e.e8[6], e.e8[7]);
return buf;

View File

@ -412,9 +412,12 @@ printifaceid(opt, printer, arg)
static char *
llv6_ntoa(eui64_t ifaceid)
{
static char b[64];
static char b[26];
sprintf(b, "fe80::%02x%02x:%02x%02x:%02x%02x:%02x%02x",
ifaceid.e8[0], ifaceid.e8[1], ifaceid.e8[2], ifaceid.e8[3],
ifaceid.e8[4], ifaceid.e8[5], ifaceid.e8[6], ifaceid.e8[7]);
sprintf(b, "fe80::%s", eui64_ntoa(ifaceid));
return b;
}