Re: [PATCH 4/4] sb/pkg-config: Add --cflags-only-I and --cflags-only-other option

2023-04-22 Thread Chris Johns
On 23/4/2023 6:12 am, Joel Sherrill wrote:
> Do these  options need some help/explanation?

https://manpages.ubuntu.com/manpages/bionic/man1/pkg-config.1.html

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[rtems-net-legacy PATCH 3/4] net: Update sysctl to use the latest libbsd linker set

2023-04-22 Thread chrisj
From: Chris Johns 

- Update linker_set.h to the latest from libbsd so the linker
  scripts work.

- Add a sysctl command to check on sysctls

- Add set defines to the networking stack
---
 netsources.py|1 +
 rtems/rtems_bsdnet.h |1 +
 rtems/rtems_glue.c   |7 +-
 rtems/rtems_showsysctl.c | 1340 ++
 sys/linker_set.h |  131 +++-
 testsuites/telnetd02/init.c  |4 +
 testsuites/telnetd02/wscript |1 +
 7 files changed, 1455 insertions(+), 30 deletions(-)
 create mode 100755 rtems/rtems_showsysctl.c

diff --git a/netsources.py b/netsources.py
index 54dbbf1..550c741 100644
--- a/netsources.py
+++ b/netsources.py
@@ -46,6 +46,7 @@ class source:
 'rtems/rtems_showipstat.c',
 'rtems/rtems_showmbuf.c',
 'rtems/rtems_showroute.c',
+'rtems/rtems_showsysctl.c',
 'rtems/rtems_showtcpstat.c',
 'rtems/rtems_showudpstat.c',
 'rtems/rtems_socketpair.c',
diff --git a/rtems/rtems_bsdnet.h b/rtems/rtems_bsdnet.h
index 4607f42..9bd3dee 100644
--- a/rtems/rtems_bsdnet.h
+++ b/rtems/rtems_bsdnet.h
@@ -48,6 +48,7 @@ void rtems_bsdnet_show_ip_stats (void);
 void rtems_bsdnet_show_icmp_stats (void);
 void rtems_bsdnet_show_udp_stats (void);
 void rtems_bsdnet_show_tcp_stats (void);
+int rtems_shell_main_sysctl(int argc, char *argv[]);
 
 /*
  * Network configuration
diff --git a/rtems/rtems_glue.c b/rtems/rtems_glue.c
index ee6c8f5..e05a2c4 100644
--- a/rtems/rtems_glue.c
+++ b/rtems/rtems_glue.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -56,6 +57,11 @@ static size_t  networkDaemonCpusetSize = 0;
 #endif
 static void networkDaemon (void *task_argument);
 
+/*
+ * SYSCTL data
+ */
+RTEMS_BSD_DEFINE_SET(sysctl_set, struct sysctl_oid *);
+
 /*
  * Network timing
  */
@@ -1261,4 +1267,3 @@ m_clalloc(int ncl, int nowait)
}
return 1;
 }
-
diff --git a/rtems/rtems_showsysctl.c b/rtems/rtems_showsysctl.c
new file mode 100755
index 000..cf3d6e2
--- /dev/null
+++ b/rtems/rtems_showsysctl.c
@@ -0,0 +1,1340 @@
+#include 
+
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1993
+ * The Regents of the University of California.  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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 lint
+static const char copyright[] =
+"@(#) Copyright (c) 1993\n\
+   The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)from: sysctl.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+  "$FreeBSD$";
+#endif /* not lint */
+
+#ifdef __rtems__
+#define __need_getopt_newlib
+#include 
+#include 
+#include 
+#define CHAR_BIT 8
+#endif /* __rtems__ */
+#include 
+#include 
+#include 
+#include 
+
+#ifdef __amd64__
+#include 
+#include 
+#endif
+
+#if defined(__amd64__) || defined(__i386__)
+#ifndef __rtems__
+#include 
+#endif /* __rtems__ */
+#endif
+
+#include 
+#include 
+#ifndef __rtems__
+#include 
+#endif /* __rtems__ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifndef __rtems__
+#include 
+#endif /* __rtems__ */
+#include 
+
+#ifndef __rtems__
+static const char *conffile;
+
+static int aflag, bflag, Bflag, dflag, eflag, hflag, iflag;
+static int Nflag, nflag, oflag, qflag, tflag, Tflag, Wflag, xflag;
+#endif /* __rtems__ */
+
+static int oidfmt(int *, int, char *, u_int *);

