kill -9 $_PROCESS_ID#forcefully terminate the process, and any subprocesses or child processes, with the ID using the SIGKILL signal (sometimes it's not enough, why?)
exit0
}
### check_ret(prog_name, val_ret)
function check_ret()
{
notgood=0
case$1 in
"filtering_away")
if[$2 -ne 0];then
notgood=1
fi
;;
"print_results")
if[$2 -ne 0];then
notgood=1
fi
;;
*)echo -e "${WARNING}Setup success value returned for function \"$1\"${DEFAULT}"
return 1;;
esac
if[$notgood -eq 1];then
echo -e "${ERROR}Problem with the execution of \"$1\", exited with status $2${DEFAULT}"
fi
}
###
function filtering_away()
{
#(TENTATIVO DI PARALLELIZZAZIONE) OK MA SCAMBIA I RISULTATI A CASO IN BASE A COME FINISCE wc
# verbose_msg "Counting packets in $_FILE_REF"
# verbose_msg "Counting packets with field 'wlan' in $_FILE_REF"
filter="($scope) && (wlan) $filterSSID"#save the complete filter which wanna use to split the data.
rm -f $_FILE_TMP$_FILE2_TMP#just as a precaution.
if[[$_UNIQ_FLAG=='true']];then
verbose_msg "Counting packets with filter '$filter' in $_FILE_REF"
_SCOPE_ALL_CNTR=$(tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -c $_MAX_TO| tr '[:lower:]''[:upper:]'| sort | uniq | tee >(wc -l) >"$_FILE2_TMP")#for details see 'man tshark'. tr swap all upper-case. sort+uniq remove the duplicates. tee split the data in the pipe.
verbose_msg "=> $_SCOPE_ALL_CNTR"
if[[$_VERBOSE_FLAG=='true']];then
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| sort | uniq | tee >(wc -l) >"$_FILE_TMP")#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). sort+uniq remove the duplicates(seems useless but necessary). tee split the data in the pipe.
else
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| sort | uniq | wc -l)#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). sort+uniq remove the duplicates(seems useless but necessary).
fi
else
verbose_msg "Counting packets with filter '$filter' in $_FILE_REF"
_SCOPE_ALL_CNTR=$(tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -e wlan.fc.type -c $_MAX_TO| tr '[:lower:]''[:upper:]'| tee >(wc -l) >"$_FILE2_TMP")#for details see 'man tshark'. tr swap all upper-case. tee split the data in the pipe.
verbose_msg "=> $_SCOPE_ALL_CNTR"
if[[$_VERBOSE_FLAG=='true']];then
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| tee >(wc -l) >"$_FILE_TMP")#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). tee split the data in the pipe.
else
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| wc -l)#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx).
echo -ne "\033[2J\033[H"#The "\033[2J" sequence clear the terminal screen, the "\033[H" sequence moves the cursor to the top left corner of the screen.
echo -e "\033[2J\033[H"#The "\033[2J" sequence clear the terminal screen, the "\033[H" sequence moves the cursor to the top left corner of the screen.
echo"$(cat $lock_print)"#The "$()" syntax is used to execute the command inside the parentheses and return the result as a string (used to handle print cases TO REVIEW)
_FILE_REF=$(mktemp)#creates a unique temporary file name in /tmp/ folder.
cat /dev/stdin > "$_FILE_REF"
fi
else
if head -c4 | od -t x4 -N4 | grep -q -e "a1b2c3d4" -e "d4c3b2a1" -e "0a0d0d0a";then#handled only pcap, pcapng files (not erf ...) using magic number of file.
_FILE_REF=$(mktemp)#creates a unique temporary file name in /tmp/ folder.
cat /dev/stdin > "$_FILE_REF"
else
error_msg $0"Not a pcap/pcapng file"
exit 1;
fi
fi
else
if ! [[$_FILE_REF=='']];then
if ! head -c4 $_FILE_REF| od -t x4 -N4 | grep -q -e "a1b2c3d4" -e "d4c3b2a1" -e "0a0d0d0a";then#handled only pcap, pcapng files (not erf ...) using magic number of file.