FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Finds and bumps refcount for objects referenced by given @rule.
 * Auto-creates non-existing tables.
 * Fills in @oib array with userland/kernel indexes.
 *
 * Returns 0 on success.
 */
Finds and bumps refcount for objects referenced by given @rule.
Auto-creates non-existing tables.
Fills in @oib array with userland/kernel indexes.

Returns 0 on success.
Finds and bumps refcount for objects referenced by given @rule . Auto - creates non - existing tables . Fills in @oib array with userland / kernel indexes . Returns 0 on success .
static int
ref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule,
    struct rule_check_info *ci, struct obj_idx *oib, struct tid_info *ti)
{
	struct obj_idx *pidx;
	ipfw_insn *cmd;
	int cmdlen, error, l, unresolved;
	pidx = oib;
	l = rule->cmd_len;
	cmd = rule->cmd;
	cmdlen = 0;
	error = 0;
	IPFW_UH_WLOCK(ch);
	for ( ;	l > 0 ; l -= cmdlen, cmd += cmdlen) {
		cmdlen = F_LEN(cmd);
		unresolved = 0;
		error = ref_opcode_object(ch, cmd, ti, pidx, &unresolved);
		if (error != 0)
			break;
		if (unresolved != 0) {
			pidx->off = rule->cmd_len - l;
			pidx++;
		}
	}
	if (error != 0) {
		unref_oib_objects(ch, rule->cmd, oib, pidx);
		IPFW_UH_WUNLOCK(ch);
		return (error);
	}
	IPFW_UH_WUNLOCK(ch);
	if (pidx != oib)
		error = create_objects_compat(ch, rule->cmd, oib, pidx, ti);
	ci->object_opcodes = (uint16_t)(pidx - oib);
	return (error);
}
static int ref_rule_objects ( struct ip_fw_chain * ch , struct ip_fw * rule , struct rule_check_info * ci , struct obj_idx * oib , struct tid_info * ti ) { struct obj_idx * pidx ; ipfw_insn * cmd ; int cmdlen , error , l , unresolved ; pidx = oib ; l = rule -> cmd_len ; cmd = rule -> cmd ; cmdlen = 0 ; error = 0 ; IPFW_UH_WLOCK ( ch ) ; for ( ; l > 0 ; l -= cmdlen , cmd += cmdlen ) { cmdlen = F_LEN ( cmd ) ; unresolved = 0 ; error = ref_opcode_object ( ch , cmd , ti , pidx , & unresolved ) ; if ( error != 0 ) break ; if ( unresolved != 0 ) { pidx -> off = rule -> cmd_len - l ; pidx ++ ; } } if ( error != 0 ) { unref_oib_objects ( ch , rule -> cmd , oib , pidx ) ; IPFW_UH_WUNLOCK ( ch ) ; return ( error ) ; } IPFW_UH_WUNLOCK ( ch ) ; if ( pidx != oib ) error = create_objects_compat ( ch , rule -> cmd , oib , pidx , ti ) ; ci -> object_opcodes = ( uint16_t ) ( pidx - oib ) ; return ( error ) ; }
Finds and bumps refcount for objects referenced by given @rule.
Finds and bumps refcount for objects referenced by given @rule .
/* Increase refcount on each existing referenced table. */ /*
		 * Compatibility stuff for old clients:
		 * prepare to automaitcally create non-existing objects.
		 */ /* Unref everything we have already done */ /* Perform auto-creation for non-existing objects */ /* Calculate real number of dynamic objects */