//************************************************
//            Global Functions
//************************************************

// Reads MAC addresses and prints them into string "string"
ARRAY string;
DWORD PrintMAC(DWORD offset)
{
BYTE temp_high;
BYTE temp_low;
BYTE i;

	for (i=0; i<3; i=i+1)
	{
		temp_high= CONV(offset+i) && 0xF0;
		temp_high= temp_high>>4;
		temp_low= CONV(offset+i) && 0x0F;
		if (temp_high < 10) string[i*2] = temp_high+ '0';
		else string[i*2] = temp_high+ 'A'-10;
		if (temp_low < 10) string[i*2+1] = temp_low+ '0';
		else string[i*2+1] = temp_low+ 'A'-10;
	}
	string[6]= '-';

	for (i=3; i<6; i=i+1)
	{
		temp_high= CONV(offset+i) && 0xF0;
		temp_high= temp_high>>4;
		temp_low= CONV(offset+i) && 0x0F;
		if (temp_high < 10) string[i*2+1] = temp_high+ '0';
		else string[i*2+1] = temp_high+ 'A'-10;
		if (temp_low < 10) string[i*2+2] = temp_low+ '0';
		else string[i*2+2] = temp_low+ 'A'-10;
	}
	string[13]= 0;
}

//************************************************
//            Packet Functions
//************************************************

DWORD Main()
{
	title("Packet Details");
	title("General Information");

	printf("Item number %u, position in dumpfile %u%%",GetVMVar ("ItemNumber"),GetVMVar ("Position")); 

	DWORD type;
	type=GetVMVar ("FrameType");

	if (type==1) printf("Item type: Time stamp & statistical information");
	if (type==128) printf( "Item type: Frame trace, %u bytes available", GetVMVar ("FrameAvail"));
	if (type==129) printf( "Item type: Minimal Frame, %u bytes available", GetVMVar ("FrameAvail"));
// Fulvio NON capisco; sembra che mi stampi sempre "partial frame" anche se il pkt e' catturato per intero
	if (type==130) printf( "Item type: Partial frame, %u bytes available", GetVMVar ("FrameAvail"));
	if (type==131) printf( "Item type: Whole frame, %u bytes available", GetVMVar ("FrameAvail"));

	printf( "Frame size is %u (%Xx) bytes",GetVMVar ("FrameSize"),GetVMVar ("FrameSize"));

	if (GetVmVar("FrameSecs")==0) printf("Timestamp: 00h:00m:00s:%06dus",GetVMVar ("FrameUSecs"));
	else
		printf( "Timestamp: %02dh:%02dm:%02ds:%06dus",(GetVMVar ("FrameSecs")%86400)/3600+2,
			(GetVMVar ("FrameSecs")%3600)/60,GetVMVar ("FrameSecs")%60,GetVMVar ("FrameUSecs"));
}

DWORD DATA()
	 {
	  DWORD s,t;
	  s=GetVMVar ("SizeNotInt");
	  t=GetVMVar ("FrameSize");
	  if (s)
	  {
	  printf("----- Data ----- [%d-%d]",t-s,t-1);
	  printf( "[%u byte(s) of data]",s);
	  }
	 }

DWORD HI_DATA()
	 {
	  DWORD s,t;
	  s=GetVMVar ("SizeNotInt");
	  t=GetVMVar ("FrameSize");
	  if (s)
		printf( " [%u byte(s) of data] - [%d-%d]",s,t-s,t-1);
	 }

DWORD UNSUPPORTED()
	 {
	  DWORD s,t;
	  s=GetVMVar ("SizeNotInt");
	  t=GetVMVar ("FrameSize");
	  if (s)
	  {
	  printf("----- NOT SUPPORTED ----- [%d-%d]",t-s,t-1);
	  printf( "[%u byte(s) of data]",s);
	  }
	 }

DWORD OPTIONS_NS()
	 {
	  DWORD s,t;
	  s=GetVMVar ("SizeNotInt");
	  t=GetVMVar ("FrameSize");
	  if (s)
	  {
	  printf("----- Option not supported ----- [%d-%d]",t-s,t-1);
	  printf( "[%u byte(s) of data]",s);
	  }
	 }

DWORD ICMPDATA ()
{
	DATA();
}

DWORD Stat()
{	
	title ("Statistical Information");
	printf("Written frames since last statistical report: %u",GetVmVar("Written"));
	printf("Discarded frames since last statistical report: %u",GetVmVar("Discarded"));
}


DWORD MAC ()
{
	return 0;
}


//***************** Token Ring *********************
// Courtesy of Dale C. Schultz, D.Schultz@telesat.ca, Nov 5th, 1999

DWORD TRINGMAC ()
{
    // Token Ring analysis
    title( "Token Ring Header");
    // Access Control
    if(AccCtrl & 0x10)
	{
	printf( "Access Control - Data Frame: %02Xh",AccCtrl);
		ResetLog(offsetof(AccCtrl),offsetof(AccCtrl)+1,1);
		printf( " %3b. .... = priority %u",AccCtrl>>5,AccCtrl>>5);
		ResetLog(offsetof(AccCtrl),offsetof(AccCtrl)+1,1);
		if(AccCtrl & 0x10)
			printf( " ...1 .... = frame contains data");
		else
			printf( " ...0 .... = frame is a free token");
		ResetLog(offsetof(AccCtrl),offsetof(AccCtrl)+1,1);
		if(AccCtrl & 0x08)
			printf( " .... 1... = set by Active Monitor");
		else
			printf( " .... 0... = sent by ring station");
	}
    else
	{
	printf( "Access Control - Free Token: %02Xh",AccCtrl);
		ResetLog(offsetof(AccCtrl),offsetof(AccCtrl)+1,1);
		printf( " %3b. .... = priority %u",AccCtrl>>5,AccCtrl>>5);
		ResetLog(offsetof(AccCtrl),offsetof(AccCtrl)+1,1);
		if(AccCtrl & 0x10)
			printf( " ...1 .... = frame contains data");
		else
			printf( " ...0 .... = frame is a free token");
		ResetLog(offsetof(AccCtrl),offsetof(AccCtrl)+1,1);
		if(AccCtrl & 0x08)
			printf( " .... 1... = set by Active Monitor");
		else
			printf( " .... 0... = sent by ring station");
    }
    if(FrmCtrl & 0x40)
	{
	printf( "Frame Control - LLC Frame: %02Xh",FrmCtrl);
		ResetLog(offsetof(FrmCtrl),offsetof(FrmCtrl)+1,1);
		printf( " %2b.. .... = LLC Frame",FrmCtrl>>6);
		ResetLog(offsetof(FrmCtrl),offsetof(FrmCtrl)+1,1);
		printf( " ..%2b %4b = not used",(FrmCtrl&&0x30)>>4,(FrmCtrl&&0x0F));
	}
    else
	{
	printf( "Frame Control - MAC Frame: %02Xh",FrmCtrl);
		ResetLog(offsetof(FrmCtrl),offsetof(FrmCtrl)+1,1);
		printf( " %2b.. .... = MAC Frame",FrmCtrl>>6);
		ResetLog(offsetof(FrmCtrl),offsetof(FrmCtrl)+1,1);
		if((FrmCtrl & 0x07)==0x00)
			printf( " ..00 0000 = normal buffered");	
		if((FrmCtrl & 0x07)==0x01)
			printf( " ..00 0001 = express buffered");
		if((FrmCtrl & 0x07)==0x02)
			printf( " ..00 0010 = beacon");
		if((FrmCtrl & 0x07)==0x03)
			printf( " ..00 0011 = claim token");
		if((FrmCtrl & 0x07)==0x04)
			printf( " ..00 0100 = ring purge");
		if((FrmCtrl & 0x07)==0x05)
			printf( " ..00 0101 = active monitor present - AMP");
		if((FrmCtrl & 0x07)==0x06)
			printf( " ..00 0110 = standby monitor present - SMP");
		else
			printf( " ..xx xxxx = not supported");
	}

    // destination address analysis
    if(DS1 & 0x1000)
	if(DS1==0xffff && DS2==0xffff && DS3==0xffff)
	    printf( "Destination = Broadcast %04X%02X-%02X%04X",DS1,DS2>>8,DS2&0xFF,DS3);
	else
	{
	    //multicast
	    if(DS1 & 0x4000)
		printf( "Destination = Multicast %04X%02X-%02X%04X (Local; Type: %m)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
	    else
		printf( "Destination = Multicast %04X%02X-%02X%04X (Universal; Type: %m)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
	}
    else
	// direct
	if(DS1 & 0x4000)
	    printf( "Destination = Computer %04X%02X-%02X%04X (Local; Vendor: %v)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
	else
	    printf( "Destination = Computer %04X%02X-%02X%04X (Universal; Vendor: %v)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
    //Source address analysis
    if(SS1 & 0x4000)
	printf( "Source = Computer %04X%02X-%02X%04X (Local; Vendor: %v)",
	    SS1,SS2>>8,SS2&0xFF,SS3,offsetof(SS1));
    else
	printf( "Source = Computer %04X%02X-%02X%04X (Universal; Vendor: %v)",
	    SS1,SS2>>8,SS2&0xFF,SS3,offsetof(SS1));
}

DWORD VECTORS ()
{
    title( "Vector analysis");
	printf("Major Vector Length: %u bytes",MVL);
	printf("Major Vector Identifier: %u",MVID);
}

// DCS: New RIF display formats
DWORD RIF ()
{
    title( "Routing Information analysis");
    printf( "Routing Control: %04Xh (Length = %u bytes)",RCI,(RCI&&0x1F00)>>8);
    ResetLog(offsetof(RCI),offsetof(RCI)+1,1);
    if((RCI &&0x1F00)==0x0200)
    {
	ResetLog(offsetof(RCI),offsetof(RCI)+1,1);
	if((RCI && 0xC000)<=0x4000)
		printf( " %3b. .... .... .... = non-broadcast",RCI>>13);
	if((RCI && 0xC000)==0x8000)
		printf( " %3b. .... .... .... = all-routes broadcast",RCI>>13);
	if((RCI && 0xC000)==0xC000)
		printf( " %3b. .... .... .... = single-route broadcast",RCI>>13);
	else
		printf( " %3b. .... .... .... = not defined",RCI>>13);
	ResetLog(offsetof(RCI),offsetof(RCI)+1,1);
	printf( " ...%1b %4b .... .... = routing information length (%u bytes)",(RCI&&0x1000)>>12,(RCI&&0x0F00)>>8,(RCI&&0x1F00)>>8);
	ResetLog(offsetof(RCI),offsetof(RCI)+2,1);
	if(RCI && 0x0080)
		printf( " .... .... %1b... .... = destination to sender",(RCI&&0x0080)>>7);
	else
		printf( " .... .... %1b... .... = sender to destination",(RCI&&0x0080)>>7);
	ResetLog(offsetof(RCI),offsetof(RCI)+2,1);
	if((RCI && 0x007E)<0x0010)
		printf( " .... .... .%3b %3b. = largest frame size = 516 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0020)
		printf( " .... .... .%3b %3b. = largest frame size = 1500 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0030)
		printf( " .... .... .%3b %3b. = largest frame size = 2052 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0040)
		printf( " .... .... .%3b %3b. = largest frame size = 4472 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0050)
		printf( " .... .... .%3b %3b. = largest frame size = 8144 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0060)
		printf( " .... .... .%3b %3b. = largest frame size = 11407 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0070)
		printf( " .... .... .%3b %3b. = largest frame size = 17800 bytes",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	if((RCI && 0x007E)<0x0080)
		printf( " .... .... .%3b %3b. = largest frame size = default",(RCI&&0x0070)>>4,(RCI&&0x000E)>>1);
	ResetLog(offsetof(RCI),offsetof(RCI)+2,1);
	printf( " .... .... .... ...%1b = reserved",(RCI&&0x0001));
    }
    else
	printf( " can not analyze RIF of  %u bytes)",(RCI&&0x1F00)>>8);
}

// End Token Ring




DWORD ETHERMAC ()
{
    // MAC analysis
    if (LEN_TYPE<=1500) title( "IEEE 802.3 MAC Header");
    else title("Ethernet v.2.0 MAC Header");

// Fulvio: if you want to print the whole MAC address
//	PrintMAC(GetVmVar("SizeInt"));
//	aprintf("%s", string);

    //destination address analysis
    if((DS1 & 0x0100)>0)
	if(DS1==0xffff && DS2==0xffff && DS3==0xffff)
	    printf( "Destination = Broadcast %04X%02X-%02X%04X",DS1,DS2>>8,DS2&0xFF,DS3);
	else
	{
	    //multicast
	    if((DS1 & 0x0200)>0)
		printf( "Destination = Multicast %04X%02X-%02X%04X (Local; Type: %m)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
	    else
		printf( "Destination = Multicast %04X%02X-%02X%04X (Universal; Type: %m)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
	}
    else
	// direct
	if((DS1 & 0x0200)>0)
	    printf( "Destination = Computer %04X%02X-%02X%04X (Local; Vendor: %v)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
	else
	    printf( "Destination = Computer %04X%02X-%02X%04X (Universal; Vendor: %v)",
		    DS1,DS2>>8,DS2&0xFF,DS3,offsetof(DS1));
    
	//source address analysis
    if((SS1 & 0x0200)>0)
	printf( "Source = Computer %04X%02X-%02X%04X (Local; Vendor: %v)",
	    SS1,SS2>>8,SS2&0xFF,SS3,offsetof(SS1));
    else
	printf( "Source = Computer %04X%02X-%02X%04X (Universal; Vendor: %v)",
	    SS1,SS2>>8,SS2&0xFF,SS3,offsetof(SS1));
    
	if (LEN_TYPE<=1500) {		// IEEE 802.3 format
		DWORD padding;
		printf( "Packet Length = %u bytes",LEN_TYPE);
		padding=GetVMVar ("FrameSize")-(LEN_TYPE+14);
		if(padding!=0)printf("Padding bytes %u (before data)",padding);
		}
	else				// Ethernet format (DIX)
		printf( "Ethertype = %04Xh (%p)",LEN_TYPE,offsetof(LEN_TYPE));

}
DWORD MACUNSUPP()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt"));
}
DWORD MACTYPEUNSUPP()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt"));
}	
DWORD LLC_ATM ()
{
    // MAC analysis
    title( "MAC Header (Not Available)");
}

DWORD LLC_IPX ()
{
	if (PCHECK == 65535) printf("IPX on 802.3");
}

DWORD LOOPBACK()
{
  title("Configuration Test Protocol");
  if (OpCode == 0x01) printf("Command 0x%X Request", OpCode);
  else if (OpCode == 0x02) printf("Command 0x%X Response", OpCode);
}

DWORD LLC ()
{
    //continues analysis of a IEEE 802.3 frame with the LLC level
    title( "LLC Header");
    printf( "DSAP = %02Xh (%l)",DSAP,offsetof(DSAP));
    printf( "SSAP = %02Xh (%l)",SSAP,offsetof(SSAP));
    //analysing control field
	if (CONTROL == 0x03)
	{
	    //Unnumbered frame
	    printf( "Unnumbered Frame");
	}
	else if (CONTROL & 0x01)
	{
	    //Supervisory frame
	    if (CONTROL == 0x05) printf("Supervisory Frame, RNR");
	    else if (CONTROL == 0x09) printf("Supervisory Frame, REJ");
	    else printf("Supervisory Frame, RR");
	}
	else 
	{
	    //Information frame
	    printf( "Information Frame, N(S)=%u", CONTROL >> 1);
	}
}
DWORD LLC_CTRL_NETBEUI()
{
	printf("N(R)=%u", CONTROL2 >> 1);
}
DWORD CTRL_NETBEUI_PAD()
{
	printf("N(R)=%u", CONTROL2 >> 1);
}

DWORD SNAP ()
{
 // SNAP frame
 TITLE( "SNAP Header");
 printf( "Vendor ID = %04X%02X (%v)",OUI,OUI2,offsetof(OUI));
 printf( "Type = %04Xh (%p)",PType,offsetof(PType));
}

DWORD IP4_6 ()
{
	return 0;
}

DWORD IP ()
{
    //IP packet Interpretation
    if(Version!=4) return -1;
    title( "IPv4 Header");
    ResetLog(offsetof(vlen),offsetof(vlen)+1,1);
    printf( "Version = %u",Version);
    ResetLog(offsetof(vlen),offsetof(vlen)+1,1);
    printf( "Header length = %u bytes",HLEN*4);
    printf( "Type of service = %02Xh",TOS);
    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
    // Completed by courtesy of J.-C. Hasler (swisscom Inc.) Jean-Claude.Hasler@swisscom.com, Dec 11th, 2000
    {
    if(TOS & 0x20)
	{
	if(TOS & 0x40)
		{
		if(TOS & 0x80)
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %uL: network control",TOS>>5,TOS>>5);
			}
		else
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: flash",TOS>>5,TOS>>5);
			}
		}
	else
		{
		if(TOS & 0x80)
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: CRITIC / ECP",TOS>>5,TOS>>5);
			}
		else
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: priority",TOS>>5,TOS>>5);
			}
		}
	}
    else
	{
	if(TOS & 0x40)
		{
		if(TOS & 0x80)
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: internetwork control",TOS>>5,TOS>>5);
			}
		else
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: immediate",TOS>>5,TOS>>5);
			}
		}
	else
		{
		if(TOS & 0x80)
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: flash override",TOS>>5,TOS>>5);
			}
		else
			{
			ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
			printf( " %3b. .... = priority %u: routine",TOS>>5,TOS>>5);
			}
		}
	}
    }
//    printf( " %3b.  . . . . = priority %u (see below)",TOS>>5,TOS>>5);
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 0 = routine");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 1 = priority");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 2 = immediate");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 3 = flash");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 4 = flash override");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 5 = CRITIC / ECP");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 6 = internetwork control");
//    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
//    printf( "                     priority 7 = network control");

    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
    if(TOS&0x10)
	printf( " ...1 .... = low delay");
    else
	printf( " ...0 .... = normal delay");
    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
    if(TOS & 0x08)
	printf( " .... 1... = high throughput");
    else
	printf( " .... 0... = normal throughput");
    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
    if(TOS & 0x04)
	printf( " .... .1.. = high reliability");
    else
	printf( " .... .0.. = normal reliability");
    ResetLog(offsetof(TOS),offsetof(TOS)+1,1);

    if(TOS & 0x02)
                {
	printf( " ....  ..1. = low monetary cost");
                ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
                printf( " .... ...0 = Reserved bit, for future usage, which has to be 0");
                }
    else
                {
			printf( " .... ..0. = normal monetary cost");
                ResetLog(offsetof(TOS),offsetof(TOS)+1,1);
                printf( " .... ...0 = Reserved bit, for future usage, which has to be 0");
                }

    printf( "Total length = %u bytes",TLen);
    printf( "Identification = %u", Identification);
    ResetLog(offsetof(Flags),offsetof(Flags)+1,1);
//FULVIO FLAGS: we should make and AND before presenting the result (flags are 3 bits only)
    printf( "Flags = %01Xh",Flags);
    ResetLog(offsetof(Flags),offsetof(Flags)+1,1);
    if(Flags&0x8)
	printf( " 1... .... = error: must be 0");
    else
	printf( " 0... .... = must be 0");
    ResetLog(offsetof(Flags),offsetof(Flags)+1,1);
    if(Flags&0x4)
	printf( " .1.. .... = do not fragment");
    else
	printf( " .0.. .... = may fragment");
    ResetLog(offsetof(Flags),offsetof(Flags)+1,1);
    if(Flags&0x2)
	printf( " ..1. .... = more fragment");
    else
	printf( " ..0. .... = last fragment");

    //FULVIO we should make an AND for the fragment offset as well
    ResetLog(offsetof(FragmentOffset),offsetof(FragmentOffset)+2,2);
    printf( "Fragment offset = %u bytes",FragmentOffset*8);
    printf( "Time to live = %u seconds/hops",TTL);
    printf( "Protocol = %u (%i)",NextProtocol,offsetof(NextProtocol));
    printf( "Header checksum = %04Xh",HCHECKSUM);

    printf( "Source address = [%u.%u.%u.%u]",SAddress>>24&0xFF,SAddress>>16&0xFF,
			SAddress>>8&0xFF,SAddress&0xFF);

    if (DAddress == 0xE0000005) printf( "Destination address = [%u.%u.%u.%u] Multicast OSPF for All Routers",
			DAddress>>24&0xFF,DAddress>>16&0xFF,DAddress>>8&0xFF,DAddress&0xFF);
    else if (DAddress == 0xE0000006)printf( "Destination address = [%u.%u.%u.%u] Multicast OSPF Designated and Backup Router",
			DAddress>>24&0xFF,DAddress>>16&0xFF,DAddress>>8&0xFF,DAddress&0xFF);
    else if (DAddress == 0xE0000009)printf( "Destination address = [%u.%u.%u.%u] Multicast RIP Router",
			DAddress>>24&0xFF,DAddress>>16&0xFF,DAddress>>8&0xFF,DAddress&0xFF);
    else if (DAddress == 0xE000000A)printf( "Destination address = [%u.%u.%u.%u] Multicast IGRP/EIGRP Router",
			DAddress>>24&0xFF,DAddress>>16&0xFF,DAddress>>8&0xFF,DAddress&0xFF);
    else printf( "Destination address = [%u.%u.%u.%u]",
			DAddress>>24&0xFF,DAddress>>16&0xFF,DAddress>>8&0xFF,DAddress&0xFF);


	ResetLog();

	if(HLEN>20) printf( "Options = %u bytes",HLEN-20);
	else printf( "No IP options");
}



//IP6 packet Interpretation
DWORD IP6 ()
{
    title( "IP v6 Header");
    resetlog(offsetof(Version),offsetof(Version)+1);
    printf( "Version = %u",Version);
    resetlog(offsetof(Version),offsetof(Version)+2);
    printf( "Priority = %08b",Priority);
    resetlog(offsetof(Version)+1,offsetof(Version)+4);
    printf("Flow Label = %05Xh",FlowLabel);
    printf( "Payload Lenght = %u",PayloadLen);
    printf( "Next Header = %u",NextHeader);
    printf( "Hop limit = %u",HopLimit);
    printf( "Source Address = %04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"
      ,SA1,SA2,SA3,SA4,SA5,SA6,SA7,SA8);
    printf( "Destination Address = %04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"
      ,DA1,DA2,DA3,DA4,DA5,DA6,DA7,DA8);
}

DWORD HBH ()
{
    title( "Hop By Hop option header" );
    printf( "Next Header = %u" ,NextHeader);
    printf( "Header length= %u" ,len);
    printf( " Options :" );
      if (opt==0)
          {
           printf( "  Pad 1" );
          }
      else if (opt==1)
          {
           printf( "  Pad N" );
		   printf( "  Length = %u",olen);
          }
      else if (opt==194)
          {
           printf( "  Jumbo Payload");
		   printf( "  Data Length = %u",olen);
		   if (olen==4) printf( "  Jumbo Payload Length = %u", jlen);
          }
}

DWORD T_N_C(BYTE Type, BYTE Code, WORD Checksum);

DWORD ICMP6 ()
{
 DWORD t;
 title( "ICMP v6" );
 T_N_C(Type,Code,Checksum);
 t=code;
 if (type==1)
 {
     printf ( "Error type: Destination Unreachable (%u)" ,type);
     if (code==0) printf( "Error code: No route to destination (%u)",t);
     else if (code==1) printf( "Error code: Communication with destination admin Prohibited (%u)",t);
     else if (code==2) printf( "Error code: Not a neighbor (%u)" ,t);
     else if (code==3) printf( "Error code: Address unreachable (%u)" ,t);
     else if (code==4) printf( "Error code: Port unreachable (%u)" ,t);
     else printf( "Unknown Error code (%u)" ,t);
     printf( "Unused = 0x%04X" ,IcmpData);
 }
 else if (type==2)
 {
     printf( "Error type: Packet too big" );
     printf( "Maximum Transmission Unit = %u" ,IcmpData);
 }
 else if (type==3)
 {
     printf( "Error type: Time Exceeded" );
     printf( "Unused = 0x%04X" ,IcmpData);
 }
 else if (type==4)
 {
     printf( "Error type: Parameter problem" );
     printf( "Pointer = %u" ,IcmpData);
 }
 else if (type==128)
   {
     printf( "Information Message: Echo Request" );
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+2);
     printf( "Identifier = %u" ,(IcmpData>>16)&0xFFFF);
     ResetLog(offsetof(IcmpData)+2,offsetof(IcmpData)+4);
     printf( "Sequence Number = %u" ,(IcmpData)&0xFFFF);
   }
 else if (type==129)
   {
     printf( "Information Message: Echo Reply" );
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+2);
     printf( "Identifier = %u" ,(IcmpData>>16)&0xFFFF);
     ResetLog(offsetof(IcmpData)+2,offsetof(IcmpData)+4);
     printf( "Sequence Number = %u" ,(IcmpData)&0xFFFF);
   }
 else if (type==130)
   {
     printf( "Information Message: Group Membership Query" );
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+2);
     printf( "Maximum Response Delay = %u" ,(IcmpData>>16)&0xFFFF);
     ResetLog(offsetof(IcmpData)+2,offsetof(IcmpData)+4);
     printf( "Unused = 0x%04X",(IcmpData)&0xFFFF);
   }
 else if (type==131)
   {
     printf( "Information Message: Group Membership Report" );
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+2);
     printf( "Maximum Response Delay = %u" ,(IcmpData>>16)&0xFFFF);
     ResetLog(offsetof(IcmpData)+2,offsetof(IcmpData)+4);
     printf( "Unused = 0x%04X",(IcmpData)&0xFFFF);
   }
 else if (type==132)
   {
     printf( "Information Message: Group Membership Termination" );
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+2);
     printf( "Maximum Response Delay = %u" ,(IcmpData>>16)&0xFFFF);
     ResetLog(offsetof(IcmpData)+2,offsetof(IcmpData)+4);
     printf( "Unused = 0x%04X",(IcmpData)&0xFFFF);
   }
 else if (type==133)
   {
     printf( "Information Message: Routing Solicitation");
     printf( "Unused = 0x%04X" ,IcmpData);
   }
 else if (type==134)
   {
     printf( "Information Message: Router Advertisement" );
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+1);
     printf( "Current Hop Limit = %u",(IcmpData>>24)&0xFF);
     ResetLog(offsetof(IcmpData)+1,offsetof(IcmpData)+2,1);
     printf( "M = %u" ,(IcmpData>>16)&0xFF&0x80);
     ResetLog(offsetof(IcmpData)+1,offsetof(IcmpData)+2,1);
     printf( "O = %u" ,(IcmpData>>16)&0xFF&0x40);
     ResetLog(offsetof(IcmpData)+1,offsetof(IcmpData)+2,1);
     printf( "Reserved = 0x%X" ,(IcmpData>>16)&0xFF%0x3F);
     ResetLog(offsetof(IcmpData)+2,offsetof(IcmpData)+4);
     printf( "Router Lifetime = 0x%X" ,(IcmpData)&0xFFFF);
   }
 else if (type==135)
   {
     printf( "Information Message: Neighbor Solicitation");
     printf("Reserved = 0x%X",IcmpData);
   }
 else if (type==136)
   {
     printf("Information Message: Neighbor Advertisement");
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+1,1);
     printf("R = %u",(IcmpData&0x80000000>0)&1);
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+1,1);
     printf("S = %u",(IcmpData&0x40000000>0)&1);
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+1,1);
     printf("O = %u",(IcmpData&0x20000000>0)&1);
     t= t&0x1FFFFFFF;
     ResetLog(offsetof(IcmpData),offsetof(IcmpData)+4,1);
     printf("Reserved = 0x%X",IcmpData&0x1FFFFFFF);
   }
 else if (type==137)
   {
     printf("Information Message: Redirect");
     printf("Reserved = 0x%X",IcmpData);
   }
 else
     printf( "Error: Unknown type");
}

DWORD T_N_C(BYTE Type, BYTE Code, WORD Checksum)
    {
     printf( "Type = %u" ,Type);
     printf( "Code = %u" ,Code);
     printf( "Checksum = 0x%X" ,Checksum);
    }

DWORD ICMP_GROUP()
{
     printf( "Multicast Address = %04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"
      ,MA1,MA2,MA3,MA4,MA5,MA6,MA7,MA8);
}

DWORD ICMP_ROUTE()
{
  printf( " Option type = %u",type);
  printf( " Option length = %u",len);
  printf( " Option not supported" );
}

DWORD ICMP_RADV()
    {
     printf( "Reachable Time = %u" ,ReachableTime);
     printf( "Retransmission Timer = %u" ,RetransmissionTimer);
    }

//DWORD ICMP_NSOL_ADV(DWORD isadv)
DWORD ICMP_NSOL_ADV()
    {
     printf("Target Address = %04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"
      ,A1,A2,A3,A4,A5,A6,A7,A8);
    }

DWORD ICMP_REDIRECT()
    {
     printf( "Source Address = %04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"
      ,SA1,SA2,SA3,SA4,SA5,SA6,SA7,SA8);
     printf( "Destination Address = %04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"
      ,DA1,DA2,DA3,DA4,DA5,DA6,DA7,DA8);
    }

DWORD RH ()
{
 title( "Routing Header" );
 printf( "Next Header = %u" ,NextHeader);
 printf( "Header length = %u" ,len);
 printf( "Routing Type = %u" ,RoutingType);
 printf( "Number Of Route Segments Remaining = %u" ,Remaining);
 resetlog(offsetof(Reserved),offsetof(Reserved)+1);
 printf( "Reserved = %u" ,Reserved);
 resetlog(offsetof(Reserved)+1,offsetof(Reserved)+4);
 printf( "Strict/Loose Bitmap = %06X" ,SLBitmap);
 printf( "Number of Adresses = %u",(len-8)/16);
}