[rtems-net-legacy PATCH 4/4] net: Update socketpair to the lwip code

2023-04-22 Thread chrisj
From: Chris Johns 

---
 rtems/rtems_socketpair.c | 133 ++-
 1 file changed, 105 insertions(+), 28 deletions(-)

diff --git a/rtems/rtems_socketpair.c b/rtems/rtems_socketpair.c
index 1dcaf6e..5b8bac3 100644
--- a/rtems/rtems_socketpair.c
+++ b/rtems/rtems_socketpair.c
@@ -1,53 +1,130 @@
 #include 
 
 /*
- *  socketpair() for RTEMS
  *
- *  This file exists primarily to document what is required to provide
- *  a functional implementation of socketpair() for RTEMS.
+ * RTEMS Project (https://www.rtems.org/)
  *
- *  The socketpair() service requires that the "local domain" sockets
- *  be functional.  This is denoted by the domain constants AF_LOCAL
- *  and AF_UNIX and the protocol constants PF_LOCAL and PF_UNIX.  The
- *  local domain functionality is implemented in the file kern/uipc_usrreq.c
- *  which was not part of the initial port of the FreeBSD stack to
- *  RTEMS.
+ * Copyright (c) 2021 Vijay Kumar Banerjee .
+ * All rights reserved.
  *
- *  The FreeBSD socketpair implementation appears to be dependent on
- *  file system features which are not available currently in RTEMS.
+ *  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.
  *
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  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.
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ *  OWNER 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.
  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#include 
+#include 
+#include 
+
+#include 
+
 #include 
+#include 
 #include 
 #include 
 
 #include "rtems_syscall.h"
 
-int socketpair (int domain, int type, int protocol, int *rsv)
+static int setup_socketpair(int listener, int *socket_vector)
+{
+  union {
+struct sockaddr addr;
+struct sockaddr_in inaddr;
+  } a;
+  int reuse = 1;
+  socklen_t addrlen = sizeof(a.inaddr);
+
+  memset(, 0, sizeof(a));
+  a.inaddr.sin_family = AF_INET;
+  a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+  a.inaddr.sin_port = 0;
+
+  if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,
+   (char*) , (socklen_t) sizeof(reuse)) == -1) {
+return 1;
+  }
+
+  if  (bind(listener, , sizeof(a.inaddr)) == -1) {
+return 1;
+  }
+
+  memset(, 0, sizeof(a));
+  if  (getsockname(listener, , ) == -1) {
+return 1;
+  }
+
+  a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+  a.inaddr.sin_family = AF_INET;
+
+  if (listen(listener, 1) == -1) {
+return 1;
+  }
+
+  socket_vector[0] = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+  if (socket_vector[0] == -1) {
+return 1;
+  }
+
+  if (connect(socket_vector[0], , sizeof(a.inaddr)) == -1) {
+return 1;
+  }
+
+  socket_vector[1] = accept(listener, NULL, NULL);
+  if (socket_vector[1] == -1) {
+return 1;
+  }
+
+  close(listener);
+  return 0;
+}
+
+/* Fake socketpair() support with a loopback TCP socket */
+int
+socketpair(int domain, int type, int protocol, int *socket_vector)
 {
-  if ( !rsv ) {
-errno = EFAULT;
+  int listener;
+  int saved_errno;
+
+  if (socket_vector == NULL) {
+errno = EINVAL;
 return -1;
   }
+  socket_vector[0] = socket_vector[1] = -1;
+
+  listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+  if (listener == -1)
+return -1;
+
+  if (setup_socketpair(listener, socket_vector) == 0) {
+return 0;
+  }
 
-  /*
-   *  Yes, we do not support socketpair() so this is really paranoid.
-   *  But it ensures that someone calling this routine and ignoring
-   *  the return status will get errors from subsequent socket calls.
-   */
-  rsv[ 0 ] = -1;
-  rsv[ 1 ] = -1;
-  errno = ENOSYS;
+  saved_errno = errno;
+  close(listener);
+  close(socket_vector[0]);
+  

[rtems-net-legacy PATCH 1/4] tests/resolv: Fix test configuration

2023-04-22 Thread chrisj
From: Chris Johns 

---
 config.inc | 1 +
 netlegacy.py   | 3 ++-
 testsuites/include/network-config.h.in | 6 ++
 testsuites/resolve/init.c  | 3 ---
 testsuites/support/net-legacy-config.c | 6 ++
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/config.inc b/config.inc
index 56497b3..7d348b7 100644
--- a/config.inc
+++ b/config.inc
@@ -4,3 +4,4 @@ NET_CFG_SELF_IP = 127.0.0.1
 NET_CFG_NETMASK = 255.0.0.0
 NET_CFG_MAC_ADDR = 00:00:00:00:00:00
 NET_CFG_GATEWAY_IP = 0.0.0.0
+NET_CFG_DOMAINNAME = localnet
diff --git a/netlegacy.py b/netlegacy.py
index c21e26c..bf816f4 100644
--- a/netlegacy.py
+++ b/netlegacy.py
@@ -60,7 +60,8 @@ def net_config_header(bld):
   (bld.env.NET_CONFIG))
 net_tags = [
 'NET_CFG_IFACE', 'NET_CFG_BOOT_PROT', 'NET_CFG_SELF_IP',
-'NET_CFG_NETMASK', 'NET_CFG_MAC_ADDR', 'NET_CFG_GATEWAY_IP'
+'NET_CFG_NETMASK', 'NET_CFG_MAC_ADDR', 'NET_CFG_GATEWAY_IP',
+'NET_CFG_DOMAINNAME', 'NET_CFG_DNS_IP', 'NET_CFG_NTP_IP'
 ]
 try:
 net_cfg_lines = open(bld.env.NET_CONFIG).readlines()
diff --git a/testsuites/include/network-config.h.in 
b/testsuites/include/network-config.h.in
index 756e3b5..e61dcce 100755
--- a/testsuites/include/network-config.h.in
+++ b/testsuites/include/network-config.h.in
@@ -38,4 +38,10 @@
 
 #define NET_CFG_GATEWAY_IP "@NET_CFG_GATEWAY_IP@"
 
+#define NET_CFG_DNS_IP "@NET_CFG_DNS_IP@"
+
+#define NET_CFG_DOMAINNAME "@NET_CFG_DOMAINNAME@"
+
+#define NET_CFG_NTP_IP "@NET_CFG_NTP_IP@"
+
 #endif /* _TEST_NETWORK_CONFIG_H_ */
diff --git a/testsuites/resolve/init.c b/testsuites/resolve/init.c
index beb0e9a..da5adb1 100644
--- a/testsuites/resolve/init.c
+++ b/testsuites/resolve/init.c
@@ -113,9 +113,6 @@ static rtems_task Init(rtems_task_argument argument)
 
   rtems_test_assert(rtems_net_legacy_config(_bsdnet_config));
 
-  rtems_bsdnet_config.domainname = "gemini.edu";
-  rtems_bsdnet_config.name_server[0] = "10.1.5.8";
-
   rv = rtems_bsdnet_initialize_network();
   rtems_test_assert(rv == 0);
 
diff --git a/testsuites/support/net-legacy-config.c 
b/testsuites/support/net-legacy-config.c
index bb512d2..1ae2468 100644
--- a/testsuites/support/net-legacy-config.c
+++ b/testsuites/support/net-legacy-config.c
@@ -25,6 +25,9 @@ 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 char* domainname = NET_CFG_DOMAINNAME;
+static char* dns_ip = NET_CFG_DNS_IP;
+static char* ntp = NET_CFG_NTP_IP;
 static struct rtems_bsdnet_ifconfig ifcfg = {
   RTEMS_BSP_NETWORK_DRIVER_NAME,
   RTEMS_BSP_NETWORK_DRIVER_ATTACH
@@ -38,6 +41,9 @@ bool rtems_net_legacy_config(struct rtems_bsdnet_config* bsd) 
{
   ifcfg.ip_address = ip;
   ifcfg.ip_netmask = netmask;
   bsd->gateway = gateway;
+  bsd->domainname = domainname;
+  bsd->name_server[0] = dns_ip;
+  bsd->ntp_server[0] = ntp;
   if (strcmp(boot_prot, "static") == 0) {
 bsd->bootp = NULL;
   } else if (strcmp(boot_prot, "bootp") == 0) {
-- 
2.37.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[rtems-net-legacy PATCH 2/4] waf: Build libs before tests

2023-04-22 Thread chrisj
From: Chris Johns 

The built libs are in lib and use when linking to get a working
order. Make sure they are built before building an tests.
---
 netlegacy.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/netlegacy.py b/netlegacy.py
index bf816f4..8533f4c 100644
--- a/netlegacy.py
+++ b/netlegacy.py
@@ -216,3 +216,5 @@ def build(bld):
 bld.install_as(
 os.path.join(bld.env.PREFIX, arch_inc_path, 'rtems',
  'rtems-net-legacy.h'), 'include/rtems/rtems-net-legacy.h')
+
+bld.add_group()
-- 
2.37.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Minor RBS fixes

2023-04-22 Thread Joel Sherrill
Other than my comment about making sure any new options are properly
documented, I am ok with this series.

On Sat, Apr 22, 2023 at 12:23 AM  wrote:

> Hi
>
> These patches fix a few minor issues in the RSB.
>
> Chris
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 4/4] sb/pkg-config: Add --cflags-only-I and --cflags-only-other option

2023-04-22 Thread Joel Sherrill
Do these  options need some help/explanation?

--joel

On Sat, Apr 22, 2023 at 12:23 AM  wrote:

> From: Chris Johns 
>
> ---
>  source-builder/pkg-config | 36 
>  1 file changed, 36 insertions(+)
>
> diff --git a/source-builder/pkg-config b/source-builder/pkg-config
> index 10db546..8d0a174 100755
> --- a/source-builder/pkg-config
> +++ b/source-builder/pkg-config
> @@ -86,6 +86,19 @@ def log(s, lf = True):
>  sys.stdout.flush()
>  print(s, end = '', file = out)
>
> +def cflags_filter(cflags, prefixes, include=True):
> +cflags = cflags.split(' ')
> +f_cflags = []
> +for f in cflags:
> +for p in prefixes:
> +if f.startswith(p):
> +f_cflags += [f]
> +if not include:
> +not_f_cflags = [f for f in cflags if f not in f_cflags]
> +f_cflags = not_f_cflags
> +return ' '.join(f_cflags)
> +
> +
>  def run(argv):
>
>  class version_action(argparse.Action):
> @@ -110,6 +123,7 @@ def run(argv):
>help = 'Make error messages short.')
>  opts.add_argument('--silence-errors', dest = 'silence_errors', action
> = 'store_true',
>default = False,
> +
>help = 'Do not print any errors.')
>  opts.add_argument('--errors-to-stdout', dest = 'errors_to_stdout',
> action = 'store_true',
>default = False,
> @@ -118,6 +132,14 @@ def run(argv):
>default = False,
>help = 'This prints pre-processor and compile flags
> required to' \
>   ' compile the package(s)')
> +opts.add_argument('--cflags-only-I', dest = 'cflags_only_i', action =
> 'store_true',
> +  default = False,
> +  help = 'This prints the -I part of "--cflags". That
> is, it defines the header' \
> + 'search path but doesn\'t specify anything
> else.')
> +opts.add_argument('--cflags-only-other', dest = 'cflags_only_other',
> action = 'store_true',
> +  default = False,
> +  help = 'Return all compiler flags, other than the
> include path flags, ' \
> + 'required to compile against the package.')
>  opts.add_argument('--libs', dest = 'libs', action = 'store_true',
>default = False,
>help = 'This option is identical to "--cflags",
> only it prints the' \
> @@ -193,6 +215,20 @@ def run(argv):
>  log('cflags: %s' % (flags['cflags']))
>  else:
>  log('cflags: empty')
> +if args.cflags_only_i:
> +cflags = cflags_filter(flags['cflags'], ['-I',
> '-system'], True)
> +if len(cflags):
> +print(cflags)
> +log('cflags: %s' % (flags['cflags']))
> +else:
> +log('cflags: empty')
> +if args.cflags_only_other:
> +cflags = cflags_filter(flags['cflags'], ['-I',
> '-system'], False)
> +if len(cflags):
> +print(cflags)
> +log('cflags: %s' % (flags['cflags']))
> +else:
> +log('cflags: empty')
>  if args.libs:
>  if len(flags['libs']):
>  print(flags['libs'])
> --
> 2.37.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel