summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-04-03 14:05:43 +1000
committerChris Johns <chrisj@rtems.org>2023-04-13 12:14:33 +1000
commitd633cc5b0301f81cc2748cba0d6fb32e19853c27 (patch)
tree3ea90bb38128cb809be84e5aa9ff5677e1cfd02c /testsuites
parentleon3: Replace ambapp_plb with ambapp_plb() (diff)
downloadrtems-net-legacy-d633cc5b0301f81cc2748cba0d6fb32e19853c27.tar.bz2
waf: Add test network configuration support
- Add a support call to use the configuration
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/include/net-legacy-config.h18
-rwxr-xr-xtestsuites/include/network-config.h.in41
-rw-r--r--testsuites/support/net-legacy-config.c53
3 files changed, 112 insertions, 0 deletions
diff --git a/testsuites/include/net-legacy-config.h b/testsuites/include/net-legacy-config.h
new file mode 100644
index 0000000..e4e5579
--- /dev/null
+++ b/testsuites/include/net-legacy-config.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2023 Chris Johns. All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _NET_LEGACY_CONFIG_H
+#define _NET_LEGACY_CONFIG_H
+
+#include <stdbool.h>
+
+struct rtems_bsdnet_config;
+
+bool rtems_net_legacy_config(struct rtems_bsdnet_config* bsd);
+
+#endif
diff --git a/testsuites/include/network-config.h.in b/testsuites/include/network-config.h.in
new file mode 100755
index 0000000..756e3b5
--- /dev/null
+++ b/testsuites/include/network-config.h.in
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2023 Chris Johns. All rights reserved.
+ *
+ * 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 _TEST_NETWORK_CONFIG_H_
+#define _TEST_NETWORK_CONFIG_H_
+
+#define NET_CFG_IFACE "@NET_CFG_IFACE@"
+
+#define NET_CFG_BOOT_PROT "@NET_CFG_BOOT_PROT@"
+
+#define NET_CFG_SELF_IP "@NET_CFG_SELF_IP@"
+
+#define NET_CFG_NETMASK "@NET_CFG_NETMASK@"
+
+#define NET_CFG_MAC_ADDR "@NET_CFG_MAC_ADDR@"
+
+#define NET_CFG_GATEWAY_IP "@NET_CFG_GATEWAY_IP@"
+
+#endif /* _TEST_NETWORK_CONFIG_H_ */
diff --git a/testsuites/support/net-legacy-config.c b/testsuites/support/net-legacy-config.c
new file mode 100644
index 0000000..bb512d2
--- /dev/null
+++ b/testsuites/support/net-legacy-config.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2023 Chris Johns. All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include <bsp.h>
+#include <rtems.h>
+#include <rtems/dhcp.h>
+#include <rtems/rtems_bsdnet.h>
+
+#include <net-legacy-config.h>
+#include <network-config.h>
+
+static char* iface = NET_CFG_IFACE;
+static char* boot_prot = NET_CFG_BOOT_PROT;
+static char* ip = NET_CFG_SELF_IP;
+static char* netmask = NET_CFG_NETMASK;
+static char* gateway = NET_CFG_GATEWAY_IP;
+static struct rtems_bsdnet_ifconfig ifcfg = {
+ RTEMS_BSP_NETWORK_DRIVER_NAME,
+ RTEMS_BSP_NETWORK_DRIVER_ATTACH
+};
+
+bool rtems_net_legacy_config(struct rtems_bsdnet_config* bsd) {
+ if (bsd->ifconfig == NULL) {
+ bsd->ifconfig = &ifcfg;
+ }
+ ifcfg.name = iface;
+ ifcfg.ip_address = ip;
+ ifcfg.ip_netmask = netmask;
+ bsd->gateway = gateway;
+ if (strcmp(boot_prot, "static") == 0) {
+ bsd->bootp = NULL;
+ } else if (strcmp(boot_prot, "bootp") == 0) {
+ bsd->bootp = rtems_bsdnet_do_bootp;
+ } else if (strcmp(boot_prot, "dhcp") == 0) {
+ bsd->bootp = rtems_bsdnet_do_dhcp;
+ } else {
+ printf("%s: %d: invalid network configuration: %s\n",
+ __FILE__, __LINE__, boot_prot);
+ return false;
+ }
+ return true;
+}