(self, *args, **kargs)
return x
lst.replace(<field>,[<oldvalue>,]<newvalue>)
        lst.replace( (fld,[ov],nv),(fld,[ov,]nv),...)
          if ov is None, all values are replaced
        ex:
          lst.replace( IP.src, "192.168.1.1", "10.0.0.1" )
          lst.replace( IP.ttl, 64 )
          lst.replace( (IP.ttl, 64), (TCP.sport, 666, 777), )
lst.replace(<field>,[<oldvalue>,]<newvalue>)
        lst.replace( (fld,[ov],nv),(fld,[ov,]nv),...)
          if ov is None, all values are replaced
        ex:
          lst.replace( IP.src, "192.168.1.1", "10.0.0.1" )
          lst.replace( IP.ttl, 64 )
          lst.replace( (IP.ttl, 64), (TCP.sport, 666, 777), )
lst . replace ( <field > [ <oldvalue > ] <newvalue > ) lst . replace ( ( fld [ ov ] nv ) ( fld [ ov ] nv ) ... ) if ov is None all values are replaced ex : lst . replace ( IP . src 192 . 168 . 1 . 1 10 . 0 . 0 . 1 ) lst . replace ( IP . ttl 64 ) lst . replace ( ( IP . ttl 64 ) ( TCP . sport 666 777 ) )
def replace(self, *args, **kargs):
        """
        lst.replace(<field>,[<oldvalue>,]<newvalue>)
        lst.replace( (fld,[ov],nv),(fld,[ov,]nv),...)
          if ov is None, all values are replaced
        ex:
          lst.replace( IP.src, "192.168.1.1", "10.0.0.1" )
          lst.replace( IP.ttl, 64 )
          lst.replace( (IP.ttl, 64), (TCP.sport, 666, 777), )
        """
        delete_checksums = kargs.get("delete_checksums",False)
        x=PacketList(name="Replaced %s" % self.listname)
        if type(args[0]) is not tuple:
            args = (args,)
        for p in self.res:
            p = self._elt2pkt(p)
            copied = False
            for scheme in args:
                fld = scheme[0]
                old = scheme[1] # not used if len(scheme) == 2
                new = scheme[-1]
                for o in fld.owners:
                    if o in p:
                        if len(scheme) == 2 or p[o].getfieldval(fld.name) == old:
                            if not copied:
                                p = p.copy()
                                if delete_checksums:
                                    p.delete_checksums()
                                copied = True
                            setattr(p[o], fld.name, new)
            x.append(p)
        return x
def replace ( self , * args , * * kargs ) : delete_checksums = kargs . get ( "delete_checksums" , False ) x = PacketList ( name = "Replaced %s" % self . listname ) if type ( args [ 0 ] ) is not tuple : args = ( args , ) for p in self . res : p = self . _elt2pkt ( p ) copied = False for scheme in args : fld = scheme [ 0 ] old = scheme [ 1 ] # not used if len(scheme) == 2 new = scheme [ - 1 ] for o in fld . owners : if o in p : if len ( scheme ) == 2 or p [ o ] . getfieldval ( fld . name ) == old : if not copied : p = p . copy ( ) if delete_checksums : p . delete_checksums ( ) copied = True setattr ( p [ o ] , fld . name , new ) x . append ( p ) return x