FreeBSD/usr.sbin/bluetooth/btpand/sdp.c
/*
 * _sdp_get_seq(ptr, limit, seq)
 *
 *	examine SDP data stream at ptr for a sequence. return
 *	seq pointer if found and advance ptr to next object.
 *	limit is the first address past the end of valid data.
 */
_sdp_get_seq(ptr, limit, seq)
examine SDP data stream at ptr for a sequence. return
seq pointer if found and advance ptr to next object.
limit is the first address past the end of valid data.
_sdp_get_seq ( ptr limit seq ) examine SDP data stream at ptr for a sequence . return seq pointer if found and advance ptr to next object . limit is the first address past the end of valid data .
bool
_sdp_get_seq(uint8_t **ptr, uint8_t *limit, uint8_t **seq)
{
	uint8_t *p = *ptr;
	int32_t l;
	if (p + 1 > limit)
		return false;
	switch (*p++) {
	case SDP_DATA_SEQ8:
		if (p + 1 > limit)
			return false;
		l = *p;
		p += 1;
		break;
	case SDP_DATA_SEQ16:
		if (p + 2 > limit)
			return false;
		l = be16dec(p);
		p += 2;
		break;
	case SDP_DATA_SEQ32:
		if (p + 4 > limit)
			return false;
		l = be32dec(p);
		p += 4;
		break;
	default:
		return false;
	}
	if (p + l > limit)
		return false;
	*seq = p;
	*ptr = p + l;
	return true;
}
bool _sdp_get_seq ( uint8_t * * ptr , uint8_t * limit , uint8_t * * seq ) { uint8_t * p = * ptr ; int32_t l ; if ( p + 1 > limit ) return false ; switch ( * p ++ ) { case SDP_DATA_SEQ8 : if ( p + 1 > limit ) return false ; l = * p ; p += 1 ; break ; case SDP_DATA_SEQ16 : if ( p + 2 > limit ) return false ; l = be16dec ( p ) ; p += 2 ; break ; case SDP_DATA_SEQ32 : if ( p + 4 > limit ) return false ; l = be32dec ( p ) ; p += 4 ; break ; default : return false ; } if ( p + l > limit ) return false ; * seq = p ; * ptr = p + l ; return true ; }
_sdp_get_seq(ptr, limit, seq)
      examine SDP data stream at ptr for a sequence.
_sdp_get_seq ( ptr limit seq ) examine SDP data stream at ptr for a sequence .