Index: builder.py
===================================================================
--- builder.py	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ builder.py	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -177,4 +177,5 @@
             '-Ifreebsd/sys/net',
             '-Ifreebsd/include',
+            '-Ifreebsd/lib',
             '-Ifreebsd/lib/libc/include',
             '-Ifreebsd/lib/libc/isc/include',
@@ -184,4 +185,5 @@
             '-Ifreebsd/lib/libmemstat',
             '-Ifreebsd/lib/libipsec',
+            '-Ifreebsd/contrib/expat/lib',
             '-Ifreebsd/contrib/libpcap',
             '-Ifreebsd/contrib/libxo',
Index: freebsd/lib/lib80211/lib80211_regdomain.c
===================================================================
--- freebsd/lib/lib80211/lib80211_regdomain.c	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ freebsd/lib/lib80211/lib80211_regdomain.c	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -29,4 +29,13 @@
 #endif /* not lint */
 
+#ifdef __rtems__
+/* We need some functions from kernel name space */
+#define sbuf_bcat	_bsd_sbuf_bcat
+#define sbuf_finish	_bsd_sbuf_finish
+#define sbuf_data	_bsd_sbuf_data
+#define sbuf_len	_bsd_sbuf_len
+#define sbuf_delete	_bsd_sbuf_delete
+#define sbuf_new	_bsd_sbuf_new
+#endif /* __rtems__ */
 #include <sys/types.h>
 #include <rtems/bsd/sys/errno.h>
Index: freebsd/sbin/ifconfig/ifconfig.c
===================================================================
--- freebsd/sbin/ifconfig/ifconfig.c	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ freebsd/sbin/ifconfig/ifconfig.c	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -383,4 +383,5 @@
 	group_ctor();
 	ifmedia_ctor();
+	ieee80211_ctor();
 	inet6_ctor();
 	inet_ctor();
Index: freebsd/sbin/ifconfig/ifieee80211.c
===================================================================
--- freebsd/sbin/ifconfig/ifieee80211.c	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ freebsd/sbin/ifconfig/ifieee80211.c	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -1,3 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
+
+#ifdef __rtems__
+#include "rtems-bsd-ifconfig-namespace.h"
+#endif /* __rtems__ */
 
 /*
@@ -60,4 +64,7 @@
  */
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <rtems/bsd/sys/param.h>
 #include <sys/ioctl.h>
@@ -96,4 +103,7 @@
 #include <lib80211/lib80211_regdomain.h>
 #include <lib80211/lib80211_ioctl.h>
+#ifdef __rtems__
+#include "rtems-bsd-ifconfig-ifieee80211-data.h"
+#endif /* __rtems__ */
 
 #ifndef IEEE80211_FIXED_RATE_NONE
@@ -3449,5 +3459,9 @@
 list_scan(int s)
 {
+#ifndef __rtems__
 	uint8_t buf[24*1024];
+#else /* __rtems__ */
+	static uint8_t buf[24*1024];
+#endif /* __rtems__ */
 	char ssid[IEEE80211_NWID_LEN+1];
 	const uint8_t *cp;
@@ -5694,5 +5708,9 @@
 };
 
+#ifndef __rtems__
 static __constructor void
+#else /* __rtems__ */
+void
+#endif /* __rtems__ */
 ieee80211_ctor(void)
 {
Index: freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h
===================================================================
--- freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -8,9 +8,9 @@
 /* ifclone.c */
 /* ifconfig.c */
-RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int setaddr);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern struct ifreq ifr);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char name[16]);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char *descr);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern size_t descrlen);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int setaddr);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int setmask);
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int doalias);
@@ -29,4 +29,5 @@
 /* ifgre.c */
 /* ifgroup.c */
+/* ifieee80211.c */
 /* iflagg.c */
 RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char lacpbuf[120]);
Index: freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifieee80211-data.h
===================================================================
--- freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifieee80211-data.h	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
+++ freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifieee80211-data.h	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -0,0 +1,24 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-ifconfig-data.h"
+/* ifieee80211.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int col);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static char spacer);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static char const *modename[14]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211req_chaninfo *chaninfo);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_regdomain regdomain);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotregdomain);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_roamparams_req roamparams);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotroam);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_txparams_req txparams);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gottxparams);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_channel curchan);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotcurchan);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmediareq *ifmr);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int htconf);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gothtconf);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ieee80211_clone_params params);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct cmd ieee80211_cmds[177]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct afswtch af_ieee80211);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int vhtconf);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static int gotvhtconf);
Index: freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h
===================================================================
--- freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -16,9 +16,9 @@
 #define clone_setdefcallback _bsd_ifconfig_clone_setdefcallback
 /* ifconfig.c */
-#define setaddr _bsd_ifconfig_setaddr
 #define ifr _bsd_ifconfig_ifr
 #define name _bsd_ifconfig_name
 #define descr _bsd_ifconfig_descr
 #define descrlen _bsd_ifconfig_descrlen
+#define setaddr _bsd_ifconfig_setaddr
 #define setmask _bsd_ifconfig_setmask
 #define doalias _bsd_ifconfig_doalias
@@ -50,4 +50,6 @@
 /* ifgroup.c */
 #define group_ctor _bsd_ifconfig_group_ctor
+/* ifieee80211.c */
+#define ieee80211_ctor _bsd_ifconfig_ieee80211_ctor
 /* iflagg.c */
 #define lacpbuf _bsd_ifconfig_lacpbuf
Index: libbsd.py
===================================================================
--- libbsd.py	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ libbsd.py	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -1946,4 +1946,6 @@
             'include/rpcsvc/yp_prot.h',
             'include/sysexits.h',
+            'lib/lib80211/lib80211_ioctl.h',
+            'lib/lib80211/lib80211_regdomain.h',
             'lib/libc/db/btree/btree.h',
             'lib/libc/db/btree/extern.h',
@@ -2041,4 +2043,6 @@
             'contrib/libxo/libxo/libxo.c',
             'contrib/libxo/libxo/xo_encoder.c',
+            'lib/lib80211/lib80211_ioctl.c',
+            'lib/lib80211/lib80211_regdomain.c',
             'lib/libc/gen/err.c',
             'lib/libc/gen/feature_present.c',
@@ -2221,4 +2225,5 @@
             'sbin/ifconfig/ifgre.c',
             'sbin/ifconfig/ifgroup.c',
+            'sbin/ifconfig/ifieee80211.c',
             'sbin/ifconfig/iflagg.c',
             'sbin/ifconfig/ifmac.c',
@@ -2259,4 +2264,43 @@
         ],
         mm.generator['source'](['-DINET6', '-DINET'])
+    )
+    return mod
+
+#
+# Contrib expat
+#
+def contrib_expat(mm):
+    mod = builder.Module('contrib_expat')
+    cflags = ['-DHAVE_MEMMOVE=1']
+    mod.addRTEMSHeaderFiles(
+        [
+            'include/bsdxml.h',
+        ]
+    )
+    mod.addUserSpaceHeaderFiles(
+        [
+            'contrib/expat/lib/ascii.h',
+            'contrib/expat/lib/asciitab.h',
+            'contrib/expat/lib/expat_external.h',
+            'contrib/expat/lib/expat.h',
+            'contrib/expat/lib/iasciitab.h',
+            'contrib/expat/lib/internal.h',
+            'contrib/expat/lib/latin1tab.h',
+            'contrib/expat/lib/nametab.h',
+            'contrib/expat/lib/utf8tab.h',
+            'contrib/expat/lib/xmlrole.h',
+            'contrib/expat/lib/xmltok.h',
+            'contrib/expat/lib/xmltok_impl.h',
+        ]
+    )
+    mod.addUserSpaceSourceFiles(
+        [
+            'contrib/expat/lib/xmlparse.c',
+            'contrib/expat/lib/xmlrole.c',
+            'contrib/expat/lib/xmltok.c',
+            'contrib/expat/lib/xmltok_impl.c',
+            'contrib/expat/lib/xmltok_ns.c',
+        ],
+        mm.generator['source'](cflags)
     )
     return mod
@@ -2831,4 +2875,5 @@
 
     mm.addModule(user_space(mm))
