コード例 #1
0
ファイル: debug.c プロジェクト: GYGit/oneteam
void nice_debug_init ()
{
  const gchar *flags_string;
  guint flags;

  flags_string = g_getenv ("NICE_DEBUG");

  nice_debug_disable (TRUE);

  if (flags_string != NULL) {
    flags = g_parse_debug_string (flags_string, keys,  4);

    if (flags & NICE_DEBUG_NICE)
      nice_debug_enable (FALSE);
    if (flags & NICE_DEBUG_STUN)
      stun_debug_enable ();

    /* Set verbose before normal so that if we use 'all', then only
       normal debug is enabled, we'd need to set pseudotcp-verbose without the
       pseudotcp flag in order to actually enable verbose pseudotcp */
    if (flags & NICE_DEBUG_PSEUDOTCP_VERBOSE)
      pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);
    if (flags & NICE_DEBUG_PSEUDOTCP)
      pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_NORMAL);

  }
}
コード例 #2
0
ファイル: debug.c プロジェクト: AlertMe/libnice
void nice_debug_init (void)
{
  static gboolean debug_initialized = FALSE;
  const gchar *flags_string;
  const gchar *gflags_string;
  guint flags = 0;

  if (!debug_initialized) {
    debug_initialized = TRUE;

    flags_string = g_getenv ("NICE_DEBUG");
    gflags_string = g_getenv ("G_MESSAGES_DEBUG");

    if (flags_string)
      flags = g_parse_debug_string (flags_string, keys,  4);
    if (gflags_string && strstr (gflags_string, "libnice-pseudotcp-verbose"))
      flags |= NICE_DEBUG_PSEUDOTCP_VERBOSE;

    stun_set_debug_handler (stun_handler);
    nice_debug_enable (TRUE);

    /* Set verbose before normal so that if we use 'all', then only
       normal debug is enabled, we'd need to set pseudotcp-verbose without the
       pseudotcp flag in order to actually enable verbose pseudotcp */
    if (flags & NICE_DEBUG_PSEUDOTCP_VERBOSE)
      pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);
    else
      pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_NORMAL);
  }
}
コード例 #3
0
int main (int argc, char *argv[])
{
  PseudoTcpCallbacks cbs = {
    NULL, opened, readable, writable, closed, write_packet
  };

  setlocale (LC_ALL, "");

  mainloop = g_main_loop_new (NULL, FALSE);

  g_type_init ();

  pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);

  left_closed = right_closed = FALSE;

  left = pseudo_tcp_socket_new (0, &cbs);
  right = pseudo_tcp_socket_new (0, &cbs);
  g_debug ("Left: %p. Right: %p", left, right);

  pseudo_tcp_socket_notify_mtu (left, 1496);
  pseudo_tcp_socket_notify_mtu (right, 1496);

  pseudo_tcp_socket_connect (left);
  adjust_clock (left);
  adjust_clock (right);

  if (argc == 3) {
    in = fopen (argv[1], "r");
    out = fopen (argv[2], "w");
  }

  g_main_loop_run (mainloop);

  g_object_unref (left);
  g_object_unref (right);

  if (in)
    fclose (in);
  if (out)
    fclose (out);

  return 0;
}
コード例 #4
0
int main (int argc, char *argv[])
{
  PseudoTcpCallbacks cbs = {
    NULL, opened, readable, writable, closed, write_packet
  };
  GOptionContext *context;
  GError *error = NULL;

  setlocale (LC_ALL, "");
  g_type_init ();

  /* Configuration. */
  context = g_option_context_new ("— fuzz-test the pseudotcp socket");
  g_option_context_add_main_entries (context, entries, NULL);

  if (!g_option_context_parse (context, &argc, &argv, &error)) {
    g_printerr ("Option parsing failed: %s\n", error->message);
    goto context_error;
  }

  if (n_changes_lambda == 0) {
    g_printerr ("Option parsing failed: %s\n",
        "Lambda values must be positive.");
    goto context_error;
  }

  g_option_context_free (context);

  /* Tweak the configuration. */
  if (seed == 0) {
    seed = g_get_real_time ();
  }

  /* Open the input and output files */
  if (argc >= 3) {
    in = fopen (argv[1], "r");
    out = fopen (argv[2], "w");
  }

  /* Set up the main loop and sockets. */
  main_loop = g_main_loop_new (NULL, FALSE);

  g_print ("Using seed: %" G_GINT64_FORMAT ", start position: %u, λ: %u\n",
      seed, fuzz_start_pos, n_changes_lambda);
  prng = g_rand_new_with_seed (seed);

  pseudo_tcp_set_debug_level (PSEUDO_TCP_DEBUG_VERBOSE);

  left = pseudo_tcp_socket_new (0, &cbs);
  right = pseudo_tcp_socket_new (0, &cbs);
  g_debug ("Left: %p. Right: %p", left, right);

  pseudo_tcp_socket_notify_mtu (left, 1496);
  pseudo_tcp_socket_notify_mtu (right, 1496);

  pseudo_tcp_socket_connect (left);
  adjust_clock (left);
  adjust_clock (right);

  /* Run the main loop. */
  g_main_loop_run (main_loop);
  g_main_loop_unref (main_loop);

  g_object_unref (left);
  g_object_unref (right);

  g_rand_free (prng);

  if (in != NULL)
    fclose (in);
  if (out != NULL)
    fclose (out);

  return retval;

context_error:
  g_printerr ("\n%s\n", g_option_context_get_help (context, TRUE, NULL));
  g_option_context_free (context);

  return 1;
}