daniel-p-carvalho commented on code in PR #3876:
URL: https://github.com/apache/nuttx-apps/pull/3876#discussion_r4308829605


##########
netutils/wifibridge/Kconfig:
##########
@@ -0,0 +1,32 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config NETUTILS_WIFIBRIDGE
+       bool "Wi-Fi SoftAP to Ethernet bridge"
+       default n
+       depends on NET_IPv4 && NET_BRIDGE && WIRELESS_WAPI
+       select NETUTILS_NETLIB

Review Comment:
   `select` follows what the other netutils users of netlib do 
(`netutils/iperf`, `discover`, `netinit`). `NETUTILS_NETLIB` only depends on 
`NET`, which `NET_IPv4` and `NET_BRIDGE` already imply here, so selecting it is 
safe and a defconfig does not need to enable it by hand.



##########
netutils/wifibridge/wifibridge.c:
##########
@@ -0,0 +1,378 @@
+/****************************************************************************
+ * apps/netutils/wifibridge/wifibridge.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <nuttx/net/ioctl.h>
+
+#include "netutils/netlib.h"
+#include "netutils/wifibridge.h"
+#include "wireless/wapi.h"
+
+#ifdef CONFIG_NETUTILS_WIFIBRIDGE_DHCPD
+#  include "netutils/dhcpd.h"
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: wifibridge_ifcmd
+ *
+ * Description:
+ *   Add or remove a bridge port.
+ *
+ ****************************************************************************/
+
+static int wifibridge_ifcmd(int sock, int cmd, FAR const char *bridge,
+                            FAR const char *ifname)
+{
+  struct ifreq req;
+
+  memset(&req, 0, sizeof(req));
+  strlcpy(req.ifr_name, bridge, IFNAMSIZ);
+  req.ifr_ifindex = if_nametoindex(ifname);
+  if (req.ifr_ifindex == 0)
+    {
+      return -ENODEV;

Review Comment:
   Done. `if_nametoindex()` sets errno, so the error is now propagated instead 
of a fixed `-ENODEV`. This code now lives in netlib (see the comment below), 
which returns -1 with errno, and `wifibridge` converts it to `-errno`.



##########
system/wifibridge/README.md:
##########
@@ -0,0 +1,44 @@
+# wifibridge
+
+Wi-Fi SoftAP to Ethernet bridge for NuttX.  It turns a Wi-Fi interface

Review Comment:
   Removed the README from this PR. I will send the documentation page to 
apache/nuttx as a separate PR under 
`Documentation/applications/system/wifibridge`.



##########
netutils/wifibridge/wifibridge.c:
##########
@@ -0,0 +1,378 @@
+/****************************************************************************
+ * apps/netutils/wifibridge/wifibridge.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <nuttx/net/ioctl.h>
+
+#include "netutils/netlib.h"
+#include "netutils/wifibridge.h"
+#include "wireless/wapi.h"
+
+#ifdef CONFIG_NETUTILS_WIFIBRIDGE_DHCPD
+#  include "netutils/dhcpd.h"
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: wifibridge_ifcmd
+ *
+ * Description:
+ *   Add or remove a bridge port.
+ *
+ ****************************************************************************/
+
+static int wifibridge_ifcmd(int sock, int cmd, FAR const char *bridge,

Review Comment:
   Yes, done. Added `netlib_add_bridge()`, `netlib_del_bridge()`, 
`netlib_bridge_addif()` and `netlib_bridge_delif()` in 
`netutils/netlib/netlib_bridge.c` (built with `CONFIG_NET_BRIDGE`). 
`wifibridge` now uses them instead of its private ioctl wrapper, and 
`system/brctl` is switched to them in a separate commit, which removes the 
duplicated `brctl_ifcmd()`. The PR now has three commits: netlib, wifibridge, 
brctl.
   
   Re-tested on an EV49N51A: five `wifibridge start`/`stop` cycles with no 
memory growth, `brctl addbr`/`addif`/`delif`/`delbr` including the error cases, 
and a Wi-Fi station getting DHCP from the board and pinging a host on the 
Ethernet port through the bridge.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to