Beispiel #1
0
int main(int argc, char *argv[]) {
	if (argc != 2) return 0;

	sscanf(argv[1], "%d", &pid);

	printf("attaching\n");
	proctrace(PTRACE_ATTACH, pid, NULL, NULL);
	printf("waiting for child to stop\n");
	proctrace_wait(-1, NULL, 0, NULL);
	print_signal();
	printf("waited. child should be stopped\n");
	proctrace(PTRACE_SYSCALL, pid, NULL, NULL);
	proctrace(PTRACE_CONT, pid, NULL, NULL);
	printf("waiting for the system call\n");
	proctrace_wait(-1, NULL, 0, NULL);
	print_signal();
	printf("child did it's thing. continuing and waiting for child to quit...\n");

	long sc = proctrace(PTRACE_PEEKUSER, pid, (void*) (4 * ORIG_EAX), NULL);
	printf("not minus 1: %ld\n", sc);

	proctrace(PTRACE_CONT, pid, NULL, NULL);
	proctrace_wait(-1, NULL, 0, NULL);

	return 0;
}
Beispiel #2
0
static void print_info(const struct iwinfo_ops *iw, const char *ifname)
{
	printf("%-9s ESSID: %s\n",
		ifname,
		print_ssid(iw, ifname));
	printf("          Access Point: %s\n",
		print_bssid(iw, ifname));
	printf("          Type: %s  HW Mode(s): %s\n",
		print_type(iw, ifname),
		print_hwmodes(iw, ifname));
	printf("          Mode: %s  Channel: %s (%s)\n",
		print_mode(iw, ifname),
		print_channel(iw, ifname),
		print_frequency(iw, ifname));
	printf("          Tx-Power: %s  Link Quality: %s/%s\n",
		print_txpower(iw, ifname),
		print_quality(iw, ifname),
		print_quality_max(iw, ifname));
	printf("          Signal: %s  Noise: %s\n",
		print_signal(iw, ifname),
		print_noise(iw, ifname));
	printf("          Bit Rate: %s\n",
		print_rate(iw, ifname));
	printf("          Encryption: %s\n",
		print_encryption(iw, ifname));
	printf("          Supports VAPs: %s\n",
		print_mbssid_supp(iw, ifname));
}
Beispiel #3
0
int		print_hub(t_taupe *taupe)
{
  wclear(taupe->top->win);
  print_sys(taupe->sys, taupe->top);
  print_task(taupe->task, taupe->top);
  print_cpu(taupe->cpu, taupe->top);
  print_mem(taupe->mem, taupe->top);
  if (taupe->signal->on)
    {
      print_opt(taupe->signal, "Send Signal");
      print_signal(taupe->signal, taupe->pid);
    }
  else if (taupe->sort->on)
    print_opt(taupe->sort, "Sort By");
  print_main(taupe);
  return (0);
}
Beispiel #4
0
void forward_signal(system_state *state, entity from, entity to, signal signal) {
  
  print_signal(from, to, signal);
  
  switch(to.type) {
  case ENTITY_SWITCH:
#if PART!=2
    switch_process_signal(state, to.switch_number, from, signal);
#endif
    break;
  case ENTITY_ROOT:
#if PART!=1
    root_process_signal(state, from, signal);
#endif
    break;
  case ENTITY_PHONE: default:
    // do nothing
    break;
  }
}
Beispiel #5
0
void	handle_exit(int *status)
{
  if (WIFEXITED(*status) || WIFSIGNALED(*status))
    {
      (void)printf(" was returned by tracee");
      (void)system("echo -n $?");
      (void)printf("\n");
      exit(EXIT_SUCCESS);
    }
  if (!(WIFSTOPPED(*status)
	&& (WSTOPSIG(*status) == SIGSEGV || WSTOPSIG(*status) == SIGTERM
	    || WSTOPSIG(*status) == SIGINT || WSTOPSIG(*status) == SIGKILL
	    || WSTOPSIG(*status) == SIGPIPE || WSTOPSIG(*status) == SIGQUIT
	    || WSTOPSIG(*status) == SIGFPE || WSTOPSIG(*status) == SIGBUS
	    || WSTOPSIG(*status) == SIGSYS || WSTOPSIG(*status) == SIGSTKFLT
	    || WSTOPSIG(*status) == SIGUSR1 || WSTOPSIG(*status) == SIGUSR2
	    || WSTOPSIG(*status) == SIGABRT)))
    return ;
  fprintf(stderr, "tracee was terminated by default action of signal ");
  print_signal(status);
  exit(EXIT_SUCCESS);
}
Beispiel #6
0
/**
 * OpenVPN's main init-run-cleanup loop.
 * @ingroup eventloop
 * 
 * This function contains the two outer OpenVPN loops.  Its structure is
 * as follows:
 *  - Once-per-process initialization.
 *  - Outer loop, run at startup and then once per \c SIGHUP:
 *    - Level 1 initialization
 *    - Inner loop, run at startup and then once per \c SIGUSR1:
 *      - Call event loop function depending on client or server mode:
 *        - \c tunnel_point_to_point()
 *        - \c tunnel_server()
 *    - Level 1 cleanup
 *  - Once-per-process cleanup.
 * 
 * @param argc - Commandline argument count.
 * @param argv - Commandline argument values.
 */
