aboutsummaryrefslogtreecommitdiffstats
path: root/src/nSocket/include/nstack_ip_addr.h
diff options
context:
space:
mode:
authorQing Chang <qing.chang1@huawei.com>2018-03-13 01:24:25 +0000
committerGerrit Code Review <gerrit@fd.io>2018-03-13 01:24:25 +0000
commiteb88437358ba4021ea4631c1b05a68a05e51d954 (patch)
tree15482c10907c00fa22fc489ea10b850d23c9a4cf /src/nSocket/include/nstack_ip_addr.h
parent1b031216ba4cd37943900b8759f50fd0e3a8f1cf (diff)
parentc398e6ec613c1f90ffe33608c511208100e7372f (diff)
Merge "Add the nSocket module for dmm"
Diffstat (limited to 'src/nSocket/include/nstack_ip_addr.h')
-rw-r--r--src/nSocket/include/nstack_ip_addr.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nSocket/include/nstack_ip_addr.h b/src/nSocket/include/nstack_ip_addr.h
new file mode 100644
index 0000000..8b15854
--- /dev/null
+++ b/src/nSocket/include/nstack_ip_addr.h
@@ -0,0 +1,36 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed 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 __NSTACK_IP_ADDR_H__
+#define __NSTACK_IP_ADDR_H__
+
+#ifndef ip4_addr1_16
+#include "nstack_types.h"
+
+/* Get one byte from the 4-byte address */
+#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0]) /* ip4_addr1(ipaddr) */
+#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1]) /* ip4_addr2(ipaddr) */
+#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2]) /* ip4_addr3(ipaddr) */
+#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3]) /* ip4_addr4(ipaddr) */
+
+/* These are cast to u16_t, with the intent that they are often arguments
+ * to printf using the U16_F format from cc.h. */
+#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) /*ip4_addr1_16(ipaddr) */
+#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) /*ip4_addr2_16(ipaddr) */
+#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) /*ip4_addr3_16(ipaddr) */
+#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) /*ip4_addr4_16(ipaddr) */
+#endif
+#endif