2 #include INTEL_LICENSE.txt
4 ########################################################################
6 # PlanetLab Ping Of Death
8 ########################################################################
12 # This shell script takes care of starting and stopping Planetlab
15 # The Planetlab POD is a Linux kernel patch that creates the feature
16 # of resetting and rebooting a computer when a particularily
17 # formatted ICMP "ping" commmand is received.
19 # A PlanetLab node's kernel gets a host, mask and hash value through
20 # sysctl's that are performed on the node. The node then looks
21 # for an ICMP packet from a host matching the host/mask and, if the
22 # packet payload is the hash value, the node forces an immediate
27 # May 17, 2003 - Paul Brett <paul.brett@intel.com>
28 # Initial version based on the work of
29 # Robert Adams <robert.adams@intel.com> and EMULAB
32 # description: enable Ping of Death
34 # Source function library.
35 . /etc/init.d/functions
37 # Source networking configuration.
38 . /etc/sysconfig/network
42 local SYSCTL=/sbin/sysctl
48 # Grotesque sed/awk converts IP addrs into an integer for sysctl
49 local IPODHOST=`echo $IP_SUBNET | \
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 local IPODMASK=`echo $IP_MASK | \
53 sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \2 \3 \4/' | \
54 awk '{ printf "%d\n", $1*16777216+$2*65536+$3*256+$4 }'`
56 # figure out the version
57 local version=`$SYSCTL net.ipv4.icmp_ipod_version 2>/dev/null`
58 if [[ "$version" == "" ]]
60 $SYSCTL net.ipv4.icmp_ipod_enabled >/dev/null 2>&1
77 $SYSCTL -w net.ipv4.icmp_ipod_host=$IPODHOST >/dev/null
78 $SYSCTL -w net.ipv4.icmp_ipod_enabled=1 >/dev/null
82 $SYSCTL -w net.ipv4.icmp_ipod_host=$IPODHOST >/dev/null
84 $SYSCTL -w net.ipv4.icmp_ipod_mask=$IPODMASK >/dev/null
85 $SYSCTL -w net.ipv4.icmp_ipod_key=$HASH >/dev/null
86 $SYSCTL -w net.ipv4.icmp_ipod_enabled=1 >/dev/null
92 function disable_pod()
94 local SYSCTL=/sbin/sysctl
95 $SYSCTL -w net.ipv4.icmp_ipod_enabled=0 >/dev/null
102 local SYSCTL="/sbin/sysctl"
104 # Check that IPOD is built into this kernel
106 version=`$SYSCTL -n net.ipv4.icmp_ipod_version 2> /dev/null`
113 # Check if it has been enabled
114 local enabled=`$SYSCTL -n net.ipv4.icmp_ipod_enabled`
115 echo -n "version $version "
116 if [[ $enabled -eq 1 ]]
125 echo -n "PlanetLab Ping Of Death "
131 # load the POD configuration file
134 # no POD configuration file - failed
136 action $"Missing configuration file $CONF" /bin/false
140 SESSION=/etc/planetlab/session
144 # load the session value file
147 # no session value (ie, no hash)
149 action $"Missing node session file $SESSION" /bin/false
153 # Check that networking is up.
154 if [[ ${NETWORKING} = "no" ]]
156 action $"" /bin/false
160 # Check the POD parameters
161 if [[ "$HASH" == "" ]]
164 action $"Missing HASH (from $SESSION)" /bin/false
168 if [[ "$IP_SUBNET" == "" ]]
171 action $"Missing IP_SUBNET in $CONF" /bin/false
175 if [[ "$IP_MASK" == "" ]]
178 action $"Missing IP_MASK in $CONF" /bin/false
182 # See how we were called.
185 enable_pod $IP_SUBNET $IP_MASK $HASH
187 if [[ $RETVAL -eq 0 ]]
191 action $"" /bin/false
197 if [[ $RETVAL -eq 0 ]]
201 action $"" /bin/false
214 echo $"Usage: $0 {start|stop|restart|status}"