Esempio n. 1
0
/**
 * Compress the 64 bit address
 *
 * @param The pbuf which is the ieee 802.15.4 frame.
 * @return NONE
 */
static u8_t
lowpan_compress_addr_64 (u8_t **hc06_ptr, u8_t shift,
                         const struct in6_addr *ipaddr,
                         const u8_t *mac_addr)
{
    if (is_addr_mac_addr_based(ipaddr, mac_addr)) {
        return (3 << shift);  /* 0-bits */

    } else if (lowpan_is_iid_16_bit_compressable(ipaddr)) {
        /* compress IID to 16 bits xxxx::XXXX */
        MEMCPY(*hc06_ptr, &(((u16_t *)(ipaddr->s6_addr))[7]), 2);
        *hc06_ptr += 2;
        return (2 << shift); /* 16-bits */

    } else {
        /* do not compress IID => xxxx::IID */
        MEMCPY(*hc06_ptr, &(((u16_t *)(ipaddr->s6_addr))[4]), 8);
        *hc06_ptr += 8;
        return (1 << shift); /* 64-bits */
    }
}
Esempio n. 2
0
static u8
lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, const struct in6_addr *ipaddr,
		 const unsigned char *lladdr)
{
	u8 val = 0;

	if (is_addr_mac_addr_based(ipaddr, lladdr))
		val = 3; /* 0-bits */
	else if (lowpan_is_iid_16_bit_compressable(ipaddr)) {
		/* compress IID to 16 bits xxxx::XXXX */
		memcpy(*hc06_ptr, &ipaddr->s6_addr16[7], 2);
		*hc06_ptr += 2;
		val = 2; /* 16-bits */
	} else {
		/* do not compress IID => xxxx::IID */
		memcpy(*hc06_ptr, &ipaddr->s6_addr16[4], 8);
		*hc06_ptr += 8;
		val = 1; /* 64-bits */
	}

	return rol8(val, shift);
}