require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_NPF_NET_H_)) {
    eval 'sub _NPF_NET_H_ () {1;}' unless defined(&_NPF_NET_H_);
    require 'sys/param.ph';
    require 'sys/types.ph';
    eval 'sub NPF_VERSION () {22;}' unless defined(&NPF_VERSION);
    if(defined(&_NPF_STANDALONE)) {
	require './net/npf_stand.ph';
    } else {
	require 'sys/ioctl.ph';
	require 'netinet/in_systm.ph';
	require 'netinet/in.ph';
    }
    eval 'sub NPF_MAX_NETMASK () {(128);}' unless defined(&NPF_MAX_NETMASK);
    eval 'sub NPF_NO_NETMASK () {(( &npf_netmask_t)~0);}' unless defined(&NPF_NO_NETMASK);
    if(defined(&NPF_BPFCOP)) {
	eval 'sub NPF_COP_L3 () {0;}' unless defined(&NPF_COP_L3);
	eval 'sub NPF_COP_TABLE () {1;}' unless defined(&NPF_COP_TABLE);
	eval 'sub BPF_MW_IPVER () {0;}' unless defined(&BPF_MW_IPVER);
	eval 'sub BPF_MW_L4OFF () {1;}' unless defined(&BPF_MW_L4OFF);
	eval 'sub BPF_MW_L4PROTO () {2;}' unless defined(&BPF_MW_L4PROTO);
    }
    eval 'sub NPF_BPF_NWORDS () {3;}' unless defined(&NPF_BPF_NWORDS);
    if(defined(&_KERNEL) || defined(&_NPF_STANDALONE)) {
	eval 'sub NPF_DECISION_BLOCK () {0;}' unless defined(&NPF_DECISION_BLOCK);
	eval 'sub NPF_DECISION_PASS () {1;}' unless defined(&NPF_DECISION_PASS);
	eval 'sub NPF_EXT_MODULE {
	    my($name, $req) = @_;
    	    eval q( &MODULE( &MODULE_CLASS_MISC, $name, ($sizeof{$req} - 1) ? (\\"npf,\\" $req) : \\"npf\\"));
	}' unless defined(&NPF_EXT_MODULE);
	require 'net/if.ph';
	require 'netinet/ip.ph';
	require 'netinet/ip6.ph';
	require 'netinet/tcp.ph';
	require 'netinet/udp.ph';
	require 'netinet/ip_icmp.ph';
	require 'netinet/icmp6.ph';
	eval 'sub NBUF_DATAREF_RESET () {0x1;}' unless defined(&NBUF_DATAREF_RESET);
	eval 'sub NPC_IP4 () {0x1;}' unless defined(&NPC_IP4);
	eval 'sub NPC_IP6 () {0x2;}' unless defined(&NPC_IP6);
	eval 'sub NPC_IPFRAG () {0x4;}' unless defined(&NPC_IPFRAG);
	eval 'sub NPC_LAYER4 () {0x8;}' unless defined(&NPC_LAYER4);
	eval 'sub NPC_TCP () {0x10;}' unless defined(&NPC_TCP);
	eval 'sub NPC_UDP () {0x20;}' unless defined(&NPC_UDP);
	eval 'sub NPC_ICMP () {0x40;}' unless defined(&NPC_ICMP);
	eval 'sub NPC_ICMP_ID () {0x80;}' unless defined(&NPC_ICMP_ID);
	eval 'sub NPC_ALG_EXEC () {0x100;}' unless defined(&NPC_ALG_EXEC);
	eval 'sub NPC_FMTERR () {0x200;}' unless defined(&NPC_FMTERR);
	eval 'sub NPC_IP46 () {( &NPC_IP4| &NPC_IP6);}' unless defined(&NPC_IP46);
	eval 'sub npf_iscached {
	    my($npc,$inf) = @_;
    	    eval q({  &KASSERT( ($npc->{npc_nbuf}) !=  &NULL);  &__predict_true(( ($npc->{npc_info}) & $inf) != 0); });
	}' unless defined(&npf_iscached);
    }
    eval 'sub NPF_SRC () {0;}' unless defined(&NPF_SRC);
    eval 'sub NPF_DST () {1;}' unless defined(&NPF_DST);
    eval 'sub NPF_RULE_PASS () {0x1;}' unless defined(&NPF_RULE_PASS);
    eval 'sub NPF_RULE_GROUP () {0x2;}' unless defined(&NPF_RULE_GROUP);
    eval 'sub NPF_RULE_FINAL () {0x4;}' unless defined(&NPF_RULE_FINAL);
    eval 'sub NPF_RULE_STATEFUL () {0x8;}' unless defined(&NPF_RULE_STATEFUL);
    eval 'sub NPF_RULE_RETRST () {0x10;}' unless defined(&NPF_RULE_RETRST);
    eval 'sub NPF_RULE_RETICMP () {0x20;}' unless defined(&NPF_RULE_RETICMP);
    eval 'sub NPF_RULE_DYNAMIC () {0x40;}' unless defined(&NPF_RULE_DYNAMIC);
    eval 'sub NPF_RULE_GSTATEFUL () {0x80;}' unless defined(&NPF_RULE_GSTATEFUL);
    eval 'sub NPF_DYNAMIC_GROUP () {( &NPF_RULE_GROUP |  &NPF_RULE_DYNAMIC);}' unless defined(&NPF_DYNAMIC_GROUP);
    eval 'sub NPF_RULE_IN () {0x10000000;}' unless defined(&NPF_RULE_IN);
    eval 'sub NPF_RULE_OUT () {0x20000000;}' unless defined(&NPF_RULE_OUT);
    eval 'sub NPF_RULE_DIMASK () {( &NPF_RULE_IN |  &NPF_RULE_OUT);}' unless defined(&NPF_RULE_DIMASK);
    eval 'sub NPF_RULE_FORW () {0x40000000;}' unless defined(&NPF_RULE_FORW);
    eval 'sub NPF_RULE_PRIVMASK () {0xf000000;}' unless defined(&NPF_RULE_PRIVMASK);
    eval 'sub NPF_RULE_MAXNAMELEN () {64;}' unless defined(&NPF_RULE_MAXNAMELEN);
    eval 'sub NPF_RULE_MAXKEYLEN () {32;}' unless defined(&NPF_RULE_MAXKEYLEN);
    eval 'sub NPF_PRI_FIRST () {(-2);}' unless defined(&NPF_PRI_FIRST);
    eval 'sub NPF_PRI_LAST () {(-1);}' unless defined(&NPF_PRI_LAST);
    eval 'sub NPF_CODE_BPF () {1;}' unless defined(&NPF_CODE_BPF);
    eval 'sub NPF_NATIN () {1;}' unless defined(&NPF_NATIN);
    eval 'sub NPF_NATOUT () {2;}' unless defined(&NPF_NATOUT);
    eval 'sub NPF_NAT_PORTS () {0x1;}' unless defined(&NPF_NAT_PORTS);
    eval 'sub NPF_NAT_PORTMAP () {0x2;}' unless defined(&NPF_NAT_PORTMAP);
    eval 'sub NPF_NAT_STATIC () {0x4;}' unless defined(&NPF_NAT_STATIC);
    eval 'sub NPF_NAT_PRIVMASK () {0xf000000;}' unless defined(&NPF_NAT_PRIVMASK);
    eval 'sub NPF_ALGO_NONE () {0;}' unless defined(&NPF_ALGO_NONE);
    eval 'sub NPF_ALGO_NETMAP () {1;}' unless defined(&NPF_ALGO_NETMAP);
    eval 'sub NPF_ALGO_IPHASH () {2;}' unless defined(&NPF_ALGO_IPHASH);
    eval 'sub NPF_ALGO_RR () {3;}' unless defined(&NPF_ALGO_RR);
    eval 'sub NPF_ALGO_NPT66 () {4;}' unless defined(&NPF_ALGO_NPT66);
    eval 'sub NPF_TABLE_IPSET () {1;}' unless defined(&NPF_TABLE_IPSET);
    eval 'sub NPF_TABLE_LPM () {2;}' unless defined(&NPF_TABLE_LPM);
    eval 'sub NPF_TABLE_CONST () {3;}' unless defined(&NPF_TABLE_CONST);
    eval 'sub NPF_TABLE_IFADDR () {4;}' unless defined(&NPF_TABLE_IFADDR);
    eval 'sub NPF_TABLE_MAXNAMELEN () {32;}' unless defined(&NPF_TABLE_MAXNAMELEN);
    eval 'sub NPF_LAYER_2 () {2;}' unless defined(&NPF_LAYER_2);
    eval 'sub NPF_LAYER_3 () {3;}' unless defined(&NPF_LAYER_3);
    eval 'sub NPF_NTAG_PASS () {0x1;}' unless defined(&NPF_NTAG_PASS);
    eval 'sub NPF_CMD_RULE_ADD () {1;}' unless defined(&NPF_CMD_RULE_ADD);
    eval 'sub NPF_CMD_RULE_INSERT () {2;}' unless defined(&NPF_CMD_RULE_INSERT);
    eval 'sub NPF_CMD_RULE_REMOVE () {3;}' unless defined(&NPF_CMD_RULE_REMOVE);
    eval 'sub NPF_CMD_RULE_REMKEY () {4;}' unless defined(&NPF_CMD_RULE_REMKEY);
    eval 'sub NPF_CMD_RULE_LIST () {5;}' unless defined(&NPF_CMD_RULE_LIST);
    eval 'sub NPF_CMD_RULE_FLUSH () {6;}' unless defined(&NPF_CMD_RULE_FLUSH);
    eval 'sub NPF_CMD_TABLE_LOOKUP () {1;}' unless defined(&NPF_CMD_TABLE_LOOKUP);
    eval 'sub NPF_CMD_TABLE_ADD () {2;}' unless defined(&NPF_CMD_TABLE_ADD);
    eval 'sub NPF_CMD_TABLE_REMOVE () {3;}' unless defined(&NPF_CMD_TABLE_REMOVE);
    eval 'sub NPF_CMD_TABLE_LIST () {4;}' unless defined(&NPF_CMD_TABLE_LIST);
    eval 'sub NPF_CMD_TABLE_FLUSH () {5;}' unless defined(&NPF_CMD_TABLE_FLUSH);
    eval 'sub IOC_NPF_VERSION () { &_IOR(ord(\'N\'), 100, \'int\');}' unless defined(&IOC_NPF_VERSION);
    eval 'sub IOC_NPF_SWITCH () { &_IOW(ord(\'N\'), 101, \'int\');}' unless defined(&IOC_NPF_SWITCH);
    eval 'sub IOC_NPF_LOAD () { &_IOWR(ord(\'N\'), 102,  &nvlist_ref_t);}' unless defined(&IOC_NPF_LOAD);
    eval 'sub IOC_NPF_TABLE () { &_IOW(ord(\'N\'), 103, \'struct npf_ioctl_table\');}' unless defined(&IOC_NPF_TABLE);
    eval 'sub IOC_NPF_STATS () { &_IOW(ord(\'N\'), 104,  &void *);}' unless defined(&IOC_NPF_STATS);
    eval 'sub IOC_NPF_SAVE () { &_IOR(ord(\'N\'), 105,  &nvlist_ref_t);}' unless defined(&IOC_NPF_SAVE);
    eval 'sub IOC_NPF_RULE () { &_IOWR(ord(\'N\'), 107,  &nvlist_ref_t);}' unless defined(&IOC_NPF_RULE);
    eval 'sub IOC_NPF_CONN_LOOKUP () { &_IOWR(ord(\'N\'), 108,  &nvlist_ref_t);}' unless defined(&IOC_NPF_CONN_LOOKUP);
    eval 'sub IOC_NPF_TABLE_REPLACE () { &_IOWR(ord(\'N\'), 109,  &nvlist_ref_t);}' unless defined(&IOC_NPF_TABLE_REPLACE);
    eval("sub NPF_STAT_PASS_DEFAULT () { 0; }") unless defined(&NPF_STAT_PASS_DEFAULT);
    eval("sub NPF_STAT_PASS_RULESET () { 1; }") unless defined(&NPF_STAT_PASS_RULESET);
    eval("sub NPF_STAT_PASS_CONN () { 2; }") unless defined(&NPF_STAT_PASS_CONN);
    eval("sub NPF_STAT_BLOCK_DEFAULT () { 3; }") unless defined(&NPF_STAT_BLOCK_DEFAULT);
    eval("sub NPF_STAT_BLOCK_RULESET () { 4; }") unless defined(&NPF_STAT_BLOCK_RULESET);
    eval("sub NPF_STAT_CONN_CREATE () { 5; }") unless defined(&NPF_STAT_CONN_CREATE);
    eval("sub NPF_STAT_CONN_DESTROY () { 6; }") unless defined(&NPF_STAT_CONN_DESTROY);
    eval("sub NPF_STAT_NAT_CREATE () { 7; }") unless defined(&NPF_STAT_NAT_CREATE);
    eval("sub NPF_STAT_NAT_DESTROY () { 8; }") unless defined(&NPF_STAT_NAT_DESTROY);
    eval("sub NPF_STAT_INVALID_STATE () { 9; }") unless defined(&NPF_STAT_INVALID_STATE);
    eval("sub NPF_STAT_INVALID_STATE_TCP1 () { 10; }") unless defined(&NPF_STAT_INVALID_STATE_TCP1);
    eval("sub NPF_STAT_INVALID_STATE_TCP2 () { 11; }") unless defined(&NPF_STAT_INVALID_STATE_TCP2);
    eval("sub NPF_STAT_INVALID_STATE_TCP3 () { 12; }") unless defined(&NPF_STAT_INVALID_STATE_TCP3);
    eval("sub NPF_STAT_RACE_CONN () { 13; }") unless defined(&NPF_STAT_RACE_CONN);
    eval("sub NPF_STAT_RACE_NAT () { 14; }") unless defined(&NPF_STAT_RACE_NAT);
    eval("sub NPF_STAT_FRAGMENTS () { 15; }") unless defined(&NPF_STAT_FRAGMENTS);
    eval("sub NPF_STAT_REASSEMBLY () { 16; }") unless defined(&NPF_STAT_REASSEMBLY);
    eval("sub NPF_STAT_REASSFAIL () { 17; }") unless defined(&NPF_STAT_REASSFAIL);
    eval("sub NPF_STAT_ERROR () { 18; }") unless defined(&NPF_STAT_ERROR);
    eval("sub NPF_STAT_NBUF_NONCONTIG () { 19; }") unless defined(&NPF_STAT_NBUF_NONCONTIG);
    eval("sub NPF_STAT_NBUF_CONTIG_FAIL () { 20; }") unless defined(&NPF_STAT_NBUF_CONTIG_FAIL);
    eval("sub NPF_STATS_COUNT () { 21; }") unless defined(&NPF_STATS_COUNT);
    eval 'sub NPF_STATS_SIZE () {($sizeof{ &uint64_t} *  &NPF_STATS_COUNT);}' unless defined(&NPF_STATS_SIZE);
}
1;
