mark pod.py as running on python2
[pingofdeath.git] / test-pod
1 #! /bin/sh
2 # Script to test the "ping-of-death" ("POD") functionality.
3 # This script is run on a machine that has the POD feature patched
4 # into the kernel and has the tools installed in the machine. 
5 #
6 # The process is:
7 #   * build the kernel with the pod patch
8 #   * install the kernel on a machine
9 #   * reboot to run that kernel
10 #   * on the machine with that kernel, run this script
11 #   * if you answer "y" to the question, you will reboot that machine
12 #
13 # This script was built from the pl-pod* script files.  It has no
14 # dependency on them other than it expects /usr/local/planetlab/bin/pl-poddoit
15 # to exist to send the POD packet.
16 # -----------------------------------------------------------------
17 # $Header: /shareddata/CVS/planetlab/admin/ipod/test-pod,v 1.2 2003/01/18 01:52:10 radams Exp $
18 #
19 # Copyright (c) 2003 Intel Corporation
20 # All rights reserved.
21 # This file is distributed under the terms in the attached INTEL_LICENSE
22 # file.  If you do not find this file, a copy can be obtained by
23 # writing to Intel Research Berkeley; Attention: Intel License Inquiry;
24 # 2150 Shattuck Avenue, suite 1300; Berkeley, CA 94704
25 # -----------------------------------------------------------------
26
27 PLBIN="/usr/local/planetlab/bin"
28 PLDOIT="$PLBIN/pl-poddoit"
29
30 SYSCTL="/sbin/sysctl"
31
32 if ! [[ -x $PLDOIT ]] ; then
33     echo "CONFIG ERROR: the send POD executable not available at $PLDOIT"
34     exit 1
35 fi
36
37 IPODHOSTP=`hostname -i`
38 IPODMASKP="255.255.255.255"
39 IPODHASHP=`printf "%04x%04x%04x%04x%04x%04x%04x%04x\n" $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM`
40
41 echo "IPODHOST = $IPODHOSTP"
42 echo "IPODMASK = $IPODMASKP"
43 echo "IPODKEY = $IPODHASHP"
44
45 echo "=== Set the set parameters into the kernel ==="
46 IPODHOST=`echo $IPODHOSTP | \
47     sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \2 \3 \4/' | \
48     awk '{ printf "%d\n", $1*16777216+$2*65536+$3*256+$4 }'`
49 IPODMASK=`echo $IPODMASKP | \
50     sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \2 \3 \4/' | \
51     awk '{ printf "%d\n", $1*16777216+$2*65536+$3*256+$4 }'`
52 IPODKEY=`echo $IPODHASHP | \
53     sed -e 's/\(.*\)/\1/'`
54 $SYSCTL -w net.ipv4.icmp_ipod_host=$IPODHOST >/dev/null
55 Success=$?
56 $SYSCTL -w net.ipv4.icmp_ipod_mask=$IPODMASK >/dev/null
57 $SYSCTL -w net.ipv4.icmp_ipod_key=$IPODKEY >/dev/null
58 $SYSCTL -w net.ipv4.icmp_ipod_enabled=1 >/dev/null
59 if [[ $Success -eq 0 ]] ; then
60     echo "SUCCESS setting parameters"
61 else
62     echo "FAILURE to set POD parameters"
63     exit 1
64 fi
65
66 echo "=== Try to reset with wrong payload -- this should fail ==="
67 echo echo "01234567890123456789012345678901" \| $PLDOIT -i - $IPODHOSTP
68 echo "01234567890123456789012345678901" | $PLDOIT -i - $IPODHOSTP
69
70 echo "=== Reset host ==="
71 echo "THIS NEXT STEP WILL RESET THIS COMPUTER!!!!"
72 read -p "Enter 'y' if you wish to reset this computer: " REPLY
73 if [[ x"$REPLY" == "xy" ]] ; then
74     echo $IPODHASHP | $PLDOIT -i - $IPODHOSTP
75     echo echo $IPODHASHP \| $PLDOIT -i - $IPODHOSTP
76 else
77     echo "Final reset test not performed."
78 fi
79
80