Example #1
0
/* capture child tells us we have new packets to read */
void
capture_input_new_packets(capture_session *cap_session, int to_read)
{
  capture_options *capture_opts = cap_session->capture_opts;
  int  err;

  g_assert(capture_opts->save_file);

  if(capture_opts->real_time_mode) {
    /* Read from the capture file the number of records the child told us it added. */
    switch (cf_continue_tail((capture_file *)cap_session->cf, to_read, &err)) {

    case CF_READ_OK:
    case CF_READ_ERROR:
      /* Just because we got an error, that doesn't mean we were unable
         to read any of the file; we handle what we could get from the
         file.

         XXX - abort on a read error? */
         capture_callback_invoke(capture_cb_capture_update_continue, cap_session);
      break;

    case CF_READ_ABORTED:
      /* Kill the child capture process; the user wants to exit, and we
         shouldn't just leave it running. */
      capture_kill_child(cap_session);
      break;
    }
  } else {
    /* increase the capture file packet counter by the number of incoming packets */
    cf_set_packet_count((capture_file *)cap_session->cf,
        cf_get_packet_count((capture_file *)cap_session->cf) + to_read);
    cf_fake_continue_tail((capture_file *)cap_session->cf);

    capture_callback_invoke(capture_cb_capture_fixed_continue, cap_session);
  }

  /* update the main window so we get events (e.g. from the stop toolbar button) */
  /* This causes a hang on Windows (see bug 7305). Do we need this on any platform? */
#ifndef _WIN32
  main_window_update();
#endif

  if(capture_opts->show_info)
    capture_info_new_packets(to_read);
}
Example #2
0
static void tick_handler(struct tm *time_now, TimeUnits changed) {
  main_window_update(time_now->tm_hour, time_now->tm_min);
}