(obj=None)
List  available layers, or infos on a given layer
List  available layers, or infos on a given layer
List available layers or infos on a given layer
def ls(obj=None):
    """List  available layers, or infos on a given layer"""
    if obj is None:
        
        import __builtin__
        all = __builtin__.__dict__.copy()
        all.update(globals())
        objlst = sorted(conf.layers, key=lambda x:x.__name__)
        for o in objlst:
            print "%-10s : %s" %(o.__name__,o.name)
    else:
        if isinstance(obj, type) and issubclass(obj, Packet):
            for f in obj.fields_desc:
                print "%-10s : %-20s = (%s)" % (f.name, f.__class__.__name__,  repr(f.default))
        elif isinstance(obj, Packet):
            for f in obj.fields_desc:
                print "%-10s : %-20s = %-15s (%s)" % (f.name, f.__class__.__name__, repr(getattr(obj,f.name)), repr(f.default))
            if not isinstance(obj.payload, NoPayload):
                print "--"
                ls(obj.payload)
                

        else:
            print "Not a packet class. Type 'ls()' to list packet classes."
def ls ( obj = None ) : if obj is None : import __builtin__ all = __builtin__ . __dict__ . copy ( ) all . update ( globals ( ) ) objlst = sorted ( conf . layers , key = lambda x : x . __name__ ) for o in objlst : print "%-10s : %s" % ( o . __name__ , o . name ) else : if isinstance ( obj , type ) and issubclass ( obj , Packet ) : for f in obj . fields_desc : print "%-10s : %-20s = (%s)" % ( f . name , f . __class__ . __name__ , repr ( f . default ) ) elif isinstance ( obj , Packet ) : for f in obj . fields_desc : print "%-10s : %-20s = %-15s (%s)" % ( f . name , f . __class__ . __name__ , repr ( getattr ( obj , f . name ) ) , repr ( f . default ) ) if not isinstance ( obj . payload , NoPayload ) : print "--" ls ( obj . payload ) else : print "Not a packet class. Type 'ls()' to list packet classes."