You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "acassis (via GitHub)" <gi...@apache.org> on 2023/07/08 14:11:33 UTC

[GitHub] [nuttx] acassis commented on a diff in pull request #9744: net: add netfilter compatible definitions for iptables

acassis commented on code in PR #9744:
URL: https://github.com/apache/nuttx/pull/9744#discussion_r1257274925


##########
include/nuttx/net/netfilter/ip6_tables.h:
##########
@@ -0,0 +1,256 @@
+/****************************************************************************
+ * include/nuttx/net/netfilter/ip6_tables.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_NET_NETFILTER_IP6_TABLES_H
+#define __INCLUDE_NUTTX_NET_NETFILTER_IP6_TABLES_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <nuttx/net/netfilter/netfilter.h>
+#include <nuttx/net/netfilter/x_tables.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/**
+ * New IP firewall options for [gs]etsockopt at the RAW IP level.
+ * Unlike BSD Linux inherits IP options so you don't have to use

Review Comment:
    ```suggestion
     * Unlike BSD, Linux inherits IP options so you don't have to use



##########
include/nuttx/net/netfilter/ip6_tables.h:
##########
@@ -0,0 +1,256 @@
+/****************************************************************************
+ * include/nuttx/net/netfilter/ip6_tables.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_NET_NETFILTER_IP6_TABLES_H
+#define __INCLUDE_NUTTX_NET_NETFILTER_IP6_TABLES_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <nuttx/net/netfilter/netfilter.h>
+#include <nuttx/net/netfilter/x_tables.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/**
+ * New IP firewall options for [gs]etsockopt at the RAW IP level.
+ * Unlike BSD Linux inherits IP options so you don't have to use
+ * a raw socket for this. Instead we check rights in the calls.
+ *
+ * ATTENTION: check linux/in6.h before adding new number here.
+ */
+
+#define IP6T_BASE_CTL                   64
+
+#define IP6T_SO_SET_REPLACE             (IP6T_BASE_CTL)
+#define IP6T_SO_SET_ADD_COUNTERS        (IP6T_BASE_CTL + 1)
+#define IP6T_SO_SET_MAX                 IP6T_SO_SET_ADD_COUNTERS
+
+#define IP6T_SO_GET_INFO                (IP6T_BASE_CTL)
+#define IP6T_SO_GET_ENTRIES             (IP6T_BASE_CTL + 1)
+#define IP6T_SO_GET_REVISION_MATCH      (IP6T_BASE_CTL + 4)
+#define IP6T_SO_GET_REVISION_TARGET     (IP6T_BASE_CTL + 5)
+#define IP6T_SO_GET_MAX                 IP6T_SO_GET_REVISION_TARGET
+
+/* Values for "inv" field in struct ip6t_ip6. */
+
+#define IP6T_INV_VIA_IN                 0x01    /* Invert the sense of IN IFACE. */
+#define IP6T_INV_VIA_OUT                0x02    /* Invert the sense of OUT IFACE */
+#define IP6T_INV_TOS                    0x04    /* Invert the sense of TOS. */
+#define IP6T_INV_SRCIP                  0x08    /* Invert the sense of SRC IP. */
+#define IP6T_INV_DSTIP                  0x10    /* Invert the sense of DST OP. */
+#define IP6T_INV_FRAG                   0x20    /* Invert the sense of FRAG. */
+#define IP6T_INV_PROTO                  XT_INV_PROTO
+#define IP6T_INV_MASK                   0x7F    /* All possible flag bits mask. */
+
+#define IP6T_STANDARD_TARGET            XT_STANDARD_TARGET
+#define IP6T_ERROR_TARGET               XT_ERROR_TARGET
+
+#define ip6t_entry_target               xt_entry_target
+#define ip6t_entry_match                xt_entry_match
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+struct ip6t_ip6
+{
+  /* Source and destination IP6 addr */
+
+  struct in6_addr src;
+  struct in6_addr dst;
+
+  /* Mask for src and dest IP6 addr */
+
+  struct in6_addr smsk;
+  struct in6_addr dmsk;
+  char iniface[IFNAMSIZ];
+  char outiface[IFNAMSIZ];
+  unsigned char iniface_mask[IFNAMSIZ];
+  unsigned char outiface_mask[IFNAMSIZ];
+
+  /* Upper protocol number
+   * - The allowed value is 0 (any) or protocol number of last parsable
+   *   header, which is 50 (ESP), 59 (No Next Header), 135 (MH), or
+   *   the non IPv6 extension headers.
+   * - The protocol numbers of IPv6 extension headers except of ESP and
+   *   MH do not match any packets.
+   * - You also need to set IP6T_FLAGS_PROTO to "flags" to check protocol.
+   */
+
+  uint16_t proto;
+
+  /* TOS to match iff flags & IP6T_F_TOS */

Review Comment:
   What is this "iff flags" ?



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org