FreeBSD/sys/netpfil/ipfw/ip_fw_table.c
/*
 * Looks up an entry in given table.
 * Data layout (v0)(current):
 * Request: [ ipfw_obj_header ipfw_obj_tentry ]
 * Reply: [ ipfw_obj_header ipfw_obj_tentry ]
 *
 * Returns 0 on success
 */
Looks up an entry in given table.

Returns 0 on success
Looks up an entry in given table . Returns 0 on success
static int
find_table_entry(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
    struct sockopt_data *sd)
{
	ipfw_obj_tentry *tent;
	ipfw_obj_header *oh;
	struct tid_info ti;
	struct table_config *tc;
	struct table_algo *ta;
	struct table_info *kti;
	struct namedobj_instance *ni;
	int error;
	size_t sz;
	sz = sizeof(*oh) + sizeof(*tent);
	if (sd->valsize != sz)
		return (EINVAL);
	oh = (struct _ipfw_obj_header *)ipfw_get_sopt_header(sd, sz);
	tent = (ipfw_obj_tentry *)(oh + 1);
	if (oh->ntlv.head.length != sizeof(oh->ntlv))
		return (EINVAL);
	objheader_to_ti(oh, &ti);
	ti.type = oh->ntlv.type;
	ti.uidx = tent->idx;
	IPFW_UH_RLOCK(ch);
	ni = CHAIN_TO_NI(ch);
	ta = NULL;
	if ((tc = find_table(ni, &ti)) == NULL) {
		IPFW_UH_RUNLOCK(ch);
		return (ESRCH);
	}
	if (tc->no.subtype != ti.type) {
		IPFW_UH_RUNLOCK(ch);
		return (EINVAL);
	}
	kti = KIDX_TO_TI(ch, tc->no.kidx);
	ta = tc->ta;
	if (ta->find_tentry == NULL)
		return (ENOTSUP);
	error = ta->find_tentry(tc->astate, kti, tent);
	IPFW_UH_RUNLOCK(ch);
	return (error);
}
static int find_table_entry ( struct ip_fw_chain * ch , ip_fw3_opheader * op3 , struct sockopt_data * sd ) { ipfw_obj_tentry * tent ; ipfw_obj_header * oh ; struct tid_info ti ; struct table_config * tc ; struct table_algo * ta ; struct table_info * kti ; struct namedobj_instance * ni ; int error ; size_t sz ; sz = sizeof ( * oh ) + sizeof ( * tent ) ; if ( sd -> valsize != sz ) return ( EINVAL ) ; oh = ( struct _ipfw_obj_header * ) ipfw_get_sopt_header ( sd , sz ) ; tent = ( ipfw_obj_tentry * ) ( oh + 1 ) ; if ( oh -> ntlv . head . length != sizeof ( oh -> ntlv ) ) return ( EINVAL ) ; objheader_to_ti ( oh , & ti ) ; ti . type = oh -> ntlv . type ; ti . uidx = tent -> idx ; IPFW_UH_RLOCK ( ch ) ; ni = CHAIN_TO_NI ( ch ) ; ta = NULL ; if ( ( tc = find_table ( ni , & ti ) ) == NULL ) { IPFW_UH_RUNLOCK ( ch ) ; return ( ESRCH ) ; } if ( tc -> no . subtype != ti . type ) { IPFW_UH_RUNLOCK ( ch ) ; return ( EINVAL ) ; } kti = KIDX_TO_TI ( ch , tc -> no . kidx ) ; ta = tc -> ta ; if ( ta -> find_tentry == NULL ) return ( ENOTSUP ) ; error = ta -> find_tentry ( tc -> astate , kti , tent ) ; IPFW_UH_RUNLOCK ( ch ) ; return ( error ) ; }
Looks up an entry in given table.
Looks up an entry in given table .
/* Check minimum header size */ /* Basic length checks for TLVs */ /*
	 * Find existing table and check its type .
	 */ /* check table type */