int
main (int argc, char *argv[])
{
  struct context c;

#if PEDANTIC
  fprintf (stderr, "Sorry, I was built with --enable-pedantic and I am incapable of doing any real work!\n");
  return 1;
#endif

  CLEAR (c);

  /* signify first time for components which can
     only be initialized once per program instantiation. */
  c.first_time = true;

  /* initialize program-wide statics */
  if (init_static ())
    {
      /*
       * This loop is initially executed on startup and then
       * once per SIGHUP.
       */
      do
	{
	  /* enter pre-initialization mode with regard to signal handling */
	  pre_init_signal_catch ();

	  /* zero context struct but leave first_time member alone */
	  context_clear_all_except_first_time (&c);

	  /* static signal info object */
	  CLEAR (siginfo_static);
	  c.sig = &siginfo_static;

	  /* initialize garbage collector scoped to context object */
	  gc_init (&c.gc);

	  /* initialize environmental variable store */
	  c.es = env_set_create (NULL);
#ifdef WIN32
	  env_set_add_win32 (c.es);
#endif

#ifdef ENABLE_MANAGEMENT
	  /* initialize management subsystem */
	  init_management (&c);
#endif

	  /* initialize options to default state */
	  init_options (&c.options, true);

	  /* parse command line options, and read configuration file */
	  parse_argv (&c.options, argc, argv, M_USAGE, OPT_P_DEFAULT, NULL, c.es);

#ifdef ENABLE_PLUGIN
	  /* plugins may contribute options configuration */
	  init_verb_mute (&c, IVM_LEVEL_1);
	  init_plugins (&c);
	  open_plugins (&c, true, OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE);
#endif

	  /* init verbosity and mute levels */
	  init_verb_mute (&c, IVM_LEVEL_1);

	  /* set dev options */
	  init_options_dev (&c.options);

	  /* openssl print info? */
	  if (print_openssl_info (&c.options))
	    break;

	  /* --genkey mode? */
	  if (do_genkey (&c.options))
	    break;

	  /* tun/tap persist command? */
	  if (do_persist_tuntap (&c.options))
	    break;

	  /* sanity check on options */
	  options_postprocess (&c.options);

	  /* show all option settings */
	  show_settings (&c.options);

	  /* print version number */
	  msg (M_INFO, "%s", title_string);

	  /* misc stuff */
	  pre_setup (&c.options);

	  /* test crypto? */
	  if (do_test_crypto (&c.options))
	    break;
	  
#ifdef ENABLE_MANAGEMENT
	  /* open management subsystem */
	  if (!open_management (&c))
	    break;
#endif

	  /* set certain options as environmental variables */
	  setenv_settings (c.es, &c.options);

	  /* finish context init */
	  context_init_1 (&c);

	  do
	    {
	      /* run tunnel depending on mode */
	      switch (c.options.mode)
		{
		case MODE_POINT_TO_POINT:
		  tunnel_point_to_point (&c);
		  break;
#if P2MP_SERVER
		case MODE_SERVER:
		  tunnel_server (&c);
		  break;
#endif
		default:
		  ASSERT (0);
		}

	      /* indicates first iteration -- has program-wide scope */
	      c.first_time = false;

	      /* any signals received? */
	      if (IS_SIG (&c))
		print_signal (c.sig, NULL, M_INFO);

	      /* pass restart status to management subsystem */
	      signal_restart_status (c.sig);
	    }
	  while (c.sig->signal_received == SIGUSR1);

	  uninit_options (&c.options);
	  gc_reset (&c.gc);
	}
      while (c.sig->signal_received == SIGHUP);
    }

  context_gc_free (&c);

  env_set_destroy (c.es);

#ifdef ENABLE_MANAGEMENT
  /* close management interface */
  close_management ();
#endif

  /* uninitialize program-wide statics */
  uninit_static ();

  openvpn_exit (OPENVPN_EXIT_STATUS_GOOD);  /* exit point */
  return 0;			            /* NOTREACHED */
}
Beispiel #7
0
/**@ingroup plp_sink
 * Prints or displays the signal according to the selected mode.
 */
