FreeBSD/usr.sbin/bluetooth/btpand/sdp.c
/*
 * _sdp_get_uuid(ptr, limit, uuid)
 *
 *	examine SDP data stream at ptr for a UUID, and extract
 *	to given storage, advancing ptr.
 *	limit is the first address past the end of valid data.
 */
_sdp_get_uuid(ptr, limit, uuid)
examine SDP data stream at ptr for a UUID, and extract
to given storage, advancing ptr.
limit is the first address past the end of valid data.
_sdp_get_uuid ( ptr limit uuid ) examine SDP data stream at ptr for a UUID and extract to given storage advancing ptr . limit is the first address past the end of valid data .
bool
_sdp_get_uuid(uint8_t **ptr, uint8_t *limit, uuid_t *uuid)
{
	uint8_t *p = *ptr;
	if (p + 1 > limit)
		return false;
	switch (*p++) {
	case SDP_DATA_UUID16:
		if (p + 2 > limit)
			return false;
		memcpy(uuid, &BASE_UUID, sizeof(uuid_t));
		uuid->time_low = be16dec(p);
		p += 2;
		break;
	case SDP_DATA_UUID32:
		if (p + 4 > limit)
			return false;
		memcpy(uuid, &BASE_UUID, sizeof(uuid_t));
		uuid->time_low = be32dec(p);
		p += 4;
		break;
	case SDP_DATA_UUID128:
		if (p + 16 > limit)
			return false;
		uuid_dec_be(p, uuid);
		p += 16;
		break;
	default:
		return false;
	}
	*ptr = p;
	return true;
}
bool _sdp_get_uuid ( uint8_t * * ptr , uint8_t * limit , uuid_t * uuid ) { uint8_t * p = * ptr ; if ( p + 1 > limit ) return false ; switch ( * p ++ ) { case SDP_DATA_UUID16 : if ( p + 2 > limit ) return false ; memcpy ( uuid , & BASE_UUID , sizeof ( uuid_t ) ) ; uuid -> time_low = be16dec ( p ) ; p += 2 ; break ; case SDP_DATA_UUID32 : if ( p + 4 > limit ) return false ; memcpy ( uuid , & BASE_UUID , sizeof ( uuid_t ) ) ; uuid -> time_low = be32dec ( p ) ; p += 4 ; break ; case SDP_DATA_UUID128 : if ( p + 16 > limit ) return false ; uuid_dec_be ( p , uuid ) ; p += 16 ; break ; default : return false ; } * ptr = p ; return true ; }
_sdp_get_uuid(ptr, limit, uuid)
      examine SDP data stream at ptr for a UUID, and extract
      to given storage, advancing ptr.
_sdp_get_uuid ( ptr limit uuid ) examine SDP data stream at ptr for a UUID and extract to given storage advancing ptr .