@@ -119,40 +119,42 @@ static int get_ihpc_inlined_size(uint16_t iphc)
119
119
* Mesh header compression
120
120
*/
121
121
122
- static inline bool net_6lo_ll_prefix_padded_with_zeros (struct in6_addr * addr )
122
+ static inline bool net_6lo_ll_prefix_padded_with_zeros (const uint8_t * addr )
123
123
{
124
- return (net_ipv6_is_ll_addr (addr ) &&
125
- (UNALIGNED_GET (& addr -> s6_addr16 [ 1 ] ) == 0x00 ) &&
126
- (UNALIGNED_GET (& addr -> s6_addr32 [ 1 ] ) == 0x00 ));
124
+ return (net_ipv6_is_ll_addr_raw (addr ) &&
125
+ (UNALIGNED_GET (( uint16_t * ) addr + 1 ) == 0x00 ) &&
126
+ (UNALIGNED_GET (( uint32_t * ) addr + 1 ) == 0x00 ));
127
127
}
128
128
129
- static inline bool net_6lo_addr_16_bit_compressible (struct in6_addr * addr )
129
+ static inline bool net_6lo_addr_16_bit_compressible (const uint8_t * addr )
130
130
{
131
- return ((UNALIGNED_GET (& addr -> s6_addr32 [ 2 ] ) == htonl (0xFFu )) &&
132
- (UNALIGNED_GET (& addr -> s6_addr16 [ 6 ] ) == htons (0xFE00u )));
131
+ return ((UNALIGNED_GET (( uint32_t * ) addr + 2 ) == htonl (0xFFu )) &&
132
+ (UNALIGNED_GET (( uint16_t * ) addr + 6 ) == htons (0xFE00u )));
133
133
}
134
134
135
- static inline bool net_6lo_maddr_8_bit_compressible (struct in6_addr * addr )
135
+ static inline bool net_6lo_maddr_8_bit_compressible (const uint8_t * addr )
136
136
{
137
- return ((addr -> s6_addr [1 ] == 0x02 ) &&
138
- (UNALIGNED_GET (& addr -> s6_addr16 [1 ]) == 0x00 ) &&
139
- (UNALIGNED_GET (& addr -> s6_addr32 [1 ]) == 0x00 ) &&
140
- (UNALIGNED_GET (& addr -> s6_addr32 [2 ]) == 0x00 ) &&
141
- (addr -> s6_addr [14 ] == 0x00 ));
137
+ return ((addr [1 ] == 0x02 ) &&
138
+ (UNALIGNED_GET ((uint16_t * )addr + 1 ) == 0x00 ) &&
139
+ (UNALIGNED_GET ((uint32_t * )addr + 1 ) == 0x00 ) &&
140
+ (UNALIGNED_GET ((uint32_t * )addr + 2 ) == 0x00 ) &&
141
+ (addr [14 ] == 0x00 ));
142
+
142
143
}
143
144
144
- static inline bool net_6lo_maddr_32_bit_compressible (struct in6_addr * addr )
145
+ static inline bool net_6lo_maddr_32_bit_compressible (const uint8_t * addr )
145
146
{
146
- return ((UNALIGNED_GET (& addr -> s6_addr32 [1 ]) == 0x00 ) &&
147
- (UNALIGNED_GET (& addr -> s6_addr32 [2 ]) == 0x00 ) &&
148
- (addr -> s6_addr [12 ] == 0x00 ));
147
+ return ((UNALIGNED_GET ((uint32_t * )addr + 1 ) == 0x00 ) &&
148
+ (UNALIGNED_GET ((uint32_t * )addr + 2 ) == 0x00 ) &&
149
+ (addr [12 ] == 0x00 ));
150
+
149
151
}
150
152
151
- static inline bool net_6lo_maddr_48_bit_compressible (struct in6_addr * addr )
153
+ static inline bool net_6lo_maddr_48_bit_compressible (const uint8_t * addr )
152
154
{
153
- return ((UNALIGNED_GET (& addr -> s6_addr32 [ 1 ] ) == 0x00 ) &&
154
- (UNALIGNED_GET (& addr -> s6_addr16 [ 4 ] ) == 0x00 ) &&
155
- (addr -> s6_addr [10 ] == 0x00 ));
155
+ return ((UNALIGNED_GET (( uint32_t * ) addr + 1 ) == 0x00 ) &&
156
+ (UNALIGNED_GET (( uint16_t * ) addr + 4 ) == 0x00 ) &&
157
+ (addr [10 ] == 0x00 ));
156
158
}
157
159
158
160
#if defined(CONFIG_NET_6LO_CONTEXT )
@@ -366,16 +368,15 @@ static uint8_t *compress_sa(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
366
368
uint8_t * inline_ptr , uint16_t * iphc )
367
369
{
368
370
/* Address is fully elided */
369
- if (net_ipv6_addr_based_on_ll ((struct in6_addr * )ipv6 -> src ,
370
- net_pkt_lladdr_src (pkt ))) {
371
+ if (net_ipv6_addr_based_on_ll_raw (ipv6 -> src , net_pkt_lladdr_src (pkt ))) {
371
372
NET_DBG ("SAM_11 src address is fully elided" );
372
373
373
374
* iphc |= NET_6LO_IPHC_SAM_11 ;
374
375
return inline_ptr ;
375
376
}
376
377
377
378
/* Following 64 bits are 0000:00ff:fe00:XXXX */
378
- if (net_6lo_addr_16_bit_compressible (( struct in6_addr * ) ipv6 -> src )) {
379
+ if (net_6lo_addr_16_bit_compressible (ipv6 -> src )) {
379
380
NET_DBG ("SAM_10 src addr 16 bit compressible" );
380
381
* iphc |= NET_6LO_IPHC_SAM_10 ;
381
382
@@ -412,8 +413,7 @@ static uint8_t *compress_sa_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
412
413
NET_DBG ("SAC_1 src address context based" );
413
414
* iphc |= NET_6LO_IPHC_SAC_1 ;
414
415
415
- if (net_ipv6_addr_based_on_ll ((struct in6_addr * )ipv6 -> src ,
416
- net_pkt_lladdr_src (pkt ))) {
416
+ if (net_ipv6_addr_based_on_ll_raw (ipv6 -> src , net_pkt_lladdr_src (pkt ))) {
417
417
NET_DBG ("SAM_11 src address is fully elided" );
418
418
419
419
/* Address is fully elided */
@@ -422,7 +422,7 @@ static uint8_t *compress_sa_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
422
422
}
423
423
424
424
/* Following 64 bits are 0000:00ff:fe00:XXXX */
425
- if (net_6lo_addr_16_bit_compressible (( struct in6_addr * ) ipv6 -> src )) {
425
+ if (net_6lo_addr_16_bit_compressible (ipv6 -> src )) {
426
426
NET_DBG ("SAM_10 src addr 16 bit compressible" );
427
427
428
428
* iphc |= NET_6LO_IPHC_SAM_10 ;
@@ -452,7 +452,7 @@ static uint8_t *compress_da_mcast(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr
452
452
453
453
NET_DBG ("M_1 dst is mcast" );
454
454
455
- if (net_6lo_maddr_8_bit_compressible (( struct in6_addr * ) ipv6 -> dst )) {
455
+ if (net_6lo_maddr_8_bit_compressible (ipv6 -> dst )) {
456
456
NET_DBG ("DAM_11 dst maddr 8 bit compressible" );
457
457
458
458
/* last byte */
@@ -464,7 +464,7 @@ static uint8_t *compress_da_mcast(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr
464
464
return inline_ptr ;
465
465
}
466
466
467
- if (net_6lo_maddr_32_bit_compressible (( struct in6_addr * ) ipv6 -> dst )) {
467
+ if (net_6lo_maddr_32_bit_compressible (ipv6 -> dst )) {
468
468
NET_DBG ("DAM_10 4 bytes: 2nd byte + last three bytes" );
469
469
470
470
/* 4 bytes: 2nd byte + last three bytes */
@@ -479,7 +479,7 @@ static uint8_t *compress_da_mcast(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr
479
479
return inline_ptr ;
480
480
}
481
481
482
- if (net_6lo_maddr_48_bit_compressible (( struct in6_addr * ) ipv6 -> dst )) {
482
+ if (net_6lo_maddr_48_bit_compressible (ipv6 -> dst )) {
483
483
NET_DBG ("DAM_01 6 bytes: 2nd byte + last five bytes" );
484
484
485
485
/* 6 bytes: 2nd byte + last five bytes */
@@ -507,16 +507,15 @@ static uint8_t *compress_da(struct net_ipv6_hdr *ipv6, struct net_pkt *pkt,
507
507
uint8_t * inline_ptr , uint16_t * iphc )
508
508
{
509
509
/* Address is fully elided */
510
- if (net_ipv6_addr_based_on_ll ((struct in6_addr * )ipv6 -> dst ,
511
- net_pkt_lladdr_dst (pkt ))) {
510
+ if (net_ipv6_addr_based_on_ll_raw (ipv6 -> dst , net_pkt_lladdr_dst (pkt ))) {
512
511
NET_DBG ("DAM_11 dst addr fully elided" );
513
512
514
513
* iphc |= NET_6LO_IPHC_DAM_11 ;
515
514
return inline_ptr ;
516
515
}
517
516
518
517
/* Following 64 bits are 0000:00ff:fe00:XXXX */
519
- if (net_6lo_addr_16_bit_compressible (( struct in6_addr * ) ipv6 -> dst )) {
518
+ if (net_6lo_addr_16_bit_compressible (ipv6 -> dst )) {
520
519
NET_DBG ("DAM_10 dst addr 16 bit compressible" );
521
520
522
521
* iphc |= NET_6LO_IPHC_DAM_10 ;
@@ -553,16 +552,15 @@ static uint8_t *compress_da_ctx(struct net_ipv6_hdr *ipv6, uint8_t *inline_ptr,
553
552
{
554
553
* iphc |= NET_6LO_IPHC_DAC_1 ;
555
554
556
- if (net_ipv6_addr_based_on_ll ((struct in6_addr * )ipv6 -> dst ,
557
- net_pkt_lladdr_dst (pkt ))) {
555
+ if (net_ipv6_addr_based_on_ll_raw (ipv6 -> dst , net_pkt_lladdr_dst (pkt ))) {
558
556
NET_DBG ("DAM_11 dst addr fully elided" );
559
557
560
558
* iphc |= NET_6LO_IPHC_DAM_11 ;
561
559
return inline_ptr ;
562
560
}
563
561
564
562
/* Following 64 bits are 0000:00ff:fe00:XXXX */
565
- if (net_6lo_addr_16_bit_compressible (( struct in6_addr * ) ipv6 -> dst )) {
563
+ if (net_6lo_addr_16_bit_compressible (ipv6 -> dst )) {
566
564
NET_DBG ("DAM_10 dst addr 16 bit compressible" );
567
565
568
566
* iphc |= NET_6LO_IPHC_DAM_10 ;
@@ -753,12 +751,12 @@ static inline int compress_IPHC_header(struct net_pkt *pkt)
753
751
inline_pos = compress_nh_udp (udp , inline_pos , false);
754
752
}
755
753
756
- if (net_6lo_ll_prefix_padded_with_zeros (( struct in6_addr * ) ipv6 -> dst )) {
754
+ if (net_6lo_ll_prefix_padded_with_zeros (ipv6 -> dst )) {
757
755
inline_pos = compress_da (ipv6 , pkt , inline_pos , & iphc );
758
756
goto da_end ;
759
757
}
760
758
761
- if (net_ipv6_is_addr_mcast (( struct in6_addr * ) ipv6 -> dst )) {
759
+ if (net_ipv6_is_addr_mcast_raw ( ipv6 -> dst )) {
762
760
inline_pos = compress_da_mcast (ipv6 , inline_pos , & iphc );
763
761
goto da_end ;
764
762
}
@@ -775,7 +773,7 @@ static inline int compress_IPHC_header(struct net_pkt *pkt)
775
773
inline_pos = set_da_inline (ipv6 , inline_pos , & iphc );
776
774
da_end :
777
775
778
- if (net_6lo_ll_prefix_padded_with_zeros (( struct in6_addr * ) ipv6 -> src )) {
776
+ if (net_6lo_ll_prefix_padded_with_zeros (ipv6 -> src )) {
779
777
inline_pos = compress_sa (ipv6 , pkt , inline_pos , & iphc );
780
778
goto sa_end ;
781
779
}
0 commit comments