Beispiel #1
0
    def _update_v4_fields(self, source_obj, dest_obj):

        dest_obj.dst_ip = Converter.stringIp2int(
            source_obj.destination_ip.value)
        dest_obj.dst_ip_mode = OstinatoEnums.unified_to_ostinato(
            source_obj.destination_ip.mode)
        dest_obj.dst_ip_count = int(source_obj.destination_ip.count)
        dest_obj.dst_ip_mask = Converter.stringIp2int(
            source_obj.destination_ip.mask)

        dest_obj.src_ip = Converter.stringIp2int(source_obj.source_ip.value)
        dest_obj.src_ip_mode = OstinatoEnums.unified_to_ostinato(
            source_obj.source_ip.mode)
        dest_obj.src_ip_count = int(source_obj.source_ip.count)
        dest_obj.src_ip_mask = Converter.stringIp2int(
            source_obj.source_ip.mask)

        dest_obj.ttl = int(source_obj.ttl)
        dest_obj.is_override_hdrlen = source_obj.enable_header_len_override
        dest_obj.is_override_totlen = source_obj.length_override
        if source_obj.checksum_mode is TGEnums.CHECKSUM_MODE.OVERRIDE:
            dest_obj.is_override_cksum = True
            dest_obj.cksum = int(source_obj.custom_checksum, 16)
        dest_obj.ver_hdrlen = source_obj.header_len_override_value
        dest_obj.tos = int(source_obj.dscp_decimal_value, 16)
        dest_obj.totlen = source_obj.length_value
        dest_obj.id = int(source_obj.identifier)
        dest_obj.frag_ofs = source_obj.fragment_offset_decimal_value
        #ip.options = source_obj.options_padding ::==>>Ostinato's TODO ip options
        #ip.is_override_ver =
        if self.packet.l4_proto is TGEnums.L4_PROTO.GRE:
            dest_obj.is_override_proto = True
            dest_obj.proto = 0x2F
        elif self.packet.l4_proto is TGEnums.L4_PROTO.NONE:
            #common default value
            dest_obj.is_override_proto = True
            dest_obj.proto = source_obj.protocol
        elif not source_obj._protocol._is_default:
            dest_obj.is_override_proto = True
            dest_obj.proto = source_obj.protocol
        df = 0 if source_obj.fragment_enable else 2
        mf = 0 if source_obj.fragment_last_enable else 1
        dest_obj.flags = df + mf
        return dest_obj
Beispiel #2
0
 def __init__(self, initdata=None):
     if initdata:
         data = initdata.split("/")
     else:
         data = [None, None, None]
     if data[0]:
         self.chassis = data[0]
     if data[1]:
         self.slot = data[1]
     isIp = Converter.stringIp2int(data[2])
     self.port = data[2] if isIp is None else str(isIp)