DWORD FH ()
{
 title( "Fragment Header");
 printf( "Next Header = %u" ,NextHeader);
 printf( "Reserved = %u",Reserved);
 printf( "Fragment Offset = %u (0x%X / 0x8)" ,FOffset,FOffset*8);
 resetlog(offsetof(FHWRD)+1,offsetof(FHWRD)+2,1);
 printf( "Reserved       = ........ .....%2b.",Res);
 resetlog(offsetof(FHWRD)+1,offsetof(FHWRD)+2,1);
 printf( "More Fragments = ........ .......%1X" ,M);
 printf( "Identification = %X" ,Identification);
}

//UDP packet Interpretation
DWORD UDP ()
{
    title( "UDP Header");
    printf( "Source port = %u (%w)",SPort,offsetof(SPort));
    printf( "Destination port = %u (%w)",DPort,offsetof(DPort));
    printf( "Message length = %u",MLen);
    printf( "Checksum = %04Xh",Checksum);
//FULVIO We should not put anything for the supported protocols here.
//These protocols are still unsupported
    if ((SPort==13)||(DPort==13)) title( "Daytime" );
     else if ((SPort==53)||(DPort==53)) return 0;
     else if ((SPort==69)||(DPort==69)) printf("Next Protocol: Trivial FTP (TFTP)");
     else if (SPort==513 || DPort==513) printf("Next Protocol: RWHO");
     else if (SPort==1021 || DPort==1021) printf("Next Protocol: NFS");
     else if (SPort==137 || DPort==137) printf("Next Protocol: NETBIOS Name Service");
     else if (SPort==138 || DPort==138) printf("Next Protocol: NETBIOS Datagram Service");
     else
    {
       printf("Next Protocol: Unsupported (s:%u,d:%u)",SPort,DPort);
    }
}

//TCP packet Interpretation
// Completed by courtesy of J.-C. Hasler (swisscom Inc.) Jean-Claude.Hasler@swisscom.com, Dec 11th, 2000
DWORD TCP ()
{
    DWORD headerLength;

    resetlog(offsetof(sport),offsetof(sport)+DataOffset*4);
    printf ("----- TCP Header -----");
    printf( "Source port = %u (%t)",SPort,offsetof(SPort));
    printf( "Destination port = %u (%t)",DPort,offsetof(DPort));
    printf( "Sequence number = %u" ,SNumber);
    printf( "Acknowledgement number = %u" ,AckNumber);
    CHECK(13);
    headerLength=DataOffset*4;
    ResetLog(offsetof(DataOffset),offsetof(DataOffset)+1,1);
    printf( "Header length = %u bytes",headerLength);

    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    printf( "6 Reserved bits & 6 bits Flags = 0%02Xh" ,Control);
    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    printf( " 0000 00.. .... = 6 Reserved bits, for future usage, which have to be 0");
    if(Control &0x20)
	printf( " 0000 001. .... = Urgent pointer");
    else
	printf( " 0000 000. .... = No urgent pointer");

    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    if (Control & 0x10)
	printf( " 0000 00.1 .... = Acknowledgement");
    else
	printf( " 0000 00.0 .... = No acknowledgement");
    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    if (Control  & 0x08)
	printf( " 0000 00.. 1... = Push");
    else
	printf( " 0000 00.. 0... = No push");
    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    if (Control  & 0x04)
	printf( " 0000 00.. .1.. = Reset");
    else
	printf( " 0000 00.. .0.. = No reset");
    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    if (Control  & 0x02)
	printf( " 0000 00.. ..1. = SYN");
    else
	printf( " 0000 00.. ..0. = No SYN");
    ResetLog(offsetof(Control),offsetof(Control)+2,1);
    if (Control  & 0x01)
	printf( " 0000 00.. ...1 = FIN");
    else
	printf( " 0000 00.. ...0 = No FIN");

    printf( "Window = %u",Window);
    printf( "Checksum = %04Xh" ,Checksum);
    printf( "Urgent pointer = %u",UrgentPtr);
    if (headerLength>20)
    {
      DWORD pos,tmp,tmp2;
      tmp2=headerLength-20;
      resetlog(offsetof(UrgentPtr)+2,offsetof(UrgentPtr)+2+tmp2);
      printf( "Options = %u bytes" ,tmp2);
      pos=GetVmVar("SizeInt")+20;
      check(pos);
      tmp=CONV16(pos);
      if (tmp==0x204)
      {
         printf( " Code = %X (MSS)" ,tmp>>8);
         printf( " Required MSS: %u",conv16(pos+2));
         tmp2=tmp2-4;
      }
      if (tmp2>0)
        printf(" Other Options");
    }
    else printf( "No TCP options" );

}

// ARP packet analysis
DWORD ARP ()
{
    DWORD Vendor;
    title("ARP frame");
    if (HType == 0x01) printf("Hardware type %u Ethernet",HType);
    else if (HType== 0x03) printf("Hardware type %u X.25",HType);
    else if (HType== 0x06) printf("Hardware type %u IEEE 802.2 NetWork",HType);
    else if (HType== 0x0B) printf("Hardware type %u Apple LocalTalk",HType);
    else if (HType== 0x0F) printf("Hardware type %u Frame Relay",HType);
    else if (HType== 0x12) printf("Hardware type %u Fibre Channel",HType);
    else if (HType== 0x14) printf("Hardware type %u Serial Link",HType);
    else printf( "Hardware type = %u (%a)",HType,offsetof(HType));
    if (PType == 0x800) printf("Protocol Type = %04Xh IP", PType);
    else printf( "Protocol type = %04Xh (%p)",PType,offsetof(PType));
    DWORD t,q;
    t=HALen;
    printf( "Length of hardware address = %u bytes",HALen);
    q=PALen;
    printf( "Length of protocol address = %u bytes",PALen);
    if (OpCode == 0x01) printf( "Operation code %u Request",OpCode);
    else if (OpCode == 0x02) printf( "Operation code %u Reply",OpCode);
    else printf( "Operation code %u",OpCode);
    if(t==6)
    printf( "Sender's hardware address = %04X%2X-%02X%04X (Vendor: %v)",
	HAdd1,(HAdd2>>8)&0xFF,(HAdd2)&0xFF,HAdd3,offsetof(HAdd1));
    if(t==6 && q==4)
    printf( "Sender's protocol address = [%u.%u.%u.%u]",PAdd1,PAdd2,PAdd3,PAdd4);
    printf( "Target hardware address = %04X%02X-%02X%04X (Vendor: %v)",
	HAdd1_2,(HAdd2_2>>8)&0xFF,(HAdd2_2)&0xFF,HAdd3_2,offsetof(HAdd1_2));
    if(t==6 && q==4)
    printf( "Target protocol address = [%u.%u.%u.%u]",PAdd1_2,PAdd2_2,PAdd3_2,PAdd4_2);
}

DWORD RIP6()
{
   title("RIPng Header");
   if (Command == 0x01) printf("Command 0x%X Request for partial or full Routing Table Information", Command);
   else if (Command == 0x02) printf("Command 0x%X Response packet containing Routing Table Information", Command);
   else printf("Command 0x%X (%n)", Command, offsetof(Command));
   printf("Version Number 0x%X", Version);
}

DWORD RIP6DATA()
{
   printf("Network: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x/%u, Metric=%u ",
		Entry1>>16&0xFFFF, Entry1&0xFFFF,
		Entry2>>16&0xFFFF, Entry2&0xFFFF,
		Entry3>>16&0xFFFF, Entry3&0xFFFF,
		Entry4>>16&0xFFFF, Entry4&0xFFFF,
		Prefix, Metric);
}

DWORD RIP()
{
   title("RIP Header");
   if (Command == 0x01) printf("Command 0x%X Request for partial or full Routing Table Information", Command);
   else if (Command == 0x02) printf("Command 0x%X Response packet containing Routing Table Information", Command);
   else printf("Command 0x%X (%n)", Command, offsetof(Command));
   printf("Version Number 0x%X", Version);
}
DWORD RIP1()
{
   printf("Address Family Identifier 0x%X", AddressFamilyID);
   printf("IpAddress [%u.%u.%u.%u]",
		IpAddress>>24&0xFF,IpAddress>>16&0xFF,
		IpAddress>>8&0xFF,IpAddress&0xFF);
   printf("Metric %u", Metric);
}
DWORD RIP2()
{
   printf("Address Family Identifier 0x%X", AddressFamilyID);
}
DWORD RIP2_AUTH()
{
   printf("Authentication Type 0x%X", AuthType);
   printf("Password (Bytes 0-3) 0x%X", Pwd0);
   printf("Password (Bytes 4-7) 0x%X", Pwd4);
   printf("Password (Bytes 8-11) 0x%X", Pwd8);
   printf("Password (Bytes 12-15) 0x%X", Pwd12);
}

DWORD RIP2_UPD1()
{
   printf("RouteTag 0x%X", RouteTag);
   printf("IPAddress [%u.%u.%u.%u]",
		IPAddress>>24&0xFF,IPAddress>>16&0xFF,
		IPAddress>>8&0xFF,IPAddress&0xFF);
   printf("NetMask [%u.%u.%u.%u]",
		NetMask>>24&0xFF,NetMask>>16&0xFF,
		NetMask>>8&0xFF,NetMask&0xFF);
   printf("Next Hop [%u.%u.%u.%u]",
		NextHop>>24&0xFF,NextHop>>16&0xFF,
		NextHop>>8&0xFF,NextHop&0xFF);
   printf("Metric %u", Metric);
}

DWORD RIP2_UPDALL()
{
   printf("Address Family Identifier 0x%X", AddressFamilyID);
   printf("RouteTag 0x%X", RouteTag);
   printf("IPAddress [%u.%u.%u.%u]",
		IPAddress>>24&0xFF,IPAddress>>16&0xFF,
		IPAddress>>8&0xFF,IPAddress&0xFF);
   printf("NetMask [%u.%u.%u.%u]",
		NetMask>>24&0xFF,NetMask>>16&0xFF,
		NetMask>>8&0xFF,NetMask&0xFF);
   printf("Next Hop [%u.%u.%u.%u]",
		NextHop>>24&0xFF,NextHop>>16&0xFF,
		NextHop>>8&0xFF,NextHop&0xFF);
   printf("Metric %u", Metric);
}

DWORD BGP ()
{
  title ("BGP Header");
  printf("First Marker 0x%X",Marker1);
  printf("Second Marker 0x%X",Marker2);
  printf("Packet Length %u bytes", Length);
  if (Type == 0x01) printf("Packet Type 0x%X Open", Type);
  else if (Type == 0x02) printf("Packet Type 0x%X Update", Type);
  else if (Type == 0x03) printf("Packet Type 0x%X Notification", Type);
  else if (Type == 0x04) printf("Packet Type 0x%X KeepAlive", Type);
  else printf("Packet Type 0x%X (%n)",Type,offsetof(Type));
}

DWORD BGP_OPEN()
{
  title("BGP Open");
  printf("Version Number 0x%X", Version);
  printf("Autonomous System Number %u", AsNumber);
  printf("Hold Time %u seconds", HoldTime);
  printf("Identifier [%u.%u.%u.%u]", 
		BGPID>>24&0xFF,BGPID>>16&0xFF,BGPID>>8&0xFF,BGPID&0xFF);
  printf("Length Option Parameter %u bytes", OptParLen);
}

DWORD BGP_OPENPAR()
{
  if (ParType==0x1) printf("Parameter Type 0x%X Authentication Information ", ParType);
  else printf ("Parameter Type 0x%X (%n)",ParType,offsetof(ParType));
  printf("Parameter Length %u bytes", ParLeng);
}

DWORD BGP_OPENAUT()
{
  printf("Authentication Code 0x%X (%n)",AUCode, offsetof(AUCode));
}

DWORD BGP_UPDATE()
{
  title("BGP Update");
  printf("Length WithDrawn Router %u bytes",RouterLen);
  printf("Number of Bit NetMask %u",Len);
  printf("Prefix [%u.%u.%u.%u]",
	IPAddr>>24&0xFF,IPAddr>>16&0xFF,IPAddr>>8&0xFF,IPAddr&0xFF);
}

DWORD BGP_UPDATEPATH()
{
  printf("Length Path Attribute %u bytes",PathAttrLen);
  printf("Flags");
  if(AttrFlag & 0x80) printf(" 1....... Optional");
  else printf(" 0....... Well-Known");
  if(AttrFlag & 0x40) printf(" .1...... Transitive");
  else printf(" .0...... Non-transitive");
  if(AttrFlag & 0x20) printf(" ..1..... Partial Information");
  else printf(" ..0..... Complete Information");
  if(AttrFlag & 0x10) printf(" ...1.... Attribute Length is 2 bytes");
  else printf(" ...0.... Attribute Length is 1 byte");
  printf(" ....0000 Reserved");
  if(AttrType==0x01)
  {
	 printf("Attribute Type 0x%X Origin",AttrType);
	 if(AttrValue==0x00) printf("Attribute Data 0x%X IGP",AttrValue);
       else if(AttrValue==0x01) printf("Attribute Data 0x%X EGP",AttrValue);
	 else if(AttrValue==0x02) printf("Attribute Data 0x%X INCOMPLETE",AttrValue);
       else printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else if (AttrType==0x02)
  {
	 printf("Attribute Type 0x%X AS_Path",AttrType);
	 if(AttrValue==0x01) printf("Attribute Data 0x%X AS_SET",AttrValue);
       else if(AttrValue==0x02) printf("Attribute Data 0x%X AS_SEQUENCE",AttrValue);
       else printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else if (AttrType==0x03)
  {
	 printf("Attribute Type 0x%X Next Hop",AttrType);
       printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else if (AttrType==0x04)
  {
	 printf("Attribute Type 0x%X MULTI_EXIT_DISC",AttrType);
       printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else if (AttrType==0x05)
  {
	 printf("Attribute Type 0x%X LOCAl_PREF",AttrType);
       printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else if (AttrType==0x06)
  {
	 printf("Attribute Type 0x%X ATOMIC_AGGREGATE",AttrType);
       printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else if (AttrType==0x07)
  {
	 printf("Attribute Type 0x%X AGGREGATOR",AttrType);
       printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
  else 
  {
	 printf("Attribute Type 0x%X (%n)",AttrType, offsetof(AttrType));
       printf("Attribute Data 0x%X (%n)",AttrValue, offsetof(AttrValue));
  }
}
DWORD BGP_UPDATENLRI()
{
  printf("Length NetWork Layer Reachability Information %u bytes",NLRILen);
  printf("Number of Bit NetMask %u",Len);
  printf("Prefix [%u.%u.%u.%u]",
	IPAddr>>24&0xFF,IPAddr>>16&0xFF,IPAddr>>8&0xFF,IPAddr&0xFF);
}
DWORD BGP_NOTIFY()
{
  title("BGP Notify");
  if(ErrCode==0x01) 
  {
	printf("Error Code 0x%X Message Header Error",ErrCode);
	if(ErrSub==0x01) printf("Error SubCode 0x%X Connection Not Synchronized",ErrSub);
	else if(ErrSub==0x02) printf("Error SubCode 0x%X Bad Message Length",ErrSub);
	else if(ErrSub==0x03) printf("Error SubCode 0x%X Bad Message Type",ErrSub);
	else printf("Error SubCode 0x%X (%n)",ErrSub,offsetof(ErrSub));
  }
  else if(ErrCode==0x02)
  {
	printf("Error Code 0x%X Open Message Error",ErrCode);
	if(ErrSub==0x01) printf("Error SubCode 0x%X Unsupported Version Number",ErrSub);
	else if(ErrSub==0x02) printf("Error SubCode 0x%X Bad Peer AS",ErrSub);
	else if(ErrSub==0x03) printf("Error SubCode 0x%X Bad BGP Identifier",ErrSub);
	else if(ErrSub==0x04) printf("Error SubCode 0x%X Unsupported Option Parameter",ErrSub);
	else if(ErrSub==0x05) printf("Error SubCode 0x%X Authentication Failure",ErrSub);
	else if(ErrSub==0x06) printf("Error SubCode 0x%X Unacceptable Hold Time",ErrSub);
	else printf("Error SubCode 0x%X (%n)",ErrSub,offsetof(ErrSub));
  }
  else if(ErrCode==0x03)
  {
	printf("Error Code 0x%X Open Message Error",ErrCode);
	if(ErrSub==0x01) printf("Error SubCode 0x%X Malformed Attribute List",ErrSub);
	else if(ErrSub==0x02) printf("Error SubCode 0x%X Unrecognized Well-Known Attribute",ErrSub);
	else if(ErrSub==0x03) printf("Error SubCode 0x%X Missing Well-Known Attribute",ErrSub);
	else if(ErrSub==0x04) printf("Error SubCode 0x%X Attribute Flag Error",ErrSub);
	else if(ErrSub==0x05) printf("Error SubCode 0x%X Attribute Length Error",ErrSub);
	else if(ErrSub==0x06) printf("Error SubCode 0x%X Invalid Origin Attribute",ErrSub);
	else if(ErrSub==0x07) printf("Error SubCode 0x%X AS Routing Loop",ErrSub);
	else if(ErrSub==0x08) printf("Error SubCode 0x%X Invalid Next Hop Attribute",ErrSub);
	else if(ErrSub==0x09) printf("Error SubCode 0x%X Optional Attribute Error",ErrSub);
	else if(ErrSub==0x0A) printf("Error SubCode 0x%X Invalid Network Field",ErrSub);
	else if(ErrSub==0x0B) printf("Error SubCode 0x%X Malformed AS_PATH",ErrSub);
	else printf("Error SubCode 0x%X (%n)",ErrSub,offsetof(ErrSub));
  }
  else if (ErrCode == 0x04) printf("Error Code 0x%X Hold Time Expired", ErrCode);
  else
  {
	printf("Error Code 0x%X (%n)",ErrCode,offsetof(ErrCode));
	printf("Error SubCode 0x%X (%n)",ErrSub,offsetof(ErrSub));
  }
}

DWORD OSPF()
{
   title("OSPF Header");
   printf("Version Number 0x%X", Version);
   if (Type == 0x1) printf("Type 0x%X Hello", Type);
   else if (Type == 0x2) printf("Type 0x%X Database Description", Type);
   else if (Type == 0x3) printf("Type 0x%X Link State Request", Type);
   else if (Type == 0x4) printf("Type 0x%X Link State Update", Type);
   else if (Type == 0x5) printf("Type 0x%X Link State Ack", Type);
   else printf("Type 0x%X (%r)", Type, offsetof(Type));
   printf("Packet Length 0x%X bytes", PacketLength);
   printf("Source Router ID [%u.%u.%u.%u]",
	RouterID>>24&0xFF,RouterID>>16&0xFF,RouterID>>8&0xFF,RouterID&0xFF);
   printf("Area ID 0x%X", AreaID);
   printf("CheckSum 0x%X", Checksum);
   ResetLog(GetVmVar("SizeInt")+14,GetVmVar("SizeInt")+2);
   if (AuType == 0x0) printf("Authentication Type 0x%X No Authentication", AuType);
   else if (AuType == 0x1) printf("Authentication Type 0x%X Simple password", AuType);
   else if (AuType == 0x2) printf("Authentication Type 0x%X Cryptographic Checksum", AuType);
   else printf("Authentication Type 0x%X (%r)", AuType, offsetof(AuType));
   DWORD Pwd;
   Pwd=Auth<<8;
   Pwd=Pwd+KeyID;
   Pwd=Pwd<<8;
   Pwd=Pwd+AuthLen;
   ResetLog(GetVmVar("SizeInt")+16,GetVmVar("SizeInt")+8);
   if (AuType == 0x1) printf("Password  0x%X", Pwd, AuthenticationHigh);
   else if (AuType == 0x2) {
  					printf("Authentication Algorithm 0x%X", KeyID);
					printf("Authentication Data Length 0x%X", AuthLen);
					printf("Cryptographic Sequence Number 0x%X", AuthenticationHigh);
				    }
   else printf("Authentication is not examined");
}
DWORD OSPF_HELLO ()
{	
   title("OSPF Hello");
   printf("NetMask [%u.%u.%u.%u]", NetMask>>24&0xFF,NetMask>>16&0xFF,
		NetMask>>8&0xFF,NetMask&0xFF);
   printf("Time between this router's Hello Packet %u seconds",HelloInt);
   ResetLog(GetVmVar("SizeInt")+6,GetVmVar("SizeInt")+1);
   printf("Capability Options");
   if (Option & 0x02) printf(" ......1. Interface is not connect to a stub area");
   else printf(" ......0. Interface is connect to a stub area");
   if (Option & 0x01) printf(" .......1 Router capable of TOS Routing");
   else printf(" .......0 Router incapable of TOS Routing");
   ResetLog(GetVmVar("SizeInt")+7,GetVmVar("SizeInt")+1);
   if (RtrPri == 0x0) printf("Router will be ineligible to become (Backup) Designated Router 0x%X",RtrPri);
   else printf("Router Priority 0x%X",RtrPri);
   printf("Time before declaring a silent router down %u seconds", DeadInt);
   printf("IpAddress of Designated Router [%u.%u.%u.%u]",
       DesRouter>>24&0xFF,DesRouter>>16&0xFF,DesRouter>>8&0xFF,DesRouter&0xFF);
   printf("IpAddress of Backup Router [%u.%u.%u.%u]",
       BackRouter>>24&0xFF,BackRouter>>16&0xFF,BackRouter>>8&0xFF,BackRouter&0xFF);
}
DWORD OSPF_HELLO_NEI()
{
   printf("RouterID with valid Hello Packet [%u.%u.%u.%u]", 
	 NeighBor>>24&0xFF,NeighBor>>16&0xFF,NeighBor>>8&0xFF,NeighBor&0xFF);
}
DWORD OSPF_DATABASE()
{
   title("OSPF Database");
   printf("Size of the largest IP packet without fragmentation 0x%X", IntMTU);
   ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+1);
   printf("Capability Options");
   printf(" 0....... Reserved");
   printf(" .0...... Reserved");
   printf(" ..0..... Reserved");
   printf(" ...0.... Reserved");
   printf(" ....0... Reserved");
   printf(" .....0.. Reserved");
   ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+1);
   if (Option & 0x02) printf(" ......1. Is meaningful only in OSPF Hello");
   else printf(" ......0. Is meaningful only in OSPF Hello");
   if (Option & 0x01) printf(" .......1 Router capable of TOS Routing");
   else printf(" .......0 Router incapable of TOS Routing");
   ResetLog(GetVmVar("SizeInt")+3,GetVmVar("SizeInt")+1);
   printf("Flags");
   printf(" 0....... Reserved");
   printf(" .0...... Reserved");
   printf(" ..0..... Reserved");
   printf(" ...0.... Reserved");
   printf(" ....0... Reserved");
   if (Flag & 0x04) printf(" .....1.. First packet of the sequence");
   printf(" .....0.. Packet of the sequence is not first");
   if (Flag & 0x02) printf(" ......1. Packet Database Descriptions is not the last");
   else printf(" ......0. Packet Database Descriptions is the last");
   if (Flag & 0x01) printf(" .......1 Router Originator is Master");
   else printf(" .......0 Router Originator is Slave");
   ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+2);
   printf ("Number of Packet Database %u", DDSeq);
}
DWORD OSPF_LSREQ()
{
  title("OSPF Link State Request");
  if (LSType == 0x1) printf("Link State 0x%X Router Links", LSType);
  else if (LSType == 0x2) printf("Link State 0x%X Network Links", LSType);
  else if (LSType == 0x3) printf("Link State 0x%X Summary Links (IP Networks)", LSType);
  else if (LSType == 0x4) printf("Link State 0x%X Summary Links (ASBR Networks)", LSType);
  else if (LSType == 0x5) printf("Link State 0x%X AS External Link", LSType);
  else if (LSType == 0x6) printf("Link State 0x%X Group Membership Link", LSType);
  else if (LSType == 0x7) printf("Link State 0x%X Not-So-Stubby-Area (NSSA) External Link", LSType);
  else if (LSType == 0x8) printf("Link State 0x%X External Attributes Link", LSType);
  else if (LSType == 0x9) printf("Link State 0x%X Opaque Link (Link-Local scope)", LSType);
  else if (LSType == 0xA) printf("Link State 0x%X Opaque Link (Area-Local scope)", LSType);
  else if (LSType == 0xB) printf("Link State 0x%X Opaque Link (AS scope)", LSType);
  else printf("Link State 0x%X (%r)", LSType, offsetof(LSType));
  printf ("Link State ID [%u.%u.%u.%u]",
	LSID>>24&0xFF,LSID>>16&0xFF,LSID>>8&0xFF,LSID&0xFF);
  printf ("Advertising Router [%u.%u.%u.%u]",
	AdvRouter>>24&0xFF,AdvRouter>>16&0xFF,AdvRouter>>8&0xFF,AdvRouter&0xFF);
}
DWORD OSPF_LSUPD ()
{
  title("OSPF Link State Update");
  printf("Number of Link State Advertisements included in this Update %u", NroAdv);
}
DWORD OSPF_LSACK ()
{
  title("OSPF Link State Acknowledgement");
  printf("Time since the Link State was originated %u seconds", LSAge);
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+1);
  printf("Capability Options");
  printf(" 0....... Reserved");
  printf(" .0...... Reserved");
  printf(" ..0..... Reserved");
  printf(" ...0.... Reserved");
  printf(" ....0... Reserved");
  printf(" .....0.. Reserved");
  if (Option & 0x02) printf(" ......1. Is meaningful only in OSPF Hello");
  else printf(" ......0. Is meaningful only in OSPF Hello");
  if (Option & 0x01) printf(" .......1 Router capable of TOS Routing");
  else printf(" .......0 Router incapable of TOS Routing");
  ResetLog(GetVmVar("SizeInt")+3,GetVmVar("SizeInt")+1);
  if (LSType == 0x1) printf("Link State 0x%X Router Links", LSType);
  else if (LSType == 0x2) printf("Link State 0x%X Network Links", LSType);
  else if (LSType == 0x3) printf("Link State 0x%X Summary Links (IP Networks)", LSType);
  else if (LSType == 0x4) printf("Link State 0x%X Summary Links (ASBR Networks)", LSType);
  else if (LSType == 0x5) printf("Link State 0x%X AS External Link", LSType);
  else if (LSType == 0x6) printf("Link State 0x%X Group Membership Link", LSType);
  else if (LSType == 0x7) printf("Link State 0x%X Not-So-Stubby-Area (NSSA) External Link", LSType);
  else if (LSType == 0x8) printf("Link State 0x%X External Attributes Link", LSType);
  else if (LSType == 0x9) printf("Link State 0x%X Opaque Link (Link-Local scope)", LSType);
  else if (LSType == 0xA) printf("Link State 0x%X Opaque Link (Area-Local scope)", LSType);
  else if (LSType == 0xB) printf("Link State 0x%X Opaque Link (AS scope)", LSType);
  else printf("Link State 0x%X (%r)", LSType, offsetof(LSType));
  printf ("Link State ID [%u.%u.%u.%u]",
	LSID>>24&0xFF,LSID>>16&0xFF,LSID>>8&0xFF,LSID&0xFF);
  printf ("Advertising Router [%u.%u.%u.%u]",
	AdvRouter>>24&0xFF,AdvRouter>>16&0xFF,AdvRouter>>8&0xFF,AdvRouter&0xFF);
  printf ("Link State Sequence Number %u", LSSeq);
  printf ("Link State Checksum 0x%X", LSCheck);
  printf ("Link State Length 0x%X bytes", LSLength);
}
DWORD OSPF_LSADV ()
{
  title("OSPF Link State Header");
  printf("Time since the Link State was originated %u seconds", LSAge);
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+1);
  printf("Capability Options");
  printf(" 0....... Reserved");
  printf(" .0...... Reserved");
  printf(" ..0..... Reserved");
  printf(" ...0.... Reserved");
  printf(" ....0... Reserved");
  printf(" .....0.. Reserved");
  if (Option & 0x02) printf(" ......1. Is meaningful only in OSPF Hello");
  else printf(" ......0. Is meaningful only in OSPF Hello");
  if (Option & 0x01) printf(" .......1 Router capable of TOS Routing");
  else printf(" .......0 Router incapable of TOS Routing");
  ResetLog(GetVmVar("SizeInt")+3,GetVmVar("SizeInt")+1);
  if (LSType == 0x1) printf("Link State 0x%X Router Links", LSType);
  else if (LSType == 0x2) printf("Link State 0x%X Network Links", LSType);
  else if (LSType == 0x3) printf("Link State 0x%X Summary Links (IP Networks)", LSType);
  else if (LSType == 0x4) printf("Link State 0x%X Summary Links (ASBR Networks)", LSType);
  else if (LSType == 0x5) printf("Link State 0x%X AS External Link", LSType);
  else if (LSType == 0x6) printf("Link State 0x%X Group Membership Link", LSType);
  else if (LSType == 0x7) printf("Link State 0x%X Not-So-Stubby-Area (NSSA) External Link", LSType);
  else if (LSType == 0x8) printf("Link State 0x%X External Attributes Link", LSType);
  else if (LSType == 0x9) printf("Link State 0x%X Opaque Link (Link-Local scope)", LSType);
  else if (LSType == 0xA) printf("Link State 0x%X Opaque Link (Area-Local scope)", LSType);
  else if (LSType == 0xB) printf("Link State 0x%X Opaque Link (AS scope)", LSType);
  else printf("Link State 0x%X (%r)", LSType, offsetof(LSType));
  printf ("Link State ID [%u.%u.%u.%u]",
	LSID>>24&0xFF,LSID>>16&0xFF,LSID>>8&0xFF,LSID&0xFF);
  printf ("Advertising Router [%u.%u.%u.%u]",
	AdvRouter>>24&0xFF,AdvRouter>>16&0xFF,AdvRouter>>8&0xFF,AdvRouter&0xFF);
  printf ("Link State Sequence Number %u", LSSeq);
  printf ("Link State Checksum 0x%X", LSCheck);
  printf ("Link State Length 0x%X bytes", LSLength);
}
DWORD OSPF_LSADVROUT ()
{
  title("OSPF Link State Router Link");
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+2);
  printf("Flags");
  printf(" 0............... Reserved");
  printf(" .0.............. Reserved");
  printf(" ..0............. Reserved");
  printf(" ...0............ Reserved");
  printf(" ....0........... Reserved");
  if (Flag & 0x400) printf(" .....1.......... Originating Router is an Endpoint");
  else printf(" .....0.......... No Originating Router is an Endpoint");
  if (Flag & 0x200) printf(" ......1......... Originating is AS Boundary Router");
  else printf(" ......0......... No AS Boundary Router");
  if (Flag & 0x100) printf(" ......1......... Originating is Area Border Router");
  else printf(" ......0......... No Area Border Router");
  printf(" .......0........ Reserved");
  printf(" ........0....... Reserved");
  printf(" .........0...... Reserved");
  printf(" ..........0..... Reserved");
  printf(" ...........0.... Reserved");
  printf(" ............0... Reserved");
  printf(" .............0.. Reserved");
  printf(" ..............0. Reserved");
  printf(" ...............0 Reserved");
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+2);
  printf("Number of Router Link %u", NroLink);
}
DWORD OSPF_ROUTLINK()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+4);
  if ((Type == 0x1) || (Type == 0x4)) printf("Neighboring router's Router ID [%u.%u.%u.%u]",
	LinkID>>24&0xFF,LinkID>>16&0xFF,LinkID>>8&0xFF,LinkID&0xFF);
  else if (Type == 0x2) printf("IP Address of DR's interface [%u.%u.%u.%u]",
	LinkID>>24&0xFF,LinkID>>16&0xFF,LinkID>>8&0xFF,LinkID&0xFF);
  else if (Type == 0x3) printf("IP Network or SubNet Address [%u.%u.%u.%u]",
	LinkID>>24&0xFF,LinkID>>16&0xFF,LinkID>>8&0xFF,LinkID&0xFF);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+4);
  if ((Type == 0x1) || (Type == 0x2)) printf("IP Address of the Originating Router [%u.%u.%u.%u]",
	LinkData>>24&0xFF,LinkData>>16&0xFF,LinkData>>8&0xFF,LinkData&0xFF);
  else if (Type == 0x3) printf("Network IP Address or SubNet Address [%u.%u.%u.%u]",
	LinkData>>24&0xFF,LinkData>>16&0xFF,LinkData>>8&0xFF,LinkData&0xFF);
  else if (Type == 0x4) printf("MIB-II ifIndex value for the Originating Router  [%u.%u.%u.%u]",
	LinkData>>24&0xFF,LinkData>>16&0xFF,LinkData>>8&0xFF,LinkData&0xFF);
  ResetLog(GetVmVar("SizeInt")+8,GetVmVar("SizeInt")+1);
  if (Type == 0x1) printf("Type 0x%X Point-to-point connection to another router",Type);
  else if (Type == 0x2) printf("Type 0x%X Connection to a transit network",Type);
  else if (Type == 0x3) printf("Type 0x%X Connection to a stub network",Type);
  else if (Type == 0x4) printf("Type 0x%X Virtual Link",Type);
  else printf("Type 0x%X (%n) Connection to a transit network",Type, offsetof(Type));
  printf("Number of TOS metrics %u", NroTOS);
  printf("Cost of using this router link for TOS0 %u", TOSMetric0);
}
DWORD OSPF_ROUTTOS1()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+2);
  printf("Cost of using this outband router link %u", Metric);
}
DWORD OSPF_ROUTTOS2()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+1);
  if (TOS2 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS2 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS2);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric2);
}
DWORD OSPF_ROUTTOS3()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+1);
  if (TOS2 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS2 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS2);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric2);
  ResetLog(GetVmVar("SizeInt")+8,GetVmVar("SizeInt")+1);
  if (TOS3 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS3 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS3);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric3);
}
DWORD OSPF_ROUTTOS4()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+1);
  if (TOS2 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS2 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS2);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric2);
  ResetLog(GetVmVar("SizeInt")+8,GetVmVar("SizeInt")+1);
  if (TOS3 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS3 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS3);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric3);
  ResetLog(GetVmVar("SizeInt")+12,GetVmVar("SizeInt")+1);
  if (TOS4 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS4 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS4 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS4 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS4 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS4 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS4 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS4 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS4);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric4);
}
DWORD OSPF_ROUTTOS5()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+1);
  if (TOS2 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS2 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS2);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric2);
  ResetLog(GetVmVar("SizeInt")+8,GetVmVar("SizeInt")+1);
  if (TOS3 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS3 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS3);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric3);
  ResetLog(GetVmVar("SizeInt")+12,GetVmVar("SizeInt")+1);
  if (TOS4 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS4 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS4 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS4 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS4 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS4 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS4 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS4 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS4);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric4);
  ResetLog(GetVmVar("SizeInt")+16,GetVmVar("SizeInt")+1);
  if (TOS5 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS5 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS5 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS5 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS5 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS5 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS5 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS5 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS5);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric5);
}
DWORD OSPF_ROUTTOS6()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+1);
  if (TOS2 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS2 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS2 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS2 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS2 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS2);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric2);
  ResetLog(GetVmVar("SizeInt")+8,GetVmVar("SizeInt")+1);
  if (TOS3 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS3 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS3 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS3 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS3 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS3);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric3);
  ResetLog(GetVmVar("SizeInt")+12,GetVmVar("SizeInt")+1);
  if (TOS4 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS4 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS4 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS4 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS4 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS4 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS4 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS4 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS4);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric4);
  ResetLog(GetVmVar("SizeInt")+16,GetVmVar("SizeInt")+1);
  if (TOS5 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS5 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS5 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS5 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS5 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS5 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS5 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS5 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS5);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric5);
  ResetLog(GetVmVar("SizeInt")+20,GetVmVar("SizeInt")+1);
  if (TOS6 == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS6 == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS6 == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS6 == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS6 == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS6 == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS6 == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS6 == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS6);
  printf("00000000 Reserved");
  printf("Cost of using this outband router link %u", Metric6);
}
DWORD OSPF_LSADVNETW()
{
 title("OSPF Network Link");
 printf("Network Mask [%u.%u.%u.%u]",
	NetMask>>24&0xFF,NetMask>>16&0xFF,NetMask>>8&0xFF,NetMask&0xFF);
}
DWORD OSPF_NETLINK()
{
  printf("Attached Router [%u.%u.%u.%u]",
    AttRouter>>24&0xFF,AttRouter>>16&0xFF,AttRouter>>8&0xFF,AttRouter&0xFF);
}
DWORD OSPF_LSADVSUMM()
{
  title("OSPF Network Summary/ASBR Summary");
  DWORD MetrTot;
  printf("Destination IP Network Mask [%u.%u.%u.%u] (Only for IP Network)",
    NetMask>>24&0xFF,NetMask>>16&0xFF,NetMask>>8&0xFF,NetMask&0xFF);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  MetrTot=Metric1;
  MetrTot=MetrTot<<16;
  MetrTot=Metric1+Metric2;
  printf("Cost of this route %u", MetrTot);
}
DWORD OSPF_LSADVSUMMR()
{
  DWORD MetrTot;
  title("OSPF Link State Header");
  printf("Time since the Link State was originated %u seconds", LSAge);
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+1);
  printf("Capability Options");
  printf(" 0....... Reserved");
  printf(" .0...... Reserved");
  printf(" ..0..... Reserved");
  printf(" ...0.... Reserved");
  printf(" ....0... Reserved");
  printf(" .....0.. Reserved");
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+1);
  if (Option & 0x02) printf(" ......1. Is meaningful only in OSPF Hello");
  else printf(" ......0. Is meaningful only in OSPF Hello");
  if (Option & 0x01) printf(" .......1 Router capable of TOS Routing");
  else printf(" .......0 Router incapable of TOS Routing");
  ResetLog(GetVmVar("SizeInt")+3,GetVmVar("SizeInt")+1);
  if (LSType == 0x1) printf("Link State 0x%X Router Links", LSType);
  else if (LSType == 0x2) printf("Link State 0x%X Network Links", LSType);
  else if (LSType == 0x3) printf("Link State 0x%X Summary Links (IP Networks)", LSType);
  else if (LSType == 0x4) printf("Link State 0x%X Summary Links (ASBR Networks)", LSType);
  else if (LSType == 0x5) printf("Link State 0x%X AS External Link", LSType);
  else printf("Link State 0x%X (%r)", LSType, offsetof(LSType));
  printf ("Link State ID [%u.%u.%u.%u]",
	LSID>>24&0xFF,LSID>>16&0xFF,LSID>>8&0xFF,LSID&0xFF);
  printf ("Advertising Router [%u.%u.%u.%u]",
	AdvRouter>>24&0xFF,AdvRouter>>16&0xFF,AdvRouter>>8&0xFF,AdvRouter&0xFF);
  printf ("Link State Sequence Number %u", LSSeq);
  printf ("Link State Checksum 0x%X", LSCheck);
  printf ("Link State Length 0x%X bytes", LSLength);
  title("OSPF Network Summary/ASBR Summary");
  printf("Destination IP Network Mask [%u.%u.%u.%u] (Only for IP Network)",
    NetMask>>24&0xFF,NetMask>>16&0xFF,NetMask>>8&0xFF,NetMask&0xFF);
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  MetrTot=Metric1;
  MetrTot=MetrTot<<16;
  MetrTot=Metric1+Metric2;
  printf("Cost of this route %u", MetrTot);
}

DWORD OSPF_LSADVASEX()
{
  DWORD MetrTot;
  title("OSPF Link AS External");
  printf("Network Mask [%u.%u.%u.%u]",
	NetMask>>24&0xFF,NetMask>>16&0xFF,NetMask>>8&0xFF,NetMask&0xFF);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+1);
  if(Flag & 0x80) printf("Type 1 external metric (E1)");
  else printf("Type 2 external metric (E2)");
  MetrTot=Metric1;
  MetrTot=MetrTot<<16;
  MetrTot=Metric1+Metric2;
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  ResetLog(GetVmVar("SizeInt")+5,GetVmVar("SizeInt")+3);
  printf("Metric %u", MetrTot);
  ResetLog(GetVmVar("SizeInt")+8,GetVmVar("SizeInt")+4);
  printf("Forwarding Address [%u.%u.%u.%u]",
	FwdAddr>>24&0xFF,FwdAddr>>16&0xFF,FwdAddr>>8&0xFF,FwdAddr&0xFF);
  printf("External Route Tag [%u.%u.%u.%u]",
	ExtRout>>24&0xFF,ExtRout>16&0xFF,ExtRout>>8&0xFF,ExtRout&0xFF);
}
DWORD OSPF_LSADVASEXR()
{
  DWORD MetrTot;
  title("OSPF Link State Header");
  printf("Time since the Link State was originated %u seconds", LSAge);
  printf("Capability Options");
  printf(" 0....... Reserved");
  printf(" .0...... Reserved");
  printf(" ..0..... Reserved");
  printf(" ...0.... Reserved");
  printf(" ....0... Reserved");
  printf(" .....0.. Reserved");
  if (Option & 0x02) printf(" ......1. Is meaningful only in OSPF Hello");
  else printf(" ......0. Is meaningful only in OSPF Hello");
  if (option & 0x01) printf(" .......1 Router capable of TOS Routing");
  else printf(" .......0 Router incapable of TOS Routing");
  if (LSType == 0x1) printf("Link State 0x%X Router Links", LSType);
  else if (LSType == 0x2) printf("Link State 0x%X Network Links", LSType);
  else if (LSType == 0x3) printf("Link State 0x%X Summary Links (IP Networks)", LSType);
  else if (LSType == 0x4) printf("Link State 0x%X Summary Links (ASBR Networks)", LSType);
  else if (LSType == 0x5) printf("Link State 0x%X AS External Link", LSType);
  else printf("Link State 0x%X (%r)", LSType, offsetof(LSType));
  printf ("Link State ID [%u.%u.%u.%u]",
	LSID>>24&0xFF,LSID>>16&0xFF,LSID>>8&0xFF,LSID&0xFF);
  printf ("Advertising Router [%u.%u.%u.%u]",
	AdvRouter>>24&0xFF,AdvRouter>>16&0xFF,AdvRouter>>8&0xFF,AdvRouter&0xFF);
  printf ("Link State Sequence Number %u", LSSeq);
  printf ("Link State Checksum 0x%X", LSCheck);
  printf ("Link State Length 0x%X bytes", LSLength);
  title("OSPF Link AS External");
  printf("Network Mask [%u.%u.%u.%u]",
	NetMask>>24&0xFF,NetMask>>16&0xFF,NetMask>>8&0xFF,NetMask&0xFF);
  if(Flag & 0x80) printf("Type 1 external metric");
  else printf("Type 2 external metric");
  MetrTot=Metric1;
  MetrTot=MetrTot<<16;
  MetrTot=Metric1+Metric2;
  if (TOS == 0) printf ("Normal Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 4) printf ("Normal Delay, Normal Throghput, High Reliability");
  else if (TOS == 8) printf ("Normal Delay, High Throghput, Normal Reliability");
  else if (TOS == 12) printf ("Normal Delay, High Throghput, High Reliability");
  else if (TOS == 16) printf ("High Delay, Normal Throghput, Normal Reliability");
  else if (TOS == 20) printf ("High Delay, Normal Throghput, High Reliability");
  else if (TOS == 24) printf ("High Delay, High Throghput, Normal Reliability");
  else if (TOS == 28) printf ("High Delay, High Throghput, High Reliability");
  else printf ("Service Type %u", TOS);
  printf("Metric %u", MetrTot);
  printf("Forwarding Address [%u.%u.%u.%u]",
	FwdAddr>>24&0xFF,FwdAddr>>16&0xFF,FwdAddr>>8&0xFF,FwdAddr&0xFF);
  printf("External Route Tag [%u.%u.%u.%u]",
	ExtRout>>24&0xFF,ExtRout>16&0xFF,ExtRout>>8&0xFF,ExtRout&0xFF);
}  

DWORD IGRP ()
{
  title("EIGRP/IGRP Header");
  printf("Version Number 0x%X", VerOpCode);
  if (VerOpCode == 0x12) title("IGRP Update");
  else if (VerOpCode == 0x11) title("IGRP Request"); 
}
DWORD IGRP_REQUEST()
{
  printf("Number Update %u", Edition);
  printf("Autonomous System Number 0x%X", AutonomousSystem);
  printf("Number of Subnets Directly Connected Local Network %u", Ninterior);
  printf("Number of Route to Network not Directly Connected in AS %u", Nsystem);
  printf("Number of Route to Network outside AS identified as Default Network %u", Nexterior);
  printf("Checksum of Header and all Entries 0x%X", Checksum);
}
DWORD IGRP_UPDATE()
{
  DWORD Ip, Del, Band, Res;
  title("IGRP Update");
  Ip=IpAddress1<<8;
  Ip=Ip+IpAddress3;
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+3);
  printf("IPAddress [%u.%u.%u]", Ip>>16&0xFF,Ip>>8&0xFF,Ip&0xFF);
  Del=Delay1<<8;
  Del=Del+Delay3;
  Del=Del*10;
  ResetLog(GetVmVar("SizeInt")+3,GetVmVar("SizeInt")+3);
  printf("Delay %u microseconds", Del);
  Band=BandWidth1<<8;
  Res=Band+BandWidth3;
  Band=10000000/Res;
  ResetLog(GetVmVar("SizeInt")+6,GetVmVar("SizeInt")+3);
  printf("BandWidth %u Kbits/sec", Band);
  printf("Smallest Maximum Trasmission Unit %u",Mtu);
  printf("Total outgoing error rates of the interface along the route 0x%X", Reliab);
  printf("Total outgoing Load of the interface along the route 0x%X", Load);
  printf("Number of Hops to the Destination %u", HopCount);
}
DWORD EIGRP()
{
  title("EIGRP Header");
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if(OpCode==0x01) printf("Type 0x%X Update", OpCode);
  else if(OpCode==0x03) printf("Type 0x%X Query", OpCode);
  else if(OpCode==0x04) printf("Type 0x%X Reply", OpCode);
  else if(OpCode==0x05) printf("Type 0x%X Hello", OpCode);
  else if(OpCode==0x06) printf("Type 0x%X IPX SAP", OpCode);
  else printf("Type 0x%X", OpCode);
  ResetLog(GetVmVar("SizeInt")+1,GetVmVar("SizeInt")+3);
  printf("CheckSum of entire EIGRP packet 0x%X", CheckSum);
  ResetLog(GetVmVar("SizeInt")+3,GetVmVar("SizeInt")+7);
  if (Flag==0x01) printf("Flag 0x%X Enclosed Route Entry are the First", Flag);
  else if (Flag==0x02) printf("Flag 0x%X Conditional Receive Bit", Flag);
  else printf("Flag 0x%X", Flag);
  printf("Sequence Number used by RTP 0x%X", Sequence);
  printf("Acknowledge 0x%X", Ack);
  printf("Identification Number of EIGRP Domain 0x%X", ASysNumber);
  if (TLV == 0x0001) printf ("Type/Length/Value 0x%X EIGRP Parameters", TLV);
  else if (TLV == 0x0003) printf ("Type/Length/Value 0x%X Sequence", TLV);
  else if (TLV == 0x0004) printf ("Type/Length/Value 0x%X Software Version", TLV);
  else if (TLV == 0x0005) printf ("Type/Length/Value 0x%X Next Multicast Sequence", TLV);
  else if (TLV == 0x0102) printf ("Type/Length/Value 0x%X IP Internal Routes", TLV);
  else if (TLV == 0x0103) printf ("Type/Length/Value 0x%X IP External Routes", TLV);
  else if (TLV == 0x0202) printf ("Type/Length/Value 0x%X AppleTalk Internal Routes", TLV);
  else if (TLV == 0x0203) printf ("Type/Length/Value 0x%X AppleTalk External Routes", TLV);
  else if (TLV == 0x0204) printf ("Type/Length/Value 0x%X Cable Configuration", TLV);
  else if (TLV == 0x0302) printf ("Type/Length/Value 0x%X IPX Internal Routes", TLV);
  else if (TLV == 0x0303) printf ("Type/Length/Value 0x%X IPX External Routes", TLV);
  else printf ("Type/Length/Value 0x%X", TLV);
}
DWORD EIGRP_PAR()
{
  title("EIGRP Parameters");
  printf("Length 0x%X", Len);
  printf("K1 0x%X", K1);
  printf("K2 0x%X", K2);
  printf("K3 0x%X", K3);
  printf("K4 0x%X", K4);
  printf("K5 0x%X", K5);
  printf("Hold Time 0x%X", HoldTime);
}
DWORD EIGRP_SEQ()
{
  title("EIGRP Sequence");
  printf("Length 0x%X", Len);
}
DWORD EIGRP_SWV()
{
  title("EIGRP Software Version");
  printf("Length 0x%X", Len);
}
DWORD EIGRP_MSEQ()
{
  title("EIGRP Next Multicast Sequence");
  printf("Length 0x%X", Len);
}
DWORD EIGRP_IPIR()
{
  DWORD Res, Mtu;
  title("EIGRP IP Internal Routes");
  printf("Length 0x%X", Length);
  printf("Next Hop [%u.%u.%u.%u]", NextHop>>24&0xFF,NextHop>>16&0xFF,NextHop>>8&0xFF,NextHop&0xFF);
  if (Delay==0xFFFFFFFF) printf("Delay 0x%X Unreachable Route", Delay);
  else printf("Delay %u in units of 10 microseconds", Delay);
  Res=2560000000/BandWidth;
  printf("BandWith %u Kbits/sec", Res);
  Mtu=Mtu1<<8;
  Mtu=Mtu+Mtu2;
  ResetLog(GetVmVar("SizeInt")+14,GetVmVar("SizeInt")+3);
  printf("Smallest Maximum Trasmission Unit %u", Mtu);
  printf("Number of Hops to the Destination %u", HopCount);
  printf("Total outgoing error rates of the interface along the route 0x%X", Reliab);
  printf("Total outgoing Load of the interface along the route 0x%X", Load);  
  printf("Number of Network bits of the Address Mask %u", PrefixLen);
}
DWORD EIGRP_IPER()
{
  DWORD Band, Mtu;
  title("EIGRP IP External Routes");
  printf("Length 0x%X", Length);
  printf("Next Hop [%u.%u.%u.%u]", NextHop>>24&0xFF,NextHop>>16&0xFF,NextHop>>8&0xFF,NextHop&0xFF);
  printf("Originating Router [%u.%u.%u.%u]", ORouter>>24&0xFF,ORouter>>16&0xFF,ORouter>>8&0xFF,ORouter&0xFF);
  printf("Originating Autonomous System Number 0x%X", OASNro);
  printf("Arbitrary Tag 0x%X", ArbFlag);
  printf("External protocol Metric 0x%X", ExtProtMtr);
  if(ExtPrID==0x01) printf("External Protocol ID 0x%X IGRP", ExtPrID);
  else if(ExtPrID==0x02) printf("External Protocol ID 0x%X EIGRP", ExtPrID);
  else if(ExtPrID==0x03) printf("External Protocol ID 0x%X Static Route", ExtPrID);
  else if(ExtPrID==0x04) printf("External Protocol ID 0x%X RIP", ExtPrID);
  else if(ExtPrID==0x05) printf("External Protocol ID 0x%X Hello", ExtPrID);
  else if(ExtPrID==0x06) printf("External Protocol ID 0x%X OSPF", ExtPrID);
  else if(ExtPrID==0x07) printf("External Protocol ID 0x%X IS-IS", ExtPrID);
  else if(ExtPrID==0x08) printf("External Protocol ID 0x%X EGP", ExtPrID);
  else if(ExtPrID==0x09) printf("External Protocol ID 0x%X BGP", ExtPrID);
  else if(ExtPrID==0x0A) printf("External Protocol ID 0x%X IDRP", ExtPrID);
  else if(ExtPrID==0x0B) printf("External Protocol ID 0x%X Connected Link", ExtPrID);
  else printf("External Protocol ID 0x%X", ExtPrID);
  if(Flag==0x01) printf("Flag 0x%X Route is an External Route", Flag);
  else if (Flag==0x02) printf("Flag 0x%X Route is candidate Default Route", Flag);
  if (Delay==0xFFFFFFFF) printf("Delay 0x%X Unreachable Route", Delay);
  else printf("Delay %u in units of 10 microseconds", Delay);
  Band=2560000000/BandWidth;
  printf("BandWith %u Kbits/sec", Band);
  Mtu=Mtu1<<8;
  Mtu=Mtu+Mtu2;
  ResetLog(GetVmVar("SizeInt")+34,GetVmVar("SizeInt")+3);
  printf("Smallest Maximum Trasmission Unit %u", Mtu);
  printf("Number of Hops to the Destination %u", HopCount);
  printf("Total outgoing error rates of the interface along the route 0x%X", Reliab);
  printf("Total outgoing Load of the interface along the route 0x%X", Load);  
  printf("Number of Network bits of the Address Mask %u", PrefixLen);
}
DWORD EIGRP_IPDEST1()
{
  DWORD DestIp;
  DestIp=DestIP1<<8;
  DestIp=DestIp+DestIP2;
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+3);
  printf("Destination [%u.%u.%u.%u]", DestIp>>24&0xFF,DestIp>>16&0xFF,
                                      DestIp>>8&0xFF,DestIp&0xFF);
}
DWORD EIGRP_IPDEST2()
{
  printf("Destination [%u.%u.%u.%u]", DestIP>>24&0xFF,DestIP>>16&0xFF,
                                      DestIP>>8&0xFF,DestIP&0xFF);
}
DWORD EIGRP_IPXIR()
{
  title("EIGRP IPX Internal Routes");
  printf("Length 0x%X", Len);
}
DWORD EIGRP_IPXER()
{
  title("EIGRP IPX External Routes");
  printf("Length 0x%X", Len);
}
       
DWORD EGP()
{
    title("EGP Header");
    printf("Version Number %u", Version);
    printf("Type %t", Type);
    printf("Code %t", Code);
    printf("Status %t", Status);
    printf("CheckSum %u", checksum);
    printf("Autonomous system number %u", AuSysNumber);
    printf("Sequence Number %u", Sequence);
}

DWORD MACBRIDGE ()
{
    title("Bridge Header");
    printf ("Protocol Identifier 0x%X", Type);
    printf ("Version 0x%X", Version);
    if (MsgType== 0x0) printf ("Message Type 0x%X Hello", MsgType);
    else if (MsgType = 0x80) printf ("Message Type 0x%X Topology Change Notification", MsgType);
    else printf ("Message Type 0x%X (%r)", MsgType, offsetof(MsgType));
}
DWORD STA_HELLO()
{
    printf ("Flags", Flag);
    if (Flag & 0x08) printf (" ....1... Topology Acknowledgement required");
    else printf (" ....0... No Topology Acknowledgement required");
    if (Flag & 0x80) printf (" 1....... Network Extension");
    else printf (" 0....... No Network Extension");
    printf ("Root ID Prority 0x%X", PriorityR);
    printf ("Root ID Address %04X%02X-%02X%04X (Local; Vendor: %v)",
		    RootID1,RootID2>>8,RootID2&0xFF,RootID3,offsetof(RootID1));
    printf ("Root Path Cost %u (%r)", PathCost, offsetof(PathCost));
    printf ("Source Bridge Prority 0x%X", PriorityB); 
    printf ("Source Bridge Address%04X%02X-%02X%04X (Local; Vendor: %v)",
		BridgeID1,BridgeID2>>8,BridgeID2&0xFF,BridgeID3,offsetof(BridgeID1));
    printf ("Source Port 0x%X", PortID);
    printf ("Message Age %u seconds", MsgAge);
    printf ("Maximum Age %u seconds", MaxAge);
    printf ("Hello Time %u seconds", Hello);
    printf ("Forward Delay %u seconds", FwdDelay);
}
DWORD STA_TOPCHANGE()
{
    printf ("Flags", Flag);
    if (Flag & 0x08) printf (" ....1... Topology Acknowledgement required");
    else printf (" ....0... No Topology Acknowledgement required");
    if (Flag & 0x80) printf (" 1....... Network Extension");
    else printf (" 0....... No Network Extension");
}

