require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_NETATALK_AT_VAR_H_)) {
    eval 'sub _NETATALK_AT_VAR_H_ () {1;}' unless defined(&_NETATALK_AT_VAR_H_);
    require 'sys/callout.ph';
    eval 'sub aa_ifp () { ($aa_ifa->{ifa_ifp});}' unless defined(&aa_ifp);
    eval 'sub aa_dstaddr () { &aa_broadaddr;;}' unless defined(&aa_dstaddr);
    eval 'sub ifra_dstaddr () { &ifra_broadaddr;}' unless defined(&ifra_dstaddr);
    eval 'sub AA_SAT {
        my($aa) = @_;
	    eval q((( ($aa->{aa_addr}))));
    }' unless defined(&AA_SAT);
    eval 'sub satosat {
        my($sa) = @_;
	    eval q((($sa)));
    }' unless defined(&satosat);
    eval 'sub satocsat {
        my($sa) = @_;
	    eval q((( &const \'struct sockaddr_at\' *)($sa)));
    }' unless defined(&satocsat);
    eval 'sub AFA_ROUTE () {0x1;}' unless defined(&AFA_ROUTE);
    eval 'sub AFA_PROBING () {0x2;}' unless defined(&AFA_PROBING);
    eval 'sub AFA_PHASE2 () {0x4;}' unless defined(&AFA_PHASE2);
    if(defined(&_KERNEL)) {
	require 'net/pktqueue.ph';
	eval 'sub sockaddr_at_init1 {
	    my($sat,$addr,$port) = @_;
    	    eval q({  ($sat->{sat_port}) = $port;  ($sat->{sat_addr}) = *$addr; });
	}' unless defined(&sockaddr_at_init1);
	eval 'sub sockaddr_at_init {
	    my($sat,$addr,$port) = @_;
    	    eval q({  &memset($sat, 0, $sizeof{$sat});  ($sat->{sat_family}) =  &AF_APPLETALK;  ($sat->{sat_len}) = $sizeof{$sat};  &sockaddr_at_init1($sat, $addr, $port); });
	}' unless defined(&sockaddr_at_init);
	eval 'sub sockaddr_at_alloc {
	    my($addr,$port,$flags) = @_;
    	    eval q({ \'struct sockaddr\' * &sa;  &sa =  &sockaddr_alloc( &AF_APPLETALK, $sizeof{\'struct sockaddr_at\'}, $flags |  &M_ZERO);  &if ( &sa ==  &NULL)  &NULL;  &sockaddr_at_init1( &satosat( &sa), $addr, $port);  &sa; });
	}' unless defined(&sockaddr_at_alloc);
    }
}
1;