+    mm.addModule(contrib_expat(mm))
     mm.addModule(contrib_libpcap(mm))
     mm.addModule(usr_sbin_tcpdump(mm))
Index: libbsd_waf.py
===================================================================
--- libbsd_waf.py	(revision 23895395ecd068753fbd8fc383b9ef1dcf766466)
+++ libbsd_waf.py	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -67,4 +67,5 @@
     includes += ["freebsd/sys/net"]
     includes += ["freebsd/include"]
+    includes += ["freebsd/lib"]
     includes += ["freebsd/lib/libc/include"]
     includes += ["freebsd/lib/libc/isc/include"]
@@ -74,4 +75,5 @@
     includes += ["freebsd/lib/libmemstat"]
     includes += ["freebsd/lib/libipsec"]
+    includes += ["freebsd/contrib/expat/lib"]
     includes += ["freebsd/contrib/libpcap"]
     includes += ["freebsd/contrib/libxo"]
@@ -231,7 +233,22 @@
 
     # Objects built with different CFLAGS
-    objs01_source = ['freebsd/bin/hostname/hostname.c',
+    objs01_source = ['freebsd/contrib/expat/lib/xmlparse.c',
+                     'freebsd/contrib/expat/lib/xmlrole.c',
+                     'freebsd/contrib/expat/lib/xmltok.c',
+                     'freebsd/contrib/expat/lib/xmltok_impl.c',
+                     'freebsd/contrib/expat/lib/xmltok_ns.c']
+    bld.objects(target = "objs01",
+                features = "c",
+                cflags = cflags,
+                includes = [] + includes,
+                defines = defines + ['HAVE_MEMMOVE=1'],
+                source = objs01_source)
+    libbsd_use += ["objs01"]
+
+    objs02_source = ['freebsd/bin/hostname/hostname.c',
                      'freebsd/contrib/libxo/libxo/libxo.c',
                      'freebsd/contrib/libxo/libxo/xo_encoder.c',
+                     'freebsd/lib/lib80211/lib80211_ioctl.c',
+                     'freebsd/lib/lib80211/lib80211_regdomain.c',
                      'freebsd/lib/libc/gen/err.c',
                      'freebsd/lib/libc/gen/feature_present.c',
@@ -414,4 +431,5 @@
                      'freebsd/sbin/ifconfig/ifgre.c',
                      'freebsd/sbin/ifconfig/ifgroup.c',
+                     'freebsd/sbin/ifconfig/ifieee80211.c',
                      'freebsd/sbin/ifconfig/iflagg.c',
                      'freebsd/sbin/ifconfig/ifmac.c',
@@ -450,22 +468,22 @@
                      'freebsd/usr.bin/vmstat/vmstat.c',
                      'freebsd/usr.sbin/arp/arp.c']
-    bld.objects(target = "objs01",
+    bld.objects(target = "objs02",
                 features = "c",
                 cflags = cflags,
                 includes = [] + includes,
                 defines = defines + ['INET', 'INET6'],
-                source = objs01_source)
-    libbsd_use += ["objs01"]
-
-    objs02_source = ['rtemsbsd/mghttpd/mongoose.c']
-    bld.objects(target = "objs02",
+                source = objs02_source)
+    libbsd_use += ["objs02"]
+
+    objs03_source = ['rtemsbsd/mghttpd/mongoose.c']
+    bld.objects(target = "objs03",
                 features = "c",
                 cflags = cflags,
                 includes = [] + includes,
                 defines = defines + ['NO_CGI', 'NO_POPEN', 'NO_SSL', 'USE_WEBSOCKET'],
-                source = objs02_source)
-    libbsd_use += ["objs02"]
-
-    objs03_source = ['freebsd/lib/libc/db/btree/bt_close.c',
+                source = objs03_source)
+    libbsd_use += ["objs03"]
+
+    objs04_source = ['freebsd/lib/libc/db/btree/bt_close.c',
                      'freebsd/lib/libc/db/btree/bt_conv.c',
                      'freebsd/lib/libc/db/btree/bt_debug.c',
@@ -491,13 +509,13 @@
                      'freebsd/lib/libc/db/recno/rec_seq.c',
                      'freebsd/lib/libc/db/recno/rec_utils.c']
-    bld.objects(target = "objs03",
+    bld.objects(target = "objs04",
                 features = "c",
                 cflags = cflags,
                 includes = [] + includes,
                 defines = defines + ['INET6', '__DBINTERFACE_PRIVATE'],
-                source = objs03_source)
-    libbsd_use += ["objs03"]
-
-    objs04_source = ['dhcpcd/arp.c',
+                source = objs04_source)
+    libbsd_use += ["objs04"]
+
+    objs05_source = ['dhcpcd/arp.c',
                      'dhcpcd/auth.c',
                      'dhcpcd/bpf.c',
@@ -521,13 +539,13 @@
                      'dhcpcd/net.c',
                      'dhcpcd/platform-bsd.c']
-    bld.objects(target = "objs04",
+    bld.objects(target = "objs05",
                 features = "c",
                 cflags = cflags,
                 includes = [] + includes,
                 defines = defines + ['INET', 'INET6', 'MASTER_ONLY', 'THERE_IS_NO_FORK', '__FreeBSD__'],
-                source = objs04_source)
-    libbsd_use += ["objs04"]
-
-    objs05_source = ['freebsd/contrib/libpcap/bpf_image.c',
+                source = objs05_source)
+    libbsd_use += ["objs05"]
+
+    objs06_source = ['freebsd/contrib/libpcap/bpf_image.c',
                      'freebsd/contrib/libpcap/etherent.c',
                      'freebsd/contrib/libpcap/fad-getad.c',
@@ -542,13 +560,13 @@
                      'freebsd/contrib/libpcap/sf-pcap-ng.c',
                      'freebsd/contrib/libpcap/sf-pcap.c']
-    bld.objects(target = "objs05",
+    bld.objects(target = "objs06",
                 features = "c",
                 cflags = cflags,
                 includes = [] + includes,
                 defines = defines + ['BSD=1', 'HAVE_INTTYPES=1', 'HAVE_LIMITS_H=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SYS_IOCCOM_H=1', 'HAVE_VSNPRINTF=1', 'INET6', '_U_=__attribute__((unused))', '__FreeBSD__=1'],
-                source = objs05_source)
-    libbsd_use += ["objs05"]
-
-    objs06_source = ['freebsd/contrib/tcpdump/addrtoname.c',
+                source = objs06_source)
+    libbsd_use += ["objs06"]
+
+    objs07_source = ['freebsd/contrib/tcpdump/addrtoname.c',
                      'freebsd/contrib/tcpdump/af.c',
                      'freebsd/contrib/tcpdump/bpf_dump.c',
@@ -693,11 +711,11 @@
                      'freebsd/contrib/tcpdump/tcpdump.c',
                      'freebsd/contrib/tcpdump/util.c']
-    bld.objects(target = "objs06",
+    bld.objects(target = "objs07",
                 features = "c",
                 cflags = cflags,
                 includes = ['freebsd/contrib/tcpdump', 'freebsd/usr.sbin/tcpdump/tcpdump'] + includes,
                 defines = defines + ['HAVE_CONFIG_H=1', 'HAVE_NET_PFVAR_H=1', 'INET6', '_U_=__attribute__((unused))', '__FreeBSD__=1'],
-                source = objs06_source)
-    libbsd_use += ["objs06"]
+                source = objs07_source)
+    libbsd_use += ["objs07"]
 
     source = ['freebsd/sys/arm/xilinx/zy7_slcr.c',
Index: rtemsbsd/include/bsdxml.h
===================================================================
--- rtemsbsd/include/bsdxml.h	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
+++ rtemsbsd/include/bsdxml.h	(revision 5c3223f138a3306ca37c2e2278acae65bfbf3b09)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef BSDXML_H
+#define BSDXML_H
+
+/*
+ * Note: On FreeBSD the bsdxml.h is generated out of the expat.h using some
+ * source manipulations. See freebsd-org/lib/libexpat/Makefile for more details.
+ */
+
+#ifdef __VMS
+#error FIXME __VMS should not be defined here.
+#endif /* __VMS */
+
+#include <expat.h>
+
+#endif /* BSDXML_H */