//IPX packet Interpretation
DWORD IPX ()
{
    title("IPX Header");
    printf( "Checksum 0x%X",Checksum);
    printf( "Packet length %u",PLen);
    printf( "Transport control %u",TControl);
    ResetLog(GetVmVar("SizeInt")+5,GetVmVar("SizeInt")+6);
    if ((DSocket==0x9001) || (SSocket==0x9001)) printf( "Packet type 0x%X NetWare Link Service Protocol",PType);
    else if ((DSocket==0x85BE) || (SSocket==0x85BE)) printf( "Packet type 0x%X IPX EIGRP",PType);
    else if ((PType == 0x00) && ((DSocket==0x451) || (SSocket==0x451))) printf( "Packet type 0x%X Netware Core Protocol",PType);
    else if ((PType == 0x00) && ((DSocket==0x452) || (SSocket==0x452))) printf( "Packet type 0x%X Service Advertising Protocol",PType);
    else if ((PType == 0x00) && ((DSocket==0x453) || (SSocket==0x453))) printf( "Packet type 0x%X Routing Information Protocol",PType);
    else if ((PType == 0x04) && ((DSocket==0x455) || (SSocket==0x455))) printf( "Packet type 0x%X IPX NetBios",PType);
    else if (PType == 0x01) printf( "Packet type 0x%X Routinf Information Protocol",PType);
    else if (PType == 0x02) printf( "Packet type 0x%X Echo",PType);
    else if (PType == 0x03) printf( "Packet type 0x%X Error",PType,offsetof(PType));
    else if (PType == 0x04) printf( "Packet type 0x%X Service Advertising Protocol",PType);
    else if (PType == 0x05) printf( "Packet type 0x%X Sequence Packet Exchange (SPX)",PType);
    else if ((PType == 0x10) || (PType == 0x1F)) printf( "Packet type 0x%X Experimental");
    else if (Ptype == 0x11) printf( "Packet type 0x%X Netware Core Protocol (NCP)",PType);
    else if (PType == 0x14) printf( "Packet type 0x%X IPX NetBios",PType);
    else printf( "Packet type 0x%X (%r)",PType,offsetof(PType));
    printf( "Destination network 0x%08X",DNet);
    printf( "Destination node %04X%02X-%02X%04X (Vendor: %v)",DNode1,(DNode2>>8),DNode2&0xff,DNode3,offsetof(DNode1));
    if (DSocket == 0x451) printf( "Destination socket 0x%04X Netware Core Protocol",DSocket);
    else if (DSocket == 0x452) printf( "Destination socket 0x%04X Service Advertising Protocol",DSocket);
    else if (DSocket == 0x453) printf( "Destination socket 0x%04X Routing Information Protocol",DSocket);
    else if (DSocket == 0x455) printf( "Destination socket 0x%04X NETBios",DSocket);
    else if (DSocket == 0x456) printf( "Destination socket 0x%04X Diagnostic Packet",DSocket);
    else if (DSocket == 0x457) printf( "Destination socket 0x%04X Serialization",DSocket);
    else if (DSocket == 0x550) printf( "Destination socket 0x%04X SMB Server Sockets - Request",DSocket);
    else if (DSocket == 0x551) printf( "Destination socket 0x%04X SMB Name Sockets - Name Query",DSocket);
    else if (DSocket == 0x552) printf( "Destination socket 0x%04X SMB Redir Sockets - Redirector",DSocket);
    else if (DSocket == 0x553) printf( "Destination socket 0x%04X SMB MailSlot Sockets",DSocket);
    else if (DSocket == 0x554) printf( "Destination socket 0x%04X SMB Messanger Sockets",DSocket);
    else if (DSocket == 0x8063) printf( "Destination socket 0x%04X Novell Virtual Terminal (NVT)",DSocket);
    else if (DSocket == 0x85BE) printf( "Destination socket 0x%04X IPX EIGRP",DSocket);
    else if (DSocket == 0x9001) printf( "Destination socket 0x%04X NetWare Link Services Protocol",DSocket);
    else if (DSocket == 0x9004) printf( "Destination socket 0x%04X IPXWAN Protocol",DSocket);
    else if (DSocket == 0x9086) printf( "Destination socket 0x%04X IPX Ping",DSocket);
    else if (DSocket >= 0x4001 && DSocket <= 0x7FFF) printf( "Destination socket 0x%04X WorkStations Sockets - Dynamically assigned",DSocket,offsetof(DSocket));
    else printf ( "Destination socket 0x%04X (%n) WorkStation Sockets ",DSocket,offsetof(DSocket));
    printf( "Source network 0x%08X",SNet);
    printf( "Source node %04X%02X-%02X%04X (Vendor: %v)",SNode1,SNode2>>8,SNode2&0xff,SNode3,Offsetof(SNode1));
    if (SSocket == 0x451) printf( "Source socket 0x%04X Netware Core Protocol",SSocket);
    else if (SSocket == 0x452) printf( "Source socket 0x%04X Service Advertising Protocol",SSocket);
    else if (SSocket == 0x453) printf( "Source socket 0x%04X Routing Information Protocol",SSocket);
    else if (SSocket == 0x455) printf( "Source socket 0x%04X NETBios",SSocket);
    else if (SSocket == 0x456) printf( "Source socket 0x%04X Diagnostic Packet",SSocket);
    else if (SSocket == 0x457) printf( "Source socket 0x%04X Serialization",SSocket);
    else if (SSocket == 0x550) printf( "Source socket 0x%04X SMB Server Sockets - Request",SSocket);
    else if (SSocket == 0x551) printf( "Source socket 0x%04X SMB Name Sockets - Name Query",SSocket);
    else if (SSocket == 0x552) printf( "Source socket 0x%04X SMB Redir Sockets - Redirector",SSocket);
    else if (SSocket == 0x553) printf( "Source socket 0x%04X SMB MailSlot Sockets",SSocket);
    else if (SSocket == 0x554) printf( "Source socket 0x%04X SMB Messanger Sockets",SSocket);
    else if (SSocket == 0x8063) printf( "Source socket 0x%04X Novell Virtual Terminal (NVT)",SSocket);
    else if (SSocket == 0x85BE) printf( "Source socket 0x%04X IPX EIGRP",SSocket);
    else if (SSocket == 0x9001) printf( "Source socket 0x%04X NetWare Link Services Protocol",SSocket);
    else if (SSocket == 0x9004) printf( "Source socket 0x%04X IPXWAN Protocol",SSocket);
    else if (SSocket == 0x9086) printf( "Source socket 0x%04X IPX Ping",SSocket);
    else if (SSocket >= 0x4001 && SSocket <= 0x7FFF) printf( "Source socket 0x%04X WorkStations Sockets - Dynamically assigned",SSocket);
    else printf ("Source Socket 0x%04X (%n)", SSocket,offsetof(SSocket));
}
DWORD SPX ()
{
    title("SPX Header");
    printf( "Connection Control Flag %u",ConnCtrlFlag);
    printf( "Data Stream Type %u",DataStreamType);
    printf( "Sequence Connection ID %u",SConnectionID);
    printf( "Destination Connection ID %u",DConnectionID);
    printf( "Sequence Number %u",SeqNumber);
    printf( "Acknowledgement control %u",AckNumber);
    printf( "Allocation Number %u",AllocNumber);
}
DWORD RIPX ()
{
    title("RIPX Header");
    if (Operation == 0x01) printf( "Operation 0x%X Request",Operation);
    else if (Operation == 0x02) printf( "Operation 0x%X Response",Operation);
    else printf( "Operation 0x%X",Operation);
    printf( "Network Number 0x%08X",Network_Number);
    printf( "Number Hops %u",Number_Hops);
    printf( "Ticks %u", Number_Ticks);
}
DWORD RIPX_NET_ENTRY ()
{
    title("RIPX Entry");
    printf( "Network Number 0x%08X",Network_Number);
    printf( "Number Hops %u",NHops);
    printf( "Ticks %u", NTicks);
}

ARRAY p;
DWORD NETBIOS_MAIN(DWORD BeginNET, DWORD OffSet)
{
 DWORD Pos;
 Pos=BeginNET+OffSet;
 BYTE n,c,m;
 DWORD q,l;

	 c='A';
	 q=0;
	 l=0;
	 clear(p);
	 do
	 {
		 CHECK(Pos+l);
		 n=CONV(Pos+l)-c;
		 m=n<<4;
		 n=CONV(Pos+l+1)-c;
		 p[q]=m+n;
		 q=q+1;
		 l=l+2;
//	 } while (q<32);
	 } while (q<15);
// Fulvio: I presume "q<16" is better; however it does not work
// it prints a bad char at the end of the string
// It the maximum NETBIOS name lenght equal to 14, maybe?
	 p[q]='\0';
}

// Fulvio: I don't know; these functions do nothing; however they must be defined
DWORD GetName(DWORD cp,DWORD nstr,DWORD pos, DWORD beginDNS);
DWORD GetStringa(DWORD nstr, DWORD Pos);
DWORD GetSRVName(DWORD Pos);

DWORD SAP_MAIN(DWORD BeginSAP, DWORD OffSet)
{
 DWORD Pos; 
 Pos=BeginSAP+OffSet;
 Pos=GetSRVName(Pos);
}
DWORD GetSRVName(DWORD Pos)
{
	clear(p);
      Pos=GetStringa(48,Pos);
}
DWORD GetStringa(DWORD nstr,DWORD Pos)
{
       DWORD q;
         q=0;
	   do
          {
           CHECK(Pos+q);
           p[q]=CONV(Pos+q);
	     q=q+1;
		DWORD ii;
          } while (q<nstr);
         p[q]='\0';
         return Pos;
}
DWORD NAME16(DWORD BeginFrame, DWORD OffSet)
{
 DWORD Pos; 
 DWORD q;

 Pos=BeginFrame+OffSet;
 clear(p);
 q=0;
 do
  {
	CHECK(Pos+q);
      p[q]=CONV(Pos+q);
	q=q+1;
   } while (q<16);
   p[q]='\0';
}
DWORD SMB_SLOT_NAME(DWORD BeginFrame, DWORD TotalFrame, DWORD OffSet)
{
  DWORD Pos;
  DWORD q;
  DWORD Fine;

  Pos=BeginFrame+OffSet;
  Fine=TotalFrame-OffSet;
  clear(p);
  q=0;
  do
  {
	CHECK(Pos+q);
	p[q]=CONV(Pos+q);
	q=q+1;
  } while(q<Fine);
  p[q]='\0';
}
DWORD SMB_SLOT_LAN(DWORD BeginFrame, DWORD OffSet, DWORD LenName)
{
  DWORD Pos;
 
  Pos=BeginFrame+OffSet;
  clear(p);
  LenName=0;
  CHECK(Pos+LenName);
  p[LenName]=CONV(Pos+LenName);
  while(p[LenName]!=0)
  {
	LenName=LenName+1;
	CHECK(Pos+LenName);
	p[LenName]=CONV(Pos+LenName);
  } 
  return LenName;
}
WORD SMB_REVERSE(WORD W1)
{
  WORD WApp1, WApp2, WRes;
		
	WApp1=W1 & 0x0F;
	WApp2=W1 >> 8;
	WRes=WApp1 << 8;
	WRes=WRes+WApp2;
  return WRes;
}		
DWORD SMB_REVERSEDW(DWORD DW1)
{
  DWORD DWApp1, DWApp2, DWApp3, DwApp4, DWRes;

	DWApp1=DW1 << 24;
	DWApp2=DW1 << 16;
	DWApp2=DWApp2 & 0xFF000000;
      DWApp2=DWApp2 >> 8;
	DWApp3=DW1 << 8;
	DWApp3=DWApp3 & 0xFF000000;
	DWApp3=DWApp3 >> 16; 
	DWApp4=DW1 >> 24; 
      DWRes=DWApp1+DWApp2+DWApp3+DWApp4;
  return DWRes;
}
DWORD SMB_UNICODE(DWORD BeginFrame, DWORD OffSet)
{
  DWORD Pos, Incr;

  Pos=BeginFrame+OffSet;
  clear(p);
  Incr=0;
  do
  {
	CHECK(Pos+Incr);
	CHECK(Pos+Incr+1);
	if(CONV(Pos+Incr)=='.') p[Incr]=CONV(Pos+Incr+1);
	else p[Incr]=CONV(Pos+Incr);
	Incr=Incr+1;
  } while(CONV(Pos+Incr-1)!='.' || CONV(Pos+Incr)!='.');
  p[Incr]='\0';
}

  	
DWORD SAP ()
{
    title("SAP Header");
    if (Operation == 0x01) printf( "Operation %u General Service Query",Operation);
    else if (Operation == 0x02) printf( "Operation %u General Service Response",Operation);
    else if (Operation == 0x03) printf( "Operation %u Get Nearest Server Query",Operation);
    else if (Operation == 0x04) printf( "Operation %u Nearest Server Response",Operation);
    else printf( "Operation %u Broadcast (%n)",Operation, offsetof(Operation));
}
DWORD SAP_REQUEST()
{
    if (SType == 0x1) printf( "Service Type 0x%X User",SType);
    else if (SType == 0x02) printf( "Service type 0x%X User Group",SType);
    else if (SType == 0x03) printf( "Service type 0x%X Print Queue",SType);
    else if (SType == 0x04) printf( "Service type 0x%X File Server",SType);    
    else if (SType == 0x05) printf( "Service type 0x%X Job Server",SType);
    else if (SType == 0x06) printf( "Service type 0x%X Gateway",SType);
    else if (SType == 0x07) printf( "Service type 0x%X Print Server",SType);
    else if (SType == 0x08) printf( "Service type 0x%X Archive Queue",SType);
    else if (SType == 0x09) printf( "Service type 0x%X Archive Server",SType);
    else if (SType == 0xA) printf( "Service type 0x%X Job Queue",SType);
    else if (SType == 0xB) printf( "Service type 0x%X Administration",SType);
    else if (SType == 0xF) printf( "Service type 0x%X Novell TI-RPC",SType);
    else if (SType == 0x17) printf( "Service type 0x%X Diagnostic",SType);
    else if (SType == 0x20) printf( "Service type 0x%X NetBios",SType);
    else if (SType == 0x21) printf( "Service type 0x%X NAS SNA Gateway",SType);
    else if (SType == 0x23) printf( "Service type 0x%X NACS",SType);
    else if (SType == 0x24) printf( "Service type 0x%X Remote Bridge Server or Routing Service",SType);
    else if (SType == 0x26) printf( "Service type 0x%X Bridge Server",SType);
    else if (SType == 0x27) printf( "Service type 0x%X TCP/IP Gateway Server",SType);
    else if (SType == 0x29) printf( "Service type 0x%X EICON 3270 Gateway",SType);    
    else if (SType == 0x2D) printf( "Service type 0x%X Time Synchronization Server",SType);  
    else if (SType == 0x2E) printf( "Service type 0x%X ARCServe 5.0",SType);
    else if (SType == 0x47) printf( "Service type 0x%X Advertising Print Server",SType);
    else if (SType == 0x4B) printf( "Service type 0x%X BTrieve VAP 5.0",SType);
    else if (SType == 0x4C) printf( "Service type 0x%X SQL VAP",SType);
    else if (SType == 0x4D) printf( "Service type 0x%X Xtree Network Version",SType);
    else if (SType == 0x50) printf( "Service type 0x%X BTrieve VAP 4.11",SType);
    else if (SType == 0x53) printf( "Service type 0x%X Print Queue User",SType);
    else if (SType == 0x72) printf( "Service type 0x%X WANCopy Utility",SType);
    else if (SType == 0x7A) printf( "Service type 0x%X TES-NetWare for VMS",SType);
    else if (SType == 0x98) printf( "Service type 0x%X NetWare Access Server",SType);
    else if (SType == 0x9E) printf( "Service type 0x%X Portable NetWare Server",SType);
    else if (SType == 0xA1) printf( "Service type 0x%X Powerchute APC UPS NLM",SType);
    else if (SType == 0x107) printf( "Service type 0x%X RSPX Remote Console",SType);
    else if (SType == 0x10F) printf ("Service type 0x%X Novell SNA GateWay", SType);
    else if (SType == 0x12B) printf ("Service type 0x%X NetWare for SAA", SType);
    else if (SType == 0x130) printf( "Service type 0x%X Communication Executive",SType);
    else if (SType == 0x133) printf( "Service type 0x%X NNS Domain",SType);
    else if (SType == 0x137) printf( "Service type 0x%X NetWare 386 Print Queue",SType);
    else if (SType == 0x1F0) printf( "Service type 0x%X Legato",SType);
    else if (SType == 0x1F5) printf( "Service type 0x%X Legato",SType);
    else if (SType == 0x24F) printf( "Service type 0x%X NASI Server Broadcast (CISCO)",SType);
    else if (SType == 0x278) printf( "Service type 0x%X NetWare Directory Services",SType);
    else if (SType == 0x26B) printf( "Service type 0x%X Time Synchronization",SType);
    else if (SType == 0x394) printf( "Service type 0x%X NetWare SAA Gateway",SType);
    else if (SType == 0x3D7) printf( "Service type 0x%X LexMark Printer Server",SType);
    else if (SType == 0x3D8) printf( "Service type 0x%X LexMark XLE Printer Server",SType);
    else if (SType == 0x3E1) printf( "Service type 0x%X UnixWare",SType);
    else if (SType == 0x3E4) printf( "Service type 0x%X UnixWare",SType);
    else if (SType == 0x60C) printf( "Service type 0x%X AXIS Network Printer",SType);
    else if (SType == 0x640) printf( "Service type 0x%X Microsoft Gateway Services for Netware",SType);
    else if (SType == 0x64E) printf( "Service type 0x%X Microsoft Internet Information Server",SType);
    else if (SType == 0x67B) printf( "Service type 0x%X Microsoft Win95/98 File and Print Sharing for NetWare",SType);
    else if (SType == 0x67C) printf( "Service type 0x%X Microsoft Win95/98 File and Print Sharing for NetWare",SType);
    else if (SType == 0x85BE) printf( "Service type 0x%X Cisco EIGRP",SType);
    else if (SType == 0xF503) printf( "Service type 0x%X Microsoft SQL Server",SType);
    else if (SType == 0xFFFF) printf( "Service type 0x%X WildCard",SType);
    else printf ("Service type 0x%X (%r)", SType, offsetof(SType));
}
DWORD SAP_REPLY()
{
    if (SType == 0x1) printf( "Service Type 0x%X User",SType);
    else if (SType == 0x02) printf( "Service type 0x%X User Group",SType);
    else if (SType == 0x03) printf( "Service type 0x%X Print Queue",SType);
    else if (SType == 0x04) printf( "Service type 0x%X File Server",SType);    
    else if (SType == 0x05) printf( "Service type 0x%X Job Server",SType);
    else if (SType == 0x06) printf( "Service type 0x%X Gateway",SType);
    else if (SType == 0x07) printf( "Service type 0x%X Print Server",SType);
    else if (SType == 0x08) printf( "Service type 0x%X Archive Queue",SType);
    else if (SType == 0x09) printf( "Service type 0x%X Archive Server",SType);
    else if (SType == 0xA) printf( "Service type 0x%X Job Queue",SType);
    else if (SType == 0xB) printf( "Service type 0x%X Administration",SType);
    else if (SType == 0xF) printf( "Service type 0x%X Novell TI-RPC",SType);
    else if (SType == 0x17) printf( "Service type 0x%X Diagnostic",SType);
    else if (SType == 0x20) printf( "Service type 0x%X NetBios",SType);
    else if (SType == 0x21) printf( "Service type 0x%X NAS SNA Gateway",SType);
    else if (SType == 0x23) printf( "Service type 0x%X NACS",SType);
    else if (SType == 0x24) printf( "Service type 0x%X Remote Bridge Server or Routing Service",SType);
    else if (SType == 0x26) printf( "Service type 0x%X Bridge Server",SType);
    else if (SType == 0x27) printf( "Service type 0x%X TCP/IP Gateway Server",SType);
    else if (SType == 0x29) printf( "Service type 0x%X EICON 3270 Gateway",SType);    
    else if (SType == 0x2D) printf( "Service type 0x%X Time Synchronization Server",SType);  
    else if (SType == 0x2E) printf( "Service type 0x%X ARCServe 5.0",SType);
    else if (SType == 0x47) printf( "Service type 0x%X Advertising Print Server",SType);
    else if (SType == 0x4B) printf( "Service type 0x%X BTrieve VAP 5.0",SType);
    else if (SType == 0x4C) printf( "Service type 0x%X SQL VAP",SType);
    else if (SType == 0x4D) printf( "Service type 0x%X Xtree Network Version",SType);
    else if (SType == 0x50) printf( "Service type 0x%X BTrieve VAP 4.11",SType);
    else if (SType == 0x53) printf( "Service type 0x%X Print Queue User",SType);
    else if (SType == 0x72) printf( "Service type 0x%X WANCopy Utility",SType);
    else if (SType == 0x7A) printf( "Service type 0x%X TES-NetWare for VMS",SType);
    else if (SType == 0x98) printf( "Service type 0x%X NetWare Access Server",SType);
    else if (SType == 0x9E) printf( "Service type 0x%X Portable NetWare Server",SType);
    else if (SType == 0xA1) printf( "Service type 0x%X Powerchute APC UPS NLM",SType);
    else if (SType == 0x107) printf( "Service type 0x%X RSPX Remote Console",SType);
    else if (SType == 0x10F) printf ("Service type 0x%X Novell SNA GateWay", SType);
    else if (SType == 0x12B) printf ("Service type 0x%X NetWare for SAA", SType);
    else if (SType == 0x130) printf( "Service type 0x%X Communication Executive",SType);
    else if (SType == 0x133) printf( "Service type 0x%X NNS Domain",SType);
    else if (SType == 0x137) printf( "Service type 0x%X NetWare 386 Print Queue",SType);
    else if (SType == 0x1F0) printf( "Service type 0x%X Legato",SType);
    else if (SType == 0x1F5) printf( "Service type 0x%X Legato",SType);
    else if (SType == 0x24F) printf( "Service type 0x%X NASI Server Broadcast (CISCO)",SType);
    else if (SType == 0x278) printf( "Service type 0x%X NetWare Directory Services",SType);
    else if (SType == 0x26B) printf( "Service type 0x%X Time Synchronization",SType);
    else if (SType == 0x394) printf( "Service type 0x%X NetWare SAA Gateway",SType);
    else if (SType == 0x3D7) printf( "Service type 0x%X LexMark Printer Server",SType);
    else if (SType == 0x3D8) printf( "Service type 0x%X LexMark XLE Printer Server",SType);
    else if (SType == 0x3E1) printf( "Service type 0x%X UnixWare",SType);
    else if (SType == 0x3E4) printf( "Service type 0x%X UnixWare",SType);
    else if (SType == 0x60C) printf( "Service type 0x%X AXIS Network Printer",SType);
    else if (SType == 0x640) printf( "Service type 0x%X Microsoft Gateway Services for Netware",SType);
    else if (SType == 0x64E) printf( "Service type 0x%X Microsoft Internet Information Server",SType);
    else if (SType == 0x67B) printf( "Service type 0x%X Microsoft Win95/98 File and Print Sharing for NetWare",SType);
    else if (SType == 0x67C) printf( "Service type 0x%X Microsoft Win95/98 File and Print Sharing for NetWare",SType);
    else if (SType == 0x85BE) printf( "Service type 0x%X Cisco EIGRP",SType);
    else if (SType == 0xF503) printf( "Service type 0x%X Microsoft SQL Server",SType);
    else if (SType == 0xFFFF) printf( "Service type 0x%X WildCard",SType);
    else printf ("Service type 0x%X (%r)", SType, offsetof(SType));
    SAP_MAIN(GetVmVar("SizeInt"),2);
    ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+50);
    aprintf ("Server Name %s",p);
    printf( "Network Address 0x%08X",NetworkAddress);
    printf( "Node Address %04X%02X-%02X%04X (Vendor: %v)",
		NodeAddress1,NodeAddress2>>8,NodeAddress2&0xff,NodeAddress3,Offsetof(NodeAddress1));
    printf( "Socket Address 0x%04X (%n)",SocketAddress, offsetof(SocketAddress));
    printf( "Hops %u ",Hops);
}

DWORD SAP_SERV_ENTRY ()
{
    title("SAP Entry");
    if (SType == 0x1) printf( "Service Type 0x%X User",SType);
    else if (SType == 0x02) printf( "Service type 0x%X User Group",SType);
    else if (SType == 0x03) printf( "Service type 0x%X Print Queue",SType);
    else if (SType == 0x04) printf( "Service type 0x%X File Server",SType);    
    else if (SType == 0x05) printf( "Service type 0x%X Job Server",SType);
    else if (SType == 0x06) printf( "Service type 0x%X Gateway",SType);
    else if (SType == 0x07) printf( "Service type 0x%X Print Server",SType);
    else if (SType == 0x08) printf( "Service type 0x%X Archive Queue",SType);
    else if (SType == 0x09) printf( "Service type 0x%X Archive Server",SType);
    else if (SType == 0xA) printf( "Service type 0x%X Job Queue",SType);
    else if (SType == 0xB) printf( "Service type 0x%X Administration",SType);
    else if (SType == 0xF) printf( "Service type 0x%X Novell TI-RPC",SType);
    else if (SType == 0x17) printf( "Service type 0x%X Diagnostic",SType);
    else if (SType == 0x20) printf( "Service type 0x%X NetBios",SType);
    else if (SType == 0x21) printf( "Service type 0x%X NAS SNA Gateway",SType);
    else if (SType == 0x23) printf( "Service type 0x%X NACS",SType);
    else if (SType == 0x24) printf( "Service type 0x%X Remote Bridge Server or Routing Service",SType);
    else if (SType == 0x26) printf( "Service type 0x%X Bridge Server",SType);
    else if (SType == 0x27) printf( "Service type 0x%X TCP/IP Gateway Server",SType);
    else if (SType == 0x29) printf( "Service type 0x%X EICON 3270 Gateway",SType);    
    else if (SType == 0x2D) printf( "Service type 0x%X Time Synchronization Server",SType);  
    else if (SType == 0x2E) printf( "Service type 0x%X ARCServe 5.0",SType);
    else if (SType == 0x47) printf( "Service type 0x%X Advertising Print Server",SType);
    else if (SType == 0x4B) printf( "Service type 0x%X BTrieve VAP 5.0",SType);
    else if (SType == 0x4C) printf( "Service type 0x%X SQL VAP",SType);
    else if (SType == 0x4D) printf( "Service type 0x%X Xtree Network Version",SType);
    else if (SType == 0x50) printf( "Service type 0x%X BTrieve VAP 4.11",SType);
    else if (SType == 0x53) printf( "Service type 0x%X Print Queue User",SType);
    else if (SType == 0x72) printf( "Service type 0x%X WANCopy Utility",SType);
    else if (SType == 0x7A) printf( "Service type 0x%X TES-NetWare for VMS",SType);
    else if (SType == 0x98) printf( "Service type 0x%X NetWare Access Server",SType);
    else if (SType == 0x9E) printf( "Service type 0x%X Portable NetWare Server",SType);
    else if (SType == 0xA1) printf( "Service type 0x%X Powerchute APC UPS NLM",SType);
    else if (SType == 0x107) printf( "Service type 0x%X RSPX Remote Console",SType);
    else if (SType == 0x10F) printf ("Service type 0x%X Novell SNA GateWay", SType);
    else if (SType == 0x12B) printf ("Service type 0x%X NetWare for SAA", SType);
    else if (SType == 0x130) printf( "Service type 0x%X Communication Executive",SType);
    else if (SType == 0x133) printf( "Service type 0x%X NNS Domain",SType);
    else if (SType == 0x137) printf( "Service type 0x%X NetWare 386 Print Queue",SType);
    else if (SType == 0x1F0) printf( "Service type 0x%X Legato",SType);
    else if (SType == 0x1F5) printf( "Service type 0x%X Legato",SType);
    else if (SType == 0x24F) printf( "Service type 0x%X NASI Server Broadcast (CISCO)",SType);
    else if (SType == 0x278) printf( "Service type 0x%X NetWare Directory Services",SType);
    else if (SType == 0x26B) printf( "Service type 0x%X Time Synchronization",SType);
    else if (SType == 0x394) printf( "Service type 0x%X NetWare SAA Gateway",SType);
    else if (SType == 0x3D7) printf( "Service type 0x%X LexMark Printer Server",SType);
    else if (SType == 0x3D8) printf( "Service type 0x%X LexMark XLE Printer Server",SType);
    else if (SType == 0x3E1) printf( "Service type 0x%X UnixWare",SType);
    else if (SType == 0x3E4) printf( "Service type 0x%X UnixWare",SType);
    else if (SType == 0x60C) printf( "Service type 0x%X AXIS Network Printer",SType);
    else if (SType == 0x640) printf( "Service type 0x%X Microsoft Gateway Services for Netware",SType);
    else if (SType == 0x64E) printf( "Service type 0x%X Microsoft Internet Information Server",SType);
    else if (SType == 0x67B) printf( "Service type 0x%X Microsoft Win95/98 File and Print Sharing for NetWare",SType);
    else if (SType == 0x67C) printf( "Service type 0x%X Microsoft Win95/98 File and Print Sharing for NetWare",SType);
    else if (SType == 0x85BE) printf( "Service type 0x%X Cisco EIGRP",SType);
    else if (SType == 0xF503) printf( "Service type 0x%X Microsoft SQL Server",SType);
    else if (SType == 0xFFFF) printf( "Service type 0x%X WildCard",SType);
    else printf ("Service type 0x%X (%r)", SType, offsetof(SType));
    SAP_MAIN(GetVmVar("SizeInt"),2);
    ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+50);
    aprintf ("Server Name %s",p);
    printf( "Network Address 0x%08X",NetworkAddress);
    printf( "Node Address %04X%02X-%02X%04X (Vendor: %v)",
		NodeAddress1,NodeAddress2>>8,NodeAddress2&0xff,NodeAddress3,Offsetof(NodeAddress1));
    printf( "Socket Address 0x%04X (%n) ",SocketAddress, offsetof(SocketAddress));
    printf( "Hops %u ",Hops);
}
DWORD NCP ()
{
    title("NCP Header");
    if(Type == 0x1111) printf("Type 0x%X Create Service Connection", Type);
    else if(Type == 0x2222) printf("Type 0x%X Service Request", Type);
    else if(Type == 0x3333) printf("Type 0x%X Service Reply", Type);
    else if(Type == 0x5555) printf("Type 0x%X Destroy service connection", Type);
    else if(Type == 0x7777) printf("Type 0x%X Burst mode transfer", Type);
    else if(Type == 0x9999) printf("Type 0x%X Request being processed response (ACK with wait)", Type);
    else printf ("Type 0x%X (%r)", Type, offsetof(Type));
    printf( "Sequence Number %u ",SequenceNumber);
    printf( "Connection Number High %u ",ConnHigh);
    printf( "Task Number %u ",TaskNumber);
    printf( "Connection Number Low %u ",ConnLow);
}
DWORD NCP_REPLY()
{
    printf("Completation Code 0x%X", ComplCode);
    printf("Connection Status 0x%x", ConnStatus);
}
DWORD NCP_REQUEST()
{
    if (FuncCode == 76) printf( "Function Code %u Open File",FuncCode);
    else if (FuncCode == 66) printf( "Function Code %u Close File",FuncCode);
    else if (FuncCode == 0) printf( "Function Code %u Successfull Completation",FuncCode);
    else if (FuncCode == 0x17 && SubFunc==0x37) printf("Function Code 0x%X Scan Bindery Object",FuncCode);
    else if (FuncCode == 0x68) printf("Function Code 0x%X Test for NetWare Directory Services Support", FuncCode);
    else if (FuncCode == 0x65) printf("Function Code 0x%X Packet Burst Connection", FuncCode);
    else if (FuncCode == 0x61) printf("Function Code 0x%X Negotiate for LIP Buffer", FuncCode);
    else if (FuncCode == 0x19) printf("Function Code 0x%X Logout", FuncCode);
    else if (FuncCode == 0x18) printf("Function Code 0x%X End of Job", FuncCode);
    else if (FuncCode == 0x16) printf("Function Code 0x%X Get Volume Number", FuncCode);
    else if (FuncCode == 0x57) printf("Function Code 0x%X NS Search Initiate", FuncCode);
    else if (FuncCode == 0x4C) printf("Function Code 0x%X File Open", FuncCode);
    else if (FuncCode == 0x40) printf("Function Code 0x%X Search File", FuncCode);
    else if (FuncCode == 0x3E) printf("Function Code 0x%X File Search Initialize", FuncCode);
    else if (FuncCode == 0x3F) printf("Function Code 0x%X File Search Continue", FuncCode);
    else printf( "Function Code %u (%r)",FuncCode, offsetof(FuncCode));
    printf("Sub Function Length 0x%X", SubLen);
    printf("Sub Function Code 0x%X", SubFunc);
}
DWORD NLSP()
{
	title("NLSP Hello");
	printf("NLSP Protocol 0x%X", ProtocolID);
	printf("Number bytes in the fixed header %u", Length);
	printf("Minor Version 0x%X", MinorVer);
	printf("Packet Type 0x%X", PckType);
	printf("Major Version 0x%X", MajorVer);
	printf("Flag2 0x%X", Flag2);
	printf("SourceID1 0x%X", SrcID1);
	printf("SourceID2 0x%X", SrcID2);
	printf("Holding Timer %u sec", HoldTime);
	printf("Packet Length %u bytes", PckLen);
	printf("CircuitID 0x%X", WANID);
}

DWORD GetDNSName(DWORD pos, DWORD beginDNS)
    {
		 clear(p);
		 pos=GetName(0,1000,pos, beginDNS);
         aprintf( " Name : %s" ,p);
         CHECK(pos+2);
         printf ( " Type = %u" ,CONV16(pos+0));
         CHECK(pos+4);
         printf ( " Code = %u",CONV16(pos+2));
         pos=pos+4;
		 return pos;
    }

