You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/11/26 09:50:59 UTC
[GitHub] [incubator-nuttx] anchao commented on a change in pull request #4896: inculude/netinet:add net mask define
anchao commented on a change in pull request #4896:
URL: https://github.com/apache/incubator-nuttx/pull/4896#discussion_r757363872
##########
File path: include/netinet/in.h
##########
@@ -132,6 +132,28 @@
#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)
Review comment:
unify the CLASSD convert type (uint32_t -> in_addr_t) or (in_addr_t -> uint32_t)
--
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