You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/27 12:19:14 UTC
[incubator-nuttx] branch master updated: inculude/netinet:add net mask define Signed-off-by: anjiahao
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 4db9513 inculude/netinet:add net mask define Signed-off-by: anjiahao <an...@xiaomi.com>
4db9513 is described below
commit 4db9513658eba2e857f5354b0f0a7cac63b9eb89
Author: anjiahao <an...@xiaomi.com>
AuthorDate: Thu Nov 25 17:30:07 2021 +0800
inculude/netinet:add net mask define
Signed-off-by: anjiahao <an...@xiaomi.com>
---
include/netinet/in.h | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/include/netinet/in.h b/include/netinet/in.h
index 8b18a40..428769e 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -132,9 +132,31 @@
#define MCAST_EXCLUDE 0
#define MCAST_INCLUDE 1
+/* Definitions of the bits in an Internet address integer.
+ * On subnets, host and network parts are found according to
+ * the subnet mask, not these masks.
+ */
+
+#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
+#define IN_CLASSA_NET 0xff000000
+#define IN_CLASSA_NSHIFT 24
+#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
+#define IN_CLASSA_MAX 128
+
+#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
+#define IN_CLASSB_NET 0xffff0000
+#define IN_CLASSB_NSHIFT 16
+#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
+#define IN_CLASSB_MAX 65536
+
+#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
+#define IN_CLASSC_NET 0xffffff00
+#define IN_CLASSC_NSHIFT 8
+#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
+
/* Test if an IPv4 address is a multicast address */
-#define IN_CLASSD(i) (((uint32_t)(i) & 0xf0000000) == 0xe0000000)
+#define IN_CLASSD(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000)
#define IN_MULTICAST(i) IN_CLASSD(i)
/* Special values of in_addr_t */