/* Parses exactly 4 hex characters (capital or lowercase). Fails if any input chars are not .  */
static bool parse_hex16(const char **sp, uint16_t *out)
/* Parses exactly 4 hex characters (capital or lowercase). Fails if any input chars are not .  */
static bool parse_hex16(const char **sp, uint16_t *out)
{
	const char *s = *sp;
	uint16_t ret = 0;
	uint16_t i;
	uint16_t tmp;
	char c;
	for (i = 0; i < 4; i++) {
		c = *s++;
		if (c >= '0' && c <= '9')
			tmp = (uint16_t) (c - '0');
		else if (c >= 'A' && c <= 'F')
			tmp = (uint16_t) (c - 'A' + 10);
		else if (c >= 'a' && c <= 'f')
			tmp = (uint16_t) (c - 'a' + 10);
		else
			return false;
		ret <<= (uint16_t)(4);
		ret += (uint16_t)tmp;
	}
	if (out)
		*out = ret;
	*sp = s;
	return true;
}