DWORD GetName(DWORD cp,DWORD nstr,DWORD pos, DWORD beginDNS)
    {
       DWORD n,q;
	   cp=0;
	   q=0;
	   clear(p);
         do
          {
           CHECK(pos+1);
           n=CONV(pos+0);
           if(n==0xc0)
             {
                DWORD savepos,j;
				savepos=pos;
                pos=pos+1;
                CHECK(pos+1);
                j=CONV(pos+0);
                if(cp!=0)
                 {p[cp]='.';
                  cp=cp+1;if(cp>=nstr) {cp=nstr;break;}}
                pos=beginDNS+j;
                pos=GetName(cp,nstr-cp,pos,beginDNS);
                pos=savepos+2;
                cp=strlen(p);
                n=0;
             } else
           {
            if ((cp!=0)&&(n!=0)) {p[cp]='.';cp=cp+1;if(cp>=nstr) {cp=1000;break;}}
            pos=pos+1;
			DWORD ii;
            for (ii=0;ii<n;ii=ii+1)
             {CHECK(pos+1);p[cp]=CONV(pos+0);pos=pos+1;cp=cp+1;if(cp>=nstr) {cp=1000;break;}}
           }
          } while (n!=0);
         p[cp]='\0';
         return pos;
    }

DWORD Answer(DWORD pos,DWORD beginDNS)
    {
         DWORD nt;
         pos=GetDNSName( pos , beginDNS );
         CHECK(pos+4);
         printf ( "  Time to live = %u" ,CONV32(pos+0));
         pos=pos+4;
         CHECK(pos+2);
         nt=CONV16(pos+0);
         printf ( " RData length = %u" ,nt);
         CHECK(pos+nt+2);
         if (nt==4)
         printf ( "  Address = %u.%u.%u.%u" ,CONV(pos+2),CONV(pos+3),CONV(pos+4),CONV(pos+5));
         else printf ("  Address = [...]: %u bytes of data" ,nt);
         pos=pos+2+nt;
		 return pos;
    }

DWORD DNS_MAIN(DWORD beginDNS,DWORD q,DWORD ans,DWORD aut,DWORD add);

DWORD DNS()
{
    DWORD temp;
    printf("----- DNS ----- [%d-%d]",GetVmVar("SizeInt"),GetVmVar("FrameAvail"));
    printf( "Identification = %u" ,ID);
    temp=FLAGS;
    printf( "Parameter = %u" ,temp);

    if (temp&0x8000) printf ( " 1....... ........ Message is a response" );
     else printf ( " 0....... ........ Message is a query." );

	if(((temp&0x7800)>>11)==0)
         printf ( " .0000... ........ type of message:0 Standard query (name to address)" );
	else if(((temp&0x7800)>>11)==1)
         printf ( " .0001... ........ type of message:1 Inverse query (address to name)" );
	else if(((temp&0x7800)>>11)==2)
         printf ( " .0010... ........ type of message:2 Server status request" );
	else if(opcode==5)
           printf ( " .0101... ........ type of message:5 Update");
	else
         printf ( " .XXXX... ........ type of message:%1d Unknown" ,((temp&0x7800)>>11));

    if (temp&0x0400) printf ( " .....1.. ........ Authoritative Answer:response made by an authoritative name server" );
     else printf ( " .....0.. ........ Authoritative Answer:response not made by an authoritative name server" );
    if (temp&0x0200) printf ( " ......1. ........ Message has been truncated" );
     else printf ( " ......0. ........ Message has not been truncated" );
    if (temp&0x0100) printf ( " .......1 ........ Request recursive service by the name server" );
     else printf ( " .......0 ........ Do not request recursive service by the name server" );
    if (temp&0x0080) printf ( " ........ 1....... Recursive service is available" );
     else printf ( " ........ 0....... Recursive service is not available" );

    printf ( " ........ .XXX.... Reserved %0d%0d%0d" ,temp&0x0040,temp&0x0020,temp&0x0010);

    if (temp&0xF==1)
         printf ( " ........ ....0001 Response Code:1 Unable to DWORDerpret query due to format error" );
    else if (temp&0xF==2)
         printf ( " ........ ....0010 Response Code:2 Unable to process due to server failure" );
    else if (temp&0xF==3)
         printf ( " ........ ....0011 Response Code:3 Name in query does not exist" );
    else if (temp&0xF==4)
         printf ( " ........ ....0100 Response Code:4 Type of query not supported" );
    else if (temp&0xF==5)
         printf ( " ........ ....0101 Response Code:5 Query refused" );
    else if (opcode==5 && rcode==5 )
         printf ( " ........ ....0101 Response Code:5 Update  refused" );
    else
         printf ( " ........ ....XXXX Response Code:%1d unknown" ,(temp&0xf));

    DWORD q,ans,aut,add;
    q=QCOUNT;
    printf( "Number of Questions = %u" ,q);
    ans=ACOUNT;
    printf( "Number of Answers = %u" ,ans);
    aut=AUTHCOUNT;
    printf( "Number of Authority Fields = %u" ,aut);
    add=ADDCOUNT;
    printf( "Number of Additional Fields = %u" ,add);
    if (GetVmVar("FrameAvail")!=GetVmVar("FrameSize")) 
    {
	printf ("Data not fully available");
	return 0;
    }
	DNS_MAIN(GetVmVar("SizeInt"),q,ans,aut,add);
}

DWORD DNS_MAIN(DWORD beginDNS,DWORD q,DWORD ans,DWORD aut,DWORD add)
{
    DWORD pos;
    pos=beginDNS+12;
    DWORD nt,temp;
    DWORD i;
    if (q)
     {
       printf( "Question Field" );
       for(i=0;i<q;i=i+1)
        {
         printf( " Question n. %u" ,i+1);
         pos=GetDNSName(pos,beginDNS);
        }
     } else printf( "Question Field is empty" );
    if (ans)
     {
       printf( "Answers Field" );
       for(i=0;i<ans;i=i+1)
        {
         printf( " Answer n. %u" ,i+1);
         pos=Answer(pos,beginDNS);
        }
     } else printf( "Answers Field is empty" );
    if (aut)
     {
       printf( "Authority Fields" );
       for(i=0;i<aut;i=i+1)
        {
         printf( " Field n. %u" ,i+1);
         pos=GetDNSName(pos,beginDNS);
         CHECK(pos+4);
         printf ( "  Time To live = %u" ,CONV32(pos+0));
         CHECK(pos+6);
         nt=CONV16(pos+4);
         printf ( " RData length = %u" ,nt);
         pos=pos+6;
		 pos=GetName(0,1000,pos,beginDNS);
         aprintf ( " Name : %s" ,p);
        }
     } else printf( "Authority Field is empty" );
    if (add)
     {
       printf( "Additional Fields" );
       for(i=0;i<add;i=i+1)
        {
         printf( " Field n. %u" ,i+1);
         pos=Answer(pos,beginDNS);
        }
     } else printf( "Additional Field is empty" );
    if(pos<GetVmVar("FrameSize"))
	 {
	 title("Other data");
	 printf( "[%u byte(s) of data]",GetVmVar("FrameSize")-pos);
	 }
}

DWORD NETBEUI ()
{
	title ("NetBEUI Header");
	Length=SMB_REVERSE(Length);
      printf ("Length %u bytes", Length);
	Signature=SMB_REVERSE(Signature);
      printf ("Signature 0x%X", Signature);
      if (Command == 0x00) printf ("Command 0x%X Add Group Name Query", Command);
      else if (Command == 0x01) printf ("Command 0x%X Add Name Query", Command);
      else if (Command == 0x16) printf ("Command 0x%X Data Only Last", Command);
      else if (Command == 0x14) printf ("Command 0x%X Data Ack", Command);
      else if (Command == 0x15) printf ("Command 0x%X Data First Middle", Command);
	else if (Command == 0x17) printf ("Command 0x%X Session Confirm", Command);
	else if (Command == 0x19) printf ("Command 0x%X Session Initialize", Command);
	else if (Command == 0x08) printf ("Command 0x%X Datagram", Command);
	else if (Command == 0x0E) printf ("Command 0x%X Name Recognized", Command);
	else if (Command == 0x1F) printf ("Command 0x%X Session Alive", Command);
      else printf ("Command 0x%X ", Command);
}
DWORD NETBEUI_PAD()
{
  title("Padding");
  ResetLog(GetVmVar("SizeInt"),GetVmVar("FrameSize"));
  printf("Padding 0x%X", Padding);
}
DWORD PAD()
{
  title("Padding");
  ResetLog(GetVmVar("SizeInt"),GetVmVar("FrameSize"));
  printf("Padding 0x%X", Padding);
}
DWORD NETBEUI_ADDNAME()
{
	printf ("Control 0x%X", Control);
	SyncID=SMB_REVERSE(SyncID);
	printf ("Re-sync indicator 0x%X", SyncID);
	Transmit=SMB_REVERSE(Transmit);
	printf ("Trasmit Correlator 0x%X", Transmit);
	Response=SMB_REVERSE(Response);
	printf ("Receive Correlator 0x%X", Response);
	NAME16(GetVmVar("SizeInt"),23);
      ResetLog(GetVmVar("SizeInt")+23,GetVmVar("SizeInt")+39);
      aprintf ("Source Name %s",p);
}
DWORD NETBEUI_SESSION()
{
	printf("Flags");
      if (Control & 0x80) printf (" 1....... Ack indicator is set");
      else printf (" 0....... No Ack is indicator is set");
  	if (Control & 0x0E) printf (" ....111. Largest Frame Seen by MAC Layer");
      else printf (" ....000. No Largest Frame Seen by MAC Layer");
      if (Control & 0x01) printf (" .......1 NetBEUI Version 2.0 or higher");
      else printf (" .......0 No NetBEUI Version 2.0 or higher");
	printf ("Max Receive Data %u bytes", MaxRecData);
	printf ("Trasmit Correlator 0x%X", Transmit);
	printf ("Receive Correlator 0x%X", Response);
      printf ("Remote Session Number 0x%X", RemoteNro);
      printf ("Local Session Number 0x%X", LocalNro);
}      
DWORD NETBEUI_NAME()
{
	printf("Flags");
      if (Control & 0x08) printf (" ....1... Ack is included with this frame");
      else printf (" ....0... No Ack is included with this frame");
  	if (Control & 0x04) printf (" .....1.. Ack with data is allowed");
      else printf (" .....0.. No Ack with data is allowed");
      if (Control & 0x02) printf (" ......1. Ack indicator is set");
      else printf (" ......0. No Ack indicator is set");
	printf ("Re-sync indicator 0x%X", SyncID);
	printf ("Trasmit Correlator 0x%X", Transmit);
	printf ("Receive Correlator 0x%X", Response);
	NAME16(GetVmVar("SizeInt"),7);
      ResetLog(GetVmVar("SizeInt")+7,GetVmVar("SizeInt")+23);
      aprintf ("Destination Name %s",p);
	NAME16(GetVmVar("SizeInt"),23);
      ResetLog(GetVmVar("SizeInt")+23,GetVmVar("SizeInt")+39);
      aprintf ("Source Name %s",p);
}
DWORD NETBEUI_ALIVE()
{
      printf ("Remote Session Number 0x%X", RemoteNro);
      printf ("Local Session Number 0x%X", LocalNro);
}
DWORD NETBEUI_ACK ()
{
	printf ("Trasmit Correlator 0x%X", Response);
      printf ("Remote Session Number 0x%X", RemoteNro);
      printf ("Local Session Number 0x%X", LocalNro);
}
DWORD NETBEUI_DATA ()
{
	printf("Flags");
      if (Control & 0x08) printf (" ....1... Ack is included with this frame");
      else printf (" ....0... No Ack is included with this frame");
  	if (Control & 0x04) printf (" .....1.. Ack with data is allowed");
      else printf (" .....0.. No Ack with data is allowed");
      if (Control & 0x02) printf (" ......1. Ack indicator is set");
      else printf (" ......0. No Ack indicator is set");
	printf ("Re-sync indicator 0x%X", SyncID);
	printf ("Transmit Correlator 0x%X", Transmit);
     	printf ("Response Correlator 0x%X", Response);
      printf ("Remote Session Number 0x%X", RemoteNro);
      printf ("Local Session Number 0x%X", LocalNro);
}
DWORD NETBIOS_IPX_TWO()
{
    title("NETBIOS IPX Header");
    printf("Route1 0x%08X", Route1);
    printf("Route2 0x%08X", Route2);
    printf("Route3 0x%08X", Route3);
    printf("Route4 0x%08X", Route4);
    printf("Route5 0x%08X", Route5);
    printf("Route6 0x%08X", Route6);
    printf("Route7 0x%08X", Route7);
    printf("Route8 0x%08X", Route8);
    ResetLog(GetVmVar("SizeInt")+32,GetVmVar("SizeInt")+1);
    printf("Flags");
    if(TypeFlag & 0x80) printf(" 1....... Not Unique Name");
    else printf(" 0....... Unique Name");
    if(TypeFlag & 0x40) printf(" .1...... Name in use");
    else printf(" .0...... Name not in use");
    if(TypeFlag & 0x4) printf(" .....1.. Name Registered");
    else printf(" .0...... Name not Registered");
    if(TypeFlag & 0x2) printf(" ......1. Name Duplicated");
    else printf(" ......0. Name not Duplicated");
    if(TypeFlag & 0x1) printf(" .......1 Name Deregistered");
    else printf(" .......0 Name not Degistered");
    if(Type==0x01) printf("Type 0x%X Find Name",Type);
    else if(Type==0x02) printf("Type 0x%X Name Recognized", Type);
    else if(Type==0x03) printf("Type 0x%X Add Name", Type);
    else printf("Type 0x%X (%n)", Type, offsetof(Type));
    NAME16(GetVmVar("SizeInt"),34);
    ResetLog(GetVmVar("SizeInt")+34,GetVmVar("SizeInt")+50);
    aprintf ("Name Being Claimed %s",p);
}
DWORD NETBIOS_IPX_ONE()
{
    title("NETBIOS IPX Header");
    printf("Flags");
    if(CtrFlag & 0x80) printf(" 1....... System packet");
    else printf(" 0....... No System Packet");
    if(CtrFlag & 0x40) printf(" .1...... Send Acknowledge");
    else printf(" .0...... No Send Acknowledge");
    if(CtrFlag & 0x20) printf(" ..1..... Attention");
    else printf(" ..0..... No Attention");
    if(CtrFlag & 0x10) printf(" ...1.... End Of Message");
    else printf(" ...0.... No End Of Message");
    if(CtrFlag & 0x8) printf(" ....1... Resend");
    else printf(" ....0... No Resend");
    if(Type==0x06) printf("Type 0x%X Session Data",Type);
    else if(Type==0x0B) printf("Type 0x%X Direct Datagram", Type);
    else printf("Type 0x%X (%n)", Type, offsetof(Type));
}
DWORD NBTIPX_SESSION()
{
    printf("Source Connection ID 0x%X", SrcConnID);
    printf("Destination Connection ID 0x%X", DstConnID);
    printf("Send Sequence Number 0x%X", SendSequence);
    printf("Total Data Length %u", TotalData);
    printf("OffSet 0x%X", OffSet);
    printf("Data Length %u", DataLen);
    printf("Receive Sequence Number 0x%X", RcvSequence);
    printf("Bytes Received %u", RcvByte);
}
DWORD NBTIPX()
{
    NAME16(GetVmVar("SizeInt"),0);
    ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+16);
    aprintf ("Name Being Claimed %s",p);
    NAME16(GetVmVar("SizeInt"),16);
    ResetLog(GetVmVar("SizeInt")+16,GetVmVar("SizeInt")+16);
    aprintf ("Name of Requesting Machine %s",p);
}
DWORD NETBIOS_IPX_NAME()
{
    title("NETBIOS IPX Header");
    printf("Route1 0x%08X", Route1);
    printf("Route2 0x%08X", Route2);
    printf("Route3 0x%08X", Route3);
    printf("Route4 0x%08X", Route4);
    printf("Route5 0x%08X", Route5);
    printf("Route6 0x%08X", Route6);
    printf("Route7 0x%08X", Route7);
    printf("Route8 0x%08X", Route8);
    if (Operation == 0xF1) printf("Operation 0x%X Server name claim message", Operation);
    else if (Operation == 0xF2) printf("Operation 0x%X Relinquish server name", Operation);
    else if (Operation == 0xF3) printf("Operation 0x%X Locate Server name", Operation);
    else if (Operation == 0xF4) printf("Operation 0x%X Response to Server Name Claim", Operation);
    else if (Operation == 0xF5) printf("Operation 0x%X Message Hangup", Operation);
    else if (Operation == 0xFC) printf("Operation 0x%X Packet contain Mailslot Write, No Resp needed", Operation);
    else if (Operation == 0xFD) printf("Operation 0x%X Find Name for Mslot Write, No data included", Operation);
    else if (Operation == 0xFE) printf("Operation 0x%X Find Name Response", Operation);
    else printf("Operation 0x%X", Operation);
    if (Type == 0x01) printf("Type of name 0x%X Machine", Type);
    else if (Type == 0x02) printf("Type of name 0x%X Workgroup", Type);
    else if (Type == 0x03) printf("Type of name 0x%X Browser", Type);
    else printf("Type of name 0x%X", Type);
    printf("Message ID for sender 0x%X", MsgID);
    NAME16(GetVmVar("SizeInt"),36);
    ResetLog(GetVmVar("SizeInt")+36,GetVmVar("SizeInt")+52);
    aprintf ("Name Being Claimed %s",p);
    NAME16(GetVmVar("SizeInt"),52);
    ResetLog(GetVmVar("SizeInt")+52,GetVmVar("SizeInt")+68);
    aprintf ("Name of Requesting Machine %s",p);
}

