diff --git a/scapy/config.py b/scapy/config.py index c7c425012ec033c10cf62886b2ac9d3a2d4a7e15..b81919564cbe2b24ef98799070787a09b4eaea59 100644 --- a/scapy/config.py +++ b/scapy/config.py @@ -91,6 +91,15 @@ class Num2Layer: return "\n".join(y for x,y in lst) +class LayersList(list): + def __repr__(self): + s=[] + for l in self: + s.append("%-20s: %s" % (l.__name__,l.name)) + return "\n".join(s) + def register(self, layer): + self.append(layer) + class Conf(ConfClass): @@ -124,6 +133,7 @@ extensions_paths: path or list of paths where extensions are to be looked for session = "" stealth = "not implemented" iface = get_working_if() + layers = LayersList() checkIPID = 0 checkIPsrc = 1 checkIPaddr = 1 diff --git a/scapy/packet.py b/scapy/packet.py index 0957fb72c59d9150fe7acecd749e1d7391568a25..de4407db7c2994be6968eb7f54e693386aebe40c 100644 --- a/scapy/packet.py +++ b/scapy/packet.py @@ -1,5 +1,6 @@ import re,time,itertools,os,random,socket from fields import * +from config import conf ################ @@ -118,6 +119,7 @@ class Packet_metaclass(type): newcls = super(Packet_metaclass, cls).__new__(cls, name, bases, dct) for f in newcls.fields_desc: f.register_owner(newcls) + conf.layers.register(newcls) return newcls def __getattr__(self, attr): for k in self.fields_desc: