[rtems-libbsd commit] doc: Clarify initialization

Sebastian Huber sebh at rtems.org
Fri May 16 11:29:46 UTC 2014


Module:    rtems-libbsd
Branch:    master
Commit:    ead7fdc193a602028df44c333d0a7fc13cb6086e
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=ead7fdc193a602028df44c333d0a7fc13cb6086e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May 16 13:35:21 2014 +0200

doc: Clarify initialization

---

 libbsd.txt |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/libbsd.txt b/libbsd.txt
index b434b47..be2aed1 100644
--- a/libbsd.txt
+++ b/libbsd.txt
@@ -49,7 +49,7 @@ the old network stack.  Make sure no header files of the old network stack are
 installed.
 . Clone the Git repository +git clone git://git.rtems.org/rtems-libbsd.git+.
 . Change into the RTEMS BSD library root directory.
-. Edit the 'config.inc' Makefile configuration file and adjust it to your environment.
+. Edit the `config.inc` Makefile configuration file and adjust it to your environment.
 . Run +make clean+.
 . Run +make install+.
 
@@ -115,8 +115,8 @@ devices (you can run multiple test instances on one virtual network).
 
 === BSD Library Configuration and Build ===
 
-In the BSD library source directory edit the file 'config.inc'.  Continuing on
-the above, the 'config.inc' used to match the above is:
+In the BSD library source directory edit the file `config.inc`.  Continuing on
+the above, the `config.inc` used to match the above is:
 
 -------------------------------------------------------------------------------
 # Mandatory: Select your BSP and installation prefix
@@ -172,18 +172,62 @@ Use the following code to initialize the BSD library:
 
 -------------------------------------------------------------------------------
 #include <assert.h>
+#include <sysexits.h>
 
+#include <machine/rtems-bsd-commands.h>
 #include <rtems/bsd/bsd.h>
 
-void do_init(void)
+static void
+network_ifconfig_lo0(void)
 {
-        rtems_status_code sc;
+	int exit_code;
+	char *lo0[] = {
+		"ifconfig",
+		"lo0",
+		"inet",
+		"127.0.0.1",
+		"netmask",
+		"255.255.255.0",
+		NULL
+	};
+	char *lo0_inet6[] = {
+		"ifconfig",
+		"lo0",
+		"inet6",
+		"::1",
+		"prefixlen",
+		"128",
+		NULL
+	};
+
+	exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(lo0), lo0);
+	assert(exit_code == EX_OK);
+
+	exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(lo0_inet6), lo0_inet6);
+	assert(exit_code == EX_OK);
+}
+
+void
+network_init(void)
+{
+	rtems_status_code sc;
 
-        sc = rtems_bsd_initialize();
-        assert(sc == RTEMS_SUCCESSFUL);
+	sc = rtems_bsd_initialize();
+	assert(sc == RTEMS_SUCCESSFUL);
+
+	network_ifconfig_lo0();
 }
 -------------------------------------------------------------------------------
 
+This performs the basic network stack initialization with a loopback interface.
+Further initialization must be done using the standard BSD network
+configuration commands
+http://www.freebsd.org/cgi/man.cgi?query=ifconfig&apropos=0&sektion=8&manpath=FreeBSD+9.2-RELEASE&arch=default&format=html[IFCONFIG(8)]
+using `rtems_bsd_command_ifconfig()` and
+http://www.freebsd.org/cgi/man.cgi?query=route&apropos=0&sektion=8&manpath=FreeBSD+9.2-RELEASE&arch=default&format=html[ROUTE(8)]
+using `rtems_bsd_command_route()`.  For an example please have a look at
+`testsuite/include/rtems/bsd/test/default-network-init.h`.
+
 == Network Stack Features
 
 http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client




More information about the vc mailing list