/* Packs unsigned 16 bit value to the buffer at the offset requested.  */
static int pack_uint16(uint16_t val, struct buf_ctx *buf)
/* Packs unsigned 16 bit value to the buffer at the offset requested.  */
static int pack_uint16(uint16_t val, struct buf_ctx *buf)
{
	if ((buf->end - buf->cur) < sizeof(uint16_t)) {
		return -ENOMEM;
	}
	NET_DBG(">> val:%04x cur:%p, end:%p", val, (void *)buf->cur, (void *)buf->end);
	*(buf->cur++) = (val >> 8) & 0xFF;
	*(buf->cur++) = val & 0xFF;
	return 0;
}