1#!/bin/sh
2
3# As requirement for NTGR Weber, if have usb storage, we will store LAN/WAN packet into usb storage, or store in sdram
4
5dist_path=""
6mnt_path="/mnt/"
7store_locate=`cat /tmp/debug_store_locate`
8wanlan_capture=`cat /tmp/wanlan_capture`
9check_usb_storage_folder()
10{
11	part_list="a b c d e f g"
12	for i in $part_list; do
13
14        	[ "X$(df | grep /dev/sd"$i")" = "X" ] && continue
15        	#echo "sd$i"
16        	j=1
17        	while [ $j -le 20 ]; do
18                	tmp=`df | grep /dev/sd"$i""$j"`
19                	mnt_tmp=`ls $mnt_path | grep sd"$i""$j"`
20                	[ "X$tmp" = "X" -o "X$mnt_tmp" = "X" ] && j=$((j+1)) && continue
21
22                        dist_path="$mnt_path"sd"$i""$j"
23                        break;
24
25                	j=$((j+1))
26        	done
27        	[ "X$dist_path" != "X" ]  && break
28	done
29}
30
31# check whether usb storage connect to DUT
32check_usb_storage_folder
33
34# Simple LAN/WAN packet capture. THe file saved in DDR memory, THe file maximum to 10MB
35if [ "X$wanlan_capture" = "X1" ]; then 
36
37	if [ "X$store_locate" = "X1" -a "X$dist_path" != "X" ]; then
38		echo "Save capture lan/wan packet in usb storage"
39		mkdir $dist_path/Capture
40		tcpdump -i br0 -s 0 -W 1 -w $dist_path/Capture/lan.pcap -C 100 &
41		tcpdump -i brwan -s 0 -W 1 -w $dist_path/Capture/wan.pcap -C 100 &
42	else
43		echo "Save capture lan/wan packet in SDRAM tmp dir"
44		tcpdump -i br0 -s 0 -W 1 -w /tmp/lan.pcap -C 5 &
45		tcpdump -i brwan  -s 0 -W 1 -w /tmp/wan.pcap -C 5 &
46	fi
47fi
48
49