FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Find named object by @uid.
 * Check @tlvs for valid data inside.
 *
 * Returns pointer to found TLV or NULL.
 */
Find named object by @uid.
Check @tlvs for valid data inside.

Returns pointer to found TLV or NULL.
Find named object by @uid . Check @tlvs for valid data inside . Returns pointer to found TLV or NULL .
ipfw_obj_ntlv *
ipfw_find_name_tlv_type(void *tlvs, int len, uint16_t uidx, uint32_t etlv)
{
	ipfw_obj_ntlv *ntlv;
	uintptr_t pa, pe;
	int l;
	pa = (uintptr_t)tlvs;
	pe = pa + len;
	l = 0;
	for (; pa < pe; pa += l) {
		ntlv = (ipfw_obj_ntlv *)pa;
		l = ntlv->head.length;
		if (l != sizeof(*ntlv))
			return (NULL);
		if (ntlv->idx != uidx)
			continue;
		if (ntlv->head.type != 0 &&
		    ntlv->head.type != (uint16_t)etlv)
			continue;
		if (ipfw_check_object_name_generic(ntlv->name) != 0)
			return (NULL);
		return (ntlv);
	}
	return (NULL);
}
ipfw_obj_ntlv * ipfw_find_name_tlv_type ( void * tlvs , int len , uint16_t uidx , uint32_t etlv ) { ipfw_obj_ntlv * ntlv ; uintptr_t pa , pe ; int l ; pa = ( uintptr_t ) tlvs ; pe = pa + len ; l = 0 ; for ( ; pa < pe ; pa += l ) { ntlv = ( ipfw_obj_ntlv * ) pa ; l = ntlv -> head . length ; if ( l != sizeof ( * ntlv ) ) return ( NULL ) ; if ( ntlv -> idx != uidx ) continue ; if ( ntlv -> head . type != 0 && ntlv -> head . type != ( uint16_t ) etlv ) continue ; if ( ipfw_check_object_name_generic ( ntlv -> name ) != 0 ) return ( NULL ) ; return ( ntlv ) ; } return ( NULL ) ; }
Find named object by @uid.
Find named object by @uid .
/*
		 * When userland has specified zero TLV type, do
		 * not compare it with eltv. In some cases userland
		 * doesn't know what type should it have. Use only
		 * uidx and name for search named_object.
		 */