コード例 #1
0
bool ResultResponse::decode_prepared(int version, char* input) {
  char* buffer = decode_string(input, &prepared_);
  buffer = decode_metadata(buffer, &metadata_, version >= 4);
  if (version > 1) {
    decode_metadata(buffer, &result_metadata_);
  }
  return true;
}
コード例 #2
0
ファイル: ocmirror.c プロジェクト: safchain/ocmirror
void
forward (int usock, int fsock, const struct sockaddr_ll *fout, int verbose)
{
  struct pcap_metadata metadata;
  struct sockaddr_in uin;
  char pkt[UDP_PKT_SIZE], *ptr;
  unsigned int len;
  int r;

  for (;;) {
    len = sizeof (struct sockaddr_in);
    r = recvfrom (usock, pkt, UDP_PKT_SIZE, 0,
                  (struct sockaddr *) &uin, &len);
    if (r <= 0) {
      fprintf (stderr, "Error while reading the UDP socket: %s\n",
               strerror (errno));
      exit (-1);
    }

    ptr = decode_metadata (pkt, r, &metadata);
    if (ptr == NULL) {
      fprintf (stderr, "Arf\n");
      continue;
    }

    len = r - (ptr - pkt);
    if (verbose) {
      print_capture (&metadata, ptr, len, verbose);
    }

    if (fsock) {
      sendto (fsock, ptr, len, 0, (struct sockaddr *) fout,
              sizeof (struct sockaddr_ll));
    }
  }
}
コード例 #3
0
bool ResultResponse::decode_rows(char* input) {
  char* buffer = decode_metadata(input, &metadata_);
  rows_ = decode_int32(buffer, row_count_);
  decode_first_row();
  return true;
}