Skip to content

Commit

Permalink
Add logs #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Zelenchuk committed Mar 28, 2024
1 parent a034f48 commit 0396b88
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mimidump.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ int main(int argc, char **argv)
strcat(dev2, dev);
fptr = fopen(dev2, "a");


filter_string[0] = '\0';

/* Read filters */
Expand Down Expand Up @@ -211,36 +210,44 @@ int main(int argc, char **argv)
pcap_setdirection(handle_inout, PCAP_D_INOUT);
pcap_setdirection(handle_out, PCAP_D_OUT);

fprintf(fptr, "BEFORE PCAP_COMPILE %d\n", 1);

/* Set filters */
if (pcap_compile(handle_inout, &bprog, filter_string, 1, PCAP_NETMASK_UNKNOWN) < 0) {
fprintf(fptr, "Error compiling IN/OUT bpf filter on\n");
exit(EXIT_FAILURE);
}

if (pcap_setfilter(handle_inout, &bprog) < 0) {


sprintf(errbuf, "%s", pcap_geterr(handle_inout));

if (strstr(errbuf, "Network is down") != NULL) {
usleep(mSleep);
continue;
}

fprintf(fptr, "Error installing IN/OUT bpf filter\n");
fprintf(fptr, "Error installing IN/OUT bpf filter: %s\n", errbuf);
exit(EXIT_FAILURE);
}

fprintf(fptr, "BEFORE PCAP_COMPILE %d\n", 2);

if (pcap_compile(handle_out, &bprog, filter_string, 1, PCAP_NETMASK_UNKNOWN) < 0) {
fprintf(fptr, "Error compiling OUT bpf filter on\n");
exit(EXIT_FAILURE);
}

if (pcap_setfilter(handle_out, &bprog) < 0) {

sprintf(errbuf, "%s", pcap_geterr(handle_out));

if (strstr(errbuf, "Network is down") != NULL) {
usleep(mSleep);
continue;
}

fprintf(fptr, "Error installing OUT bpf filter\n");
fprintf(fptr, "Error installing OUT bpf filter: %s\n", errbuf);
exit(EXIT_FAILURE);
}

Expand Down

0 comments on commit 0396b88

Please sign in to comment.