DWORD NETBIOS_NAME ()
{
	title("NetBIOS Name Service Header");
	printf("Transaction ID %u", NAME_TRN);
	printf("Flags");

	if (REQ) printf (" 1............... Response Packet");
	else printf     (" 0............... Request Packet");

	if (OPCODE == 0) printf (" .0000........... Query");
	else if (OPCODE == 5) printf (" .0101........... Registration");
	else if (OPCODE == 6) printf (" .0110........... Release");
	else if (OPCODE == 7) printf (" .0111........... Wait for Acknowledgement");
	else if (OPCODE == 8) printf (" .1000........... Refresh");

	if (Flag & 0x400) printf (" .....1.......... Authoritative Answer");
	printf                   (" .....0.......... Not Authoritative Answer");
	if (Flag & 0x200) printf (" ......1......... Datagram truncated");
	else printf              (" ......0......... Datagram not truncated");

	if (Flag & 0x100) printf (" .......1........ Recursion desired");
      else printf (" .......0........ Recursion not desired");
	if (Flag & 0x80) printf (" ........1....... Recursion available");
      else printf (" ........0....... Recursion not available");
	printf (" .........0...... Reserved");
	printf (" ..........0..... Reserved");
	if (Flag & 0x10) printf (" ...........1.... Broadcast or Multicast Packet");
      else printf (" ...........0.... Unicast Packet");

	if (RCODE == 0x0) printf (" ............0000 Success");
	else if (RCODE == 0x01) printf (" ............0001 Format Error");
	else if (RCODE == 0x02) printf (" ............0010 Server Failure");
	else if (RCODE == 0x03) printf (" ............0011 Name Error");
	else if (RCODE == 0x04) printf (" ............0100 Unsupported Request Error");
	else if (RCODE == 0x05) printf (" ............0101 Refused Error");
	else if (RCODE == 0x06) printf (" ............0110 Active Error");
	else if (RCODE == 0x07) printf (" ............0111 Name in Conflict Error");

	printf ("Question Count %u", QDCount);
	printf ("Answer Count %u", ANCount);
	printf ("Name Service Count %u", NSCount);
	printf ("Additional Record Count %u", ARCount);
	printf ("NetBios Name Len 0x%X", NameLen);
      NETBIOS_MAIN(GetVmVar("SizeInt"),13);
      ResetLog(GetVmVar("SizeInt")+13,GetVmVar("SizeInt")+45);
      aprintf("NetBios Name %s", p);
	if (Type == 0x0001) printf ("Record Type 0x%X : IP Address Resource Record", Type);
	else if (Type == 0x0002) printf ("Record Type 0x%X : Name Server Resource Record", Type);
	else if (Type == 0x0020) printf ("Record Type 0x%X : NetBios general Name Service Resource Record", Type);
	else if (Type == 0x0021) printf ("Record Type 0x%X : NetBios Node Status Resource Record", Type);
	else if (Type == 0x000A) printf ("Record Type 0x%X : Null Resource Record", Type);
      else printf ("Record Type 0x%X (%r)", Type, offsetof(Type));
	if (Class == 0x0001) printf ("Record Class %u : Internet Class", Class);
      else printf ("Record Class %u", Class);
}
DWORD NETBIOS_NAME_REG()
{
	if (Type == 0x0001) printf ("Record Type 0x%X (%r): IP Address Resource Record", Type, offsetof(Type));
	else if (Type == 0x0002) printf ("Record Type 0x%X (%r): Name Server Resource Record", Type, offsetof(Type));
	else if (Type == 0x0020) printf ("Record Type 0x%X (%r): NetBios general Name Service Resource Record", Type, offsetof(Type));
	else if (Type == 0x0021) printf ("Record Type 0x%X (%r): NetBios Node Status Resource Record", Type, offsetof(Type));
	else if (Type == 0x000A) printf ("Record Type 0x%X (%r): Null Resource Record", Type, offsetof(Type));
      else printf ("Record Type 0x%X (%r)", Type, offsetof(Type));
	if (Class == 0x0001) printf ("Record Class %u : Internet Class", Class);
      else printf ("Record Class %u", Class);
	printf("Time to live %u", TTL);
	printf("Length of Data field %u bytes", Length);
	if (Flag & 0x8000) printf("Group NetBIOS Name");
	else printf("Unique NetBIOS Name");
	printf("IpAddress [%u.%u.%u.%u]", IpAddress>>24&0xFF,IpAddress>>16&0xFF,
		IpAddress>>8&0xFF,IpAddress&0xFF);
}
DWORD NETBIOS_SESSION()
{
   title("NetBios Session Service");
   if (Type == 0x00) printf ("Type %u Session Message", Type);
   else if (Type == 0x81) printf ("Type %u Session Request", Type);
   else if (Type == 0x82) printf ("Type %u Positive Session Response", Type);
   else if (Type == 0x83) printf ("Type %u Negative Session Response", Type);
   else if (Type == 0x84) printf ("Type %u Retarget Session Response", Type);
   else if (Type == 0x85) printf ("Type %u Session Keep Alive", Type);
   else printf ("Type %u Unsupported", Type);
   ResetLog(GetVmVar("SizeInt")+1,GetVmVar("SizeInt")+1);
   printf ("Flags");
   printf (" 0000000. Reserved");
   if (Flag & 0x01)  printf (" .......1 Length Extension");
   else printf (" .......0 No Length Extension");
   printf ("Packet Length %u byte", Len);
}
DWORD NEGATIVE_SESSION ()
{
	if (ErrorCode == 0x80) printf ("ErrorCode %u Not listening on called name", ErrorCode);
      else if (ErrorCode == 0x81) printf("ErrorCode %u Not listening for calling name", ErrorCode);
      else if (ErrorCode == 0x82) printf("ErrorCode %u Called name not present", ErrorCode);
      else if (ErrorCode == 0x83) printf("ErrorCode %u Called name present but insufficient resource", ErrorCode);
      else if (ErrorCode == 0x8F) printf("ErrorCode %u Unspecified Error", ErrorCode);
}
DWORD REQUEST_SESSION ()
{
      NETBIOS_MAIN(GetVmVar("SizeInt"),0);
      ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+32);
      aprintf("Called Name %s", p);
      NETBIOS_MAIN(GetVmVar("SizeInt"),32);
      ResetLog(GetVmVar("SizeInt")+32,GetVmVar("SizeInt")+64);
      aprintf("Calling Name %s", p);
}
DWORD RETARGET_SESSION ()
{
	printf( "Retarget IP Address [%u.%u.%u.%u]", RT_IpAddress>>24&0xFF,RT_IpAddress>>16&0xFF,
		RT_IpAddress>>8&0xFF,RT_IpAddress&0xFF);
	printf( "Retarget Port %u", Port);
}
DWORD NETBIOS_DATAGRAM()
{
   title("NetBios Datagram Service");
   if (Type == 0x10) printf ("Type 0x%X Direct Unique Datagram", Type);
   else if (Type == 0x11) printf ("Type 0x%X Direct Group Datagram", Type);
   else if (Type == 0x12) printf ("Type 0x%X Broadcast Datagram", Type);
   else if (Type == 0x13) printf ("Type 0x%X Datagram Error", Type);
   else if (Type == 0x14) printf ("Type 0x%X Datagram Query Request", Type);
   else if (Type == 0x15) printf ("Type 0x%X Datagram Positive Query Response", Type);
   else if (Type == 0x16) printf ("Type 0x%X Datagram Negative Query Response", Type);
   else printf ("Type 0x%X Unsupported", Type);
   printf ("Flags");
   printf (" 0000.... Reserved");
   if ((Flag & 0x0C)==0x0) printf (" ....00.. B Node");
   else if (Flag & 0x02) printf (" ....01.. P Node");
   else if (Flag & 0x08) printf (" ....10.. M Node");
   else if (Flag & 0x0C) printf (" ....11.. NBDD");
   else printf (" ....XX.. 0x%X", Flag);
   if (Flag & 0x02) printf (" ......1. Fragment of NetBios Datagram");
   else printf (" ......0. No Fragment of NetBios Datagram");
   if (Flag & 0x01) printf (" .......1 More NetBios datagram fragments follow");
   else printf (" .......0 No NetBios datagram fragments follow");
   printf ("Datagram ID %u", DgmId);
   printf( "Source IP Address [%u.%u.%u.%u]", SIpAddr>>24&0xFF,SIpAddr>>16&0xFF,
		SIpAddr>>8&0xFF,SIpAddr&0xFF);
   printf ("Source Port %u", SPort);	
}
DWORD DIRECT_DATAGRAM()
{
  printf ("Datagram Length 0x%X", DgmLen);
  printf ("Packet offset 0x%X", OffSet);
  NETBIOS_MAIN(GetVmVar("SizeInt"),5);
  ResetLog(GetVmVar("SizeInt")+5,GetVmVar("SizeInt")+37);
  aprintf("Source NetBios Name %s", p);
  NETBIOS_MAIN(GetVmVar("SizeInt"),39);
  ResetLog(GetVmVar("SizeInt")+39,GetVmVar("SizeInt")+71);
  aprintf("Destination NetBios Name %s", p);
}
DWORD ERROR_DATAGRAM ()
{
  if (Error == 0x82) printf ("Destination Name not present");
  else if (Error == 0x83) printf ("Invalid Source Name Format");
  else if (Error == 0x84) printf ("Invalid Destination Name Format");
  else printf ("Error Code %u", Error);
}
DWORD QUERY_DATAGRAM()
{
  NETBIOS_MAIN(GetVmVar("SizeInt"),0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+32);
  aprintf("Destination NetBios Name %s", p);
}
DWORD TESTSMB()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt"));
}
DWORD PROTO_PAD()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt"));
}
DWORD SMB()
{
  title("SMB Header");
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  if (Command==0x00) printf("Command 0x%X Create Directory", Command);
  else if (Command==0x01) printf("Command 0x%X Delete Directory", Command);
  else if (Command==0x02) printf("Command 0x%X Open", Command);
  else if (Command==0x03) printf("Command 0x%X Create", Command);
  else if (Command==0x04) printf("Command 0x%X Close", Command);
  else if (Command==0x05) printf("Command 0x%X Flush", Command);
  else if (Command==0x06) printf("Command 0x%X Delete", Command);
  else if (Command==0x07) printf("Command 0x%X Rename", Command);
  else if (Command==0x08) printf("Command 0x%X Query Information", Command);
  else if (Command==0x09) printf("Command 0x%X Set Information", Command);
  else if (Command==0x0A) printf("Command 0x%X Read", Command);
  else if (Command==0x0B) printf("Command 0x%X Write", Command);
  else if (Command==0x0C) printf("Command 0x%X Lock Byte Range", Command);
  else if (Command==0x0D) printf("Command 0x%X UnLock Byte Range", Command);
  else if (Command==0x0E) printf("Command 0x%X Create Temporary", Command);
  else if (Command==0x0F) printf("Command 0x%X Create New", Command);
  else if (Command==0x10) printf("Command 0x%X Check Directory", Command);
  else if (Command==0x11) printf("Command 0x%X Process Exit", Command);
  else if (Command==0x12) printf("Command 0x%X Seek", Command);
  else if (Command==0x13) printf("Command 0x%X Lock and Read", Command);
  else if (Command==0x14) printf("Command 0x%X Write and UnLock", Command);
  else if (Command==0x1A) printf("Command 0x%X Read Raw", Command);
  else if (Command==0x1B) printf("Command 0x%X Read Mpx", Command);
  else if (Command==0x1B) printf("Command 0x%X Read Mpx", Command);
  else if (Command==0x1C) printf("Command 0x%X Read Mpx Secondary", Command);
  else if (Command==0x1D) printf("Command 0x%X Write Raw", Command);
  else if (Command==0x1E) printf("Command 0x%X Write Mpx", Command);
  else if (Command==0x20) printf("Command 0x%X Write Complete", Command);
  else if (Command==0x22) printf("Command 0x%X Set Information2", Command);
  else if (Command==0x23) printf("Command 0x%X Query Information2", Command);
  else if (Command==0x24) printf("Command 0x%X Locking AndX", Command);
  else if (Command==0x25) printf("Command 0x%X Transaction", Command);
  else if (Command==0x26) printf("Command 0x%X Transaction Secondary", Command);
  else if (Command==0x27) printf("Command 0x%X IoCtl", Command);
  else if (Command==0x28) printf("Command 0x%X IoCtl Secondary", Command);
  else if (Command==0x29) printf("Command 0x%X Copy", Command);
  else if (Command==0x2A) printf("Command 0x%X Move", Command);
  else if (Command==0x2B) printf("Command 0x%X Echo", Command);
  else if (Command==0x2C) printf("Command 0x%X Write and Close", Command);
  else if (Command==0x2D) printf("Command 0x%X Open andX", Command);
  else if (Command==0x2E) printf("Command 0x%X Read andX", Command);
  else if (Command==0x2F) printf("Command 0x%X Write andX", Command);
  else if (Command==0x31) printf("Command 0x%X Close and Tree Disconnect", Command);
  else if (Command==0x32) printf("Command 0x%X Transaction2", Command);
  else if (Command==0x33) printf("Command 0x%X Transaction2 Secondary", Command);
  else if (Command==0x34) printf("Command 0x%X Find Close2", Command);
  else if (Command==0x35) printf("Command 0x%X Find Notify lose", Command);
  else if (Command==0x70) printf("Command 0x%X Tree Connect", Command);
  else if (Command==0x71) printf("Command 0x%X Tree Disconnect", Command);
  else if (Command==0x72) printf("Command 0x%X Negotiate", Command);
  else if (Command==0x73) printf("Command 0x%X Session Setup andX", Command);
  else if (Command==0x74) printf("Command 0x%X Logoff andX", Command);
  else if (Command==0x75) printf("Command 0x%X Tree Connect andX", Command);
  else if (Command==0x80) printf("Command 0x%X Query Information Disk", Command);
  else if (Command==0x81) printf("Command 0x%X Search", Command);
  else if (Command==0x82) printf("Command 0x%X Find", Command);
  else if (Command==0x83) printf("Command 0x%X Find Unique", Command);
  else if (Command==0xA0) printf("Command 0x%X NT Transact", Command);
  else if (Command==0xA1) printf("Command 0x%X NT Transact Secondary", Command);
  else if (Command==0xA2) printf("Command 0x%X NT Create andX", Command);
  else if (Command==0xA4) printf("Command 0x%X NT Cancel", Command);
  else if (Command==0xC0) printf("Command 0x%X Open Print File", Command);
  else if (Command==0xC1) printf("Command 0x%X Write Print", Command);
  else if (Command==0xC2) printf("Command 0x%X Close Print", Command);
  else if (Command==0xC3) printf("Command 0x%X Get Print Queue", Command);
  else printf("Command 0x%X (%n)", Command, offsetof(Command));
  Error=SMB_REVERSE(Error); 
  if(ErrorClass==0x00) 
  {
	printf("Error Class 0x%X The Request was successful",ErrorClass);
	printf("Error Code  0x%X The Request was successful",Error);
  }
  else if(ErrorClass==0x01) 
  {
	printf("ErrorClass 0x%X Error generated by core DOS",ErrorClass);
	if(Error==0x01) printf("Error Code 0x%X Invalid Function",Error);
	else if(Error==0x02) printf("Error Code 0x%X File not found",Error);
	else if(Error==0x03) printf("Error Code 0x%X Directory invalid",Error);
	else if(Error==0x04) printf("Error Code 0x%X Too many Open File",Error);
	else if(Error==0x05) printf("Error Code 0x%X Access Denied",Error);
	else if(Error==0x06) printf("Error Code 0x%X Invalid File Handle",Error);
	else if(Error==0x07) printf("Error Code 0x%X Memory Control Block destroyed",Error);
	else if(Error==0x08) printf("Error Code 0x%X Insufficient Server Memory",Error);
	else if(Error==0x09) printf("Error Code 0x%X Invalid Memory Block Address",Error);
	else if(Error==0x0A) printf("Error Code 0x%X Invalid Environment",Error);
	else if(Error==0x0B) printf("Error Code 0x%X Invalid Format",Error);
	else if(Error==0x0C) printf("Error Code 0x%X Invalid Open Mode",Error);
	else if(Error==0x0D) printf("Error Code 0x%X Invalid Data",Error);
	else if(Error==0x0F) printf("Error Code 0x%X Invalid Drive Specification",Error);
	else if(Error==16) printf("Error Code 0x%X Delete Directory",Error);
	else if(Error==17) printf("Error Code 0x%X Not Same Device",Error);
	else if(Error==18) printf("Error Code 0x%X No more file matching",Error);
	else if(Error==32) printf("Error Code 0x%X The sharing mode specified for an Open conflict with FIDs on the file",Error);
	else if(Error==33) printf("Error Code 0x%X A Lock request conflicted with existing lock",Error);
	else if(Error==80) printf("Error Code 0x%X The file named already exists",Error);
	else if(Error==230) printf("Error Code 0x%X Pipe invalid",Error);
	else if(Error==231) printf("Error Code 0x%X All instances of the requested pipe are busy",Error);
      else if(Error==232) printf("Error Code 0x%X Pipe close in progress",Error);
	else if(Error==233) printf("Error Code 0x%X No process on other end of pipe",Error);
	else if(Error==234) printf("Error Code 0x%X There is more data to be returned",Error);
	else printf("Error Code 0x%X (%n)",Error, offsetof(Error));
  }
  else if(ErrorClass==0x02) 
  {
	printf("ErrorClass 0x%X Error generated by the server network",ErrorClass);
	if(Error==1) printf("Error Code 0x%X Non specific error code",Error);
	else if(Error==2) printf("Error Code 0x%X Bad password",Error);
	else if(Error==4) printf("Error Code 0x%X The client does not have ACL",Error);
	else if(Error==5) printf("Error Code 0x%X The TID specified is invalid",Error);
	else if(Error==6) printf("Error Code 0x%X Invalid Network Name in tree connect",Error);
	else if(Error==7) printf("Error Code 0x%X Invalid device",Error);
	else if(Error==49) printf("Error Code 0x%X Print queue full - files",Error);
	else if(Error==50) printf("Error Code 0x%X Print queue full - no space",Error);
	else if(Error==51) printf("Error Code 0x%X EOF on print queue dump",Error);
	else if(Error==52) printf("Error Code 0x%X Invalid print file FID",Error);
	else if(Error==64) printf("Error Code 0x%X The Server did not recognize the command",Error);
	else if(Error==65) printf("Error Code 0x%X The Server encountered an internal error",Error);
	else if(Error==67) printf("Error Code 0x%X The FID and pathname parameters are in conflict",Error);
	else if(Error==69) printf("Error Code 0x%X The ACL specified are not valid",Error);
	else if(Error==71) printf("Error Code 0x%X The attribute mode is invalid",Error);
	else if(Error==81) printf("Error Code 0x%X Server is paused",Error);
	else if(Error==82) printf("Error Code 0x%X Not receiving message",Error);
	else if(Error==83) printf("Error Code 0x%X No room to buffer message",Error);
	else if(Error==87) printf("Error Code 0x%X Too many remote user names",Error);
	else if(Error==88) printf("Error Code 0x%X Operation timed out",Error);
	else if(Error==89) printf("Error Code 0x%X No resource currently available for request",Error);
	else if(Error==90) printf("Error Code 0x%X Too many UID active on this session",Error);
	else if(Error==91) printf("Error Code 0x%X The UID is not known",Error);
	else if(Error==250) printf("Error Code 0x%X Temporarily unable to support Raw, use MPX",Error);
	else if(Error==251) printf("Error Code 0x%X Temporarily unable to support Raw, use standard read/write",Error);
	else if(Error==252) printf("Error Code 0x%X Continue in MPX mode",Error);
	else if(Error==65535) printf("Error Code 0x%X Fuction not supported",Error);
	else printf("Error Code 0x%X (%n)",Error, offsetof(Error));
  }
  else if(ErrorClass==0x03) 
  {
	printf("ErrorClass 0x%X Error generated by Hardware",ErrorClass);
	if(Error==19) printf("Error Code 0x%X Attempt to write on write-protected media",Error);
	else if(Error==20) printf("Error Code 0x%X Unknown unit",Error);
	else if(Error==21) printf("Error Code 0x%X Drive not ready",Error);
	else if(Error==22) printf("Error Code 0x%X Unknown command",Error);
	else if(Error==23) printf("Error Code 0x%X Data Error(CRC)",Error);
	else if(Error==24) printf("Error Code 0x%X Bad request structure length",Error);
	else if(Error==25) printf("Error Code 0x%X Seek error",Error);
	else if(Error==26) printf("Error Code 0x%X Unknown media type",Error);
	else if(Error==27) printf("Error Code 0x%X Sector not found",Error);
	else if(Error==28) printf("Error Code 0x%X Printer out of paper",Error);
	else if(Error==29) printf("Error Code 0x%X Write fault",Error);
	else if(Error==30) printf("Error Code 0x%X Read fault",Error);
	else if(Error==31) printf("Error Code 0x%X General failure",Error);
	else if(Error==32) printf("Error Code 0x%X A Open conflict with an existing path",Error);
	else if(Error==33) printf("Error Code 0x%X A Lock request conflicted with an existing lock",Error);
	else if(Error==34) printf("Error Code 0x%X The wrong disk was found in a drive",Error);
	else if(Error==35) printf("Error Code 0x%X No FCB are available to process request",Error);
	else if(Error==36) printf("Error Code 0x%X A sharing buffer has been exceeded",Error);
      else printf("Error Code 0x%X (%n)",Error, offsetof(Error));
  }
  else if(ErrorClass==0xFF) 
  {
 	printf("ErrorClass 0x%X Command is not in SMB format",ErrorClass);
	printf("Error Code 0x%X (%n)",Error,offsetof(Error));
  }
  else 
  {
	printf("ErrorClass 0x%X (%n)",ErrorClass,offsetof(ErrorClass));
	printf("Error Code 0x%X (%n)",Error,offsetof(Error));
  }
  ResetLog(GetVmVar("SizeInt")+5,GetVmVar("SizeInt")+6);
  printf("Flags");
  if (Flags & 0x80) printf(" 1....... Server Response");
  else printf(" 0....... Client Request");
  if (Flags & 0x40) printf(" .1...... Change Notify");
  else printf(" .0...... No Change Notify");
  if (Flags & 0x20) printf(" ..1..... Opportunistic Lock");
  else printf(" ..0..... No Opportunistic Lock");
  if (Flags & 0x10) printf(" ...1.... Canonicalized PathName");
  else printf(" ...0.... No Canonicalized PathName");
  if (Flags & 0x08) printf(" ....1... No PathName Case Sensitive");
  else printf(" ....0... PathName Case Sensitive");
  printf(" .....0.. Reserved");
  if (Flags & 0x02) printf(" ......1. Receive Buffer posted such that a send without Ack");
  else printf(" ......0. No Receive Buffer posted such that a send without Ack");
  if (Flags & 0x01) printf(" .......1 Server support LockandRead and WriteandUnlock");
  else printf(" .......0 Server not support LockandRead and WriteandUnlock");
  Flags2=SMB_REVERSE(Flags2); 
  ResetLog(GetVmVar("SizeInt")+6,GetVmVar("SizeInt")+8);
  printf("Flags");
  if (Flags2 & 0x8000) printf(" 1............... Using UNICODE string");
  else printf(" 0............... Using ASCII string");
  if (Flags2 & 0x4000) printf(" .1.............. Using NT Status");
  else printf(" .0.............. Using SMB Status");
  if (Flags2 & 0x2000) printf(" ..1............. Read will be permetted with only Execute Permission");
  else printf(" ..0............. Read will be Not permetted with only Execute Permission");
  printf(" ...0000000000... Reserved");
  if (Flags2 & 0x04) printf(" .............1.. Understands Long FileNames");
  else printf(" .............0.. No Understands Long Filenames");
  if (Flags2 & 0x02) printf(" ..............1. Understands Extended Attribute");
  else printf(" ..............0. No Understands Extended Attribute");
  if (Flags2 & 0x01) printf(" ...............1 Client known name conform to MS-DOS 8.3");
  else printf(" ...............0 Client not known name conform to MS-DOS 8.3");
  TID=SMB_REVERSE(TID);
  printf("Tree ID %u (0x%X)", TID, TID);
  PID=SMB_REVERSE(PID);
  printf("Process ID %u (0x%X)",PID, PID);
  UID=SMB_REVERSE(UID);
  printf("User ID %u (0x%X)",UID, UID);
  MID=SMB_REVERSE(MID);
  printf("Multiplex ID %u (0x%X)",MID, MID);
}
DWORD SMB_QUERYINFDISK_C()
{
  title("SMB Query Information Disk Request");
  printf("Count of Parameter Word %u", WordCount);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Count of Data Bytes %u bytes", ByteCount);
}
DWORD SMB_QUERYINFDISK_S()
{
  title("SMB Query Information Disk Response");
  printf("Count of Parameter Word %u", WordCount);
  TotalUnit=SMB_REVERSE(TotalUnit);
  printf("Total Allocation units per server %u", TotalUnit);
  BlockUnit=SMB_REVERSE(BlockUnit);
  printf("Block per allocation unit %u bytes", BlockUnit);
  BlockSize=SMB_REVERSE(BlockSize);
  printf("Block Size %u bytes", BlockSize);
  FreeUnit=SMB_REVERSE(FreeUnit);
  printf("Number of free units %u", FreeUnit);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Count of Data Bytes %u bytes", ByteCount);
}
DWORD SMB_ECHO_C()
{
  title("SMB Echo Request");
  printf("Count of Parameter Word %u", WordCount);
  EchoCount=SMB_REVERSE(EchoCount);
  printf("Number of times to echo data back %u", EchoCount);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Count of Data Bytes %u bytes", ByteCount);
}
DWORD SMB_ECHO_S()
{
  title("SMB Echo Response");
  printf("Count of Parameter Word %u", WordCount);
  SequenceNro=SMB_REVERSE(SequenceNro);
  printf("Sequence Number of this Echo %u", SequenceNro);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Count of Data Bytes %u bytes", ByteCount);
} 
DWORD SMB_TREECONNECTX_C()
{
  title("SMB Tree Connect & X Request");
  printf("Word Count %u", WordCount);
  if (SecCommand == 0xFF) printf ("Secondary Command 0x%X Null", SecCommand);
  else printf("Secondary Command 0x%X", SecCommand);
  OffSet=SMB_REVERSE(OffSet);
  printf("OffSet to Next Command 0x%X", OffSet);
  DiscFlag=SMB_REVERSE(DiscFlag);
  printf("Disconnect Flag 0x%X", DiscFlag);
  PwdLen=SMB_REVERSE(PwdLen);
  printf("Password lenght 0x%X", Pwdlen);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Byte Count %u", ByteCount);
}
DWORD SMB_TREE_PWD()
{
  DWORD LenName;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("Password %s",p);
} 
DWORD SMB_TREE_PATH()
{
  DWORD LenName;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("Path %s",p);
}
DWORD SMB_TREE_SERVICE()
{
  DWORD LenName;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("Service Name %s",p);
}
DWORD SMB_TREECONNECTX_S()
{
  title("SMB Tree Connect & X Response");
  printf("Count of Parameter Word %u", WordCount);
  if (SecCommand == 0xFF) printf ("Secondary Command 0x%X Null", SecCommand);
  else printf("Secondary Command 0x%X", SecCommand);
  OffSet=SMB_REVERSE(OffSet);
  printf("OffSet to Next Command 0x%X", OffSet);
  OptSupp=SMB_REVERSE(OptSupp);
  if (OptSupp==0x01)printf("Optional Support 0x%X Search Bits Supported", OptSupp);
  else printf ("Optional Support 0x%X", OptSupp);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Byte Count %u", ByteCount);
  DWORD LenName;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),9,0);
  ResetLog(GetVmVar("SizeInt")+9,GetVmVar("FrameSize"));
  aprintf("Service Name %s",p);
}
DWORD SMB_WRITEX_C()
{
  title("SMB Write to File Request");
  printf("Count of Parameter Word %u", WordCount);
  if (AndXCmd == 0xFF) printf ("Type 0xX No Secondary Command", AndXCmd);
  else printf("Secondary Command 0x%X", AndXCmd);
  printf("OffSet to Next Command %u", AndXOffSet);
  printf("File Handle 0x%X", Fid);
  printf("OffSet in File to Begin Write 0x%X", OffSet);
  if (WriteMode == 0x00) printf("Write Mode 0x%X Write Through", WriteMode);
  else if (WriteMode == 0x01) printf("Write Mode 0x%X Return Remaining", WriteMode);
  else if (WriteMode == 0x02) printf("Write Mode 0x%X Use WriteRawPipe", WriteMode);
  else if (WriteMode == 0x03) printf("Write Mode 0x%X Start of the Message", WriteMode);
  else printf("Write Mode 0x%X", WriteMode);
  printf("Byte Remaining to satisfy request %u", Remain);
  printf("Number of data bytes in buffer %u bytes", DataLen);
  printf("OffSet to data bytes %u bytes", DataOffSet);
  printf("Upper 32 bits of OffSet %u", OffSetH);
  printf("Count of Data Bytes %u bytes", ByteCount);
}
DWORD SMB_WRITEX_S()
{
  title("SMB Write to File Response");
  printf("Count of Parameter Word %u", WordCount);
  if (AndXCmd == 0xFF) printf ("Type 0xX No Secondary Command", AndXCmd);
  else printf("Secondary Command 0x%X", AndXCmd);
  printf("OffSet to Next Command %u", AndXOffSet);
  printf("Number of bytes written %u bytes", Count);
  printf("Bytes Remaining to be read in pipe %u", Remain);
  printf("Count of Data Bytes %u bytes", ByteCount);
}
DWORD SMB_RENAME_C()
{
  title("SMB RENAME File Request");
  printf("Count of Parameter Word %u", WordCount);
  if (SearchAttr == 0x01) printf("Type 0x%X Read Only File", SearchAttr);
  else if (SearchAttr == 0x02) printf("Type 0x%X Hidden File", SearchAttr);
  else if (SearchAttr == 0x04) printf("Type 0x%X System File", SearchAttr);
  else if (SearchAttr == 0x08) printf("Type 0x%X Volume", SearchAttr);
  else if (SearchAttr == 0x10) printf("Type 0x%X Directory", SearchAttr);
  else if (SearchAttr == 0x20) printf("Type 0x%X Archive File", SearchAttr);
  else printf("Type 0x%X", SearchAttr);
  printf("Count of Data bytes %u bytes", ByteCount);
  printf("Buffer Format 0x%X", BufferFrm);
}
DWORD SMB_RENAME_S()
{
  title("SMB RENAME File Response");
  printf("Count of Parameter Word %u", WordCount);
  printf("Count of Data bytes %u bytes", ByteCount);
}
DWORD SMB_QUERYINF_C()
{
  title("SMB GET File Attribute Request");
  printf("Count of Parameter Word %u", WordCount);
  printf("Count of Data Byte %u", ByteCount);
  printf("Buffer Format 0x%X", BuffFrm);
  SMB_UNICODE(GetVmVar("SizeInt")+4,0);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("FrameSize"));
  aprintf("File Name %s", p);
}
DWORD SMB_QUERYINF_S()
{
   title("SMB GET File Attribute Response");
   printf("Count of Parameter Word %u", WordCount);
   if (FileAttr & 0x01) printf(".......1 Read Only File");
   else printf(".......0 Not Read Only File");
   if (FileAttr & 0x02) printf("......1. Hidden File");
   else printf("......0. Not Hidden File");
   if (FileAttr & 0x04) printf(".....1.. System File");
   else printf(".....0.. Not System File");
   if (FileAttr & 0x08) printf("....1... Volume");
   else printf("....0... Not Volume");
   if (FileAttr & 0x10) printf("...1.... Directory");
   else printf("...0.... Not Directory");
   if (FileAttr & 0x20) printf("..1..... Archive File");
   else printf("..0..... Not Archive File");
   Time=SMB_REVERSE(Time);
   printf("Last Write Time %u", Time);
   Date=SMB_REVERSE(Date);
   printf("Last Write Date %u", Date);
   FileSize=SMB_REVERSEDW(FileSize);
   printf("File Size %u bytes", FileSize);
   ByteCount=SMB_REVERSE(ByteCount);
   printf("Count of Data bytes %u bytes", ByteCount);
}
DWORD SMB_FINDCLOSE2_C()
{
  title("SMB Close Search Request");
  printf("Count of Parameter Word %u", WordCount);
  printf("Find Handle 0x%X", Sid);
  printf("Count of Data bytes %u bytes", ByteCount);
}
DWORD SMB_FINDCLOSE2_S()
{
  title("SMB Close Search Response");
  printf("Count of Parameter Word %u", WordCount);
  printf("Count of Data bytes %u bytes", ByteCount);
}
DWORD SMB_READX_C()
{
  title("SMB Read Data Request");
  printf("Count of Parameter Word %u", WordCount);
  if (AndXCmd == 0xFF) printf ("Type 0xX No Secondary Command", AndXCmd);
  else printf("Secondary Command 0x%X", AndXCmd);
  printf("OffSet to Next Command 0x%X", AndXOffSet);
  printf("File Handle 0x%X", Fid);
  printf("Maximum Number of bytes to return %u bytes", MaxCount);
  printf("Minimum Number of bytes to return %u bytes", MinCount);
  printf("Upper 32 Bits of OffSet 0x%X", OffSetHigh);
  printf("Count of Data bytes %u bytes", ByteCount);
}
DWORD SMB_READX_S()
{
  title("SMB Read Data Response");
  printf("Count of Parameter Word %u", WordCount);
  if (AndXCmd == 0xFF) printf ("Type 0xX No Secondary Command", AndXCmd);
  else printf("Secondary Command 0x%X", AndXCmd);
  printf("OffSet to Next Command 0x%X", AndXOffSet);
  printf("Byte Remaining to be Read %u bytes", Remain);
  printf("Data Compaction Mode 0x%X", DataCompMode);
  printf("Number of data bytes %u bytes", DataLen);
  printf("OffSet (from header start) to data %u", DataOffSet);
  printf("Count of Data bytes %u bytes", ByteCount);
}
DWORD SMB_READRAW_C()
{
  title("SMB Read Raw Request");
  printf("Count of Parameter Word %u", WordCount);
  Fid=SMB_REVERSE(Fid);
  printf("File Handle 0x%X", Fid);
  OffSet=SMB_REVERSE(OffSet);
  printf("OffSet in file to begin read 0x%X", OffSet);
  MaxCount=SMB_REVERSE(MaxCount);
  printf("Max Byte to return %u bytes", MaxCount);
  MinCount=SMB_REVERSE(MinCount);
  printf("Min Byte to return %u bytes", MinCount);
  TimeOut=SMB_REVERSEDW(TimeOut);
  printf("Wait Time %u", TimeOut);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Count of Data Bytes %u", ByteCount);
}
DWORD SMB_NTCREATEX_C()
{
  title("SMB Create File Request");
  printf("Count of Parameter Word %u", WordCount);
  if (AndXCmd == 0xFF) printf ("Type 0xX No Secondary Command", AndXCmd);
  else printf("Secondary Command 0x%X", AndXCmd);
  printf("OffSet to Next Command 0x%X", AndXOffSet);
  printf("Lenght of Name %u bytes", NameLen);
  if (Flag == 0x02) printf("Flag 0x%X Request an OpLock", Flag);
  else if (Flag == 0x04) printf("Flag 0x%X Request a batch OpLock", Flag);
  else if (Flag == 0x08) printf("Flag 0x%X Target of open must be directory", Flag);
  else printf("Flag 0x%X", Flag);
  if (RootDirFid == 0x00) printf("Open is Not relative to this Directory");
  else printf("Open is relative to this Directory");
  if (AccessMode & 0x4000) printf("NT Access Desired : .1.............. Write Through Mode");
  else printf("NT Access Desired : .0.............. No Write Through Mode");
  if (AccessMode & 0x10) printf("NT Access Desired : ..........1.... Deny Read/Write/Execute(Exclusive)");
  else if (AccessMode & 0x20) printf("NT Access Desired : .........1.....  Deny Write");
  else if (AccessMode & 0x30) printf("NT Access Desired : ........1......  Deny Read/Execute");
  else if (AccessMode & 0x40) printf("NT Access Desired : .......1.......  Deny None");
  else if ((AccessMode & 0x112) == 0x0) printf("NT Access Desired : .......000..... Compatibilty Mode");
  if (AccessMode & 0x01) printf("NT Access Desired : ...............1 Open for Writing");
  else printf("NT Access Desired : ...............0 Open for Reading");
  if (AccessMode & 0x02) printf("NT Access Desired : ..............1. Open for Reading/Writing");
  if (AccessMode & 0x08) printf("NT Access Desired : .............1.. Open for Execute");
  if (AccessMode & 0x1000) printf("NT Access Desired : ...1............ Do Not Cache this File");
  else printf("NT Access Desired : ...0............ Normal File");
  if (AccessMode & 0x4000) printf("NT Access Desired : .1.............. Write Through Mode");
  else printf("NT Access Desired : .0.............. No Write Through Mode");
  printf("Initial Allocation Size %u", AllocSize);
  if (FileAttr == 0x01) printf("Type 0x%X Read Only File", FileAttr);
  else if (FileAttr == 0x02) printf("Type 0x%X Hidden File", FileAttr);
  else if (FileAttr == 0x04) printf("Type 0x%X System File", FileAttr);
  else if (FileAttr == 0x08) printf("Type 0x%X Volume", FileAttr);
  else if (FileAttr == 0x10) printf("Type 0x%X Directory", FileAttr);
  else if (FileAttr == 0x20) printf("Type 0x%X Archive File", FileAttr);
  else printf("Type 0x%X", FileAttr);
  printf("Share Access 0x%X", ShareAcc);
  printf("Action to take if File Exists 0x%X", CreateDisp);
  printf("Option Use if creating a File 0x%X", CreateOpt);
  printf("Security QOS Information 0x%X", ImpsLevel);
  if (SecurFlag == 0x01) printf("Security 0x%X Dynamic Tracking");
  else if (SecurFlag == 0x02) printf("Security 0x%X Effective Only");
  printf("Count of Data bytes %u bytes", ByteCount);
}

