Exemple #1
0
/* Write out a formatted representation of the given tcp_info buffer. */
static void write_tcp_info(struct code_state *code,
				   const struct _tcp_info *info,
				   int len)
{
	assert(len >= sizeof(struct _tcp_info));

	write_symbols(code);

	/* Emit the recorded values of tcpi_foo values. */
	emit_var(code, "tcpi_state",		info->tcpi_state);
	emit_var(code, "tcpi_options",		info->tcpi_options);
	emit_var(code, "tcpi_snd_wscale",	info->tcpi_snd_wscale);
	emit_var(code, "tcpi_rcv_wscale",	info->tcpi_rcv_wscale);
	emit_var(code, "tcpi_rto",		info->tcpi_rto);
	emit_var(code, "tcpi_snd_mss",		info->tcpi_snd_mss);
	emit_var(code, "tcpi_rcv_mss",		info->tcpi_rcv_mss);
	emit_var(code, "tcpi_last_data_recv",	info->tcpi_last_data_recv);
	emit_var(code, "tcpi_rtt",		info->tcpi_rtt);
	emit_var(code, "tcpi_rttvar",		info->tcpi_rttvar);
	emit_var(code, "tcpi_snd_ssthresh",	info->tcpi_snd_ssthresh);
	emit_var(code, "tcpi_snd_cwnd",		info->tcpi_snd_cwnd);
	emit_var(code, "tcpi_rcv_space",	info->tcpi_rcv_space);

	/* FreeBSD extensions to tcp_info. */
	emit_var(code, "tcpi_snd_wnd",		info->tcpi_snd_wnd);
	emit_var(code, "tcpi_snd_bwnd",		info->tcpi_snd_bwnd);
	emit_var(code, "tcpi_snd_nxt",		info->tcpi_snd_nxt);
	emit_var(code, "tcpi_rcv_nxt",		info->tcpi_rcv_nxt);
	emit_var(code, "tcpi_toe_tid",		info->tcpi_toe_tid);
	emit_var(code, "tcpi_snd_rexmitpack",	info->tcpi_snd_rexmitpack);
	emit_var(code, "tcpi_rcv_ooopack",	info->tcpi_rcv_ooopack);
	emit_var(code, "tcpi_snd_zerowin",	info->tcpi_snd_zerowin);

	emit_var_end(code);
}
Exemple #2
0
 std::string get_symbols(void *const *ptrs,int size)
 {
     if(!ptrs)
         return std::string();
     std::ostringstream res;
     res.imbue(std::locale::classic());
     write_symbols(ptrs,size,res);
     return res.str();
 }
