Exemple #1
0
int pring_test(ppring_t *pring, int spot_numbers[], char* license_numbers)
{
  if (pring && spot_numbers && license_numbers)
  {
    int i, res;
    for (i = 0; i < pring->num_permits; ++i)
    {
      res = permit_test(&pring->permits[i], spot_numbers[i], &license_numbers[i * 10]);
      if (res != PRES_OK)
        return res;
    }
    return PRES_OK;
  }
  return PRES_ERROR;
}
Exemple #2
0
void handle_test_permit(char *buf, int buf_len)
{
  if (buf_len >= MASTER_KEY_LEN + sizeof(ppermit_t) + 2 * sizeof(int))
  {
    if (g_auth && memcmp(g_session_key, buf, MASTER_KEY_LEN) == 0)
    {
      if (permit_test((ppermit_t *)&buf[MASTER_KEY_LEN], *(int *)&buf[MASTER_KEY_LEN + sizeof(ppermit_t)], &buf[MASTER_KEY_LEN + sizeof(ppermit_t) + sizeof(int)]) == PRES_OK)
      {
        _send_response(RES_OK, NULL, 0);
        g_auth--;
        return;
      }
    }
  }
  _send_response(RES_ERROR, NULL, 0);
}
Exemple #3
0
void handle_new_permit_ring(char *buf, int buf_len)
{
  int i, c, count;
  char key[16];
  ppring_t pring;
  if (buf_len >= MASTER_KEY_LEN + sizeof(ppring_t))
  {
    cgc_memset(&pring, 0, sizeof(ppring_t));
    cgc_memcpy(key, g_session_key, MASTER_KEY_LEN);
    if (g_auth && memcmp(key, buf, MASTER_KEY_LEN) == 0)
    {
      count = *(int *)&buf[MASTER_KEY_LEN];
      if (count <= MAX_NUM_PERMITS)
      {
#if PATCHED
        for (i = 0; i < count; ++i)
#else
        for (i = 0; i <= count; ++i)
#endif
        {
          if (i == count && buf_len - MASTER_KEY_LEN - sizeof(ppring_t) == 0)
            break;
          c = MASTER_KEY_LEN + sizeof(int) + i * sizeof(ppermit_t);
          if (permit_test((ppermit_t *)&buf[c], *(int *)&buf[c + 22], &buf[c + 8]) == PRES_OK)
          {
            cgc_memcpy(&pring.permits[i], &buf[c], sizeof(ppermit_t));
            pring.num_permits++;
          }
          else
          {
            _send_response(RES_ERROR, NULL, 0);
            return;
          }
        }
        _send_response(RES_OK, (char *)&pring, sizeof(ppring_t));
        g_auth--;
        return;
      }
    }
  }
  _send_response(RES_ERROR, NULL, 0);
}