DWORD SMB_TRANSACTION_C()
{
  title("SMB Transaction Request");
  printf("Count of parameter Word %u", WordCount);
  TParamCount=SMB_REVERSE(TParamCount);
  printf("Total Parameter being sent %u bytes", TParamCount);
  TDataCount=SMB_REVERSE(TDataCount);
  printf("Total bytes being sent %u bytes", TDataCount);
  MaxParCount=SMB_REVERSE(MaxParCount);
  printf("Max Parameter %u bytes to return", MaxParCount);
  MaxDataCount=SMB_REVERSE(MaxDataCount);
  printf("Max Data %u bytes to return", MaxDataCount);
  printf("Max Setup Words %u to return", MaxSetupCount);
  Flag=SMB_REVERSE(Flag);
  printf("Flags");
  if (Flag & 0x2) printf(" ..............1. No Response Required");
  else printf(" ..............0. Response Required");
  if (Flag & 0x1) printf(" ...............1 No Leave Session Intact");
  else printf(" ...............0 Leave Session Intact");
  TimeOut=SMB_REVERSEDW(TimeOut);
  printf("Transact Timeout %u", TimeOut);
  ParamCount=SMB_REVERSE(ParamCount);
  printf("Parameter sent this buffer %u bytes",ParamCount);
  ParamOffSet=SMB_REVERSE(ParamOffSet);
  printf("Parameter OffSet %u",ParamOffSet);
  DataCount=SMB_REVERSE(DataCount);
  printf("Data sent this buffer %u bytes",DataCount);
  DataOffSet=SMB_REVERSE(DataOffSet);
  printf("Data OffSet %u bytes",DataOffSet);
  printf("Count of Setup words %u",SetupCount);
}
DWORD SMB_MAILSLOT()
{
  printf("MailSlot Code %u Write",Setup1);
  printf("Size of data %u bytes",ByteCount);
  NAME16(GetVmVar("SizeInt"),9);
  ResetLog(GetVmVar("SizeInt")+9,GetVmVar("SizeInt")+25);
  if (OpCode != 0x4C) aprintf("File Name %s ",p);
  if (OpCode == 0x01) printf("Code 0x%X Server Announcement", OpCode);
  else if (OpCode == 0x02) printf("Code 0x%X Announcement Request", OpCode);
  else if (OpCode == 0x08) printf("Code 0x%X Force Election", OpCode);
  else if (OpCode == 0x09) printf("Code 0x%X Get Backup List Request", OpCode);
  else if (OpCode == 0x0A) printf("Code 0x%X Get Backup List Response", OpCode);
  else if (OpCode == 0x0C) printf("Code 0x%X WorkGroup Announcement", OpCode);
  else if (OpCode == 0x0F) printf("Code 0x%X Local Master Announcement", OpCode);
}
DWORD SLOT_NET()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt"));
}
DWORD SLOT_NETLOGON()
{
  DWORD LenName;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("File Name %s",p);
  if (OpCode == 0x07) printf("Command 0x%X Query for Primary DC", OpCode);
  else printf ("Command 0x%X", OpCode);
}
DWORD SLOT_NETNAME()
{
  DWORD LenName, LenName1;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("Computer Name %s",p);
  LenName1=SMB_SLOT_LAN(GetVmVar("SizeInt")+LenName+1,0,LenName);
  ResetLog(GetVmVar("SizeInt")+LenName+1,GetVmVar("SizeInt")+LenName1);
  aprintf("Mailslot Name %s",p);
}
DWORD SLOT_BROWSE()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  printf("Update Count %u", UpdCount);
  TimeAnn=SMB_REVERSEDW(TimeAnn);
  ResetLog(GetVmVar("SizeInt")+1,GetVmVar("SizeInt")+5);
  printf("Annoucement Interval %u minutes", TimeAnn/60000);
  NAME16(GetVmVar("SizeInt"),5);
  ResetLog(GetVmVar("SizeInt")+5,GetVmVar("SizeInt")+21);
  aprintf("Computer Name %s",p);
  printf("Major Version %u", MajVer);
  printf("Minor Version %u", MinVer);
  printf("Flags");
 if (Flag1 & 0x01) printf(" ...............................1 WorkStation Service Running");
  else printf(" ...............................0 No WorkStation Service Running");
  if (Flag1 & 0x02) printf(" ..............................1. Server Service Running");
  else printf(" ..............................0. No Server Service Running");
  if (Flag1 & 0x04) printf(" .............................1.. SQL Server Running");
  else printf(" .............................0.. No SQL Server Running");
  if (Flag1 & 0x08) printf(" ............................1... Primary Domain Controller");
  else printf(" ............................0... Not Primary Domain Controller");
  if (Flag1 & 0x10) printf(" ...........................1.... Backup Domain Controller");
  else printf(" ...........................0.... Not Backup Domain Controller");
  if (Flag1 & 0x20) printf(" ..........................1..... Time Source");
  else printf(" ..........................0..... Not Time Source");
  if (Flag1 & 0x40) printf(" .........................1...... Apple Server");
  else printf(" .........................0...... Not Apple Server");
  if (Flag1 & 0x80) printf(" ........................1....... Novell Server");
  else printf(" ........................0....... Not Novell Server");
  if (Flag2 & 0x01) printf(" .......................1........ Domain Member Server");
  else printf(" .......................0........ Not Domain Member Server");
  if (Flag2 & 0x02) printf(" ......................1......... Print Queue Server");
  else printf(" ......................0......... Not Print Queue Server");
  if (Flag2 & 0x04) printf(" .....................1.......... Dialin Server");
  else printf(" .....................0.......... Not Dialin Server");
  if (Flag2 & 0x08) printf(" ....................1........... Xenix Server");
  else printf(" ....................0........... Not Xenix Server");
  if (Flag2 & 0x10) printf(" ...................1............ Windows NT Workstation");
  else printf(" ...................0............ Not Windows NT Workstation");
  if (Flag2 & 0x20) printf(" ..................1............. WFW System");
  else printf(" ..................0............. Not WFW System");
  if (Flag2 & 0x80) printf(" ................1............... Windows NT Server");
  else printf(" ................0............... Not Windows NT Server");
  if (Flag3 & 0x01) printf(" ...............1................ Potential Browser Server");
  else printf(" ...............0................ Not Potential Browser Server");
  if (Flag3 & 0x02) printf(" ..............1................. Backup Browser");
  else printf(" ..............0................. Not Backup Browser");
  if (Flag3 & 0x04) printf(" .............1.................. Master Browser");
  else printf(" .............0.................. Not Master Browser");
  if (Flag3 & 0x08) printf(" ............1................... Domain Master Browser");
  else printf(" ............0................... Not Domain Master Browser");
  if (Flag3 & 0x10) printf(" ...........1.................... OSF System");
  else printf(" ...........0.................... Not OSF System");
  if (Flag3 & 0x20) printf(" ..........1..................... VMS System");
  else printf(" ..........0..................... Not VMS System");
  if (Flag3 & 0x40) printf(" .........1...................... Windows 95 System");
  else printf(" .........0...................... Not Windows 95 System");
  if (Flag4 & 0x40) printf(" .1.............................. Local List Only");
  else printf(" .0.............................. Not Local List Only");
  if (Flag4 & 0x80) printf(" 1............................... Domain Enum");
  else printf(" 0............................... Not Domain Enum");
  BrowVer=SMB_REVERSE(BrowVer);
  printf("Browser Election Version %u", BrowVer);
  BrowConst=SMB_REVERSE(BrowConst);
  printf("Browser Constant 0x%X", BrowConst);
}
DWORD SLOT_WRKGRP()
{
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+1);
  printf("Update Count %u", UpdCount);
  TimeAnn=SMB_REVERSEDW(TimeAnn);
  ResetLog(GetVmVar("SizeInt")+1,GetVmVar("SizeInt")+5);
  printf("Annoucement Interval %u minutes", TimeAnn/60000);
  NAME16(GetVmVar("SizeInt"),5);
  ResetLog(GetVmVar("SizeInt")+5,GetVmVar("SizeInt")+21);
  aprintf("WorkGroup Announcement %s",p);
  printf("Major Version %u", MajVer);
  printf("Minor Version %u", MinVer);
  printf("Flags");
  if (Flag1 & 0x01) printf(" ...............................1 WorkStation Service Running");
  else printf(" ...............................0 No WorkStation Service Running");
  if (Flag1 & 0x02) printf(" ..............................1. Server Service Running");
  else printf(" ..............................0. No Server Service Running");
  if (Flag1 & 0x04) printf(" .............................1.. SQL Server Running");
  else printf(" .............................0.. No SQL Server Running");
  if (Flag1 & 0x08) printf(" ............................1... Primary Domain Controller");
  else printf(" ............................0... Not Primary Domain Controller");
  if (Flag1 & 0x10) printf(" ...........................1.... Backup Domain Controller");
  else printf(" ...........................0.... Not Backup Domain Controller");
  if (Flag1 & 0x20) printf(" ..........................1..... Time Source");
  else printf(" ..........................0..... Not Time Source");
  if (Flag1 & 0x40) printf(" .........................1...... Apple Server");
  else printf(" .........................0...... Not Apple Server");
  if (Flag1 & 0x80) printf(" ........................1....... Novell Server");
  else printf(" ........................0....... Not Novell Server");
  if (Flag2 & 0x01) printf(" .......................1........ Domain Member Server");
  else printf(" .......................0........ Not Domain Member Server");
  if (Flag2 & 0x02) printf(" ......................1......... Print Queue Server");
  else printf(" ......................0......... Not Print Queue Server");
  if (Flag2 & 0x04) printf(" .....................1.......... Dialin Server");
  else printf(" .....................0.......... Not Dialin Server");
  if (Flag2 & 0x08) printf(" ....................1........... Xenix Server");
  else printf(" ....................0........... Not Xenix Server");
  if (Flag2 & 0x10) printf(" ...................1............ Windows NT Workstation");
  else printf(" ...................0............ Not Windows NT Workstation");
  if (Flag2 & 0x20) printf(" ..................1............. WFW System");
  else printf(" ..................0............. Not WFW System");
  if (Flag2 & 0x80) printf(" ................1............... Windows NT Server");
  else printf(" ................0............... Not Windows NT Server");
  if (Flag3 & 0x01) printf(" ...............1................ Potential Browser Server");
  else printf(" ...............0................ Not Potential Browser Server");
  if (Flag3 & 0x02) printf(" ..............1................. Backup Browser");
  else printf(" ..............0................. Not Backup Browser");
  if (Flag3 & 0x04) printf(" .............1.................. Master Browser");
  else printf(" .............0.................. Not Master Browser");
  if (Flag3 & 0x08) printf(" ............1................... Domain Master Browser");
  else printf(" ............0................... Not Domain Master Browser");
  if (Flag3 & 0x10) printf(" ...........1.................... OSF System");
  else printf(" ...........0.................... Not OSF System");
  if (Flag3 & 0x20) printf(" ..........1..................... VMS System");
  else printf(" ..........0..................... Not VMS System");
  if (Flag3 & 0x40) printf(" .........1...................... Windows 95 System");
  else printf(" .........0...................... Not Windows 95 System");
  if (Flag4 & 0x40) printf(" .1.............................. Local List Only");
  else printf(" .0.............................. Not Local List Only");
  if (Flag4 & 0x80) printf(" 1............................... Domain Enum");
  else printf(" 0............................... Not Domain Enum");
  PComment=SMB_REVERSEDW(PComment);
  printf("Comment Pointer 0x%X", PComment);
}
DWORD SLOT_ANNREQ()
{
  DWORD LenName;
  SMB_SLOT_LAN(GetVmVar("SizeInt"),1,LenName);
  ResetLog(GetVmVar("SizeInt")+1,GetVmVar("FrameSize"));
  aprintf("Reply System Name %s",p);
}
DWORD SLOT_FORCE()
{
  printf("Election Version 0x%X", Version);
  printf("Election Criteria 0x%X,", Criteria);
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+3);
  printf(" 0....... Not used");
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+3);
  printf(" .0...... Not used");
  if(Flag1 & 0x20) printf(" ..1..... Windows NT Server");
  else printf(" ..0..... Not Windows NT Server");
  if(Flag1 & 0x10) printf(" ...1.... Windows NT Workstation");
  else printf(" ...0.... Not Windows NT Workstation");
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+3);
  printf(" ....0... Not used");
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+3);
  printf(" .....0.. Not used");
  ResetLog(GetVmVar("SizeInt")+2,GetVmVar("SizeInt")+3);
  printf(" ......0. Not used");
  if (Flag1 & 0x01) printf(" .......1 WFW");
  else printf(" .......0 Not WFW");
  printf("Election Revision 0x%X", Revision);
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+5);
  if (Flag2 & 0x80) printf(" 1....... Advanced Server");
  else printf(" 0....... Not Advanced Server");
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+5);
  printf(" .0...... Not used");
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+5);
  if (Flag2 & 0x20) printf(" ..1..... WINS Client");
  else printf(" ..0..... Not WINS Client");
  ResetLog(GetVmVar("SizeInt")+4,GetVmVar("SizeInt")+5);
  printf(" ...0.... Not used");
  if (Flag2 & 0x08) printf(" ....1... Domain Master Browser");
  else printf(" ....0... Not Domain Master Browser");
  if (Flag2 & 0x04) printf(" .....1.. Master Browser");
  else printf(" .....0.. Not Master Browser");
  if (Flag2 & 0x02) printf(" ......1. Standby Browse Server");
  else printf(" ......0. Not Standby Browse Server");
  if (Flag2 & 0x01) printf(" .......1 Backup Browse Server");
  else printf(" .......0 Not Backup Browse Server");
  printf("Server Up Time %u%u", DateTime1, DateTime2);
}
DWORD SMBSLOTFORCE()
{
  SMB_SLOT_NAME(GetVmVar("SizeInt"),GetVMVar ("FrameSize"),0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("FrameSize"));
  aprintf("Election Server Name %s",p);
}
DWORD SLOT_BCKREQ()
{
  printf("Get Backup List Requested Count 0x%X", ReqCount);
  printf("Backup Request Token 0x%x", ReqToken);
}
DWORD SLOT_BCKRESP()
{
  printf("Backup Server Count 0x%X", RespCount);
  printf("Backup Response Token 0x%X", RespToken);
}
DWORD SMBSLOTBCK()
{
  DWORD LenName, LenName1;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  SMB_SLOT_NAME(GetVmVar("SizeInt"),GetVMVar ("SizeInt")+LenName+1,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("Backup Server %s",p);
  LenName1=SMB_SLOT_LAN(GetVmVar("SizeInt")+LenName+1,0,0);
  SMB_SLOT_NAME(GetVmVar("SizeInt")+LenName+1,GetVMVar ("SizeInt")+LenName1+1,0);
}
DWORD SLOT_LANMAN()
{
  printf("Flags");
  if (Flag1 & 0x01) printf(" ...............................1 WorkStation Service Running");
  else printf(" ...............................0 No WorkStation Service Running");
  if (Flag1 & 0x02) printf(" ..............................1. Server Service Running");
  else printf(" ..............................0. No Server Service Running");
  if (Flag1 & 0x04) printf(" .............................1.. SQL Server Running");
  else printf(" .............................0.. No SQL Server Running");
  if (Flag1 & 0x08) printf(" ............................1... Primary Domain Controller");
  else printf(" ............................0... Not Primary Domain Controller");
  if (Flag1 & 0x10) printf(" ...........................1.... Backup Domain Controller");
  else printf(" ...........................0.... Not Backup Domain Controller");
  printf("Major Version %u", MajVer);
  printf("Minor Version %u", MinVer);
  TimeAnn=SMB_REVERSE(TimeAnn);
  ResetLog(GetVmVar("SizeInt")+7,GetVmVar("SizeInt")+9);
  printf("Server Announce Rate %u minutes", TimeAnn/60);
}
DWORD SLOT_LAN_NAME()
{
  DWORD LenName;
  LenName=SMB_SLOT_LAN(GetVmVar("SizeInt"),0,0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("SizeInt")+LenName);
  aprintf("Computer Name %s",p);
  SMB_SLOT_NAME(GetVmVar("SizeInt")+LenName+1,GetVMVar ("FrameSize"),0);
  ResetLog(GetVmVar("SizeInt")+LenName+1,GetVmVar("FrameSize"));
  aprintf("Host Comment %s",p);
}
DWORD SMBSLOTSRVCMT()
{
  SMB_SLOT_NAME(GetVmVar("SizeInt"),GetVMVar ("FrameSize"),0);
  ResetLog(GetVmVar("SizeInt"),GetVmVar("FrameSize"));
  aprintf("Host Comment %s",p);
}
DWORD SMB_PIPE()
{
  Setup1=SMB_REVERSE(Setup1);
  if (Setup1 == 0x54) printf ("Code %u Open/Write/Read/Close",Setup1);
  else if (Setup1 == 0x53) printf("Code 0x%X Wait for pipe to be NonBusy",Setup1);
  else if (Setup1 == 0x23) printf("Code 0x%X Read but don't remove data",Setup1);
  else if (Setup1 == 0x21) printf("Code 0x%X Query pipe handle modes",Setup1);
  else if (Setup1 == 0x01) printf("Code 0x%X Set pipe handle modes",Setup1);
  else if (Setup1 == 0x22) printf("Code 0x%X Query pipe attributes",Setup1);
  else if (Setup1 == 0x26) printf("Code 0x%X Write/read operation on pipe",Setup1);
  else if (Setup1 == 0x11) printf("Code 0x%X Read pipe in raw",Setup1);
  else if (Setup1 == 0x31) printf("Code 0x%X Write pipe in raw",Setup1);
  else printf("Code 0x%X", Setup1);
  Setup2=SMB_REVERSE(Setup2);
  printf("Fid of Pipe %u", Setup2);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Size of data %u bytes",ByteCount);
  NAME16(GetVmVar("SizeInt"),7);
  ResetLog(GetVmVar("SizeInt")+7,GetVmVar("SizeInt")+26);
  aprintf("File Name %s ",p);
}
DWORD SMB_TRANSACTION_S()
{
  title("SMB Transaction Reply");
  printf("Count of parameter Word %u", WordCount);
  TotalParByte=SMB_REVERSE(TotalParByte);
  printf("Total Parameter being sent %u bytes", TotalParByte);
  TotalDataByte=SMB_REVERSE(TotalDataByte);
  printf("Total bytes being sent %u bytes", TotalDataByte);
  ParCount=SMB_REVERSE(ParCount);
  printf("Parameter bytes sent this buffer %u bytes", ParCount);
  ParOffSet=SMB_REVERSE(ParOffSet);
  printf("OffSet (from header) to params 0x%X", ParOffSet);
  ParDisplac=SMB_REVERSE(ParDisplac);
  printf("Displacement of these data bytes %u", ParDisplac);
  DataCount=SMB_REVERSE(DataCount);
  printf("Parameter bytes sent this buffer %u bytes", DataCount);
  DataOffSet=SMB_REVERSE(DataOffSet);
  printf("OffSet (from header) to data 0x%X", DataOffSet);
  DataDisplac=SMB_REVERSE(DataDisplac);
  printf("Displacement of these data bytes %u", DataDisplac);
  printf("Count of Setup Words %u", SetupCount);
}
DWORD SMB_TRANS_SECONDARY()
{
  Setup1=SMB_REVERSE(Setup1);
  if (Setup1==0x00) printf("Command 0x%X Create file with extended attributes", Setup1);
  else if (Setup1==0x01) printf("Command 0x%X Begin search for files", Setup1);
  else if (Setup1==0x02) printf("Command 0x%X Resume search for files, Setup1");
  else if (Setup1==0x03) printf("Command 0x%X Get File System Information, Setup1");
  else if (Setup1==0x04) printf("Command 0x%X Reserved", Setup1);
  else if (Setup1==0x05) printf("Command 0x%X Get Information about a named file or directory", Setup1);
  else if (Setup1==0x06) printf("Command 0x%X Set Information about a named file or directory", Setup1);
  else if (Setup1==0x07) printf("Command 0x%X Get Information about Handle", Setup1);
  else if (Setup1==0x08) printf("Command 0x%X Set Information by Handle", Setup1);
  else if (Setup1==0x09) printf("Command 0x%X Not implemented by NT Server", Setup1);
  else if (Setup1==0x0A) printf("Command 0x%X Not implemented by NT Server", Setup1);
  else if (Setup1==0x0B) printf("Command 0x%X Not implemented by NT Server", Setup1);
  else if (Setup1==0x0C) printf("Command 0x%X Not implemented by NT Server", Setup1);
  else if (Setup1==0x0D) printf("Command 0x%X Create Directory with extended attributes", Setup1);
  else if (Setup1==0x0E) printf("Command 0x%X Session Setup with Extended Security Information", Setup1);
  else printf("Command 0x%X", Setup1);
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Byte Count %u", ByteCount);
}
DWORD SMB_TRANS_PIPE()
{
  ByteCount=SMB_REVERSE(ByteCount);
  printf("Byte Count %u", ByteCount);
  SMB_UNICODE(GetVmVar("SizeInt")+3,0);
  ResetLog(GetVmVar("SizeInt")+3,GetVmVar("FrameSize"));
}
DWORD SMB_NEGOTIATE_C()
{
  title("SMB Negotiate Request");
  printf("Count of Parameter Word %u", WordCount);
  printf("Count of data bytes %u", ByteCount);
  printf("Dialect 0x%X", BufferFormat);
}
DWORD SMB_DIALECT_C()
{
  if (Carattere != 0x00) printf("%c", Carattere);
  else printf("\n");
}
DWORD SMB_NEGOTIATE_S()
{
  title("SMB Negotiate Reply");
  printf("Count of Parameter Word %u", WordCount);
  printf("Index of Selected Dialect %u", DialectIx);
  printf("Flags");
  if (Security & 0x01) printf(" .......1 User level security");
  else printf(" .......0 Share level security");
  if (Security & 0x02) printf(" ......1. Encrypt password");
  else printf(" ......0. No Encrypt password");
  printf("Max Pending Multiplexed request %u", MaxMpx);
  printf("Max VC between Client and Server %u", MaxVc);
  printf("Max Transmit Buffer Size %u", MaxBufferS);
  printf("Max Raw buffer Size %u", MaxRawSize);
  printf("Unique token identifyng session %u", SessionKey);
  printf("Flags");
  if (Capability & 0x0001) printf(" ...............................1 Server Supports Raw Read and Write");
  else printf(" ...............................0 Server Not Supports Raw Read and Write");
  if (Capability & 0x0002) printf(" ..............................1. Server Supports Multiplexed Command");  
  else printf(" ..............................0. Server Not Supports Multiplexed Command");
  if (Capability & 0x0004) printf(" .............................1.. Server Supports Unicode String");
  else printf(" .............................0.. Server Not Supports Unicode String");
  if (Capability & 0x0008) printf(" ............................1... Server Supports Large files with 64 bit offsets");
  else printf(" ............................0... Server Not Supports Large files with 64 bit offsets");
  if (Capability & 0x0010) printf(" ...........................1.... Server Supports NT SMB Extensions");
  else printf(" ...........................0.... Server Not Supports NT SMB Extensions");
  if (Capability & 0x0020) printf(" ..........................1..... Server Supports remote API requests via RPC");
  else printf(" ..........................0..... Server Supports remote API requests via RPC");
  if (Capability & 0x0040) printf(" .........................1...... Server recognize NT Status Code");
  else printf(" .........................0...... Server not recognize NT Status Code");
  if (Capability & 0x0080) printf(" ........................1....... Server Supports Level II OpLock");
  else printf(" ........................0....... Server Not Supports Level II OpLock");
  if (Capability & 0x0100) printf(" .......................1........ Server Supports Lock and Read and Write and Unlock SMB");
  else printf(" .......................0........ Server Not Supports Lock and Read and Write and Unlock SMB");
  if (Capability & 0x0200) printf(" ......................1......... Server Supports Bulk Transfers");
  else printf(" ......................0......... Server Not Supports Bulk Transfers");
  if (Capability & 0x0400) printf(" .....................1.......... Server Supports Compressed Bulk Transfers");
  else printf(" .....................0.......... Server Supports Compressed Bulk Transfers");
  if (Capability & 0x0800) printf(" ....................1........... Server is DFS aware");
  else printf(" ....................0........... Server is Not DFS aware");
  if (Capability & 0x1000) printf(" ...................1............ ReadX Responses not must negotiated with buffer size");
  else printf(" ...................0............ ReadX Responses must negotiated with buffer size");
  printf("TimeZone 0x%X", TimeZone);
  printf("Lenght of Encryption Key %u", EncrLen);
  printf("Count of Data bytes %u", ByteCount);
}
DWORD SMB_SESSIONX_S()
{
    title("SMB Session Setup Reply");
    printf("Count of Parameter Word %u", WordCount);
    if (SecCommand == 0xFF) printf("No Secondary Command (Type 0x%X)", SecCommand);
    else printf ("Secondary Command 0x%X", SecCommand);
    if (Action == 0x00) printf("Request Mode 0x%X Logged on as User", Action);
    else printf("Request Mode 0x%X Logged on as Guest", Action);
    printf("Count of Data Byte %u", ByteCount);
}
DWORD SMB_SESSIONX_C()
{
    title("SMB Session Setup Request");
    printf("Count of Parameter Word %u", WordCount);
    if (SecCommand == 0xFF) printf("No Secondary Command (Type 0x%X)", SecCommand);
    else printf ("Secondary Command 0x%X", SecCommand);
    printf("Max Buffer Size %u bytes", MaxBufferSize);
    printf("Max Multiplexed Request %u", MaxMpxCount);
    printf("VC Number %u", VCNro);
    if (VCNro != 0) printf("Session Key %u", SessKey);
    printf("Password Length (ANSI) %u", CaseInsPwd);
    printf("Password Length (UNICODE) %u", CaseSenPwd);
    printf("Flags");
    if (Capability & 0x0001) printf(" ...............................1 Client Supports Raw Read and Write");
    else printf(" ...............................0 Client Not Supports Raw Read and Write");
    if (Capability & 0x0002) printf(" ..............................1. Client Supports Multiplexed Command");  
    else printf(" ..............................0. Client Not Supports Multiplexed Command");
    if (Capability & 0x0004) printf(" .............................1.. Client Supports Unicode String");
    else printf(" .............................0.. Client Not Supports Unicode String");
    if (Capability & 0x0008) printf(" ............................1... Client Supports Large files with 64 bit offsets");
    else printf(" ............................0... Client Not Supports Large files with 64 bit offsets"); 
    if (Capability & 0x0010) printf(" ...........................1.... Client Supports NT SMB Extensions");
    else printf(" ...........................0.... Client Not Supports NT SMB Extensions");
    if (Capability & 0x0020) printf(" ..........................1..... Client Supports remote API requests via RPC");
    else printf(" ..........................0..... Client Supports remote API requests via RPC");
    if (Capability & 0x0040) printf(" .........................1...... Client recognize NT Status Code");
    else printf(" .........................0...... Client not recognize NT Status Code");
    if (Capability & 0x0080) printf(" ........................1....... Client Supports Level II OpLock");
    else printf(" ........................0....... Client Not Supports Level II OpLock");
    if (Capability & 0x0100) printf(" .......................1........ Client Supports Lock and Read and Write and Unlock SMB");
    else printf(" .......................0........ Client Not Supports Lock and Read and Write and Unlock SMB");
    if (Capability & 0x0200) printf(" ......................1......... Client Supports Bulk Transfers");
    else printf(" ......................0......... Client Not Supports Bulk Transfers");
    if (Capability & 0x0400) printf(" .....................1.......... Client Supports Compressed Bulk Transfers");
    else printf(" .....................0.......... Client Supports Compressed Bulk Transfers");
    if (Capability & 0x0800) printf(" ....................1........... Client is DFS aware");
    else printf(" ....................0........... Client is Not DFS aware");
    if (Capability & 0x1000) printf(" ...................1............ ReadX Responses not must negotiated with buffer size");
    else printf(" ...................0............ ReadX Responses must negotiated with buffer size");
    printf("Count of data bytes %u", ByteCount);
}
DWORD SMB_TREEDISC_C()
{
    title("SMB Tree Disconnect Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_TREEDISC_S()
{
    title("SMB Tree Disconnect Reply");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_CREATEDIR_C()
{
    title("SMB Create Directory Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_CREATEDIR_S()
{
    title("SMB Create Directory Reply");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_CREATEDIR_C()
{
    title("SMB Create Directory Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_DELDIR_C()
{
    title("SMB Delete Directory Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
    printf("Buffer Format 0x%X", BufferForm);
}
DWORD SMB_DELDIR_S()
{
    title("SMB Delete Directory Reply");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_CHKDIR_C()
{
    title("SMB Check Directory Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
    printf("Buffer Format 0x%X", BufferForm);
}
DWORD SMB_CHKDIR_S()
{
    title("SMB Check Directory Reply");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_CLOSEFILE_C()
{
    title("SMB Close File Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("File Handle 0x%X", fileHandle);
    printf("Date File was last written %u-%u-%u", Day, Month, Year);
    printf("Time File was last written %u-%u-%u", Hour, Minute, Second);
    printf("Count of data byte %u", ByteCount);
}
DWORD SMB_CLOSEFILE_S()
{
    title("SMB Close File Reply");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}   
DWORD SMB_FLUSHFILE_C()
{
    title("SMB Flush File Request");
    printf("Count of Parameter Word %u", WordCount);
    printf("File Handle 0x%X", FileHandle);
    printf("Count of data byte %u", ByteCount);
}   
DWORD SMB_FLUSHFILE_S()
{
    title("SMB Flush File Reply");
    printf("Count of Parameter Word %u", WordCount);
    printf("Count of data byte %u", ByteCount);
}   


// Completed by courtesy of J.-C. Hasler (swisscom Inc.) Jean-Claude.Hasler@swisscom.com, Dec 11th, 2000
DWORD ICMP ()
{
    title("ICMP Header");
    DWORD t;
    t=ICode;
    ResetLog(offsetof(IType),offsetof(IType)+1);
    if(IType==0) 
                        {
	         printf("Type 0x%X Echo reply.",IType);
	         if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
		}
    else if(IType==3) 
		{
		 printf("Type 0x%X Destination unreachable.", IType);
		 if(ICode==0) printf("Code 0x%X Network unreachable.", ICode);
		 else if(ICode==1) printf("Code 0x%X Host unreachable.", ICode);
		 else if(ICode==2) printf("Code 0x%X Protocol unreachable.", ICode);
		 else if(ICode==3) printf("Code 0x%X Port unreachable.", ICode);
		 else if(ICode==4) printf("Code 0x%X Fragmentation needed and DF set.", ICode);
		 else if(ICode==5) printf("Code 0x%X Source route failed.", ICode);
		 else if(ICode==6) printf("Code 0x%X Destination Network Unknown.", ICode);
	       else if(ICode==7) printf("Code 0x%X Destination Host Unknown.", ICode);
             else if(ICode==8) printf("Code 0x%X Source Host Isolate.", ICode);
             else if(ICode==9) printf("Code 0x%X Destination Network Administratively Prohibited.", ICode);
             else if(ICode==10) printf("Code 0x%X Destination Host Administratively Prohibited.", ICode);
             else if(ICode==11) printf("Code 0x%X Destination Network Unreachable for Type Of Service.", ICode);
             else if(ICode==12) printf("Code 0x%X Destination Host Unreachable for Type Of Service.", ICode);
		}
    else if(IType==4) 
		{
		 printf("Type 0x%X Source Quench.",IType);
	     	 if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                 }
    else if(IType==5) 
		{
		 printf("Type 0x%X Redirect.",IType);
		 if(ICode==0) printf("Code 0x%X Redirect Datagrams for the Network (or Subnet).", ICode);
		 else if(ICode==1) printf("Code 0x%X Redirect datagrams for the host.", ICode);
		 else if(ICode==2) printf("Code 0x%X Redirect datagrams for the Type Of Service and Network.", ICode);
		 else if(ICode==3) printf("Code 0x%X Redirect datagrams for the Type Of Service and Host.", ICode);
		}
    else if(IType==6)
		{
		 printf("Type 0x%X Alternate Host Address.",IType);
	     	 if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                 }
    else if(IType==8)
		{
		 printf("Type 0x%X Echo Request.",IType);
	     	 if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                 }
    else if(IType==9)
		{
		 printf("Type 0x%X Router Advertisement.",IType);
	     	 if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                 }
    else if(IType==10)
		  {
		   printf("Type 0x%X Router Selection.",IType);
	     	   if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                   }
    else if(IType==11)
		{
		 printf("Type 0x%X Time exceeded.",IType);
		 if(ICode==0) printf("Code 0x%X Time to live exceeded in transit.", ICode);
		 else if(ICode==1) printf("Code 0x%X Fragment reassemble time exceeded.", ICode);
		}
    else if(IType==12)
		 {
		  printf("Type 0x%X Parameter problem.",IType);
	     	  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==13)
		 {
		  printf("Type 0x%X Timestamp request.",IType);
	     	  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==14)
		 {
		  printf("Type 0x%X Timestamp reply.",IType);
	     	  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==15)
		 {
		  printf("Type 0x%X Information request (IP-Address).",IType);
	     	  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==16)
		 {
		  printf("Type 0x%X Information reply (IP-Address).",IType);
     		  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==17)
		 {
		  printf("Type 0x%X Address Mask request (Subnet-Mask).",IType);
     		  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==18)
		 {
		  printf("Type 0x%X Address Mask reply (Subnet-Mask).",IType);
     		  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else if(IType==30)
		 {
		  printf("Type 0x%X TraceRoute.",IType);
     		  if(ICode==0) printf("Code 0x%X No significant Code.", ICode);
	                  }
    else 
	{
	 printf ("Type 0x%X ",IType);
	 printf ("Code 0x%X ",ICode);
	}
    printf( "Checksum 0x%X",IChecksum);
}
DWORD ICMP_PPM()
{
    printf("Octet where an error was detected %u", Pointer);
}
DWORD ICMP_REDG()
{
    printf("Address Gateway %u.%u.%u.%u", IpAddress>>24&0xFF,IpAddress>>16&0xFF,
                                          IpAddress>>8&0xFF,IpAddress&0xFF);
}
DWORD ICMP_ECHO()
{
    printf("Identifier %u", Identif);
    printf( "Sequence Number %u",SeqNumber);
}
DWORD ICMP_TIME()
{
    printf("Identifier %u", Identif);
    printf("Sequence Number %u", SeqNumber);
    printf("Originate TimeStamp %u milliseconds", OTime);
    printf("Receive TimeStamp %u milliseconds", RTime);
    printf("Transmit TimeStamp %u milliseconds", TTime);
}

ARRAY Str_RTSP;

DWORD Print_RTSP(DWORD Start,DWORD End, DWORD CR)
{
	DWORD i,j,t,n,nr,s,e;
	Str_RTSP[0]=0;
	j=0;
	n=2;
	nr=1;
	s=0;e=0;
	for (i=0;i<End-Start;i=i+1)
	{
		if (check(Start+i)==0) return 0;
		t=CONV(Start+i);
		if(t==0x0d || t==0x0a) 
		{
			if (t==0x0a) n=n+1;
			Str_RTSP[j]=0;
			if (n>=2)
			{
				if(j!=0)
				{
				 if (cr==0) 
				 {
					ResetLog(s,start+i);
					printf("Command number %d",nr);
				 }
				 else 
				 {
					if (nr==1) printf("Reply data");
				 }
				 //printf("Reply number %d",nr);
				 n=0;
				 nr=nr+1;
				}
			}
			ResetLog(s,start+i);
			if(j!=0) 
			{
				if (j>100)
				{
					Str_RTSP[96]=' ';
					Str_RTSP[97]='.';
					Str_RTSP[98]='.';
					Str_RTSP[99]='.';
					Str_RTSP[100]=0;
				}
				aprintf(" %s",Str_RTSP);
			}
			//printf(" %d",n);
			j=0;
		}
		else 
		{
			if (j==0&&n<=1) n=0;
			if (j==0) s=start+i;
			if (t>=32 && t<128) 
			{
				Str_RTSP[j]=t;
				j=j+1;
			}
		}
	}
}

DWORD RTSP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- RTSP -----");
	printf("Data: %d",getvmvar("SizeNotInt"));
	Print_RTSP(GetVmVar("SizeInt"),GetVmVar("SizeInt")+getvmvar("SizeNotInt"),0);
}

DWORD RTSP_REP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- RTSP Reply -----");
	printf("Data: %d",getvmvar("SizeNotInt"));
	Print_RTSP(GetVmVar("SizeInt"),GetVmVar("SizeInt")+getvmvar("SizeNotInt"),1);
}

DWORD RA_HANDSHAKE()
{
	if (p!=0x50 || n!=0x4e || a!=0x41) return 0;
	resetlog (offsetof(P),offsetof(P)+GetVmVar("SizeNotInt"));
	printf("----- Real Audio Handshake protocol -----");
	printf("Version: %d",Version);
}

DWORD RA_O()
{
	if (O!=0x4f) return 0;
	resetlog (offsetof(O),offsetof(O)+GetVmVar("SizeNotInt"));
	printf("----- Real Audio Handshake protocol -----");
	printf("Robust UDP response message");
	printf("Data Length: %d",DataLength);
	printf("Op. Code: %d",opcode);
	printf("Server Port: %d",srport);
	printf("Player Request ID: %d",RID);
}

DWORD RA_H_MESS()
{
	printf("Opcode: %d",Opcode);
	printf(" Length: %d",ByteCount);
}

DWORD RA_HELLO()
{
	printf("Hello Data: %d",Hello_Data);
}

DWORD RA_OTHER()
{
	  DWORD s,t;
	  s=GetVMVar ("SizeNotInt");
	  t=GetVMVar ("FrameSize");
	  if (s)
	  {
	  printf("----- Real Audio PNA protocol ----- [%d-%d]",t-s,t-1);
	  printf( "[%u byte(s) of data]",s);
	  }
}

ARRAY str;

DWORD Print_StrProto(DWORD Start,DWORD End)
{
	DWORD i,j,t,s,e;
	Str[0]=0;
	j=0;
	s=0;e=0;
	for (i=0;i<End-Start;i=i+1)
	{
		if (check(Start+i)==0) return 0;
		t=CONV(Start+i);
		if(t==0x0d || t==0x0a) 
		{
			Str[j]=0;
			ResetLog(s,start+i);
			if(j!=0) 
			{
				if (j>100)
				{
					Str[96]=' ';
					Str[97]='.';
					Str[98]='.';
					Str[99]='.';
					Str[100]=0;
				}
				aprintf(" %s",Str);
			}
			j=0;
		}
		else 
		{
			if (j==0) s=start+i;
			if (t>=32 && t<128) 
			{
				Str[j]=t;
				j=j+1;
			}
			else 
			{
				ResetLog(start+i,end);
				printf(" Binary Data: %d",end-(start+i));
				return 0;
			}
		}
	}
	if(j!=0) 
	{
		if (j>100)
		{
			Str[96]=' ';
			Str[97]='.';
			Str[98]='.';
			Str[99]='.';
			Str[100]=0;
		}
		str[j]=0;
		printf("%d",j);
		aprintf(" %s",Str);
	}
}

DWORD FTP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- FTP Control Connection -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
	Print_StrProto(GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
}

DWORD FTP_DATA()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- FTP Data Connection -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD TELNET()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- Telnet -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD Daytime()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- Daytime -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD SMTP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- SMTP -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD Gopher()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- Gopher -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD Finger()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- Finger -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD POP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- POP -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD NNTP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- NNTP -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD XWindows()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- XWindows -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD TFTP()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- Trivial FTP -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}


//***************** BOOTP *********************
// Courtesy of Nelson B. Bolyard, nbolyard@home.com, Jun 26th, 2000

DWORD PrintIPaddrs(DWORD offs, DWORD limit)
{
    DWORD ipad;
    while (offs < limit) {
        ipad = CONV32(offs);
        ResetLog(offs, offs + 4, 1);
        printf(" [%u.%u.%u.%u]",
            ipad>>24&0xFF, ipad>>16&0xFF, ipad>>8&0xFF, ipad&0xFF);
        offs = offs + 4;
    }
    return 0;
}

DWORD PrintDHCPOptionsList(DWORD offs, DWORD limit)
{
    DWORD cc;
    while (offs < limit) {
        cc = CONV(offs);
        ResetLog(offs, offs + 1, 1);
        if      (cc == 0)  printf(" 0: Pad");
        else if (cc == 1)  printf(" 1: Subnet Mask");
        else if (cc == 2)  printf(" 2: Time Offset");
        else if (cc == 3)  printf(" 3: Router list");
        else if (cc == 4)  printf(" 4: Time server list");
        else if (cc == 5)  printf(" 5: IEN 116 Name server list");
        else if (cc == 6)  printf(" 6: Domain Name server list");
        else if (cc == 7)  printf(" 7: Log    server list");
        else if (cc == 8)  printf(" 8: Cookie server list");
        else if (cc == 9)  printf(" 9: LPR    server list");
        else if (cc == 10) printf(" 10: Impress server list");
        else if (cc == 11) printf(" 11: Resource Location server list");
        else if (cc == 12) printf(" 12: Client Host Name");
        else if (cc == 13) printf(" 13: Boot File Size");
        else if (cc == 14) printf(" 14: Dump File Pathname");
        else if (cc == 15) printf(" 15: Domain Name");
        else if (cc == 16) printf(" 16: Swap server");
        else if (cc == 17) printf(" 17: Boot PathName");
        else if (cc == 18) printf(" 18: Extensions PathName");
        else if (cc == 19) printf(" 19: IP forwarding Option");
        else if (cc == 20) printf(" 20: Source Routing Option");
        else if (cc == 21) printf(" 21: Policy Filter Option");
        else if (cc == 22) printf(" 22: Maximum Datagram Reassembly Size");
        else if (cc == 23) printf(" 23: Default IP TTL");
        else if (cc == 24) printf(" 24: Path MTU Aging Timeout");
        else if (cc == 25) printf(" 25: Path MTU Plateau Table");
        else if (cc == 26) printf(" 26: Interface MTU");
        else if (cc == 27) printf(" 27: All subnets share MTU");
        else if (cc == 28) printf(" 28: Broadcast Address");
        else if (cc == 29) printf(" 29: ICMP subnet mask discovery option");
        else if (cc == 30) printf(" 30: ICMP subnet mask supplier option");
        else if (cc == 31) printf(" 31: Router Discovery Option");
        else if (cc == 32) printf(" 32: Router Solicitation Address");
        else if (cc == 33) printf(" 33: Statis Routes");
        else if (cc == 34) printf(" 34: Trailer Encapsulation");
        else if (cc == 35) printf(" 35: ARP cache timeout time");
        else if (cc == 36) printf(" 36: Ethernet Encapsulation");
        else if (cc == 37) printf(" 37: Default IP MTU for TCP");
        else if (cc == 38) printf(" 38: TCP KeepAlive Interval");
        else if (cc == 39) printf(" 39: TCP KeepAlive Garbage Option");
        else if (cc == 40) printf(" 40: NIS Domain");
        else if (cc == 41) printf(" 41: NIS Server list");
        else if (cc == 42) printf(" 42: NTP Server list");
        else if (cc == 43) printf(" 43: Vendor-specific Info");
        else if (cc == 44) printf(" 44: NetBIOS/TCP Name Server list");
        else if (cc == 45) printf(" 45: NetBIOS/TCP Datagram Server list");
        else if (cc == 46) printf(" 46: NetBIOS/TCP Node Type");
        else if (cc == 47) printf(" 47: NetBIOS/TCP Scope");
        else if (cc == 48) printf(" 48: X-Windows Font Server list");
        else if (cc == 49) printf(" 49: X-Windows Display Manager list");
        else if (cc == 50) printf(" 50: Requested IP address");
        else if (cc == 51) printf(" 51: IP address lease time");
        else if (cc == 52) printf(" 52: Option Overload");
        else if (cc == 53) printf(" 53: DHCP Message Type");
        else if (cc == 54) printf(" 54: Server Identifier");
        else if (cc == 55) printf(" 55: Parameter Request List");
        else if (cc == 56) printf(" 56: Error Message");
        else if (cc == 57) printf(" 57: Maximum DHCP Message Size");
        else if (cc == 58) printf(" 58: Renewal (T1) Time value");
        else if (cc == 59) printf(" 59: Rebinding (t2) Time value");
        else if (cc == 60) printf(" 60: Vendor Class Identifier");
        else if (cc == 61) printf(" 61: Client Identifier");
//      else if (cc == 62) printf(" 62:
//      else if (cc == 63) printf(" 63:
        else if (cc == 64) printf(" 64: NIS+ Domain");
        else if (cc == 65) printf(" 65: NIS+ Server list");
        else if (cc == 66) printf(" 66: TFTP Server list");
        else if (cc == 67) printf(" 67: Boot File Name");
        else if (cc == 68) printf(" 68: Mobile IP Home Agent");
        else if (cc == 69) printf(" 69: SMTP Server list");
        else if (cc == 70) printf(" 70: POP3 Server list");
        else if (cc == 71) printf(" 71: NNTP Server list");
        else if (cc == 72) printf(" 72: default WWW server list");
        else if (cc == 73) printf(" 73: default finger server list");
        else if (cc == 74) printf(" 74: default IRC server list");
        else if (cc == 75) printf(" 75: StreetTalk Server List");
        else if (cc == 76) printf(" 76: StreetTalk Directory server list");
        else if (cc == 77) printf(" 77: User Class option");
//      else if (cc == 78) printf(" 78:
//      else if (cc == 79) printf(" 79:
//      else if (cc == 80) printf(" 80:
        else if (cc == 81) printf(" 81: Client FQDN");

        else if (cc == 255) printf(" 255: End");
        else                printf(" %d: (unknown)", cc);
        offs = offs + 1;
    }
    return 0;

}

DWORD Bootp()
{
    DWORD base;
    DWORD end;
    DWORD len;
    DWORD options;
    DWORD remain;
    DWORD ipad;
    base = GETVmVar("SizeInt");
    len = GetVmVar("SizeNotInt");
    end = base+len;
    resetlog (base,end);
    printf("----- Bootp -----");

    ResetLog(offsetof(Op),offsetof(Op)+1);
    printf("Op %u", Op);
    ResetLog(offsetof(HardwareType),offsetof(HardwareType)+1);
    printf("Hardware Type %u", HardwareType);
    ResetLog(offsetof(HardwareMACLen),offsetof(HardwareMACLen)+1);
    printf("Hardware MAC Length %u bytes", HardwareMACLen);
    ResetLog(offsetof(Hops),offsetof(Hops)+1);
    printf("Hops %u", Hops);
    ResetLog(offsetof(Xid),offsetof(Xid)+4);
    printf("Transaction ID %x", Xid);
    ResetLog(offsetof(Secs),offsetof(Secs)+2);
    printf("Seconds aquiring %u", Secs);
    ResetLog(offsetof(BPflags),offsetof(BPflags)+2);
    Printf("Flags");
    ResetLog(offsetof(BPflags),offsetof(BPflags)+2,1);
    if (BPFlags & 0x8000) printf(" 1....... ........ Broadcast");
    else                  printf(" 0....... ........ No Broadcast");
    ResetLog(offsetof(CIaddr),offsetof(CIaddr)+4);
    printf("Client address = [%u.%u.%u.%u]",
        CIaddr>>24&0xFF, CIaddr>>16&0xFF, CIaddr>>8&0xFF, CIaddr&0xFF);
    ResetLog(offsetof(YIaddr),offsetof(YIaddr)+4);
    printf("Your address = [%u.%u.%u.%u]",
        YIaddr>>24&0xFF, YIaddr>>16&0xFF, YIaddr>>8&0xFF, YIaddr&0xFF);
    ResetLog(offsetof(SIaddr),offsetof(SIaddr)+4);
    printf("Server address = [%u.%u.%u.%u]",
        SIaddr>>24&0xFF, SIaddr>>16&0xFF, SIaddr>>8&0xFF, SIaddr&0xFF);
    ResetLog(offsetof(GIaddr),offsetof(GIaddr)+4);
    printf("Relay address = [%u.%u.%u.%u]",
        GIaddr>>24&0xFF, GIaddr>>16&0xFF, GIaddr>>8&0xFF, GIaddr&0xFF);

    ResetLog(offsetof(CHaddr0),offsetof(CHaddr0)+16);
    printf("Client Hardware Address");

    options = GetStringa(64, offsetof(CHaddr0)+16);
    ResetLog(offsetof(CHaddr0)+16,offsetof(CHaddr0)+80);
    aprintf("Server Host Name: %s", p);

    options = GetStringa(128, offsetof(CHaddr0)+80);
    ResetLog(offsetof(CHaddr0)+80,offsetof(CHaddr0)+208);
    aprintf("Boot File Name: %s",p);

    options = offsetof(CHaddr0)+208;
    ResetLog(options,end);

    CHECK(options+3);
    if (CONV32(options) != 0x63825363 ) {		//not DHCP packet (only BOOTP)
        printf("Options [%u byte(s)]",end - options);
        return 0;
    }

    base = options + 4;
    printf("----- DHCP Options -----");
    ResetLog(options, base);
    printf("Magic DHCP Cookie: 0x63825363");
    remain = end - base;
    while (remain > 0) {
        DWORD option;
        DWORD offs;
        DWORD mask;
        offs = base + 2;
        CHECK(base);
        option = CONV(base);
        len = 1;
        if (option > 0 && option < 255 ) {
            CHECK(base + 1);
            len = 2 + CONV(base + 1);
            CHECK(base + len - 1);
        }
        ResetLog(base, base + len);
        if (option == 0) {
            printf("Pad");
        } else if (option == 1) {
            ipad = CONV32(base + 2);
            printf("Subnet Mask = [%u.%u.%u.%u]",
                ipad>>24&0xFF, ipad>>16&0xFF,
                ipad>>8&0xFF, ipad&0xFF);
        } else if (option == 2) {
            ipad = CONV32(base + 2);
            printf("Time Offset = %d seconds", ipad);
        } else if (option == 3) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Router = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Routers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 4) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Time Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Time Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 5) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("IEN 116 Name Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("IEN 116 Name Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 6) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Domain Name Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Domain Name Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 7) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Log Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Log Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 8) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Cookie Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Cookie Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 9) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("LPR Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("LPR Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 10) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Impress Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Impress Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 11) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Resource Location Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Resrouce Location Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 12) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Client host name: %s", p);
        } else if (option == 13) {
            offs = CONV16(offs);
            printf("Boot File Size: %u", offs);
        } else if (option == 14) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Dump file path name: %s", p);
        } else if (option == 15) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Domain name: %s", p);
        } else if (option == 16) {
            ipad = CONV32(offs);
            printf("Swap Server = [%u.%u.%u.%u]",
                ipad>>24&0xFF, ipad>>16&0xFF,
                ipad>>8&0xFF, ipad&0xFF);
        } else if (option == 17) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Root Path: %s", p);
        } else if (option == 18) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Extensions File Path: %s", p);
        } else if (option == 19) {
            if (CONV(offs)) printf("IP Forwarding Enabled");
            else            printf("IP Forwarding Disabled");
        } else if (option == 20) {
            if (CONV(offs)) printf("Source Routing Enabled");
            else            printf("Source Routing Disabled");
        } else if (option == 21) {
            printf("Policy Filter Address + Mask");
            while (offs < base + len) {
                ipad = CONV32(offs);
                mask = CONV32(offs + 4);
                ResetLog(offs, offs + 8, 1);
                printf("[%u.%u.%u.%u] [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF, ipad>>8&0xFF, ipad&0xFF,
                    mask>>24&0xFF, mask>>16&0xFF, mask>>8&0xFF, mask&0xFF);
                offs = offs + 8;
            }
        } else if (option == 22) {
            offs = CONV16(offs);
            printf("Minimum Datagram Reassembly Size: %u bytes", offs);
        } else if (option == 23) {
            offs = CONV(offs);
            printf("Default IP TTL: %u", offs);
        } else if (option == 24) {
            offs = CONV32(offs);
            printf("Path MTU Aging timeout: %u seconds", offs);
        } else if (option == 26) {
            offs = CONV16(offs);
            printf("Interface MTU: %u bytes", offs);
        } else if (option == 27) {
            if (CONV(offs)) printf("All subnets share MTU");
            else            printf("All subnets DO NOT share MTU");
        } else if (option == 28) {
            ipad = CONV32(offs);
            printf("Broadcast Address = [%u.%u.%u.%u]",
                ipad>>24&0xFF, ipad>>16&0xFF,
                ipad>>8&0xFF, ipad&0xFF);
        } else if (option == 29) {
            if (CONV(offs)) printf("Do ICMP subnet mask discovery");
            else            printf("Do no ICMP subnet mask discovery");
        } else if (option == 30) {
            if (CONV(offs)) printf("Respond to ICMP subnet mask request");
            else            printf("Ignore ICMP subnet mask request");
        } else if (option == 31) {
            if (CONV(offs)) printf("Do router discovery");
            else            printf("Do no router discovery");
        } else if (option == 32) {
            ipad = CONV32(offs);
            printf("Router Solicitation Address = [%u.%u.%u.%u]",
                ipad>>24&0xFF, ipad>>16&0xFF,
                ipad>>8&0xFF, ipad&0xFF);
        } else if (option == 33) {
            printf("Static Route Destinations + Routers");
            while (offs < base + len) {
                ipad = CONV32(offs);
                mask = CONV32(offs + 4);
                ResetLog(offs, offs + 8, 1);
                printf(" [%u.%u.%u.%u] [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF, ipad>>8&0xFF, ipad&0xFF,
                    mask>>24&0xFF, mask>>16&0xFF, mask>>8&0xFF, mask&0xFF);
                offs = offs + 8;
            }
        } else if (option == 35) {
            offs = CONV32(offs);
            printf("ARP cache timeout: %u seconds", offs);
        } else if (option == 37) {
            offs = CONV(offs);
            printf("Default IP TTL for TCP: %u", offs);
        } else if (option == 38) {
            offs = CONV32(offs);
            printf("TCP KeepAlive Interval: %u seconds", offs);
        } else if (option == 39) {
            if (CONV(offs)) printf("Do TCP KeepAlive Garbage");
            else            printf("Do no TCP KeepAlive Garbage");
        } else if (option == 40) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("NIS Domain name: %s", p);
        } else if (option == 41) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("NIS Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("NIS Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 42) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("NTP Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("NTP Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 44) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("NetBIOS/TCP Name Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("NetBIOS/TCP Name Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 45) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("NetBIOS/TCP Datagram Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("NetBIOS/TCP Datagram Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 46) {
            offs = CONV(offs);
            printf("NetBIOS/TCP node Type: %x");
        } else if (option == 47) {
            printf("NetBIOS/TCP Scope [%u byte(s)]", len - 2);
        } else if (option == 48) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("X-Windows font Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("X-Windows font Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 49) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("X-Windows Display Manager = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("X-Windows Display Managers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 50) {
            ipad = CONV32(offs);
            printf("Requested ID address: [%u.%u.%u.%u]",
                ipad>>24&0xFF, ipad>>16&0xFF,
                ipad>>8&0xFF, ipad&0xFF);
        } else if (option == 51) {
            offs = CONV32(offs);
            printf("IP address lease time: %u seconds", offs);
        } else if (option == 53) {
            offs = CONV(offs);
            if      (offs == 1) printf("DHCP message type: Discover");
            else if (offs == 2) printf("DHCP message type: Offer");
            else if (offs == 3) printf("DHCP message type: Request");
            else if (offs == 4) printf("DHCP message type: Decline");
            else if (offs == 5) printf("DHCP message type: Ack");
            else if (offs == 6) printf("DHCP message type: Nak");
            else if (offs == 7) printf("DHCP message type: Release");
            else if (offs == 8) printf("DHCP message type: Inform");
            else                printf("DHCP message type: %u (unknown)");
        } else if (option == 54) {
            ipad = CONV32(offs);
            printf("Server Identifier: [%u.%u.%u.%u]",
                ipad>>24&0xFF, ipad>>16&0xFF,
                ipad>>8&0xFF, ipad&0xFF);
        } else if (option == 55) {
            printf("Parameter request list [%u byte(s)]", len - 2);
            PrintDHCPOptionsList(offs, base + len);
        } else if (option == 56) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Error message: %s", p);
        } else if (option == 57) {
            offs = CONV16(offs);
            printf("Max DHCP message size: %u bytes", offs);
        } else if (option == 58) {
            offs = CONV32(offs);
            printf("Renewal (T1) time: %u seconds", offs);
        } else if (option == 59) {
            offs = CONV32(offs);
            printf("Rebinding (T2) time: %u seconds", offs);
        } else if (option == 60) {
            clear(p);
            ipad = GetStringa(len - 2, offs);
            ipad = 0;
            while (offs < base + len) {
                DWORD cx;
                cx = CONV(offs);
                if (cx < 0x20 || cx > 0x7f) { ipad = 1; break; }
                offs = offs + 1;
            }
            ResetLog(base, base + len);
            if (ipad == 0)
                aprintf("Vendor class identifier: %s", p);
            else
                printf("Vendor class identifier [%u byte(s)]", len - 2);
        } else if (option == 61) {
            printf("Client identifier [%u byte(s)]", len - 2);
        } else if (option == 64) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("NIS+ Domain name: %s", p);
        } else if (option == 65) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("NIS+ Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("NIS+ Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 66) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("TFTP Server name: %s", p);
        } else if (option == 67) {
            clear(p);
            offs = GetStringa(len - 2, offs);
            ResetLog(base, base + len);
            aprintf("Boot file name: %s", p);
        } else if (option == 68) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("Mobile IP home agent = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("Mobile IP home agents");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 69) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("SMTP Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("SMTP Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 70) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("POP3 Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("POP3 Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 71) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("NNTP Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("NNTP Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 72) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("default WWW Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("default WWW Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 73) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("default finger Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("default finger Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 74) {
            if (len == 6) {
                ipad = CONV32(offs);
                printf("default IRC Server = [%u.%u.%u.%u]",
                    ipad>>24&0xFF, ipad>>16&0xFF,
                    ipad>>8&0xFF, ipad&0xFF);
            } else {
                printf("default IRC Servers");
                PrintIPaddrs(offs, base + len);
            }
        } else if (option == 77) {
            printf("User Class [%u byte(s)]", len - 2);
        } else if (option == 81) {
            clear(p);
            offs = GetStringa(len - 5, offs + 3);
            ResetLog(base, base + len);
            aprintf("Client FQDN: %s", p);
        } else if (option == 255) {
            printf("End Option");
            break;
        } else {
            printf("Unknown Option %d [%u byte(s)]", option, len - 2);
        }
        base = base + len;
        remain = remain - len;
    }
    return 0;
}

//*********************** End BOOTP
//DWORD Bootp()
//{
//	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
//	printf("----- Bootp -----");
//	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
//}

DWORD RWHO()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- RWho -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}

DWORD NFS()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- Network File System -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
}


DWORD HTTP_CL()
{
	resetlog (GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
	printf("----- HTTP Client Request -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
	Print_StrProto(GetVmVar("SizeInt"),GetVmVar("SizeInt")+GetVmVar("SizeNotInt"));
}

DWORD HTTP_SV()
{
	resetlog (offsetof(h),offsetof(h)+GetVmVar("SizeNotInt"));
	printf("----- HTTP Server Reply -----");
	printf( "[%u byte(s) of data]",GetVMVar ("SizeNotInt"));
	if (h!='H' || t1!='T' || t2!='T' || p!='P' ) return 0;
	Print_StrProto(offsetof(h),offsetof(h)+GetVmVar("SizeNotInt"));
}

DWORD RTP_RTCP ()
{
//	printf("----- %d -----",XR);
	return 0;
}

DWORD BAD_RTP_RTCP ()
{
//	printf("----- %d -----",XR);
	return 0;
}

DWORD RTP ()
{
	ResetLog(OffsetOf(HDR),OffsetOf(CSRC1)+CC*4);
	printf("----- RTP (approximate detection method) -----");
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	printf("Version = %d", version);
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	if (p) printf("Padding Present");
	 else printf("No Padding Present");
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	if (x) printf("Extension Present");
	 else printf("No Extension Present");
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	printf("CSRC Count = %d", CC);
	ResetLog(OffsetOf(HDR)+1,OffsetOf(HDR)+2,1);
	printf("Marker bit = %d",m);
	ResetLog(OffsetOf(HDR)+1,OffsetOf(HDR)+2,1);
	printf("Payload Type = %d",PT);
	printf("Sequence Number = %d",SeqNumber);
	printf("TimeStamp = %u",TimeStamp);
	printf("SSRC = %u",SSRC);
	if (CC>=1) printf("CSRC N. 1 = %u",CSRC1);
	if (CC>=2) printf("CSRC N. 2 = %u",CSRC2);
	if (CC>=3) printf("CSRC N. 3 = %u",CSRC3);
	if (CC>=4) printf("CSRC N. 4 = %u",CSRC4);
}

DWORD RTCP ()
{
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+(length+1)*4);
	printf("----- RTCP (approximate detection method) -----");
	DWORD PayloadType;
	PayloadType=PT;
	if (Version==2)
	{
	 if (PT==200)
		printf("Sender report");
	 else if (PT==201)
		printf("Recever report");
	 else if (PT==202)
		printf("Source Description");
	 else if (PT==203)
		printf("BYE");
	 else if (PT==204)
		printf("APP");
	}
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	printf("Version = %d", version);
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	if (p) printf("Padding Present");
	 else printf("No Padding Present");
	ResetLog(OffsetOf(HDR),OffsetOf(HDR)+1,1);
	if(PayloadType==200 || PayloadType==201)
		printf("RC Count = %d", XC);
	else if(PayloadType==202 || PayloadType==203)
		printf("SC Count = %d", XC);
	else if(PayloadType==204)
		printf("Subtype = %d", XC);
	ResetLog(OffsetOf(HDR)+1,OffsetOf(HDR)+2);
	printf("Payload Type = %d",PT);
	printf("Length = %d",Length);
}


DWORD PIM6()
{
	title("PIM6 Header");
	printf ("Version: %d", version);
	printf ("Checksum: 0x%x", checksum);
}

DWORD PIM6_HELLO()
{
	printf ("Command: Hello");
	if (optiontype == 1) printf ("Option Type: %d (Hold Time)", optiontype);
	else printf("Option Type: %d (Not Supported)", optiontype);
	printf ("Option Length: %d", optionlength);
	printf ("Value: %d", optionvalue);
}

DWORD PIM6_REGISTER()
{
	printf ("Command: Register");
	if (b==0) printf ("Border Bit: 0 (Router is a DR for a source that it is directly connected to)");
	if (b==1) printf ("Border Bit: 1 (Router is a PMBR for a source in a directly connected cloud)");
	if (n==0) printf ("Null Register Bit: 0 (Set to 1 by a DR that is probing the RP before expiring its local Register-Suppression timer)");
	if (n==1) printf ("Null Register Bit: 1 (Set to 1 by a DR that is probing the RP before expiring its local Register-Suppression timer)");

}

DWORD PIM6_REGISTER_STOP()
{
	printf ("Command: Register-Stop");
}

DWORD PIM6_JOIN_PRUNE()
{
	printf ("Command: Join - Prune");
}

DWORD PIM6_BOOTSTRAP()
{
	printf ("Command: Bootstrap");
}

DWORD PIM6_ASSERT()
{
	printf ("Command: Assert");
}

DWORD PIM6_GRAFT()
{
	printf ("Command: Graft (used in PIM-DM only)");
}

DWORD PIM6_GRAFT_ACK()
{
	printf ("Command: Graft-Ack (used in PIM-DM only)");
}

DWORD PIM6_CANDIDATE_RP()
{
	printf ("Command: Candidate-RP-Advertisement");
}