|
PCS
0.4
|
Public Member Functions | |
| def | __init__ |
| def | __repr__ |
| def | decode |
| def | encode |
| def | set_value |
| def | get_value |
| def | reset |
| def | bounds |
| def | __copy__ |
| def | __deepcopy__ |
| def | default_compare |
Public Attributes | |
| packet | |
| name | |
| the name of the Field | |
| width | |
| the width, in bites, of the field's data | |
| default | |
| the default value of the field, must fit into bits | |
| discriminator | |
| Is this field used to demultiplex higher layer packets? | |
| compare | |
| the comparison function for this field | |
| value | |
| Fields store the values. | |
Static Public Attributes | |
| tuple | default_compare = staticmethod(default_compare) |
A field is a name, a type, a width in bits, possibly a default value and can be marked as a dicriminator for higher level packet demultiplexing . These classes are used by the packet to define the layout of the data and how it is addressed.
| def pcs.Field.__init__ | ( | self, | |
name = "", |
|||
width = 1, |
|||
default = None, |
|||
discriminator = False, |
|||
compare = None |
|||
| ) |
initialize a field name - a string name width - a width in bits default - a default value discriminator - is this field used to demultiplex packets match - a match function used to compare this field with another.
References pcs.Field.packet.
| def pcs.Field.__copy__ | ( | self | ) |
Return a shallow copy of a Field; used by copy module. Fields may be copied, they are not immutable.
References pcs.Field.__deepcopy__().
| def pcs.Field.__deepcopy__ | ( | self, | |
memo = {} |
|||
| ) |
Return a deep copy of a Field; used by copy module. Fields may be copied, they are not immutable; however they always contain integer types which *are* immutable.
References pcs.Field.compare, pcs.Field.default, pcs.Field.discriminator, pcs.Field.name, pcs.Field.value, and pcs.Field.width.
Referenced by pcs.Field.__copy__(), pcs.Packet.__copy__(), and pcs.Chain.__copy__().
| def pcs.Field.__repr__ | ( | self | ) |
return an appropriate representation for the Field object
Reimplemented in pcs.StringField.
References pcs.Field.default, pcs.Field.discriminator, pcs.Field.name, and pcs.Field.width.
Referenced by pcs.Packet.println().
| def pcs.Field.bounds | ( | self, | |
| value | |||
| ) |
| def pcs.Field.decode | ( | self, | |
| bytes, | |||
| curr, | |||
| byteBR | |||
| ) |
Decode a field and return the value and the updated current pointer into the bytes array bytes - the byte array for the packet curr - the current byte position in the bytes array byteBR - the number of Bits Remaining in the current byte
Reimplemented in pcs.StringField.
References pcs.Field.value, and pcs.Field.width.
Referenced by pcs.Packet.__init__().
| def pcs.Field.default_compare | ( | lp, | |
| lf, | |||
| rp, | |||
| rf | |||
| ) |
Default comparison method. lp - packet on left hand side of comparison lf - field in lp being compared rp - packet on right hand side of comparison rf - field in rp being compared This function is installed in Field.compare on assignment. It is declared static to allow folk to override it with lambda functions. The packets are passed so that back-references to other fields in the packet are possible during the match.
| def pcs.Field.encode | ( | self, | |
| bytearray, | |||
| value, | |||
| byte, | |||
| byteBR | |||
| ) |
encode the a field into the bytes necessary to transmit it as part of a packet bytearray - the array of bytes that will be returned value - the value to encode byte - the byte we are encoding, we can encode partial bytes byteBR - the bits remaining in the current byte being encoded.
Reimplemented in pcs.StringField.
References pcs.Field.width.
Referenced by pcs.Chain.__init__(), pcs.Chain.append(), pcs.Chain.fixup(), pcs.Packet.getbytes(), and pcs.Chain.insert_after().
| def pcs.Field.reset | ( | self | ) |
Return a resonable value to use in resetting a field of this type.
Reimplemented in pcs.StringField.
| def pcs.Field.set_value | ( | self, | |
| value | |||
| ) |
Set the value of a field.
References pcs.Field.value.
1.8.0