int work(void **inp, void **out) {
	int n,i,j;
	int mode;
	float *r_input;
	_Complex float *c_input;
	dft_plan_t *plan;

	strdef(xlabel);

	if (mode_id != NULL) {
		if (param_get_int(mode_id,&mode) != 1) {
			mode = 0;
		}
	} else {
		mode = 0;
	}
	memset(signal_lengths,0,sizeof(int)*2*NOF_INPUT_ITF);
	for (n=0;n<NOF_INPUT_ITF;n++) {
		if (is_complex && mode != MODE_PSD) {
			signal_lengths[2*n] = get_input_samples(n)/2;
			signal_lengths[2*n+1] = signal_lengths[2*n];
		} else {
			signal_lengths[n] = get_input_samples(n);
		}
		if (get_input_samples(n) != last_rcv_samples) {
			last_rcv_samples = get_input_samples(n);
#ifdef _COMPILE_ALOE
			modinfo_msg("Receiving %d samples at tslot %d\n",last_rcv_samples,
					oesr_tstamp(ctx));
#endif
		}
	}

#ifdef _COMPILE_ALOE
	if (print_not_received) {
		for (n=0;n<NOF_INPUT_ITF;n++) {
			if (MOD_DEBUG) {
				ainfo_msg("ts=%d, rcv_len=%d\n",oesr_tstamp(ctx),get_input_samples(n));
			}
			if (!get_input_samples(n)) {
				printf("ts=%d. Data not received from interface %d\n",oesr_tstamp(ctx),n);
			}

		}
	}
#endif


#ifdef _COMPILE_ALOE
	if (oesr_tstamp(ctx)-last_tstamp < interval_ts) {
		return 0;
	}
	last_tstamp = interval_ts;
#endif


	switch(mode) {
	case MODE_SILENT:
		break;
	case MODE_PRINT:
		for (n=0;n<NOF_INPUT_ITF;n++) {
			if (inp[n]) {
				print_signal(inp[n],get_input_samples(n));
			}
		}
	break;
	case MODE_SCOPE:
#ifdef _COMPILE_ALOE
		snprintf(xlabel,STR_LEN,"# sample (ts=%d)",oesr_tstamp(ctx));
#else
		snprintf(xlabel,STR_LEN,"# sample");
#endif
		if (is_complex) {
			set_legend(c_legends,2*NOF_INPUT_ITF);
		} else {
			set_legend(r_legends,NOF_INPUT_ITF);
		}
		set_labels(xlabel,"amp");

		for (n=0;n<NOF_INPUT_ITF;n++) {
			if (inp[n]) {
				if (is_complex) {
					c_input = inp[n];
					for (i=0;i<signal_lengths[2*n];i++) {
						pl_signals[2*n*INPUT_MAX_SAMPLES+i] = (double) __real__ c_input[i];
						pl_signals[(2*n+1)*INPUT_MAX_SAMPLES+i] = (double) __imag__ c_input[i];
					}
				} else {
					r_input = inp[n];
					for (i=0;i<signal_lengths[n];i++) {
						pl_signals[n*INPUT_MAX_SAMPLES+i] = (double) r_input[i];
					}
				}
			}

		}

		plp_draw(pl_signals,signal_lengths,0);
	break;
	case MODE_PSD:
#ifdef _COMPILE_ALOE
		snprintf(xlabel,STR_LEN,"freq. idx (ts=%d)",oesr_tstamp(ctx));
#else
		snprintf(xlabel,STR_LEN,"freq. idx");
#endif

		set_labels(xlabel,"PSD (dB/Hz)");

		set_legend(fft_legends,NOF_INPUT_ITF);

		for (i=0;i<NOF_INPUT_ITF;i++) {
			if (signal_lengths[i]) {
				if (fft_size) {
					signal_lengths[i] = signal_lengths[i]>fft_size?fft_size:signal_lengths[i];
				}
				plan = find_plan(signal_lengths[i]);
				c_input = inp[i];
				r_input = inp[i];
				if (!plan) {
					if ((plan = generate_new_plan(signal_lengths[i])) == NULL) {
						moderror("Generating plan.\n");
						return -1;
					}
				}
				if (is_complex) {
					dft_run_c2r(plan, c_input, &f_pl_signals[i*INPUT_MAX_SAMPLES]);
				} else {
					dft_run_r2r(plan, r_input, &f_pl_signals[i*INPUT_MAX_SAMPLES]);
				}
				/*if (!is_complex) {
					signal_lengths[i] = signal_lengths[i]/2;
				}*/
				for (j=0;j<signal_lengths[i];j++) {
					pl_signals[i*INPUT_MAX_SAMPLES+j] = (double) f_pl_signals[i*INPUT_MAX_SAMPLES+j];
				}
			}
		}
		for (i=NOF_INPUT_ITF;i<2*NOF_INPUT_ITF;i++) {
			signal_lengths[i] = 0;
		}
		plp_draw(pl_signals,signal_lengths,0);

	break;
	default:
		moderror_msg("Unknown mode %d\n",mode);
		return -1;

	}
	return 0;
}