Esempio n. 1
0
/* ARGSUSED */
static int
dump_one_flow_stats(dladm_handle_t handle, dladm_flow_attr_t *attr, void *arg)
{
	char	*flowname = attr->fa_flowname;
	void	*stat;

	stat = dladm_flow_stat_query_all(flowname);
	if (stat == NULL)
		goto done;
	print_all_stats(stat);
	dladm_flow_stat_query_all_free(stat);

done:
	return (DLADM_WALK_CONTINUE);
}
Esempio n. 2
0
//aux to call stats functions
void statistics(char stat)
{
    if(stopApp==1)main();
    char tmp[1024]= {0x0};
    int fldcnt=0;
    char arr[MAXFLDS][MAXFLDSIZE]= {0x0};
    int recordcnt=0;

    if(stat=='a') strcpy(filename,"");

    if (!strcmp(filename,""))
    {
        printf("Enter key [d] to assume defaults [logcsv.csv],\n");
        printf("or insert the name of the CSV file [file.csv]: ");
        scanf("%s", filename);
    }
    if (!strcmp(filename,"d"))
        strcpy(filename,"logcsv.csv");

    in = fopen(filename,"r");/* open file on command line */

    if(checkFileIn()==-1)
    {
        optionSaveStats='3';
        printf("Error loading file...[%s]\n\n", filename);
        statistics('a');
    }
    if(checkFileIn()==0)
    {
        if(stat=='a')printf("Loading file...[%s]\n\n", filename);
        fgets(tmp,sizeof(tmp),in); /*jump over header*/
        while(fgets(tmp,sizeof(tmp),in)!=0) /* read a record */
        {
            i=0;
            j=0;
            recordcnt++;
            parse(tmp,",",arr,&fldcnt);    /* whack record into fields */
            for(i; i<fldcnt; i++)
            {
                //copy all records to strs
                strcpy(strs[recordcnt-1][i],arr[i]);
            }

        }
        if(stat=='a')printf("Done!!!\n", filename);
        if(stat=='a')PressEnterToReturn();
    }

    if (stat=='b') {
        system("clear");
        print_all_macip(recordcnt, 2,"Source devices:\n"); //list of all source devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='c') {
        system("clear");
        print_all(recordcnt, 8, "Source ports:\n"); //list of all source ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='d') {
        system("clear");
        print_all_macip(recordcnt, 3,"\nDestination devices:\n"); //list of all destination devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='e') {
        system("clear");
        print_all(recordcnt, 9, "Destination ports:\n"); //list of all destination ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='f') {
        system("clear");
        rep_count(recordcnt, 12, "0", "\nNº of Queries: "); //count number of queries, verifying the flag response=o
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='g') {
        system("clear");
        rep_count(recordcnt, 12, "1", "\nNº of Responses: "); //count number of responses, verifying the flag response=1
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='h') {
        system("clear");
        rep_count(recordcnt, 13, "3", "\nNº of Rcodes: "); //count number of Rcodes errors
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='i') {
        system("clear");
        check_times(recordcnt, 10); //verify delay between question and answer
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='j') {
        system("clear");
        print_all_stats(recordcnt, 2, "\nMAC source:"); //stats MAC Source
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='k') {
        system("clear");
        print_all_stats(recordcnt, 3, "\nMAC destination:");//stats MAC destination
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='l') {
        system("clear");
        print_all_stats(recordcnt, 18, "\nNames:");//stats Name
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='m') {
        system("clear");
        string keyword;
        printf("Insert the keyword to search in all queries: ");
        scanf("%s", keyword);
        count_occurrences(recordcnt, 18, "\nThe selected keyword:", keyword);
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='n') {
        system("clear");
        check_blacklisted(recordcnt, 21, "\nCheck queries responses:\n");//Check queries responses
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }

    statsMenu();
}