Exemplo n.º 1
0
static void deserialize_b_b_p(uint8_t fn_index, struct net_buf *buf)
{
	const uint8_t *p_vbuf1;
	uint16_t vbuf1_length;
	const uint8_t *p_vbuf2;
	uint16_t vbuf2_length;
	uintptr_t priv;

	deserialize_buf(buf, &p_vbuf1, &vbuf1_length);
	deserialize_buf(buf, &p_vbuf2, &vbuf2_length);
	deserialize_ptr(buf, &priv);

	{
		/* Always align structures on word boundary */
		uintptr_t vbuf1[(vbuf1_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		uintptr_t vbuf2[(vbuf2_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		void *buf1 = NULL;
		void *buf2 = NULL;

		if (vbuf1_length) {
			memcpy(vbuf1, p_vbuf1, vbuf1_length);
			buf1 = vbuf1;
		}

		if (vbuf2_length) {
			memcpy(vbuf2, p_vbuf2, vbuf2_length);
			buf2 = vbuf2;
		}

		m_fct_b_b_p[fn_index](buf1, vbuf1_length, buf2, vbuf2_length,
				      (void *)priv);
	}
}
Exemplo n.º 2
0
static void deserialize_s_b_b_p(uint8_t fn_index, const uint8_t *buf,
				uint16_t length)
{
	const uint8_t *p_struct_data;
	uint8_t struct_length;
	const uint8_t *p_vbuf1;
	uint16_t vbuf1_length;
	const uint8_t *p_vbuf2;
	uint16_t vbuf2_length;
	uintptr_t priv;
	const uint8_t *p;

	p = deserialize_struct(buf, &p_struct_data, &struct_length);
	p = deserialize_buf(p, &p_vbuf1, &vbuf1_length);
	p = deserialize_buf(p, &p_vbuf2, &vbuf2_length);
	p += 4;

	if ((length != (p - buf)) ||
	    (struct_length != m_size_s_b_b_p[fn_index])) {
		panic(-1);
	} else {
		/* Always align structures on word boundary */
		uintptr_t struct_data[(struct_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		uintptr_t vbuf1[(vbuf1_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		uintptr_t vbuf2[(vbuf2_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		void *buf1 = NULL;
		void *buf2 = NULL;

		memcpy(struct_data, p_struct_data, struct_length);

		if (vbuf1_length) {
			memcpy(vbuf1, p_vbuf1, vbuf1_length);
			buf1 = vbuf1;
		}

		if (vbuf2_length) {
			memcpy(vbuf2, p_vbuf2, vbuf2_length);
			buf2 = vbuf2;
		}

		p = p_vbuf2 + vbuf2_length;

		/* little endian conversion */
		priv = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);

		m_fct_s_b_b_p[fn_index](struct_data, buf1, vbuf1_length, buf2,
					vbuf2_length, (void *)priv);
	}
}
Exemplo n.º 3
0
static void deserialize_s_b_p(uint8_t fn_index, struct net_buf *buf)
{
	const uint8_t *p_struct_data;
	uint8_t struct_length;
	const uint8_t *p_vbuf;
	uint16_t vbuf_length;
	uintptr_t priv;

	deserialize_struct(buf, &p_struct_data, &struct_length);
	deserialize_buf(buf, &p_vbuf, &vbuf_length);
	deserialize_ptr(buf, &priv);

	if (struct_length != m_size_s_b_p[fn_index]) {
		panic(-1);
	} else {
		/* Always align structures on word boundary */
		uintptr_t struct_data[(struct_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		uintptr_t vbuf[(vbuf_length +
				(sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		void *buf = NULL;

		memcpy(struct_data, p_struct_data, struct_length);

		if (vbuf_length) {
			memcpy(vbuf, p_vbuf, vbuf_length);
			buf = vbuf;
		}

		m_fct_s_b_p[fn_index](struct_data, buf, vbuf_length,
				      (void *)priv);
	}
}
Exemplo n.º 4
0
static void deserialize_s_b(uint8_t fn_index, const uint8_t * p_buf, uint16_t length) {
	const uint8_t *p_struct_data;
	uint8_t struct_length;
	const uint8_t *p_vbuf;
	uint16_t vbuf_length;
	const uint8_t *p;

	p = deserialize_struct(p_buf, &p_struct_data, &struct_length);
	p = deserialize_buf(p, &p_vbuf, &vbuf_length);

	if ((length != (p - p_buf)) ||
	    (struct_length != m_size_s_b[fn_index]))
		panic(-1);

	{
		/* Always align structures on word boundary */
		uintptr_t struct_data[(struct_length + (sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		uintptr_t vbuf[(vbuf_length + (sizeof(uintptr_t) - 1))/(sizeof(uintptr_t))];
		void * buf = NULL;

		memcpy(struct_data, p_struct_data, struct_length);

		if (vbuf_length) {
			memcpy(vbuf, p_vbuf, vbuf_length);
			buf = vbuf;
		}

		m_fct_s_b[fn_index](struct_data, buf, vbuf_length);
	}
}