added compilation macro to eui64.[ch] and cleaned unix-dependant code

This commit is contained in:
Sylvain Rochet 2012-06-20 13:39:08 +02:00
parent c36d73f42a
commit cd7894dfc9
2 changed files with 11 additions and 32 deletions

View File

@ -35,19 +35,16 @@
* $Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $
*/
#define RCSID "$Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $"
#include "lwip/opt.h"
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
#include "pppd.h"
static const char rcsid[] = RCSID;
#include "ppp_impl.h"
#include "eui64.h"
/*
* eui64_ntoa - Make an ascii representation of an interface identifier
*/
char *
eui64_ntoa(e)
eui64_t e;
{
char *eui64_ntoa(eui64_t e) {
static char buf[32];
snprintf(buf, 32, "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
@ -55,3 +52,5 @@ eui64_ntoa(e)
e.e8[4], e.e8[5], e.e8[6], e.e8[7]);
return buf;
}
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */

View File

@ -35,30 +35,12 @@
* $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $
*/
#include "lwip/opt.h"
#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef __EUI64_H__
#define __EUI64_H__
#if !defined(INET6)
#error "this file should only be included when INET6 is defined"
#endif /* not defined(INET6) */
#if defined(SOL2)
#include <netinet/in.h>
typedef union {
uint8_t e8[8]; /* lower 64-bit IPv6 address */
uint32_t e32[2]; /* lower 64-bit IPv6 address */
} eui64_t;
/*
* Declare the two below, since in.h only defines them when _KERNEL
* is declared - which shouldn't be true when dealing with user-land programs
*/
#define s6_addr8 _S6_un._S6_u8
#define s6_addr32 _S6_un._S6_u32
#else /* else if not defined(SOL2) */
/*
* TODO:
*
@ -71,8 +53,6 @@ typedef union
u_int32_t e32[2];
} eui64_t;
#endif /* defined(SOL2) */
#define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0)
#define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \
((e).e32[1] == (o).e32[1]))
@ -111,4 +91,4 @@ typedef union
char *eui64_ntoa __P((eui64_t)); /* Returns ascii representation of id */
#endif /* __EUI64_H__ */
#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */