Index: freebsd-userspace/Makefile
===================================================================
--- freebsd-userspace/Makefile	(revision 4a3e48913b351cdc3144d61aa17233b11ea44fe4)
+++ freebsd-userspace/Makefile	(revision bd6dd6e2337dc57406d5d40acb43fb09e9a12ff9)
@@ -8,4 +8,5 @@
 #CFLAGS += -ffreestanding 
 CFLAGS += -I include 
+CFLAGS += -I rtems/include 
 CFLAGS += -I lib/libc/include 
 CFLAGS += -I sys
@@ -109,4 +110,6 @@
 	cd include; for i in `find . -name '*.h'` ; do \
 	  install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done
+	cd rtems/include; for i in `find . -name '*.h'` ; do \
+	  install -c -m 644 -D "$$i" "$(INSTALL_BASE)/include/$$i" ; done
 	install -c -m 644 $(LIB) $(INSTALL_BASE)
 
Index: freebsd-userspace/rtems/rtems-net-setup.c
===================================================================
--- freebsd-userspace/rtems/rtems-net-setup.c	(revision 4a3e48913b351cdc3144d61aa17233b11ea44fe4)
+++ freebsd-userspace/rtems/rtems-net-setup.c	(revision bd6dd6e2337dc57406d5d40acb43fb09e9a12ff9)
@@ -10,4 +10,6 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <net/route.h>
+#include <rtems/rtems_bsdnet.h>
 
 static const struct sockaddr_in address_template = {
@@ -19,4 +21,28 @@
 };
 
+/*
+ * Manipulate routing tables
+ */
+int rtems_bsdnet_rtrequest(
+  int              req,
+  struct sockaddr *dst,
+  struct sockaddr *gateway,
+  struct sockaddr *netmask,
+  int              flags,
+  struct rtentry **net_nrt
+)
+{
+  int error;
+
+  // rtems_bsdnet_semaphore_obtain();
+  error = rtrequest(req, dst, gateway, netmask, flags, net_nrt);
+  // rtems_bsdnet_semaphore_release();
+  if (error) {
+    errno = error;
+    return -1;
+  }
+  return 0;
+}
+
 static void
 rtems_bsdnet_initialize_sockaddr_in(struct sockaddr_in *addr)
@@ -36,15 +62,15 @@
    * Configure interfaces
    */
-  s = socket (AF_INET, SOCK_DGRAM, 0);
+  s = socket(AF_INET, SOCK_DGRAM, 0);
   if (s < 0)
     return -1;
 
-  strncpy (ifreq.ifr_name, ifname, IFNAMSIZ);
+  strncpy(ifreq.ifr_name, ifname, IFNAMSIZ);
 
   switch (cmd) {
     case SIOCSIFADDR:
     case SIOCSIFNETMASK:
-      memcpy (&ifreq.ifr_addr, param, sizeof (struct sockaddr));
-      r = ioctl (s, cmd, &ifreq);
+      memcpy(&ifreq.ifr_addr, param, sizeof(struct sockaddr));
+      r = ioctl(s, cmd, &ifreq);
       break;
 
@@ -53,12 +79,12 @@
     case OSIOCGIFNETMASK:
     case SIOCGIFNETMASK:
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
-        break;
-      memcpy (param, &ifreq.ifr_addr, sizeof (struct sockaddr));
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
+        break;
+      memcpy(param, &ifreq.ifr_addr, sizeof(struct sockaddr));
       break;
 
     case SIOCGIFFLAGS:
     case SIOCSIFFLAGS:
-      if ((r = ioctl (s, SIOCGIFFLAGS, &ifreq)) < 0)
+      if ((r = ioctl(s, SIOCGIFFLAGS, &ifreq)) < 0)
         break;
       if (cmd == SIOCGIFFLAGS) {
@@ -71,38 +97,38 @@
           ifreq.ifr_flags &= ~(IFF_UP);
       }
-      r = ioctl (s, SIOCSIFFLAGS, &ifreq);
+      r = ioctl(s, SIOCSIFFLAGS, &ifreq);
       break;
 
     case SIOCSIFDSTADDR:
-      memcpy (&ifreq.ifr_dstaddr, param, sizeof (struct sockaddr));
-      r = ioctl (s, cmd, &ifreq);
+      memcpy(&ifreq.ifr_dstaddr, param, sizeof(struct sockaddr));
+      r = ioctl(s, cmd, &ifreq);
       break;
 
     case OSIOCGIFDSTADDR:
     case SIOCGIFDSTADDR:
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
-        break;
-      memcpy (param, &ifreq.ifr_dstaddr, sizeof (struct sockaddr));
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
+        break;
+      memcpy(param, &ifreq.ifr_dstaddr, sizeof(struct sockaddr));
       break;
 
     case SIOCSIFBRDADDR:
-      memcpy (&ifreq.ifr_broadaddr, param, sizeof (struct sockaddr));
-      r = ioctl (s, cmd, &ifreq);
+      memcpy(&ifreq.ifr_broadaddr, param, sizeof(struct sockaddr));
+      r = ioctl(s, cmd, &ifreq);
       break;
 
     case OSIOCGIFBRDADDR:
     case SIOCGIFBRDADDR:
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
-        break;
-      memcpy (param, &ifreq.ifr_broadaddr, sizeof (struct sockaddr));
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
+        break;
+      memcpy(param, &ifreq.ifr_broadaddr, sizeof(struct sockaddr));
       break;
 
     case SIOCSIFMETRIC:
       ifreq.ifr_metric = *((int*) param);
-      r = ioctl (s, cmd, &ifreq);
+      r = ioctl(s, cmd, &ifreq);
       break;
 
     case SIOCGIFMETRIC:
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
         break;
       *((int*) param) = ifreq.ifr_metric;
@@ -111,9 +137,9 @@
     case SIOCSIFMTU:
       ifreq.ifr_mtu = *((int*) param);
-      r = ioctl (s, cmd, &ifreq);
+      r = ioctl(s, cmd, &ifreq);
       break;
 
     case SIOCGIFMTU:
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
         break;
       *((int*) param) = ifreq.ifr_mtu;
@@ -122,9 +148,9 @@
     case SIOCSIFPHYS:
       ifreq.ifr_phys = *((int*) param);
-      r = ioctl (s, cmd, &ifreq);
+      r = ioctl(s, cmd, &ifreq);
       break;
 
     case SIOCGIFPHYS:
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
         break;
       *((int*) param) = ifreq.ifr_phys;
@@ -133,5 +159,5 @@
     case SIOCSIFMEDIA:
       ifreq.ifr_media = *((int*) param);
-      r = ioctl (s, cmd, &ifreq);
+      r = ioctl(s, cmd, &ifreq);
       break;
 
@@ -141,5 +167,5 @@
        */
       ifreq.ifr_media = *((int*) param);
-      if ((r = ioctl (s, cmd, &ifreq)) < 0)
+      if ((r = ioctl(s, cmd, &ifreq)) < 0)
         break;
       *((int*) param) = ifreq.ifr_media;
@@ -157,5 +183,5 @@
   }
 
-  close (s);
+  close(s);
   return r;
 }
@@ -177,6 +203,6 @@
    */
   flags = IFF_UP;
-  if (rtems_bsdnet_ifconfig (name, SIOCSIFFLAGS, &flags) < 0) {
-    printf ("Can't bring %s up: %s\n", name, strerror (errno));
+  if (rtems_bsdnet_ifconfig(name, SIOCSIFFLAGS, &flags) < 0) {
+    printf("Can't bring %s up: %s\n", name, strerror(errno));
     return false;
   }
@@ -186,7 +212,7 @@
    */
   rtems_bsdnet_initialize_sockaddr_in(&netmask);
-  netmask.sin_addr.s_addr = inet_addr (ip_netmask);
-  if (rtems_bsdnet_ifconfig (name, SIOCSIFNETMASK, &netmask) < 0) {
-    printf ("Can't set %s netmask: %s\n", name, strerror (errno));
+  netmask.sin_addr.s_addr = inet_addr(ip_netmask);
+  if (rtems_bsdnet_ifconfig(name, SIOCSIFNETMASK, &netmask) < 0) {
+    printf("Can't set %s netmask: %s\n", name, strerror(errno));
     return false;
   }
@@ -196,7 +222,7 @@
    */
   rtems_bsdnet_initialize_sockaddr_in(&address);
-  address.sin_addr.s_addr = inet_addr (ip_address);
-  if (rtems_bsdnet_ifconfig (name, SIOCSIFADDR, &address) < 0) {
-    printf ("Can't set %s address: %s\n", name, strerror (errno));
+  address.sin_addr.s_addr = inet_addr(ip_address);
+  if (rtems_bsdnet_ifconfig(name, SIOCSIFADDR, &address) < 0) {
+    printf("Can't set %s address: %s\n", name, strerror(errno));
     return false;
   }
@@ -206,6 +232,6 @@
    * broadcast flag set.
    */
-  if (rtems_bsdnet_ifconfig (name, SIOCGIFFLAGS, &flags) < 0) {
-    printf ("Can't read %s flags: %s\n", name, strerror (errno));
+  if (rtems_bsdnet_ifconfig(name, SIOCGIFFLAGS, &flags) < 0) {
+    printf("Can't read %s flags: %s\n", name, strerror(errno));
     return false;
   }
@@ -217,5 +243,5 @@
     broadcast.sin_addr.s_addr =
         address.sin_addr.s_addr | ~netmask.sin_addr.s_addr;
-    if (rtems_bsdnet_ifconfig (name, SIOCSIFBRDADDR, &broadcast) < 0) {
+    if (rtems_bsdnet_ifconfig(name, SIOCSIFBRDADDR, &broadcast) < 0) {
       struct in_addr  in_addr;
       char      buf[20];
@@ -223,6 +249,6 @@
       if (!inet_ntop(AF_INET, &in_addr, buf, sizeof(buf)))
           strcpy(buf,"?.?.?.?");
-      printf ("Can't set %s broadcast address %s: %s\n",
-        name, buf, strerror (errno));
+      printf("Can't set %s broadcast address %s: %s\n",
+        name, buf, strerror(errno));
     }
   }
@@ -235,5 +261,6 @@
 void rtems_initialize_interfaces(void)
 {
-  bool any_if_configured;
+  bool                          any_if_configured;
+  struct rtems_bsdnet_ifconfig *ifp;
 
   any_if_configured = false;
@@ -245,5 +272,4 @@
   );
 
-#if 0
 
   for (ifp = rtems_bsdnet_config.ifconfig ; ifp ; ifp = ifp->next) {
@@ -257,5 +283,29 @@
     );
   }
-#endif
-
-}
+  /*
+   * Set default route
+   */
+  if (rtems_bsdnet_config.gateway && any_if_configured) {
+    struct sockaddr_in address;
+    struct sockaddr_in netmask;
+    struct sockaddr_in gateway;
+
+    rtems_bsdnet_initialize_sockaddr_in(&address);
+    rtems_bsdnet_initialize_sockaddr_in(&netmask);
+    rtems_bsdnet_initialize_sockaddr_in(&gateway);
+
+    gateway.sin_addr.s_addr = inet_addr (rtems_bsdnet_config.gateway);
+
+    if (rtems_bsdnet_rtrequest (
+        RTM_ADD,
+        (struct sockaddr *)&address,
+        (struct sockaddr *)&gateway,
+        (struct sockaddr *)&netmask,
+        (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL) < 0) {
+      printf ("Can't set default route: %s\n", strerror (errno));
+      return -1;
+    }
+  }
+  return 0;
+
+}
Index: rtemsbsd/freebsd/machine/rtems-bsd-config.h
===================================================================
--- rtemsbsd/freebsd/machine/rtems-bsd-config.h	(revision 4a3e48913b351cdc3144d61aa17233b11ea44fe4)
+++ rtemsbsd/freebsd/machine/rtems-bsd-config.h	(revision bd6dd6e2337dc57406d5d40acb43fb09e9a12ff9)
@@ -89,5 +89,5 @@
 #define IPSEC 1
 #define INET  1
-#define INET6 1
+// #define INET6 1
 #define TCP_SIGNATURE 1
 
