#include "nb30.h--"

struct _ASTAT_
{
	ADAPTER_STATUS adapt;
	NAME_BUFFER    NameBuff[30];
}Adapter;

dword busygetmac=FALSE;

:word SWAPWORD(AX)
{
	AL><AH;
}

void GetMAC(dword ip,mac)
{
NCB ncb;
	busygetmac=TRUE;
	ncb=0;
	ncb.ncb_command=NCBRESET;
	Netbios(#ncb);
	wsprintf(#ncb.ncb_callname,"%d.%d.%d.%d",SSBYTE[#ip],SSBYTE[#ip+1],SSBYTE[#ip+2],SSBYTE[#ip+3]);
	ncb.ncb_command=NCBASTAT;
	Adapter=0;
	ncb.ncb_buffer=#Adapter;
	ncb.ncb_length=sizeof(Adapter);
	Netbios(#ncb);
	DSWORD[mac]=@SWAPWORD(DSWORD[#Adapter.adapt.adapter_address]);
	DSWORD[mac+2]=@SWAPWORD(DSWORD[#Adapter.adapt.adapter_address+2]);
	DSWORD[mac+4]=@SWAPWORD(DSWORD[#Adapter.adapt.adapter_address+4]);
	busygetmac=FALSE;
}
