aboutsummaryrefslogtreecommitdiffstats
path: root/net/6lowpan
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-10-20 02:31:22 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-10-20 18:49:25 -0400
commit6350047eb8dbd3dcf0ff29a637ece96db8f59d8d (patch)
treef6cd61e1ddf0b7602e1d73c0e929dbf5958a7cbd /net/6lowpan
parent607b0bd3f2b9ac118f2c67dbd18c55f1f5aefeb1 (diff)
6lowpan: move IPHC functionality defines
This patch removes the IPHC related defines for doing bit manipulation from global 6lowpan header to the iphc file which should the only one implementation which use these defines. Also move next header compression defines to their nhc implementation. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/6lowpan')
-rw-r--r--net/6lowpan/iphc.c88
-rw-r--r--net/6lowpan/nhc_udp.c22
2 files changed, 109 insertions, 1 deletions
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index afe36aab04ca..fcf583fe6791 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -58,6 +58,94 @@
58 58
59#include "nhc.h" 59#include "nhc.h"
60 60
61/* Values of fields within the IPHC encoding first byte
62 * (C stands for compressed and I for inline)
63 */
64#define LOWPAN_IPHC_TF 0x18
65
66#define LOWPAN_IPHC_FL_C 0x10
67#define LOWPAN_IPHC_TC_C 0x08
68#define LOWPAN_IPHC_NH_C 0x04
69#define LOWPAN_IPHC_TTL_1 0x01
70#define LOWPAN_IPHC_TTL_64 0x02
71#define LOWPAN_IPHC_TTL_255 0x03
72#define LOWPAN_IPHC_TTL_I 0x00
73
74/* Values of fields within the IPHC encoding second byte */
75#define LOWPAN_IPHC_CID 0x80
76
77#define LOWPAN_IPHC_ADDR_00 0x00
78#define LOWPAN_IPHC_ADDR_01 0x01
79#define LOWPAN_IPHC_ADDR_02 0x02
80#define LOWPAN_IPHC_ADDR_03 0x03
81
82#define LOWPAN_IPHC_SAC 0x40
83#define LOWPAN_IPHC_SAM 0x30
84
85#define LOWPAN_IPHC_SAM_BIT 4
86
87#define LOWPAN_IPHC_M 0x08
88#define LOWPAN_IPHC_DAC 0x04
89#define LOWPAN_IPHC_DAM_00 0x00
90#define LOWPAN_IPHC_DAM_01 0x01
91#define LOWPAN_IPHC_DAM_10 0x02
92#define LOWPAN_IPHC_DAM_11 0x03
93
94#define LOWPAN_IPHC_DAM_BIT 0
95
96/* ipv6 address based on mac
97 * second bit-flip (Universe/Local) is done according RFC2464
98 */
99#define is_addr_mac_addr_based(a, m) \
100 ((((a)->s6_addr[8]) == (((m)[0]) ^ 0x02)) && \
101 (((a)->s6_addr[9]) == (m)[1]) && \
102 (((a)->s6_addr[10]) == (m)[2]) && \
103 (((a)->s6_addr[11]) == (m)[3]) && \
104 (((a)->s6_addr[12]) == (m)[4]) && \
105 (((a)->s6_addr[13]) == (m)[5]) && \
106 (((a)->s6_addr[14]) == (m)[6]) && \
107 (((a)->s6_addr[15]) == (m)[7]))
108
109/* check whether we can compress the IID to 16 bits,
110 * it's possible for unicast addresses with first 49 bits are zero only.
111 */
112#define lowpan_is_iid_16_bit_compressable(a) \
113 ((((a)->s6_addr16[4]) == 0) && \
114 (((a)->s6_addr[10]) == 0) && \
115 (((a)->s6_addr[11]) == 0xff) && \
116 (((a)->s6_addr[12]) == 0xfe) && \
117 (((a)->s6_addr[13]) == 0))
118
119/* check whether the 112-bit gid of the multicast address is mappable to: */
120
121/* 48 bits, FFXX::00XX:XXXX:XXXX */
122#define lowpan_is_mcast_addr_compressable48(a) \
123 ((((a)->s6_addr16[1]) == 0) && \
124 (((a)->s6_addr16[2]) == 0) && \
125 (((a)->s6_addr16[3]) == 0) && \
126 (((a)->s6_addr16[4]) == 0) && \
127 (((a)->s6_addr[10]) == 0))
128
129/* 32 bits, FFXX::00XX:XXXX */
130#define lowpan_is_mcast_addr_compressable32(a) \
131 ((((a)->s6_addr16[1]) == 0) && \
132 (((a)->s6_addr16[2]) == 0) && \
133 (((a)->s6_addr16[3]) == 0) && \
134 (((a)->s6_addr16[4]) == 0) && \
135 (((a)->s6_addr16[5]) == 0) && \
136 (((a)->s6_addr[12]) == 0))
137
138/* 8 bits, FF02::00XX */
139#define lowpan_is_mcast_addr_compressable8(a) \
140 ((((a)->s6_addr[1]) == 2) && \
141 (((a)->s6_addr16[1]) == 0) && \
142 (((a)->s6_addr16[2]) == 0) && \
143 (((a)->s6_addr16[3]) == 0) && \
144 (((a)->s6_addr16[4]) == 0) && \
145 (((a)->s6_addr16[5]) == 0) && \
146 (((a)->s6_addr16[6]) == 0) && \
147 (((a)->s6_addr[14]) == 0))
148
61static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr, 149static inline void iphc_uncompress_eui64_lladdr(struct in6_addr *ipaddr,
62 const void *lladdr) 150 const void *lladdr)
63{ 151{
diff --git a/net/6lowpan/nhc_udp.c b/net/6lowpan/nhc_udp.c
index 72d0b57eb6e5..69537a2eaab1 100644
--- a/net/6lowpan/nhc_udp.c
+++ b/net/6lowpan/nhc_udp.c
@@ -17,7 +17,27 @@
17 17
18#include "nhc.h" 18#include "nhc.h"
19 19
20#define LOWPAN_NHC_UDP_IDLEN 1 20#define LOWPAN_NHC_UDP_MASK 0xF8
21#define LOWPAN_NHC_UDP_ID 0xF0
22#define LOWPAN_NHC_UDP_IDLEN 1
23
24#define LOWPAN_NHC_UDP_4BIT_PORT 0xF0B0
25#define LOWPAN_NHC_UDP_4BIT_MASK 0xFFF0
26#define LOWPAN_NHC_UDP_8BIT_PORT 0xF000
27#define LOWPAN_NHC_UDP_8BIT_MASK 0xFF00
28
29/* values for port compression, _with checksum_ ie bit 5 set to 0 */
30
31/* all inline */
32#define LOWPAN_NHC_UDP_CS_P_00 0xF0
33/* source 16bit inline, dest = 0xF0 + 8 bit inline */
34#define LOWPAN_NHC_UDP_CS_P_01 0xF1
35/* source = 0xF0 + 8bit inline, dest = 16 bit inline */
36#define LOWPAN_NHC_UDP_CS_P_10 0xF2
37/* source & dest = 0xF0B + 4bit inline */
38#define LOWPAN_NHC_UDP_CS_P_11 0xF3
39/* checksum elided */
40#define LOWPAN_NHC_UDP_CS_C 0x04
21 41
22static int udp_uncompress(struct sk_buff *skb, size_t needed) 42static int udp_uncompress(struct sk_buff *skb, size_t needed)
23{ 43{