#!/bin/bash

#arg 1 is the interface
if [ "$1" != "" ]; then
	INT=$1
else
	echo "ERROR: no interface name given"
	echo ""
	echo "USUAGE:"
	echo "      ./mtp2-trace.sh <interface name> <optional:filename>"
	echo "      i.e. ./mtp2-trace.sh w1g1" 
	echo "      i.e. ./mtp2-trace.sh w1g1 custom.pcap"
	echo ""
	exit 1;
fi

#arg 2 is a custom filename
if [ "$2" != "" ]; then
	FILE=$2
else
	FILE="mtp2-$INT.pcap"
fi

echo ""
echo "Starting capture on interface $INT to file $FILE"
echo ""

eval "wanpipemon -i $INT -pcap -pcap_file $FILE -diff -prot MTP2 -full -systime -c trh"

echo "Stopping capture on interface $INT to file $FILE"
echo ""

exit 0
