static void printResults(u_int64_t tot_usec) { u_int32_t i; printf("\x1b[2K\n"); printf("pcap file contains\n"); printf("\tIP packets: \x1b[33m%-13llu\x1b[0m of %llu packets total\n", (long long unsigned int)ip_packet_count, (long long unsigned int)raw_packet_count); printf("\tIP bytes: \x1b[34m%-13llu\x1b[0m\n", (long long unsigned int)total_bytes); printf("\tUnique flows: \x1b[36m%-13u\x1b[0m\n", ndpi_flow_count); if(tot_usec > 0) { char buf[32], buf1[32]; float t = (float)(ip_packet_count*1000000)/(float)tot_usec; float b = (float)(total_bytes * 8 *1000000)/(float)tot_usec; printf("\tnDPI throughout: \x1b[36m%s pps / %s/sec\x1b[0m\n", formatPackets(t, buf), formatTraffic(b, 1, buf1)); } for(i=0; i<NUM_ROOTS; i++) ndpi_twalk(ndpi_flows_root[i], node_proto_guess_walker, NULL); if(enable_protocol_guess) printf("\tGuessed flow protocols: \x1b[35m%-13u\x1b[0m\n", guessed_flow_protocols); printf("\n\nDetected protocols:\n"); for (i = 0; i <= ndpi_get_num_supported_protocols(ndpi_struct); i++) { if(protocol_counter[i] > 0) { printf("\t\x1b[31m%-20s\x1b[0m packets: \x1b[33m%-13llu\x1b[0m bytes: \x1b[34m%-13llu\x1b[0m " "flows: \x1b[36m%-13u\x1b[0m\n", ndpi_get_proto_name(ndpi_struct, i), (long long unsigned int)protocol_counter[i], (long long unsigned int)protocol_counter_bytes[i], protocol_flows[i]); } } if(verbose && (protocol_counter[0] > 0)) { printf("\n"); for(i=0; i<NUM_ROOTS; i++) ndpi_twalk(ndpi_flows_root[i], node_print_known_proto_walker, NULL); printf("\n\nUndetected flows:\n"); for(i=0; i<NUM_ROOTS; i++) ndpi_twalk(ndpi_flows_root[i], node_print_unknown_proto_walker, NULL); } printf("\n\n"); }
/** * Fonction de redémarrage d'un device */ void restart_device_cb(GtkButton *button, Project *project) { GtkWidget *dialog; Device *device; char *packet; guint result; device = (Device *)g_object_get_data(G_OBJECT(button), "device"); dialog = gtk_message_dialog_new(GTK_WINDOW(project->networksetup.dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "\nAre you sure to restart the device ?"); gtk_window_set_title(GTK_WINDOW(dialog), "Restart the device"); result = gtk_dialog_run(GTK_DIALOG(dialog)); switch(result) { case GTK_RESPONSE_YES : { packet = formatPackets(3, device->name, "restartDevice", "on"); pushQueue(&project->server.sender_queue, packet, project->server.sender_lock); g_cond_broadcast(project->server.notifier); free(packet); gtk_widget_destroy(dialog); gtk_widget_destroy(project->networksetup.dialog); break; } case GTK_RESPONSE_NO : gtk_widget_destroy(dialog); break; } }