Changeset 917a78b in rtems-libbsd


Ignore:
Timestamp:
Dec 12, 2013, 8:11:00 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, c1e05b9ea378b2971e3d7704779112b4bc4296da, freebsd-9.3, 4a77611a223ea883fb548679b516d326a020d447
Children:
e6d558f
Parents:
ec37843
git-author:
Sebastian Huber <sebastian.huber@…> (12/12/13 08:11:00)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/30/14 15:23:03)
Message:

DHCPCD(8): Add basic support

Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rec37843 r917a78b  
    11061106        $(CC) $(CPPFLAGS) $(CFLAGS) -DINET6 -c $< -o $@
    11071107
     1108TEST_DHCPCD01 = testsuite/dhcpcd01/dhcpcd01.exe
     1109TEST_DHCPCD01_O_FILES =
     1110TEST_DHCPCD01_D_FILES =
     1111TEST_DHCPCD01_O_FILES += testsuite/dhcpcd01/test_main.o
     1112TEST_DHCPCD01_D_FILES += testsuite/dhcpcd01/test_main.d
     1113$(TEST_DHCPCD01): $(TEST_DHCPCD01_O_FILES) $(LIB)
     1114        $(LINK.c) -Wl,-Map,testsuite/dhcpcd01/dhcpcd01.map $^ -lm -lz -o $@
     1115NET_TESTS += $(TEST_DHCPCD01)
     1116O_FILES += $(TEST_DHCPCD01_O_FILES)
     1117D_FILES += $(TEST_DHCPCD01_D_FILES)
     1118
     1119TEST_DHCPCD02 = testsuite/dhcpcd02/dhcpcd02.exe
     1120TEST_DHCPCD02_O_FILES =
     1121TEST_DHCPCD02_D_FILES =
     1122TEST_DHCPCD02_O_FILES += testsuite/dhcpcd02/test_main.o
     1123TEST_DHCPCD02_D_FILES += testsuite/dhcpcd02/test_main.d
     1124$(TEST_DHCPCD02): $(TEST_DHCPCD02_O_FILES) $(LIB)
     1125        $(LINK.c) -Wl,-Map,testsuite/dhcpcd02/dhcpcd02.map $^ -lm -lz -o $@
     1126NET_TESTS += $(TEST_DHCPCD02)
     1127O_FILES += $(TEST_DHCPCD02_O_FILES)
     1128D_FILES += $(TEST_DHCPCD02_D_FILES)
     1129
    11081130TEST_ARPHOLE = testsuite/arphole/arphole.exe
    11091131TEST_ARPHOLE_O_FILES =
     
    13021324D_FILES += $(TEST_THREAD01_D_FILES)
    13031325RUN_TESTS += $(TEST_THREAD01)
     1326LIB_C_FILES += dhcpcd/arp.c
     1327dhcpcd/arp.o: dhcpcd/arp.c
     1328        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1329LIB_C_FILES += dhcpcd/auth.c
     1330dhcpcd/auth.o: dhcpcd/auth.c
     1331        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1332LIB_C_FILES += dhcpcd/bpf.c
     1333dhcpcd/bpf.o: dhcpcd/bpf.c
     1334        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1335LIB_C_FILES += dhcpcd/common.c
     1336dhcpcd/common.o: dhcpcd/common.c
     1337        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1338LIB_C_FILES += dhcpcd/dhcp6.c
     1339dhcpcd/dhcp6.o: dhcpcd/dhcp6.c
     1340        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1341LIB_C_FILES += dhcpcd/dhcp.c
     1342dhcpcd/dhcp.o: dhcpcd/dhcp.c
     1343        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1344LIB_C_FILES += dhcpcd/dhcpcd.c
     1345dhcpcd/dhcpcd.o: dhcpcd/dhcpcd.c
     1346        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1347LIB_C_FILES += dhcpcd/dhcpcd-embedded.c
     1348dhcpcd/dhcpcd-embedded.o: dhcpcd/dhcpcd-embedded.c
     1349        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1350LIB_C_FILES += dhcpcd/dhcp-common.c
     1351dhcpcd/dhcp-common.o: dhcpcd/dhcp-common.c
     1352        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1353LIB_C_FILES += dhcpcd/duid.c
     1354dhcpcd/duid.o: dhcpcd/duid.c
     1355        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1356LIB_C_FILES += dhcpcd/eloop.c
     1357dhcpcd/eloop.o: dhcpcd/eloop.c
     1358        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1359LIB_C_FILES += dhcpcd/if-bsd.c
     1360dhcpcd/if-bsd.o: dhcpcd/if-bsd.c
     1361        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1362LIB_C_FILES += dhcpcd/if-options.c
     1363dhcpcd/if-options.o: dhcpcd/if-options.c
     1364        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1365LIB_C_FILES += dhcpcd/if-pref.c
     1366dhcpcd/if-pref.o: dhcpcd/if-pref.c
     1367        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1368LIB_C_FILES += dhcpcd/ipv4.c
     1369dhcpcd/ipv4.o: dhcpcd/ipv4.c
     1370        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1371LIB_C_FILES += dhcpcd/ipv4ll.c
     1372dhcpcd/ipv4ll.o: dhcpcd/ipv4ll.c
     1373        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1374LIB_C_FILES += dhcpcd/ipv6.c
     1375dhcpcd/ipv6.o: dhcpcd/ipv6.c
     1376        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1377LIB_C_FILES += dhcpcd/ipv6nd.c
     1378dhcpcd/ipv6nd.o: dhcpcd/ipv6nd.c
     1379        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1380LIB_C_FILES += dhcpcd/net.c
     1381dhcpcd/net.o: dhcpcd/net.c
     1382        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1383LIB_C_FILES += dhcpcd/platform-bsd.c
     1384dhcpcd/platform-bsd.o: dhcpcd/platform-bsd.c
     1385        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1386LIB_C_FILES += dhcpcd/compat/pselect.c
     1387dhcpcd/compat/pselect.o: dhcpcd/compat/pselect.c
     1388        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1389LIB_C_FILES += dhcpcd/crypt/hmac_md5.c
     1390dhcpcd/crypt/hmac_md5.o: dhcpcd/crypt/hmac_md5.c
     1391        $(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
     1392LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-shell-dhcpcd.c
    13041393
    13051394ifeq ($(NEED_DUMMY_PIC_IRQ),yes)
  • freebsd-to-rtems.py

    rec37843 r917a78b  
    24302430
    24312431tests = Module('tests')
     2432tests.addTest('dhcpcd01', ['test_main'], runTest = False, netTest = True)
     2433tests.addTest('dhcpcd02', ['test_main'], runTest = False, netTest = True)
    24322434tests.addTest('arphole', ['test_main'], runTest = False, netTest = True)
    24332435tests.addTest('unix01', ['test_main'])
     
    24472449tests.addTest('thread01', ['test_main'])
    24482450
     2451dhcpcd = Module('dhcpcd')
     2452dhcpcd.addSourceFiles(
     2453        [
     2454                'dhcpcd/arp.c',
     2455                'dhcpcd/auth.c',
     2456                'dhcpcd/bpf.c',
     2457                'dhcpcd/common.c',
     2458                'dhcpcd/dhcp6.c',
     2459                'dhcpcd/dhcp.c',
     2460                'dhcpcd/dhcpcd.c',
     2461                'dhcpcd/dhcpcd-embedded.c',
     2462                'dhcpcd/dhcp-common.c',
     2463                'dhcpcd/duid.c',
     2464                'dhcpcd/eloop.c',
     2465                'dhcpcd/if-bsd.c',
     2466                'dhcpcd/if-options.c',
     2467                'dhcpcd/if-pref.c',
     2468                'dhcpcd/ipv4.c',
     2469                'dhcpcd/ipv4ll.c',
     2470                'dhcpcd/ipv6.c',
     2471                'dhcpcd/ipv6nd.c',
     2472                'dhcpcd/net.c',
     2473                'dhcpcd/platform-bsd.c',
     2474                'dhcpcd/compat/pselect.c',
     2475                'dhcpcd/crypt/hmac_md5.c',
     2476        ],
     2477        '-D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6'
     2478)
     2479dhcpcd.addRTEMSSourceFiles(
     2480        [
     2481                'rtems/rtems-bsd-shell-dhcpcd.c',
     2482        ]
     2483)
     2484
    24492485# Register all the Module instances with the Module Manager
    24502486mm.addModule(rtems)
     
    24892525
    24902526mm.addModule(tests)
     2527mm.addModule(dhcpcd)
    24912528
    24922529# XXX TODO Check that no file is also listed in empty
  • rtemsbsd/include/machine/rtems-bsd-commands.h

    rec37843 r917a78b  
    5757int rtems_bsd_command_route(int argc, char **argv);
    5858
     59int rtems_bsd_command_dhcpcd(int argc, char **argv);
     60
    5961__END_DECLS
    6062
  • rtemsbsd/include/rtems/netcmds-config.h

    rec37843 r917a78b  
    2929  extern rtems_shell_cmd_t rtems_shell_ROUTE_Command;
    3030  extern rtems_shell_cmd_t rtems_shell_NETSTAT_Command;
     31  extern rtems_shell_cmd_t rtems_shell_DHCPCD_Command;
    3132// #endif
    3233
  • testsuite/include/rtems/bsd/test/default-network-init.h

    rec37843 r917a78b  
    3030 */
    3131
     32#include <sys/stat.h>
     33
    3234#include <net/if.h>
    3335
    3436#include <assert.h>
     37#include <fcntl.h>
    3538#include <ifaddrs.h>
    3639#include <stdio.h>
     
    4346#include <rtems/stackchk.h>
    4447#include <rtems/bsd/bsd.h>
     48
     49#if defined(DEFAULT_NETWORK_DHCPCD_ENABLE) && \
     50    !defined(DEFAULT_NETWORK_NO_STATIC_IFCONFIG)
     51#define DEFAULT_NETWORK_NO_STATIC_IFCONFIG
     52#endif
    4553
    4654#ifndef DEFAULT_NETWORK_NO_STATIC_IFCONFIG
     
    144152}
    145153
     154#ifdef DEFAULT_NETWORK_DHCPCD_ENABLE
     155static void
     156default_network_dhcpcd_task(rtems_task_argument arg)
     157{
     158        int exit_code;
     159        char *dhcpcd[] = {
     160                "dhcpcd",
     161                NULL
     162        };
     163
     164#ifdef DEFAULT_NETWORK_DHCPCD_NO_DHCP_DISCOVERY
     165        static const char cfg[] = "nodhcp\nnodhcp6\n";
     166        int fd;
     167        int rv;
     168        ssize_t n;
     169
     170        fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY,
     171            S_IRWXU | S_IRWXG | S_IRWXO);
     172        assert(fd >= 0);
     173
     174        n = write(fd, cfg, sizeof(cfg));
     175        assert(n == (ssize_t) sizeof(cfg));
     176
     177        rv = close(fd);
     178        assert(rv == 0);
     179#endif
     180
     181        exit_code = rtems_bsd_command_dhcpcd(RTEMS_BSD_ARGC(dhcpcd), dhcpcd);
     182        assert(exit_code == EXIT_SUCCESS);
     183}
     184#endif
     185
     186static void
     187default_network_dhcpcd(void)
     188{
     189#ifdef DEFAULT_NETWORK_DHCPCD_ENABLE
     190        rtems_status_code sc;
     191        rtems_id id;
     192
     193        sc = rtems_task_create(
     194                rtems_build_name('D', 'H', 'C', 'P'),
     195                RTEMS_MAXIMUM_PRIORITY - 1,
     196                RTEMS_MINIMUM_STACK_SIZE,
     197                RTEMS_DEFAULT_MODES,
     198                RTEMS_FLOATING_POINT,
     199                &id
     200        );
     201        assert(sc == RTEMS_SUCCESSFUL);
     202
     203        sc = rtems_task_start(id, default_network_dhcpcd_task, 0);
     204        assert(sc == RTEMS_SUCCESSFUL);
     205#endif
     206}
     207
    146208static void
    147209default_network_on_exit(int exit_code, void *arg)
     
    200262        default_network_ifconfig_hwif0(ifname);
    201263        default_network_route_hwif0(ifname);
     264        default_network_dhcpcd();
    202265
    203266        test_main();
Note: See TracChangeset for help on using the changeset viewer.