Browse files

Add a method to get a field by name from a packet

This will be used by scripts that want to know about fields during runtime.
  • Loading branch information...
gvnn3 committed Aug 14, 2017
1 parent 791b0f1 commit ba777cb1a23436f32033a2c1f61460fbd1911b5a
Showing with 11 additions and 0 deletions.
  1. +11 −0 pcs/
@@ -227,6 +227,10 @@ def bounds(self, value):
(value > (2 ** self.width) - 1)):
raise FieldBoundsError, "Value must be between 0 and %d but is %d" % ((2 ** self.width - 1), value)
def width(self):
"""Return the width of a field."""
return self.width
def __copy__(self):
"""Return a shallow copy of a Field; used by copy module.
Fields may be copied, they are not immutable."""
@@ -1315,6 +1319,13 @@ def fromHTML(self):
"""Create a Packet from HTML."""
def field(self, name):
"""Return a field by name"""
for field in self._layout:
if == name:
return (field)
raise FieldError()
class Chain(list):
"""A chain is simply a list of packets. Chains are used to
aggregate related sub packets into one chunk for transmission."""

0 comments on commit ba777cb

Please sign in to comment.