Added code to send ICMP timestamp request.
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
Change-Id: Iba6344033f98f020a00e27ed695dcdca6d5d054a
diff --git a/lib/resource.robot b/lib/resource.robot
index 698c34b..58b5b9c 100755
--- a/lib/resource.robot
+++ b/lib/resource.robot
@@ -47,10 +47,14 @@
${OS_WAIT_TIMEOUT} ${15*60}
# Networking related parameters
-${NETWORK_PORT} 80
-${PACKET_TYPE} tcp
-${NETWORK_RETRY_TIME} 6
-${NETWORK_TIMEOUT} 18
+${NETWORK_PORT} 80
+${PACKET_TYPE} tcp
+${ICMP_PACKETS} icmp
+${NETWORK_RETRY_TIME} 6
+${NETWORK_TIMEOUT} 18
+${ICMP_TIMESTAMP_REQUEST} 13
+${ICMP_ECHO_REQUEST} 8
+
# BMC debug tarball parameter
${DEBUG_TARBALL_PATH} ${EMPTY}
diff --git a/security/test_bmc_icmp_security.robot b/security/test_bmc_icmp_security.robot
new file mode 100644
index 0000000..5bfc695
--- /dev/null
+++ b/security/test_bmc_icmp_security.robot
@@ -0,0 +1,61 @@
+*** Settings ***
+Documentation Network stack stress tests using "nping" tool.
+
+Resource ../lib/resource.robot
+
+Library OperatingSystem
+Library String
+Library ../lib/gen_robot_valid.py
+Library ../lib/bmc_network_utils.py
+
+Suite Setup Suite Setup Execution
+
+Force Tags Network_Nping
+
+*** Variables ***
+
+${delay} 1000ms
+${count} 4
+${program_name} nping
+
+*** Test Cases ***
+
+Send ICMP Timestamp Request
+ [Documentation] Send ICMP packet type 13 and check BMC drops such packets
+ [Tags] Send_ICMP_Timestamp_Request
+
+ # Send ICMP packet type 13 to BMC and check packet loss.
+ ${packet_loss}= Send Network Packets And Get Packet Loss
+ ... ${OPENBMC_HOST} ${ICMP_PACKETS} ${NETWORK_PORT} ${ICMP_TIMESTAMP_REQUEST}
+ Should Be Equal ${packet_loss} 100.00
+ ... msg=FAILURE: BMC is not dropping timestamp request messages.
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Validate the setup.
+
+ Valid Value OPENBMC_HOST
+ Valid Program program_name
+
+Send Network Packets And Get Packet Loss
+ [Documentation] Send TCP, UDP or ICMP packets to the target.
+ [Arguments] ${host} ${packet_type}=${ICMP_PACKETS} ${port}=80 ${icmp_type}=${ICMP_ECHO_REQUEST}
+
+ # Description of argument(s):
+ # host The host name or IP address of the target system.
+ # packet_type The type of packets to be sent ("tcp, "udp", "icmp").
+ # port Network port.
+ # icmp_type Type of ICMP packets (e.g. 8, 13, 17, etc.).
+
+ # This keyword expects host, port, type and number of packets to be sent
+ # and rate at which packets to be sent, should be given in command line.
+ # By default it sends 4 ICMP echo request packets at 1 packets/second.
+
+ ${cmd_suffix}= Set Variable If '${packet_type}' == 'icmp'
+ ... --icmp-type ${icmp_type}
+ ... -p ${port}
+ ${cmd_buf}= Set Variable --delay ${delay} ${host} -c ${count} --${packet_type} ${cmd_suffix}
+
+ ${nping_result}= Nping ${cmd_buf}
+ [Return] ${nping_result['percent_lost']}