diff options
author | Bill Meier <wmeier@newsguy.com> | 2014-10-13 15:04:21 -0400 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2014-10-13 19:09:07 +0000 |
commit | 6a9479ecf90ef64f944526354fb26ee876d3ad25 (patch) | |
tree | ff0542670c21c9323020d89002d3a2c64e93a46c /ui/cli/tap-camelsrt.c | |
parent | 63faad686b49e02b86cd1961dd3bc8283f120da8 (diff) |
Add editor modelines and/or adjust whilespace.
Change-Id: I626b7bd8ac6e4b91c57cc9152e7ce038754e7278
Reviewed-on: https://code.wireshark.org/review/4658
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'ui/cli/tap-camelsrt.c')
-rw-r--r-- | ui/cli/tap-camelsrt.c | 191 |
1 files changed, 102 insertions, 89 deletions
diff --git a/ui/cli/tap-camelsrt.c b/ui/cli/tap-camelsrt.c index 6e31d73350..83e6d2b963 100644 --- a/ui/cli/tap-camelsrt.c +++ b/ui/cli/tap-camelsrt.c @@ -57,33 +57,33 @@ struct camelsrt_t { /* Reset the counter */ static void camelsrt_reset(void *phs) { - struct camelsrt_t *hs=(struct camelsrt_t *)phs; - memset(hs,0,sizeof(struct camelsrt_t)); + struct camelsrt_t *hs = (struct camelsrt_t *)phs; + memset(hs, 0, sizeof(struct camelsrt_t)); } static int camelsrt_packet(void *phs, - packet_info *pinfo _U_, - epan_dissect_t *edt _U_, - const void *phi) + packet_info *pinfo _U_, + epan_dissect_t *edt _U_, + const void *phi) { - struct camelsrt_t *hs=(struct camelsrt_t *)phs; - const struct camelsrt_info_t * pi=(const struct camelsrt_info_t *)phi; + struct camelsrt_t *hs = (struct camelsrt_t *)phs; + const struct camelsrt_info_t * pi = (const struct camelsrt_info_t *)phi; int i; for (i=0; i<NB_CAMELSRT_CATEGORY; i++) { if (pi->bool_msginfo[i] && - pi->msginfo[i].is_delta_time - && pi->msginfo[i].request_available - && !pi->msginfo[i].is_duplicate ) { + pi->msginfo[i].is_delta_time + && pi->msginfo[i].request_available + && !pi->msginfo[i].is_duplicate ) { time_stat_update(&(hs->stats[i]), - &(pi->msginfo[i].delta_time), - pinfo); + &(pi->msginfo[i].delta_time), + pinfo); if (hs->count[i] < NUM_RAS_STATS) { - hs->delta_time[i][hs->count[i]++] - = pi->msginfo[i].delta_time; + hs->delta_time[i][hs->count[i]++] + = pi->msginfo[i].delta_time; } } } @@ -93,13 +93,13 @@ static int camelsrt_packet(void *phs, static void camelsrt_draw(void *phs) { - struct camelsrt_t *hs=(struct camelsrt_t *)phs; - guint j,z; + struct camelsrt_t *hs = (struct camelsrt_t *)phs; + guint j, z; guint32 li; - int somme,iteration=0; + int somme, iteration = 0; timestat_t *rtd_temp; - double x,delay,delay_max,delay_min,delta; - double criteria[NB_CRITERIA]={ 5.0, 10.0, 75.0, 90.0, 95.0,99.0,99.90 }; + double x, delay, delay_max, delay_min, delta; + double criteria[NB_CRITERIA] = { 5.0, 10.0, 75.0, 90.0, 95.0, 99.0, 99.90 }; double delay_criteria[NB_CRITERIA]; printf("\n"); @@ -108,33 +108,33 @@ static void camelsrt_draw(void *phs) printf("| Category | Measure | Min SRT | Max SRT | Avg SRT | Min frame | Max frame |\n"); printf("|-------------------------|---------|-----------|-----------|-----------|-----------|-----------|\n"); - j=1; + j = 1; printf("|%24s |%8u |%8.2f s |%8.2f s |%8.2f s |%10u |%10u |\n", - val_to_str(j,camelSRTtype_naming,"Unknown Message 0x%02x"), - hs->stats[j].num, - nstime_to_sec(&(hs->stats[j].min)), - nstime_to_sec(&(hs->stats[j].max)), - get_average(&(hs->stats[j].tot),hs->stats[j].num)/1000.0, - hs->stats[j].min_num, - hs->stats[j].max_num - ); - for(j=2; j<NB_CAMELSRT_CATEGORY; j++) { - if(hs->stats[j].num==0){ + val_to_str(j, camelSRTtype_naming, "Unknown Message 0x%02x"), + hs->stats[j].num, + nstime_to_sec(&(hs->stats[j].min)), + nstime_to_sec(&(hs->stats[j].max)), + get_average(&(hs->stats[j].tot), hs->stats[j].num)/1000.0, + hs->stats[j].min_num, + hs->stats[j].max_num + ); + for (j=2; j<NB_CAMELSRT_CATEGORY; j++) { + if (hs->stats[j].num == 0) { printf("|%24s |%8u |%8.2f ms|%8.2f ms|%8.2f ms|%10u |%10u |\n", - val_to_str(j,camelSRTtype_naming,"Unknown Message 0x%02x"), - 0, 0.0, 0.0, 0.0, 0, 0); + val_to_str(j, camelSRTtype_naming, "Unknown Message 0x%02x"), + 0, 0.0, 0.0, 0.0, 0, 0); continue; } printf("|%24s |%8u |%8.2f ms|%8.2f ms|%8.2f ms|%10u |%10u |\n", - val_to_str(j,camelSRTtype_naming,"Unknown Message 0x%02x"), - hs->stats[j].num, - MIN(9999,nstime_to_msec(&(hs->stats[j].min))), - MIN(9999,nstime_to_msec(&(hs->stats[j].max))), - MIN(9999,get_average(&(hs->stats[j].tot),hs->stats[j].num)), - hs->stats[j].min_num, - hs->stats[j].max_num - ); + val_to_str(j, camelSRTtype_naming, "Unknown Message 0x%02x"), + hs->stats[j].num, + MIN(9999, nstime_to_msec(&(hs->stats[j].min))), + MIN(9999, nstime_to_msec(&(hs->stats[j].max))), + MIN(9999, get_average(&(hs->stats[j].tot), hs->stats[j].num)), + hs->stats[j].min_num, + hs->stats[j].max_num + ); } /* j category */ printf("=================================================================================================\n"); @@ -143,89 +143,89 @@ static void camelsrt_draw(void *phs) */ printf("| Category/Criteria |"); - for(z=0; z<NB_CRITERIA; z++) printf("%7.2f%% |", criteria[z]); + for (z=0; z<NB_CRITERIA; z++) printf("%7.2f%% |", criteria[z]); printf("\n"); printf("|-------------------------|"); - for(z=0; z<NB_CRITERIA; z++) printf("---------|"); + for (z=0; z<NB_CRITERIA; z++) printf("---------|"); printf("\n"); /* calculate the delay max to have a given number of messages (in percentage) */ - for(j=2;j<NB_CAMELSRT_CATEGORY;j++) { + for (j=2; j<NB_CAMELSRT_CATEGORY;j++) { rtd_temp = &(hs->stats[j]); - if (hs->count[j]>0) { + if (hs->count[j] > 0) { /* Calculate the delay to answer to p% of the MS */ - for(z=0; z<NB_CRITERIA; z++) { - iteration=0; - delay_max=(double)rtd_temp->max.secs*1000 +(double)rtd_temp->max.nsecs/1000000; - delay_min=(double)rtd_temp->min.secs*1000 +(double)rtd_temp->min.nsecs/1000000; - delay=delay_min; - delta=delay_max-delay_min; - while( (delta > 0.001) && (iteration < 10000) ) { - somme=0; - iteration++; - - for(li=0;li<hs->count[j];li++) { - x=hs->delta_time[j][li].secs*1000 - + (double)hs->delta_time[j][li].nsecs/1000000; - if (x <= delay) somme++; - } - if ( somme*100 > hs->count[j]*criteria[z] ) { /* trop grand */ - delay_max=delay; - delay=(delay_max+delay_min)/2; - delta=delay_max-delay_min; - } else { /* trop petit */ - delay_min=delay; - delay=(delay_max+delay_min)/2; - delta=delay_max-delay_min; - } - } /* while */ - delay_criteria[z]=delay; + for (z=0; z<NB_CRITERIA; z++) { + iteration = 0; + delay_max = (double)rtd_temp->max.secs*1000 +(double)rtd_temp->max.nsecs/1000000; + delay_min = (double)rtd_temp->min.secs*1000 +(double)rtd_temp->min.nsecs/1000000; + delay = delay_min; + delta = delay_max-delay_min; + while ( (delta > 0.001) && (iteration < 10000) ) { + somme = 0; + iteration++; + + for (li=0; li<hs->count[j]; li++) { + x = hs->delta_time[j][li].secs*1000 + + (double)hs->delta_time[j][li].nsecs/1000000; + if (x <= delay) somme++; + } + if ( somme*100 > hs->count[j]*criteria[z] ) { /* trop grand */ + delay_max = delay; + delay = (delay_max+delay_min)/2; + delta = delay_max-delay_min; + } else { /* trop petit */ + delay_min = delay; + delay = (delay_max+delay_min)/2; + delta = delay_max-delay_min; + } + } /* while */ + delay_criteria[z] = delay; } /* z criteria */ /* Append the result to the table */ printf("X%24s |", val_to_str(j, camelSRTtype_naming, "Unknown") ); - for(z=0; z<NB_CRITERIA; z++) printf("%8.2f |", MIN(9999,delay_criteria[z])); + for (z=0; z<NB_CRITERIA; z++) printf("%8.2f |", MIN(9999, delay_criteria[z])); printf("\n"); } else { /* count */ printf("X%24s |", val_to_str(j, camelSRTtype_naming, "Unknown") ); - for(z=0; z<NB_CRITERIA; z++) printf("%8.2f |", 0.0); + for (z=0; z<NB_CRITERIA; z++) printf("%8.2f |", 0.0); printf("\n"); } /* count */ }/* j category */ printf("==========================="); - for(z=0; z<NB_CRITERIA; z++) printf("=========="); + for (z=0; z<NB_CRITERIA; z++) printf("=========="); printf("\n"); } -static void camelsrt_init(const char *opt_arg, void* userdata _U_) +static void camelsrt_init(const char *opt_arg, void *userdata _U_) { struct camelsrt_t *p_camelsrt; GString *error_string; - p_camelsrt = g_new(struct camelsrt_t,1); - if(!strncmp(opt_arg,"camel,srt,",9)){ - p_camelsrt->filter=g_strdup(opt_arg+9); + p_camelsrt = g_new(struct camelsrt_t, 1); + if (!strncmp(opt_arg, "camel,srt,", 9)) { + p_camelsrt->filter = g_strdup(opt_arg+9); } else { - p_camelsrt->filter=NULL; + p_camelsrt->filter = NULL; } camelsrt_reset(p_camelsrt); - error_string=register_tap_listener("CAMEL", - p_camelsrt, - p_camelsrt->filter, - 0, - NULL, - camelsrt_packet, - camelsrt_draw); + error_string = register_tap_listener("CAMEL", + p_camelsrt, + p_camelsrt->filter, + 0, + NULL, + camelsrt_packet, + camelsrt_draw); - if(error_string){ + if (error_string) { /* error, we failed to attach to the tap. clean up */ g_free(p_camelsrt->filter); g_free(p_camelsrt); fprintf(stderr, "tshark: Couldn't register camel,srt tap: %s\n", - error_string->str); + error_string->str); g_string_free(error_string, TRUE); exit(1); } @@ -236,8 +236,8 @@ static void camelsrt_init(const char *opt_arg, void* userdata _U_) * Whereas, with wireshark, it is not possible to have the correct display, if the stats are * not saved along the analyze */ - gtcap_StatSRT=TRUE; - gcamel_StatSRT=TRUE; + gtcap_StatSRT = TRUE; + gcamel_StatSRT = TRUE; } @@ -246,3 +246,16 @@ register_tap_listener_camelsrt(void) { register_stat_cmd_arg("camel,srt", camelsrt_init, NULL); } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local Variables: + * c-basic-offset: 2 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=2 tabstop=8 expandtab: + * :indentSize=2:tabSize=8:noTabs=true: + */ |