require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&__IF_SAN_COMMON_H)) {
    eval 'sub __IF_SAN_COMMON_H () {1;}' unless defined(&__IF_SAN_COMMON_H);
    require 'dev/pci/if_san_te1.ph';
    require 'dev/pci/if_sandrv.ph';
    eval 'sub ADDR_MASK {
        my($x,$y) = @_;
	    eval q((( - 0) & ($y)));
    }' unless defined(&ADDR_MASK);
    eval 'sub WANPIPE_LITE_VERSION () {"1.1.1";}' unless defined(&WANPIPE_LITE_VERSION);
    eval 'sub WAN_OPENBSD_PLATFORM () {0x6;}' unless defined(&WAN_OPENBSD_PLATFORM);
    eval 'sub WAN_PLATFORM_ID () { &WAN_OPENBSD_PLATFORM;}' unless defined(&WAN_PLATFORM_ID);
    eval 'sub WANPIPE_MAGIC () {0x414c4453;}' unless defined(&WANPIPE_MAGIC);
    eval 'sub ROUTER_NAME () {"wanrouter";}' unless defined(&ROUTER_NAME);
    eval 'sub ROUTER_IOCTL () {ord(\'W\');}' unless defined(&ROUTER_IOCTL);
    eval 'sub WANROUTER_MAJOR_VER () {2;}' unless defined(&WANROUTER_MAJOR_VER);
    eval 'sub WANROUTER_MINOR_VER () {1;}' unless defined(&WANROUTER_MINOR_VER);
    eval 'sub WANPIPE_DUMP () { &_IOW( &ROUTER_IOCTL, 16,  &wan_conf_t);}' unless defined(&WANPIPE_DUMP);
    eval 'sub WANPIPE_EXEC () { &_IOWR( &ROUTER_IOCTL, 17,  &wan_conf_t);}' unless defined(&WANPIPE_EXEC);
    eval 'sub SIOC_WANPIPE_PIPEMON () { &_IOWR(ord(\'i\'), 150, \'struct ifreq\');}' unless defined(&SIOC_WANPIPE_PIPEMON);
    eval 'sub SIOC_WANPIPE_DEVICE () { &_IOWR(ord(\'i\'), 151, \'struct ifreq\');}' unless defined(&SIOC_WANPIPE_DEVICE);
    eval 'sub SIOC_WANPIPE_HWPROBE () { &_IOWR(ord(\'i\'), 152, \'struct ifreq\');}' unless defined(&SIOC_WANPIPE_HWPROBE);
    eval 'sub SIOC_WANPIPE_DUMP () { &_IOWR(ord(\'i\'), 153, \'struct ifreq\');}' unless defined(&SIOC_WANPIPE_DUMP);
    eval 'sub WAN_EXTERNAL () {0;}' unless defined(&WAN_EXTERNAL);
    eval 'sub WAN_INTERNAL () {1;}' unless defined(&WAN_INTERNAL);
    eval 'sub WAN_RS232 () {0;}' unless defined(&WAN_RS232);
    eval 'sub WAN_V35 () {1;}' unless defined(&WAN_V35);
    eval 'sub WAN_UDP_FAILED_CMD () {0xcf;}' unless defined(&WAN_UDP_FAILED_CMD);
    eval 'sub WAN_UDP_INVALID_CMD () {0xce;}' unless defined(&WAN_UDP_INVALID_CMD);
    eval 'sub WAN_UDP_TIMEOUT_CMD () {0xaa;}' unless defined(&WAN_UDP_TIMEOUT_CMD);
    eval 'sub WAN_UDP_INVALID_NET_CMD () {0xcd;}' unless defined(&WAN_UDP_INVALID_NET_CMD);
    eval 'sub WAN_NO () {0;}' unless defined(&WAN_NO);
    eval 'sub WAN_YES () {1;}' unless defined(&WAN_YES);
    eval 'sub UDP_PKT_FRM_STACK () {0x;}' unless defined(&UDP_PKT_FRM_STACK);
    eval 'sub UDP_PKT_FRM_NETWORK () {0x1;}' unless defined(&UDP_PKT_FRM_NETWORK);
    eval 'sub WANCONFIG_FR () {102;}' unless defined(&WANCONFIG_FR);
    eval 'sub WANCONFIG_PPP () {103;}' unless defined(&WANCONFIG_PPP);
    eval 'sub WANCONFIG_CHDLC () {104;}' unless defined(&WANCONFIG_CHDLC);
    eval 'sub WANCONFIG_AFT () {117;}' unless defined(&WANCONFIG_AFT);
    eval("sub FE_UNITIALIZED () { 0x00; }") unless defined(&FE_UNITIALIZED);
    eval("sub FE_DISCONNECTED () { 1; }") unless defined(&FE_DISCONNECTED);
    eval("sub FE_CONNECTED () { 2; }") unless defined(&FE_CONNECTED);
    eval("sub WAN_UNCONFIGURED () { 0; }") unless defined(&WAN_UNCONFIGURED);
    eval("sub WAN_DISCONNECTED () { 1; }") unless defined(&WAN_DISCONNECTED);
    eval("sub WAN_CONNECTING () { 2; }") unless defined(&WAN_CONNECTING);
    eval("sub WAN_CONNECTED () { 3; }") unless defined(&WAN_CONNECTED);
    eval("sub WAN_LIMIT () { 4; }") unless defined(&WAN_LIMIT);
    eval("sub WAN_DUALPORT () { 5; }") unless defined(&WAN_DUALPORT);
    eval("sub WAN_DISCONNECTING () { 6; }") unless defined(&WAN_DISCONNECTING);
    eval("sub WAN_FT1_READY () { 7; }") unless defined(&WAN_FT1_READY);
    eval 'sub WAN_MODEM_CTS () {0x1;}' unless defined(&WAN_MODEM_CTS);
    eval 'sub WAN_MODEM_DCD () {0x2;}' unless defined(&WAN_MODEM_DCD);
    eval 'sub WAN_MODEM_DTR () {0x10;}' unless defined(&WAN_MODEM_DTR);
    eval 'sub WAN_MODEM_RTS () {0x20;}' unless defined(&WAN_MODEM_RTS);
    eval 'sub TRACE_ALL () {0x;}' unless defined(&TRACE_ALL);
    eval 'sub TRACE_PROT () {0x1;}' unless defined(&TRACE_PROT);
    eval 'sub TRACE_DATA () {0x2;}' unless defined(&TRACE_DATA);
    eval 'sub UDPMGMT_REQUEST () {0x1;}' unless defined(&UDPMGMT_REQUEST);
    eval 'sub UDPMGMT_REPLY () {0x2;}' unless defined(&UDPMGMT_REPLY);
    eval 'sub UDP_OFFSET () {12;}' unless defined(&UDP_OFFSET);
    eval 'sub MAX_FT1_RETRY () {100;}' unless defined(&MAX_FT1_RETRY);
    eval("sub SEND_CRIT () { 0; }") unless defined(&SEND_CRIT);
    eval("sub PERI_CRIT () { 1; }") unless defined(&PERI_CRIT);
    eval("sub RX_CRIT () { 2; }") unless defined(&RX_CRIT);
    eval("sub PRIV_CRIT () { 3; }") unless defined(&PRIV_CRIT);
    eval 'sub TRC_INCOMING_FRM () {0x;}' unless defined(&TRC_INCOMING_FRM);
    eval 'sub TRC_OUTGOING_FRM () {0x1;}' unless defined(&TRC_OUTGOING_FRM);
    eval 'sub GLOBAL_UDP_SIGNATURE () {"WANPIPE";}' unless defined(&GLOBAL_UDP_SIGNATURE);
    eval 'sub GLOBAL_UDP_SIGNATURE_LEN () {7;}' unless defined(&GLOBAL_UDP_SIGNATURE_LEN);
    eval 'sub UDPMGMT_UDP_PROTOCOL () {0x11;}' unless defined(&UDPMGMT_UDP_PROTOCOL);
    eval 'sub WAN_UDP_CMD_START () {0x60;}' unless defined(&WAN_UDP_CMD_START);
    eval 'sub WAN_GET_PROTOCOL () {( &WAN_UDP_CMD_START+0);}' unless defined(&WAN_GET_PROTOCOL);
    eval 'sub WAN_GET_PLATFORM () {( &WAN_UDP_CMD_START+1);}' unless defined(&WAN_GET_PLATFORM);
    eval 'sub WAN_GET_MEDIA_TYPE () {( &WAN_UDP_CMD_START+2);}' unless defined(&WAN_GET_MEDIA_TYPE);
    eval 'sub WAN_UDP_CMD_END () {0x6f;}' unless defined(&WAN_UDP_CMD_END);
    eval 'sub WAN_FE_CMD_START () {0x90;}' unless defined(&WAN_FE_CMD_START);
    eval 'sub WAN_FE_CMD_END () {0x9f;}' unless defined(&WAN_FE_CMD_END);
    eval 'sub WAN_INTERFACE_CMD_START () {0xa0;}' unless defined(&WAN_INTERFACE_CMD_START);
    eval 'sub WAN_INTERFACE_CMD_END () {0xaf;}' unless defined(&WAN_INTERFACE_CMD_END);
    eval 'sub WAN_FE_UDP_CMD_START () {0xb0;}' unless defined(&WAN_FE_UDP_CMD_START);
    eval 'sub WAN_FE_UDP_CMD_END () {0xbf;}' unless defined(&WAN_FE_UDP_CMD_END);
    eval 'sub wan_udphdr_signature () { ($wan_mgmt->{signature});}' unless defined(&wan_udphdr_signature);
    eval 'sub wan_udphdr_request_reply () { ($wan_mgmt->{request_reply});}' unless defined(&wan_udphdr_request_reply);
    eval 'sub wan_udphdr_id () { ($wan_mgmt->{id});}' unless defined(&wan_udphdr_id);
    eval 'sub wan_udphdr_opp_flag () { ($wan_cmd->{wan_cmd_opp_flag});}' unless defined(&wan_udphdr_opp_flag);
    eval 'sub wan_udphdr_command () { ($wan_cmd->{wan_cmd_command});}' unless defined(&wan_udphdr_command);
    eval 'sub wan_udphdr_data_len () { ($wan_cmd->{wan_cmd_data_len});}' unless defined(&wan_udphdr_data_len);
    eval 'sub wan_udphdr_return_code () { ($wan_cmd->{wan_cmd_return_code});}' unless defined(&wan_udphdr_return_code);
    eval 'sub wan_udphdr_chdlc_num_frames () { ($wan_udphdr_u->{chdlc}->{trace_info}->{num_frames});}' unless defined(&wan_udphdr_chdlc_num_frames);
    eval 'sub wan_udphdr_chdlc_ismoredata () { ($wan_udphdr_u->{chdlc}->{trace_info}->{ismoredata});}' unless defined(&wan_udphdr_chdlc_ismoredata);
    eval 'sub wan_udphdr_chdlc_data () { ($wan_udphdr_u->{chdlc}->{data});}' unless defined(&wan_udphdr_chdlc_data);
    eval 'sub wan_udphdr_aft_num_frames () { ($wan_udphdr_u->{aft}->{trace_info}->{num_frames});}' unless defined(&wan_udphdr_aft_num_frames);
    eval 'sub wan_udphdr_aft_ismoredata () { ($wan_udphdr_u->{aft}->{trace_info}->{ismoredata});}' unless defined(&wan_udphdr_aft_ismoredata);
    eval 'sub wan_udphdr_aft_data () { ($wan_udphdr_u->{aft}->{data});}' unless defined(&wan_udphdr_aft_data);
    eval 'sub wan_udphdr_data () { ($wan_udphdr_u->{data});}' unless defined(&wan_udphdr_data);
    eval 'sub MAX_LGTH_UDP_MGNT_PKT () {2000;}' unless defined(&MAX_LGTH_UDP_MGNT_PKT);
    eval 'sub INTR_TEST_MODE () {0x2;}' unless defined(&INTR_TEST_MODE);
    eval 'sub WUM_SIGNATURE_L () {0x50495046;}' unless defined(&WUM_SIGNATURE_L);
    eval 'sub WUM_SIGNATURE_H () {0x444e3845;}' unless defined(&WUM_SIGNATURE_H);
    eval 'sub WUM_KILL () {0x50;}' unless defined(&WUM_KILL);
    eval 'sub WUM_EXEC () {0x51;}' unless defined(&WUM_EXEC);
    if(defined( &_KERNEL)) {
	eval 'sub MAX_E1_CHANNELS () {32;}' unless defined(&MAX_E1_CHANNELS);
	eval 'sub MAX_FR_CHANNELS () {(991+1);}' unless defined(&MAX_FR_CHANNELS);
	unless(defined(&min)) {
	    eval 'sub min {
	        my($a,$b) = @_;
    		eval q(((($a)<($b))?($a):($b)));
	    }' unless defined(&min);
	}
	unless(defined(&max)) {
	    eval 'sub max {
	        my($a,$b) = @_;
    		eval q(((($a)>($b))?($a):($b)));
	    }' unless defined(&max);
	}
	eval 'sub is_digit {
	    my($ch) = @_;
    	    eval q(((($ch)>=ord(\'0\'&&(ch)<=(unsigned)\'9\'))?1:0));
	}' unless defined(&is_digit);
	eval 'sub is_alpha {
	    my($ch) = @_;
    	    eval q((((($ch)>=ord(\'a\'&&(ch)<=(unsigned)\'z\')||			((ch)>=(unsigned)\'A\'&&(ch)<=(unsigned)\'Z\')))?1:0));
	}' unless defined(&is_alpha);
	eval 'sub is_hex_digit {
	    my($ch) = @_;
    	    eval q((((($ch)>=ord(\'0\'&&(ch)<=(unsigned)\'9\')||			((ch)>=(unsigned)\'a\'&&(ch)<=(unsigned)\'f\')||		((ch)>=(unsigned)\'A\'&&(ch)<=(unsigned)\'F\')))?1:0));
	}' unless defined(&is_hex_digit);
	if(!defined( &offsetof)) {
	    eval 'sub offsetof {
	        my($type, $member) = @_;
    		eval q((((($type*)0)->$member)));
	    }' unless defined(&offsetof);
	}
	eval 'sub irqreturn_t () { &void;}' unless defined(&irqreturn_t);
	eval 'sub WAN_IRQ_RETVAL {
	    my($a) = @_;
    	    eval q( &return;);
	}' unless defined(&WAN_IRQ_RETVAL);
	eval 'sub _bit_byte {
	    my($bit) = @_;
    	    eval q((($bit) >> 3));
	}' unless defined(&_bit_byte);
	eval 'sub _bit_mask {
	    my($bit) = @_;
    	    eval q((1<< (($bit)&0x7)));
	}' unless defined(&_bit_mask);
	eval 'sub bit_test {
	    my($name, $bit) = @_;
    	    eval q((($name)[ &_bit_byte($bit)] &  &_bit_mask($bit)));
	}' unless defined(&bit_test);
	eval 'sub bit_set {
	    my($name, $bit) = @_;
    	    eval q((($name)[ &_bit_byte($bit)] |=  &_bit_mask($bit)));
	}' unless defined(&bit_set);
	eval 'sub bit_clear {
	    my($name, $bit) = @_;
    	    eval q((($name)[ &_bit_byte($bit)] &= ~ &_bit_mask($bit)));
	}' unless defined(&bit_clear);
	eval 'sub SAN_ASSERT {
	    my($a) = @_;
    	    eval q( &if ($a){  &log( &LOG_INFO, \\"%s:%d: Critical Error!\\\\n\\",  &__FUNCTION__, &__LINE__);  &return ( &EINVAL); });
	}' unless defined(&SAN_ASSERT);
	eval 'sub wan_udp_cmd () { ($wan_udp_hdr->{wan_cmd});}' unless defined(&wan_udp_cmd);
	eval 'sub wan_udp_signature () { ($wan_udp_hdr->{wan_udphdr_signature});}' unless defined(&wan_udp_signature);
	eval 'sub wan_udp_request_reply () { ($wan_udp_hdr->{wan_udphdr_request_reply});}' unless defined(&wan_udp_request_reply);
	eval 'sub wan_udp_id () { ($wan_udp_hdr->{wan_udphdr_id});}' unless defined(&wan_udp_id);
	eval 'sub wan_udp_opp_flag () { ($wan_udp_hdr->{wan_udphdr_opp_flag});}' unless defined(&wan_udp_opp_flag);
	eval 'sub wan_udp_command () { ($wan_udp_hdr->{wan_udphdr_command});}' unless defined(&wan_udp_command);
	eval 'sub wan_udp_data_len () { ($wan_udp_hdr->{wan_udphdr_data_len});}' unless defined(&wan_udp_data_len);
	eval 'sub wan_udp_return_code () { ($wan_udp_hdr->{wan_udphdr_return_code});}' unless defined(&wan_udp_return_code);
	eval 'sub wan_udp_hdlc_PF_bit () { ($wan_udp_hdr->{wan_udphdr_hdlc_PF_bit});}' unless defined(&wan_udp_hdlc_PF_bit);
	eval 'sub wan_udp_fr_dlci () { ($wan_udp_hdr->{wan_udphdr_fr_dlci});}' unless defined(&wan_udp_fr_dlci);
	eval 'sub wan_udp_fr_attr () { ($wan_udp_hdr->{wan_udphdr_fr_attr});}' unless defined(&wan_udp_fr_attr);
	eval 'sub wan_udp_fr_rxlost1 () { ($wan_udp_hdr->{wan_udphdr_fr_rxlost1});}' unless defined(&wan_udp_fr_rxlost1);
	eval 'sub wan_udp_fr_rxlost2 () { ($wan_udp_hdr->{wan_udphdr_fr_rxlost2});}' unless defined(&wan_udp_fr_rxlost2);
	eval 'sub wan_udp_chdlc_num_frames () { ($wan_udp_hdr->{wan_udphdr_chdlc_num_frames});}' unless defined(&wan_udp_chdlc_num_frames);
	eval 'sub wan_udp_chdlc_ismoredata () { ($wan_udp_hdr->{wan_udphdr_chdlc_ismoredata});}' unless defined(&wan_udp_chdlc_ismoredata);
	eval 'sub wan_udp_chdlc_data () { ($wan_udp_hdr->{wan_udphdr_chdlc_data});}' unless defined(&wan_udp_chdlc_data);
	eval 'sub wan_udp_aft_num_frames () { ($wan_udp_hdr->{wan_udphdr_aft_num_frames});}' unless defined(&wan_udp_aft_num_frames);
	eval 'sub wan_udp_aft_ismoredata () { ($wan_udp_hdr->{wan_udphdr_aft_ismoredata});}' unless defined(&wan_udp_aft_ismoredata);
	eval 'sub wan_udp_data () { ($wan_udp_hdr->{wan_udphdr_data});}' unless defined(&wan_udp_data);
	eval 'sub WAN_IFP_TO_COMMON {
	    my($ifp) = @_;
    	    eval q(( &wanpipe_common_t*)(($ifp)-> &if_softc));
	}' unless defined(&WAN_IFP_TO_COMMON);
	eval 'sub fe_te () { ($u_fe->{te_sc});}' unless defined(&fe_te);
    }
}
1;
