/* NULL is returned (and @ptr and @len will not be updated) if there are no more IEs in the buffer or the buffer is too short.  */
struct uwb_ie_hdr* uwb_ie_next(void **ptr, size_t *len)
/* NULL is returned (and @ptr and @len will not be updated) if there are no more IEs in the buffer or the buffer is too short.  */
struct uwb_ie_hdr* uwb_ie_next(void **ptr, size_t *len)
{
	struct uwb_ie_hdr *hdr;
	size_t ie_len;
	if (*len < sizeof(struct uwb_ie_hdr))
		return NULL;
	hdr = *ptr;
	ie_len = sizeof(struct uwb_ie_hdr) + hdr->length;
	if (*len < ie_len)
		return NULL;
	*ptr += ie_len;
	*len -= ie_len;
	return hdr;
}