Q Algorithm
Construct ] [ Algorithm ]

All packets:
{
    If there is a q construct in the path:
        Skip to "All packets with q constructs"

    If the packet entered the server from an UDP port:
    {
        Append ,qAU,SERVERLOGIN
        Quit q processing
    }

    If the packet entered the server from an unverified connection and has been converted to TCPXX format (per current validation algorithm):
    {
        (All packets not deemed "OK" from an unverified connection should never make it here.)
        Append ,qAX,FROMCALL
        Skip to "All packets with q constructs"
    }

    If packet entered the server from a verified connection:
    {
        If header is terminated with ,I:
        {
            If the VIACALL preceding the ,I matches the login:

                Change from ,VIACALL,I to ,qAR,VIACALL
            Else
                Change from ,VIACALL,I to ,qAr,VIACALL
        }
        Else If the FROMCALL matches the login:
            Append ,qAC,FROMCALL
        Else
            Append ,qAS,login
        Skip to "All packets with q constructs"
    }

    If packet entered the server from an outbound connection (to another server's port 1313, for instance):
    {
        If header is terminated with ,I:
            Change from ,VIACALL,I to ,qAr,VIACALL
        
Else
            Append ,qAS,IPADDR (IPADDR is an 8 character hex representation of the IP address of the remote server)
    }
}

All packets with q constructs:
{
    if ,qAZ, is the q construct:
    {
        Dump to the packet to the reject log
        Quit processing the packet
    }

    If ,SERVERLOGIN or IGATECALL is found after the q construct:
    {

        Dump to the loop log with the sender's IP address for identification
        Quit processing the packet
    }

    If the packet is from a verified port and the login is found after the q construct but is not the LAST VIACALL:
    {
        Dump to the loop log with the sender's IP address for identification
        Quit processing the packet
    }

    If trace is on, the q construct is qAI, or the FROMCALL is on the server's trace list:
    {
        If the packet is from a verified port where the login is not found after the q construct:
            Append ,login
        Append ,SERVERLOGIN
    }
}