Exemple #3
0
/* Write out a formatted representation of the given tcp_info buffer. */
static void write_tcp_info(struct code_state *code,
				   const struct _tcp_info *info,
				   int len)
{
	assert(len >= sizeof(struct _tcp_info));

	write_symbols(code);

	/* Emit the recorded values of tcpi_foo values. */
	emit_var(code, "tcpi_state",		info->tcpi_state);
	emit_var(code, "tcpi_ca_state",		info->tcpi_ca_state);
	emit_var(code, "tcpi_retransmits",	info->tcpi_retransmits);
	emit_var(code, "tcpi_probes",		info->tcpi_probes);
	emit_var(code, "tcpi_backoff",		info->tcpi_backoff);
	emit_var(code, "tcpi_options",		info->tcpi_options);
	emit_var(code, "tcpi_snd_wscale",	info->tcpi_snd_wscale);
	emit_var(code, "tcpi_rcv_wscale",	info->tcpi_rcv_wscale);
	emit_var(code, "tcpi_rto",		info->tcpi_rto);
	emit_var(code, "tcpi_ato",		info->tcpi_ato);
	emit_var(code, "tcpi_snd_mss",		info->tcpi_snd_mss);
	emit_var(code, "tcpi_rcv_mss",		info->tcpi_rcv_mss);
	emit_var(code, "tcpi_unacked",		info->tcpi_unacked);
	emit_var(code, "tcpi_sacked",		info->tcpi_sacked);
	emit_var(code, "tcpi_lost",		info->tcpi_lost);
	emit_var(code, "tcpi_retrans",		info->tcpi_retrans);
	emit_var(code, "tcpi_fackets",		info->tcpi_fackets);
	emit_var(code, "tcpi_last_data_sent",	info->tcpi_last_data_sent);
	emit_var(code, "tcpi_last_ack_sent",	info->tcpi_last_ack_sent);
	emit_var(code, "tcpi_last_data_recv",	info->tcpi_last_data_recv);
	emit_var(code, "tcpi_last_ack_recv",	info->tcpi_last_ack_recv);
	emit_var(code, "tcpi_pmtu",		info->tcpi_pmtu);
	emit_var(code, "tcpi_rcv_ssthresh",	info->tcpi_rcv_ssthresh);
	emit_var(code, "tcpi_rtt",		info->tcpi_rtt);
	emit_var(code, "tcpi_rttvar",		info->tcpi_rttvar);
	emit_var(code, "tcpi_snd_ssthresh",	info->tcpi_snd_ssthresh);
	emit_var(code, "tcpi_snd_cwnd",		info->tcpi_snd_cwnd);
	emit_var(code, "tcpi_advmss",		info->tcpi_advmss);
	emit_var(code, "tcpi_reordering",	info->tcpi_reordering);
	emit_var(code, "tcpi_total_retrans",	info->tcpi_total_retrans);

	emit_var(code, "tcpi_rcv_rtt",		info->tcpi_rcv_rtt);
	emit_var(code, "tcpi_rcv_space",	info->tcpi_rcv_space);

	emit_var_end(code);
}
Exemple #4
0
 std::string get_symbols(void *const *ptrs,int size)
 {
     std::ostringstream ss;
     write_symbols(ptrs,size,ss);
     return ss.str();
 }
Exemple #5
0
int main(int argc,char **argv)
{
    int binary = 0,hex = 0;
    const char *output = NULL;
    const char *symbols = NULL;
    const char *flash_security = NULL;
    int c,i;

    error_init();
    id_init();
    code_init();
    cpp_option = alloc_type_n(char *,argc*2);
    while ((c = getopt(argc,argv,"bef:hD:I:m:o:U:V")) != EOF) {
	char opt[] = "-?";

    	switch (c) {

	    case 'b':
		binary = 1;
		break;
	    case 'e':
		allow_extensions = 1;
		break;
	    case 'f':
		if (flash_security)
		    usage(*argv);
		flash_security = optarg;
		break;
	    case 'h':
		hex = 1;
		break;
	    case 'o':
		if (output)
		    usage(*argv);
		output = optarg;
		break;
	    case 'm':
		symbols = optarg;
		break;
	    case 'D':
	    case 'I':
	    case 'U':
		opt[1] = c;
		cpp_option[cpp_options*2] = stralloc(opt);
		cpp_option[cpp_options*2+1] = stralloc(optarg);
		cpp_options++;
		break;
	    case 'V':
		printf("m8cas from m8cutils version %s\n",VERSION);
		exit(0);
	    default:
		usage(*argv);
	}
    }
    if (binary && hex)
	usage(*argv);

    if (cpp_options && !allow_extensions) {
	fprintf(stderr,"CPP options are only supported if using CPP (-e)\n");
	return 1;
    }

    read_protection(flash_security);

    /* move stdin to a safe place, because we may open other files before */
    fd0 = dup(0);
    if (fd0 < 0) {
	perror("dup");
	exit(1);
    }
    (void) close(0);

    if (optind == argc)
	do_file(NULL);
    else {
	for (i = optind; i != argc; i++)
	    do_file(argv[i]);
    }

    resolve();
    if (symbols)
	write_symbols(symbols);
    program_size = text->highest_pc;
    id_cleanup();
    code_cleanup();
    error_cleanup();
    if (!hex)
	for (i = 0; i != security_size; i++)
	    if (security[i]) {
		fprintf(stderr,
		  "output must be Intel HEX for non-zero flash protection\n");
		exit(1);
	    }
    write_file(output ? output : "-",binary,hex);
    return 0;
}