diff options
author | gjb <gjb@FreeBSD.org> | 2016-04-04 23:55:32 +0000 |
---|---|---|
committer | gjb <gjb@FreeBSD.org> | 2016-04-04 23:55:32 +0000 |
commit | 1dc4c40e3b35564cb2e787ad968e6b4a9fb7eb0f (patch) | |
tree | a027fe5a27446f32854d6a07b34b5f2a992bf283 /lib/libstand | |
parent | 3669a0dced7e344be71d234ffc3a71530ef0ae08 (diff) | |
parent | 589cedfe0cde2b49d5f47fc240de37c8bf307abd (diff) | |
download | FreeBSD-src-1dc4c40e3b35564cb2e787ad968e6b4a9fb7eb0f.zip FreeBSD-src-1dc4c40e3b35564cb2e787ad968e6b4a9fb7eb0f.tar.gz |
MFH
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/libstand')
-rw-r--r-- | lib/libstand/Makefile | 2 | ||||
-rw-r--r-- | lib/libstand/bootp.c | 8 | ||||
-rw-r--r-- | lib/libstand/bootp.h | 1 | ||||
-rw-r--r-- | lib/libstand/bswap.c | 57 | ||||
-rw-r--r-- | lib/libstand/globals.c | 3 | ||||
-rw-r--r-- | lib/libstand/net.h | 1 | ||||
-rw-r--r-- | lib/libstand/stand.h | 5 |
7 files changed, 13 insertions, 64 deletions
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index 835b535..0ebcaf1 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -26,7 +26,7 @@ WARNS?= 0 CFLAGS+= -I${LIBSTAND_SRC} # standalone components and stuff we have modified locally -SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ +SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \ globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \ sbrk.c twiddle.c zalloc.c zalloc_malloc.c diff --git a/lib/libstand/bootp.c b/lib/libstand/bootp.c index 1af7bd5..f3bc816 100644 --- a/lib/libstand/bootp.c +++ b/lib/libstand/bootp.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> +#include <sys/endian.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -393,6 +394,13 @@ vend_rfc1048(cp, len) val = (const char *)cp; strlcpy(hostname, val, sizeof(hostname)); } + if (tag == TAG_INTF_MTU) { + if ((val = getenv("dhcp.interface-mtu")) != NULL) { + intf_mtu = (u_int)strtoul(val, NULL, 0); + } else { + intf_mtu = be16dec(cp); + } + } #ifdef SUPPORT_DHCP if (tag == TAG_DHCP_MSGTYPE) { if(*cp != expected_dhcpmsgtype) diff --git a/lib/libstand/bootp.h b/lib/libstand/bootp.h index ed9101f..47e5649 100644 --- a/lib/libstand/bootp.h +++ b/lib/libstand/bootp.h @@ -91,6 +91,7 @@ struct bootp { #define TAG_DOMAINNAME ((unsigned char) 15) #define TAG_SWAPSERVER ((unsigned char) 16) #define TAG_ROOTPATH ((unsigned char) 17) +#define TAG_INTF_MTU ((unsigned char) 26) #ifdef SUPPORT_DHCP #define TAG_REQ_ADDR ((unsigned char) 50) diff --git a/lib/libstand/bswap.c b/lib/libstand/bswap.c deleted file mode 100644 index 308edda..0000000 --- a/lib/libstand/bswap.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Written by Manuel Bouyer <bouyer@netbsd.org>. - * Public domain. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$NetBSD: bswap32.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $"; -static char *rcsid = "$NetBSD: bswap64.c,v 1.3 2009/03/16 05:59:21 cegger Exp $"; -#endif - -#include <sys/types.h> - -#undef bswap32 -#undef bswap64 - -u_int32_t bswap32(u_int32_t x); -u_int64_t bswap64(u_int64_t x); - -u_int32_t -bswap32(u_int32_t x) -{ - return ((x << 24) & 0xff000000 ) | - ((x << 8) & 0x00ff0000 ) | - ((x >> 8) & 0x0000ff00 ) | - ((x >> 24) & 0x000000ff ); -} - -u_int64_t -bswap64(u_int64_t x) -{ -#ifdef __LP64__ - /* - * Assume we have wide enough registers to do it without touching - * memory. - */ - return ( (x << 56) & 0xff00000000000000UL ) | - ( (x << 40) & 0x00ff000000000000UL ) | - ( (x << 24) & 0x0000ff0000000000UL ) | - ( (x << 8) & 0x000000ff00000000UL ) | - ( (x >> 8) & 0x00000000ff000000UL ) | - ( (x >> 24) & 0x0000000000ff0000UL ) | - ( (x >> 40) & 0x000000000000ff00UL ) | - ( (x >> 56) & 0x00000000000000ffUL ); -#else - /* - * Split the operation in two 32bit steps. - */ - u_int32_t tl, th; - - th = bswap32((u_int32_t)(x & 0x00000000ffffffffULL)); - tl = bswap32((u_int32_t)((x >> 32) & 0x00000000ffffffffULL)); - return ((u_int64_t)th << 32) | tl; -#endif -} diff --git a/lib/libstand/globals.c b/lib/libstand/globals.c index 0310823..f2c6240 100644 --- a/lib/libstand/globals.c +++ b/lib/libstand/globals.c @@ -30,7 +30,8 @@ struct in_addr myip; /* my ip address */ struct in_addr nameip; /* DNS server ip address */ struct in_addr rootip; /* root ip address */ struct in_addr swapip; /* swap ip address */ -struct in_addr gateip; /* swap ip address */ +struct in_addr gateip; /* gateway ip address */ n_long netmask = 0xffffff00; /* subnet or net mask */ +u_int intf_mtu; /* interface mtu from bootp/dhcp */ int errno; /* our old friend */ diff --git a/lib/libstand/net.h b/lib/libstand/net.h index 94f2aab..ce7df49 100644 --- a/lib/libstand/net.h +++ b/lib/libstand/net.h @@ -83,6 +83,7 @@ extern struct in_addr swapip; extern struct in_addr gateip; extern struct in_addr nameip; extern n_long netmask; +extern u_int intf_mtu; extern int debug; /* defined in the machdep sources */ diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h index 22ee319..a841523 100644 --- a/lib/libstand/stand.h +++ b/lib/libstand/stand.h @@ -335,11 +335,6 @@ static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); } static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); } -/* swaps (undocumented, useful?) */ -#ifdef __i386__ -extern u_int32_t bswap32(u_int32_t x); -extern u_int64_t bswap64(u_int64_t x); -#endif /* null functions for device/filesystem switches (undocumented) */ extern int nodev(void); |