Пример #1
0
void icaoFilterAdd(uint32_t addr)
{
    uint32_t h, h0;
    h0 = h = icaoHash(addr);
    while (icao_filter_active[h] && icao_filter_active[h] != addr) {
        h = (h+1) & (ICAO_FILTER_SIZE-1);
        if (h == h0) {
            FPRINTF(stderr, "ICAO hash table full, increase ICAO_FILTER_SIZE\n");
            return;
        }
    }
    if (!icao_filter_active[h])
        icao_filter_active[h] = addr;

    // also add with a zeroed top byte, for handling DF20/21 with Data Parity
    h0 = h = icaoHash(addr & 0x00ffff);
    while (icao_filter_active[h] && (icao_filter_active[h] & 0x00ffff) != (addr & 0x00ffff)) {
        h = (h+1) & (ICAO_FILTER_SIZE-1);
        if (h == h0) {
            FPRINTF(stderr, "ICAO hash table full, increase ICAO_FILTER_SIZE\n");
            return;
        }
    }
    if (!icao_filter_active[h])
        icao_filter_active[h] = addr;
}
Пример #2
0
void icaoFilterAdd(uint32_t addr)
{
    uint32_t h = icaoHash(addr);
    while (icao_filter_active[h] && icao_filter_active[h] != addr)
        h = (h+1) & (ICAO_FILTER_SIZE-1);
    if (!icao_filter_active[h])
        icao_filter_active[h] = addr;

    // also add with a zeroed top byte, for handling DF20/21 with Data Parity
    h = icaoHash(addr & 0x00ffff);
    while (icao_filter_active[h] && (icao_filter_active[h] & 0x00ffff) != (addr & 0x00ffff))
        h = (h+1) & (ICAO_FILTER_SIZE-1);
    if (!icao_filter_active[h])
        icao_filter_active[h] = addr;
}
Пример #3
0
uint32_t icaoFilterTestFuzzy(uint32_t partial)
{
    uint32_t h, h0;

    partial &= 0x00ffff;
    h0 = h = icaoHash(partial);
    while (icao_filter_a[h] && (icao_filter_a[h] & 0x00ffff) != partial) {
        h = (h+1) & (ICAO_FILTER_SIZE-1);
        if (h == h0)
            break;
    }
    if ((icao_filter_a[h] & 0x00ffff) == partial)
        return icao_filter_a[h];

    h = h0;
    while (icao_filter_b[h] && (icao_filter_b[h] & 0x00ffff) != partial) {
        h = (h+1) & (ICAO_FILTER_SIZE-1);
        if (h == h0)
            break;
    }
    if ((icao_filter_b[h] & 0x00ffff) == partial)
        return icao_filter_b[h];

    return 0;
}
Пример #4
0
int icaoFilterTest(uint32_t addr)
{
    uint32_t h, h0;

    h0 = h = icaoHash(addr);
    while (icao_filter_a[h] && icao_filter_a[h] != addr)
        h = (h+1) & (ICAO_FILTER_SIZE-1);
    if (icao_filter_a[h])
        return 1;

    h = h0;
    while (icao_filter_b[h] && icao_filter_b[h] != addr)
        h = (h+1) & (ICAO_FILTER_SIZE-1);
    if (icao_filter_b[h])
        return 1;

    return 0;
}