require '_h2ph_pre.ph';

unless(defined(&_NETISO_TP_PCB_H_)) {
    eval 'sub _NETISO_TP_PCB_H_ () {1;}' unless defined(&_NETISO_TP_PCB_H_);
    require 'netiso/tp_param.ph';
    require 'netiso/tp_timer.ph';
    require 'netiso/tp_user.ph';
    unless(defined(&sblock)) {
	require 'sys/socketvar.ph';
    }
    eval 'sub REF_FROZEN () {3;}' unless defined(&REF_FROZEN);
    eval 'sub REF_OPEN () {2;}' unless defined(&REF_OPEN);
    eval 'sub REF_OPENING () {1;}' unless defined(&REF_OPENING);
    eval 'sub REF_FREE () {0;}' unless defined(&REF_FREE);
    eval 'sub TM_NTIMERS () {6;}' unless defined(&TM_NTIMERS);
    eval 'sub tp_Nretrans () { ($_tp_param->{p_Nretrans});}' unless defined(&tp_Nretrans);
    eval 'sub tp_dr_ticks () { ($_tp_param->{p_dr_ticks});}' unless defined(&tp_dr_ticks);
    eval 'sub tp_cc_ticks () { ($_tp_param->{p_cc_ticks});}' unless defined(&tp_cc_ticks);
    eval 'sub tp_dt_ticks () { ($_tp_param->{p_dt_ticks});}' unless defined(&tp_dt_ticks);
    eval 'sub tp_xpd_ticks () { ($_tp_param->{p_x_ticks});}' unless defined(&tp_xpd_ticks);
    eval 'sub tp_cr_ticks () { ($_tp_param->{p_cr_ticks});}' unless defined(&tp_cr_ticks);
    eval 'sub tp_keepalive_ticks () { ($_tp_param->{p_keepalive_ticks});}' unless defined(&tp_keepalive_ticks);
    eval 'sub tp_sendack_ticks () { ($_tp_param->{p_sendack_ticks});}' unless defined(&tp_sendack_ticks);
    eval 'sub tp_refer_ticks () { ($_tp_param->{p_ref_ticks});}' unless defined(&tp_refer_ticks);
    eval 'sub tp_inact_ticks () { ($_tp_param->{p_inact_ticks});}' unless defined(&tp_inact_ticks);
    eval 'sub tp_xtd_format () { ($_tp_param->{p_xtd_format});}' unless defined(&tp_xtd_format);
    eval 'sub tp_xpd_service () { ($_tp_param->{p_xpd_service});}' unless defined(&tp_xpd_service);
    eval 'sub tp_ack_strat () { ($_tp_param->{p_ack_strat});}' unless defined(&tp_ack_strat);
    eval 'sub tp_rx_strat () { ($_tp_param->{p_rx_strat});}' unless defined(&tp_rx_strat);
    eval 'sub tp_use_checksum () { ($_tp_param->{p_use_checksum});}' unless defined(&tp_use_checksum);
    eval 'sub tp_use_efc () { ($_tp_param->{p_use_efc});}' unless defined(&tp_use_efc);
    eval 'sub tp_use_nxpd () { ($_tp_param->{p_use_nxpd});}' unless defined(&tp_use_nxpd);
    eval 'sub tp_use_rcc () { ($_tp_param->{p_use_rcc});}' unless defined(&tp_use_rcc);
    eval 'sub tp_tpdusize () { ($_tp_param->{p_tpdusize});}' unless defined(&tp_tpdusize);
    eval 'sub tp_class () { ($_tp_param->{p_class});}' unless defined(&tp_class);
    eval 'sub tp_winsize () { ($_tp_param->{p_winsize});}' unless defined(&tp_winsize);
    eval 'sub tp_no_disc_indications () { ($_tp_param->{p_no_disc_indications});}' unless defined(&tp_no_disc_indications);
    eval 'sub tp_dont_change_params () { ($_tp_param->{p_dont_change_params});}' unless defined(&tp_dont_change_params);
    eval 'sub tp_netservice () { ($_tp_param->{p_netservice});}' unless defined(&tp_netservice);
    eval 'sub tp_version () { ($_tp_param->{p_version});}' unless defined(&tp_version);
    eval 'sub tp_ptpdusize () { ($_tp_param->{p_ptpdusize});}' unless defined(&tp_ptpdusize);
    eval 'sub TPF_NLQOS_PDN () { &TPFLAG_NLQOS_PDN;}' unless defined(&TPF_NLQOS_PDN);
    eval 'sub TPF_PEER_ON_SAMENET () { &TPFLAG_PEER_ON_SAMENET;}' unless defined(&TPF_PEER_ON_SAMENET);
    eval 'sub TPF_GENERAL_ADDR () { &TPFLAG_GENERAL_ADDR;}' unless defined(&TPF_GENERAL_ADDR);
    eval 'sub TPF_DELACK () {0x8;}' unless defined(&TPF_DELACK);
    eval 'sub TPF_ACKNOW () {0x10;}' unless defined(&TPF_ACKNOW);
    eval 'sub PEER_IS_LOCAL {
        local($t) = @_;
	    eval q(((($t)-> &tp_flags &  &TPF_PEER_ON_SAME_NET) != 0));
    }' unless defined(&PEER_IS_LOCAL);
    eval 'sub USES_PDN {
        local($t) = @_;
	    eval q(((($t)-> &tp_flags &  &TPF_NLQOS_PDN) != 0));
    }' unless defined(&USES_PDN);
    if(defined(&TP_PERF_MEAS)) {
    }
    eval 'sub SHORT_LSUFXP {
        local($tpcb) = @_;
	    eval q(((($tpcb)-> &tp_lsuffix)));
    }' unless defined(&SHORT_LSUFXP);
    eval 'sub SHORT_FSUFXP {
        local($tpcb) = @_;
	    eval q(((($tpcb)-> &tp_fsuffix)));
    }' unless defined(&SHORT_FSUFXP);
    if(0) {
    } else {
	eval 'sub tp_Xrcv () { ($tp_sock->{so_rcv});}' unless defined(&tp_Xrcv);
    }
    eval 'sub ROUND {
        local($scaled_int) = @_;
	    eval q(((($scaled_int) >> 8) + ((($scaled_int) & 0x80) ? 1:0)));
    }' unless defined(&ROUND);
    eval 'sub CONG_INIT_SAMPLE {
        local($pcb) = @_;
	    eval q( ($pcb->{tp_cong_sample}->{cs_received}) =  ($pcb->{tp_cong_sample}->{cs_ce_set}) = 0;  ($pcb->{tp_cong_sample}->{cs_size}) =  &max( ($pcb->{tp_lcredit}), 1) << 1;);
    }' unless defined(&CONG_INIT_SAMPLE);
    eval 'sub CONG_UPDATE_SAMPLE {
        local($pcb, $ce_bit) = @_;
	    eval q( ($pcb->{tp_cong_sample}->{cs_received})++;  &if ($ce_bit) {  ($pcb->{tp_cong_sample}->{cs_ce_set})++; }  &if ( ($pcb->{tp_cong_sample}->{cs_size}) <=  ($pcb->{tp_cong_sample}->{cs_received})) {  &if (( ($pcb->{tp_cong_sample}->{cs_ce_set}) << 1) >=  ($pcb->{tp_cong_sample}->{cs_size}) ) {  ($pcb->{tp_win_recv}) -=  ($pcb->{tp_win_recv}) >> 3;  ($pcb->{tp_win_recv}) =  &max(1<< 8,  ($pcb->{tp_win_recv})); }  &else {  ($pcb->{tp_win_recv}) += (1<< 8); }  ($pcb->{tp_lcredit}) =  &ROUND( ($pcb->{tp_win_recv}));  &CONG_INIT_SAMPLE($pcb); });
    }' unless defined(&CONG_UPDATE_SAMPLE);
    if(defined(&_KERNEL)) {
    }
    eval 'sub sototpcb {
        local($so) = @_;
	    eval q((( ($so->{so_pcb}))));
    }' unless defined(&sototpcb);
    eval 'sub sototpref {
        local($so) = @_;
	    eval q((( &sototpcb($so)-> &tp_ref)));
    }' unless defined(&sototpref);
    eval 'sub tpcbtoso {
        local($tp) = @_;
	    eval q(((($tp)-> &tp_sock)));
    }' unless defined(&tpcbtoso);
    eval 'sub tpcbtoref {
        local($tp) = @_;
	    eval q(((($tp)-> &tp_ref)));
    }' unless defined(&tpcbtoref);
}
1;
