From ead7fdc193a602028df44c333d0a7fc13cb6086e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 16 May 2014 13:35:21 +0200 Subject: doc: Clarify initialization --- libbsd.txt | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/libbsd.txt b/libbsd.txt index b434b47d..be2aed19 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 +#include +#include #include -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 -- cgit v1.2.3