2009-05-29 21:10:40 +00:00
|
|
|
from wspy_dissector import Dissector
|
|
|
|
from wspy_dissector import FT_UINT8, FT_NONE
|
|
|
|
from wspy_dissector import BASE_NONE, BASE_HEX
|
|
|
|
|
2011-10-11 19:16:15 +00:00
|
|
|
class homeplug_py(Dissector):
|
2009-05-29 21:10:40 +00:00
|
|
|
# return the two first parameters of dissector_add as a tuple
|
|
|
|
def protocol_ids(self):
|
|
|
|
#you could use self.find_dissector() or self.create_dissector_handle() as
|
|
|
|
#defined in proto.h and pass the result in the third element of the tuple
|
|
|
|
#returned
|
|
|
|
return [ ("ethertype", 0x887B, None) ]
|
|
|
|
|
|
|
|
#Main default entry point of dissection
|
|
|
|
def dissect(self):
|
|
|
|
self.dissect_mctrl()
|
|
|
|
self.dissect_mehdr()
|
|
|
|
self.dissect_melen()
|
|
|
|
|
|
|
|
def dissect_mctrl(self):
|
2009-05-30 13:37:02 +00:00
|
|
|
self.subt = self.subtrees
|
|
|
|
self.c_tree = self.tree
|
2009-05-29 21:10:40 +00:00
|
|
|
try:
|
|
|
|
tree = self.c_tree.add_item(self.hf.homeplug_mctrl, length=1, adv=False)
|
|
|
|
mctrl_tree = tree.add_subtree(self.subt.mctrl)
|
|
|
|
|
|
|
|
mctrl_tree.add_item(self.hf.homeplug_mctrl_rsvd, length=1, adv=False)
|
|
|
|
mctrl_tree.add_item(self.hf.homeplug_mctrl_ne, length=1)
|
2009-05-30 13:37:02 +00:00
|
|
|
#item = self.libhandle.proto_tree_add_text(mctrl_tree.raw_tree, self.raw_tvb, 0, 1, "test") => example using libhandle
|
2009-05-29 21:10:40 +00:00
|
|
|
except Exception, e:
|
|
|
|
print e
|
|
|
|
|
|
|
|
def dissect_mehdr(self):
|
|
|
|
try:
|
|
|
|
tree = self.c_tree.add_item(self.hf.homeplug_mehdr, length=1, adv=False)
|
|
|
|
mehdr_tree = tree.add_subtree(self.subt.mehdr)
|
|
|
|
|
|
|
|
mehdr_tree.add_item(self.hf.homeplug_mehdr_mev, length=1, adv=False)
|
|
|
|
mehdr_tree.add_item(self.hf.homeplug_mehdr_metype, length=1)
|
|
|
|
except Exception, e:
|
|
|
|
print e
|
|
|
|
|
|
|
|
def dissect_melen(self):
|
|
|
|
try:
|
|
|
|
self.c_tree.add_item(self.hf.homeplug_melen, length=1)
|
|
|
|
except Exception, e:
|
|
|
|
print e
|
|
|
|
|
|
|
|
def dissect_mme(self):
|
|
|
|
try:
|
|
|
|
self.c_tree.add_item(self.hf.homeplug_mme, length=1)
|
|
|
|
except Exception, e:
|
|
|
|
print e
|
|
|
|
|
|
|
|
|
|
|
|
HOMEPLUG_MCTRL_RSVD = 0x80
|
|
|
|
HOMEPLUG_MCTRL_NE = 0x7F
|
|
|
|
HOMEPLUG_MEHDR_MEV = 0xE0
|
|
|
|
HOMEPLUG_MEHDR_METYPE = 0x1F
|
|
|
|
|
|
|
|
def register_protocol():
|
2011-10-11 19:16:15 +00:00
|
|
|
tp = homeplug_py("HomePlug protocol (python)", "HomePlug.py", "homeplug_py")
|
2009-05-29 21:10:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Register Protocol Fields
|
|
|
|
#
|
2009-05-30 13:37:02 +00:00
|
|
|
hf = tp.hf
|
2009-05-29 21:10:40 +00:00
|
|
|
# MAC Control Field
|
2011-10-11 19:16:15 +00:00
|
|
|
hf.add("Mac Control Field", "homeplug_py.mctrl", FT_NONE, BASE_NONE)
|
|
|
|
hf.add("Reserved", "homeplug_py.mctrl.rsvd", FT_UINT8, bitmask=HOMEPLUG_MCTRL_RSVD)
|
|
|
|
hf.add("Number of MAC Data Entries", "homeplug_py.mctrl.ne", FT_UINT8, bitmask=HOMEPLUG_MCTRL_NE)
|
2009-05-29 21:10:40 +00:00
|
|
|
|
|
|
|
# MAC Entry Header
|
2011-10-11 19:16:15 +00:00
|
|
|
hf.add("MAC Management Entry Header", "homeplug_py.mehdr", FT_NONE, BASE_NONE)
|
|
|
|
hf.add("MAC Entry Version", "homeplug_py.mehdr.mev", FT_UINT8, bitmask=HOMEPLUG_MEHDR_MEV)
|
|
|
|
hf.add("MAC Entry Type", "homeplug_py.mehdr.metype", FT_UINT8, BASE_HEX, bitmask=HOMEPLUG_MEHDR_METYPE)
|
2009-05-29 21:10:40 +00:00
|
|
|
|
|
|
|
# MAC Entry Len
|
2011-10-11 19:16:15 +00:00
|
|
|
hf.add("MAC Management Entry Length", "homeplug_py.melen", FT_UINT8)
|
2009-05-29 21:10:40 +00:00
|
|
|
|
|
|
|
# MAC Management Entry
|
2011-10-11 19:16:15 +00:00
|
|
|
hf.add("MAC Management Entry Data", "homeplug_py.mmentry", FT_UINT8)
|
2009-05-29 21:10:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Register Subtrees
|
|
|
|
#
|
2009-05-30 13:37:02 +00:00
|
|
|
subt = tp.subtrees
|
2011-10-11 19:16:15 +00:00
|
|
|
#subt.add("homeplug_py") => we let Dissector output the main tree of this protocol
|
2009-05-29 21:10:40 +00:00
|
|
|
subt.add("mctrl")
|
|
|
|
subt.add("mehdr")
|
|
|
|
return tp
|