Re: P25 North America reflector


Steve N4IRS
 

Updated patch.

void CP25Network::clock(unsigned int ms)
{
    unsigned char buffer[BUFFER_LENGTH];

    sockaddr_storage address;
    unsigned int addrLen;
    int length = m_socket.read(buffer, BUFFER_LENGTH, address, addrLen);
    if (length <= 0)
        return;

    if (!CUDPSocket::match(m_addr, address)) {
        LogMessage("P25, packet received from an invalid source");
        return;
    }

    if (!m_enabled)
        return;

    if (m_debug)
        CUtils::dump(1U, "P25 Network Data Received", buffer, length);

    while (length > 0) {
        unsigned char addBytes = 0;
        int recSize[] = {22, 14, 17, 17, 17, 17, 17, 17, 16, 22, 14, 17, 17, 17, 17, 17, 17, 16};
        unsigned char recType = buffer[0];
        if ((recType >= 0x62) && (recType <= 0x73))
            addBytes = recSize[recType - 0x62];
        else if (recType == 0x80)
            addBytes = 17;
        else {
            if (recType != 0xF0)   // its a poll, don't say anything
                LogMessage("Got a network byte I did not expect %0X, %d", buffer[0], length);
            addBytes = 0;
            length = 0; // Don't add it and don't continue
        }
        if ((addBytes > 0) && (addBytes <= length)) {
            m_buffer.addData(&addBytes, 1U);
            m_buffer.addData(buffer, addBytes);
        }
        length -= addBytes;
    }
}


On 9/18/21 10:29 AM, Miguel wrote:

ah ok. Thanks. That is helpful. (was writing my other response before seeing yours)

Don't want to change a lot of variables so will see if I can compile and replace in one of the hotspots.

thx


Join main@DVSwitch.groups.io to automatically receive all group messages.