FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Export rule into v1 format (Current).
 * Layout:
 * [ ipfw_obj_tlv(IPFW_TLV_RULE_ENT)
 *     [ ip_fw_rule ] OR
 *     [ ip_fw_bcounter ip_fw_rule] (depends on rcntrs).
 * ]
 * Assume @data is zeroed.
 */
Export rule into v1 format (Current).
Export rule into v1 format ( Current ) .
static void
export_rule1(struct ip_fw *krule, caddr_t data, int len, int rcntrs)
{
	struct ip_fw_bcounter *cntr;
	struct ip_fw_rule *urule;
	ipfw_obj_tlv *tlv;
	tlv = (ipfw_obj_tlv *)data;
	tlv->type = IPFW_TLV_RULE_ENT;
	tlv->length = len;
	if (rcntrs != 0) {
		cntr = (struct ip_fw_bcounter *)(tlv + 1);
		urule = (struct ip_fw_rule *)(cntr + 1);
		export_cntr1_base(krule, cntr);
	} else
		urule = (struct ip_fw_rule *)(tlv + 1);
	urule->act_ofs = krule->act_ofs;
	urule->cmd_len = krule->cmd_len;
	urule->rulenum = krule->rulenum;
	urule->set = krule->set;
	urule->flags = krule->flags;
	urule->id = krule->id;
	memcpy(urule->cmd, krule->cmd, krule->cmd_len * sizeof(uint32_t));
}
static void export_rule1 ( struct ip_fw * krule , caddr_t data , int len , int rcntrs ) { struct ip_fw_bcounter * cntr ; struct ip_fw_rule * urule ; ipfw_obj_tlv * tlv ; tlv = ( ipfw_obj_tlv * ) data ; tlv -> type = IPFW_TLV_RULE_ENT ; tlv -> length = len ; if ( rcntrs != 0 ) { cntr = ( struct ip_fw_bcounter * ) ( tlv + 1 ) ; urule = ( struct ip_fw_rule * ) ( cntr + 1 ) ; export_cntr1_base ( krule , cntr ) ; } else urule = ( struct ip_fw_rule * ) ( tlv + 1 ) ; urule -> act_ofs = krule -> act_ofs ; urule -> cmd_len = krule -> cmd_len ; urule -> rulenum = krule -> rulenum ; urule -> set = krule -> set ; urule -> flags = krule -> flags ; urule -> id = krule -> id ; memcpy ( urule -> cmd , krule -> cmd , krule -> cmd_len * sizeof ( uint32_t ) ) ; }
Export rule into v1 format (Current).
Export rule into v1 format ( Current ) .
/* Fill in TLV header */ /* Copy counters */ /* copy header */ /* Copy opcodes */