X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FSFC%2FVerifyPacket.py;h=84eb6aa0a247cb3592dc60042245827e213742f4;hp=fd72bb296b716e5c1c3b5872a125af8359e57007;hb=eb9eec208b6e66bf585546ffe5a9554a48fe1208;hpb=050ece3a87fbbad7d04e69ed951c48118edf0a89 diff --git a/resources/libraries/python/SFC/VerifyPacket.py b/resources/libraries/python/SFC/VerifyPacket.py index fd72bb296b..84eb6aa0a2 100644 --- a/resources/libraries/python/SFC/VerifyPacket.py +++ b/resources/libraries/python/SFC/VerifyPacket.py @@ -20,11 +20,9 @@ import ipaddress from scapy.layers.inet import IP, UDP from scapy.all import Raw -from resources.libraries.python.constants import Constants as con from resources.libraries.python.SFC.SFCConstants import SFCConstants as sfccon from resources.libraries.python.SFC.TunnelProtocol import VxLAN, VxLANGPE, NSH -from robot.api import logger def valid_ipv4(ipaddr): """Check if IP address has the correct IPv4 address format. @@ -108,9 +106,14 @@ class VerifyPacket(object): # get the NSH packet and check it nsh_pkt = NSH(payload_data[8:32]) - if nsh_pkt.flags != sfccon.NSH_FLAGS: - raise RuntimeError("Unexpected NSH flags: {0}". - format(nsh_pkt.flags)) + if nsh_pkt.Version != 0: + raise RuntimeError("Unexpected NSH version: {0}". + format(nsh_pkt.Version)) + + print type(nsh_pkt.OAM) + if nsh_pkt.OAM != 0 or nsh_pkt.OAM != 1: + raise RuntimeError("Unexpected NSH OAM: {0}". + format(nsh_pkt.OAM)) if nsh_pkt.length != sfccon.NSH_HEADER_LENGTH: raise RuntimeError("NSH length {0} incorrect". @@ -185,9 +188,9 @@ class VerifyPacket(object): recv_pkt_len = len(ether) if recv_pkt_len != expect_pkt_len: - raise RuntimeError("Received packet size {0} not " \ - "the expect size {1}".format(recv_pkt_len, \ - expect_pkt_len)) + raise RuntimeError("Received packet size {0} not " + "the expect size {1}".format(recv_pkt_len, + expect_pkt_len)) if not ether.haslayer(IP): raise RuntimeError("Not a IPv4 packet")