$1 ~ /------/ {
	start = 1
}
$1 ~ /DYNAMIC/{
	start = 0
}
$1=="#" {
	com++;
	}

start==1 {
	fstart = 2;
	if ($1 == "#")
		next		
	if ($1 ~ /\/..p/)
	{
		if ( $1 ~ /tcp/ )
			tcp = 1
		else
			tcp = 0
		fstart = 1
		fname = "reserved"
		if ( ($2 == "any") && ($3=="private"))
		{
			fname = "priv"
			for (i=4;i<=NF;i++)
				fname = fname "-" $i
		}
	}
	if (fstart == 2)
	{
		fname = $1
		if ($2 ~ /tcp/)
		{
			tcp = 1
		}
		else if ($2 ~ /udp/)
		{
			tcp = 0
		}
		else
			next;
	}
	split($fstart,work,"/")
	port = work[1]
	if (fname=="reserved")
		fname = port "-reserved"
	comment = ""
	for (i=fstart+1;i<=NF;i++)
	{
		comment = comment " " $i
	}
 
	if (tcp==1)
	{
	    if ( port ~ /\-/ )
	    {
		split(port,allp,"-")
		sport = allp[1]
		fport = allp[2]

	    }
	    else
	    {
		sport = port
		fport = port
	    }
		print "TCP " port " = " sport " to " fport
	    ofname = fname
	    for (port=sport;port<=fport;port++)
	    { 
		if (sport!=fport)
			fname = port "-" ofname
		printf "addtolist(tcp_port_types,%d,\"%s\",TCPHASH);\n",
			port,fname  > "tcp.gen"
		print port > "tcp.ports"
            }
	}
	else
	{
	    if ( port ~ /\-/ )
	    {
		split(port,allp,"-")
		sport = allp[1]
		fport = allp[2]
	    }
	    else
	    {
		sport = port
		fport = port
	    }
		print "UDP " port " = " sport " to " fport
	    ofname = fname
	    for (port=sport;port<=fport;port++)
	    { 
		if (sport!=fport)
			fname = port "-" ofname
		printf "addtolist(udp_port_types,%d,\"%s\",UDPHASH);\n",
			port,fname  > "udp.gen"
		print port > "udp.ports"
            }
	}
} 