Ask Your Question

Revision history [back]

Is it possible to read multiple pcap file using tshark source code using a loop in the main function of tshark.c?

Suppose in tshark.c,
I rename the int main() function to Old_Main(int argc, char* argv[]) and call it in a loop in the newly created int main() function.

Example:

//main function renamed as Old_Main
int
Old_Main(int argc, char* argv[])
{
    //the code inside the main function as it was, I make no change.
}
//new main function
int
main(int argc, char* argv[])
{
    int i = 1;
    while (i <= 3)
    {
        argc = 4;
        argv[1] = "-Tjson";
        argv[2] = "-r";
        sprintf(argv[3], "D:\\Windows\\files\\packet%d.pcap", i);
        Old_Main(argc, argv);
        i++;
    }
    return exit_status; //I declare exit_status globally so that I can return it here.
}

I am getting the following exception after doing it,

** (tshark:10488) 20:01:33.061563 [Wiretap ERROR] C:\Development\wireshark\wiretap\file_access.c:1273 -- wtap_init_file_type_subtypes(): assertion failed: file_type_subtype_table_arr == ((void *)0)

** (tshark:10488) Aborting on fatal log level exception

Anyone kindly help me to find a way.
Thanks in advance for your help.

Is it possible to read multiple pcap file using tshark source code using a loop in the main function of tshark.c?

Suppose in tshark.c,
I rename the int main() function to Old_Main(int argc, char* argv[]) and call it in a loop in the newly created int main() function.

Example:

//main function renamed as Old_Main
int
Old_Main(int argc, char* argv[])
{
    //the code inside the main function as it was, I make no change.
}
//new main function
int
main(int argc, char* argv[])
{
    int i = 1;
    while (i <= 3)
    {
        argc = 4;
        argv[1] = "-Tjson";
        argv[2] = "-r";
        sprintf(argv[3], "D:\\Windows\\files\\packet%d.pcap", i);
        Old_Main(argc, argv);
        i++;
    }
    return exit_status; //I declare exit_status globally so that I can return it here.
}

I am getting the following exception after doing it,

** (tshark:10488) 20:01:33.061563 [Wiretap ERROR] C:\Development\wireshark\wiretap\file_access.c:1273 -- wtap_init_file_type_subtypes(): assertion failed: file_type_subtype_table_arr == ((void *)0)

** (tshark:10488) Aborting on fatal log level exception

Anyone kindly help me to find a way.
Thanks in advance for your help.

Is it possible to read multiple pcap file using tshark source code code, using a loop in inside the main function of tshark.c?

Suppose in tshark.c,
I rename the int main() function to Old_Main(int argc, char* argv[]) and call it in a loop in the newly created int main() function.

Example:

//main function renamed as Old_Main
int
Old_Main(int argc, char* argv[])
{
    //the code inside the main function as it was, I make no change.
}
//new main function
int
main(int argc, char* argv[])
{
    int i = 1;
    while (i <= 3)
    {
        argc = 4;
        argv[1] = "-Tjson";
        argv[2] = "-r";
        sprintf(argv[3], "D:\\Windows\\files\\packet%d.pcap", i);
        Old_Main(argc, argv);
        i++;
    }
    return exit_status; //I declare exit_status globally so that I can return it here.
}

I am getting the following exception after doing it,

** (tshark:10488) 20:01:33.061563 [Wiretap ERROR] C:\Development\wireshark\wiretap\file_access.c:1273 -- wtap_init_file_type_subtypes(): assertion failed: file_type_subtype_table_arr == ((void *)0)

** (tshark:10488) Aborting on fatal log level exception

Anyone kindly help me to find a way.
Thanks in advance for your help.

Is it possible to read multiple pcap file using tshark source code, using a loop inside the main function of tshark.c?

Suppose in tshark.c,
I rename the int main() function to Old_Main(int argc, char* argv[]) and call it in a loop in the newly created int main() function.

Example:

//main function renamed as Old_Main
int
Old_Main(int argc, char* argv[])
{
    //the code inside the main function as it was, I make no change.
}
 //new main function
//Here I am reading 3 pcap file (packet1.pcap, packet2.pcap, packet3.pcap)
int
main(int argc, char* argv[])
{
    int i = 1;
    while (i <= 3)
    {
        argc = 4;
        argv[1] = "-Tjson";
        argv[2] = "-r";
        sprintf(argv[3], "D:\\Windows\\files\\packet%d.pcap", i);
        Old_Main(argc, argv);
        i++;
    }
    return exit_status; //I declare exit_status globally so that I can return it here.
}

I am getting the following exception after doing it,

** (tshark:10488) 20:01:33.061563 [Wiretap ERROR] C:\Development\wireshark\wiretap\file_access.c:1273 -- wtap_init_file_type_subtypes(): assertion failed: file_type_subtype_table_arr == ((void *)0)

** (tshark:10488) Aborting on fatal log level exception

Anyone kindly help me to find a way.
Thanks in advance for your help.

Is it possible to read multiple pcap file using a loop inside the main function of tshark.c?

Suppose in tshark.c,
I rename the int main() function to Old_Main(int argc, char* argv[]) and call it in a loop in the newly created int main() function.

Example:

//main function renamed as Old_Main
int
Old_Main(int argc, char* argv[])
{
    //the code inside the main function as it was, I make no change.
}

//new main function
//Here I am reading 3 pcap file (packet1.pcap, packet2.pcap, packet3.pcap)
int
main(int argc, char* argv[])
{
    int i = 1;
    while (i <= 3)
    {
        argc = 4;
        argv[1] = "-Tjson";
        argv[2] = "-r";
        sprintf(argv[3], "D:\\Windows\\files\\packet%d.pcap", i);
        Old_Main(argc, argv);
        i++;
    }
    return exit_status; //I declare exit_status globally so that I can return it here.
}

I am getting the following exception after doing it,

** (tshark:10488) 20:01:33.061563 [Wiretap ERROR] C:\Development\wireshark\wiretap\file_access.c:1273 -- wtap_init_file_type_subtypes(): assertion failed: file_type_subtype_table_arr == ((void *)0)

** (tshark:10488) Aborting on fatal log level exception

Anyone kindly help me to find a way.
Thanks in advance for your help.