PCS  0.4
Public Member Functions | Public Attributes
pcs.Chain Class Reference

List of all members.

Public Member Functions

def __init__
def __eq__
def __ne__
def __str__
def __repr__
def __div__
def __copy__
def __deepcopy__
def append
def insert_after
def contains
def matches
def wildcard_mask
def encode
def decode
def index_of
def collate_following
def find_first_of
def find_preceding
def calc_checksums
def calc_lengths
def fixup

Public Attributes

 packets
 bytes

Detailed Description

A chain is simply a list of packets.  Chains are used to
aggregate related sub packets into one chunk for transmission.

Constructor & Destructor Documentation

def pcs.Chain.__init__ (   self,
  packets = [] 
)
initialize a Chain object

packets - an optional list of packets to add to the new Chain

References pcs.Field.encode(), pcs.StringField.encode(), pcs.LengthValueField.encode(), pcs.TypeValueField.encode(), pcs.TypeLengthValueField.encode(), pcs.OptionListField.encode(), pcs.Packet.encode(), pcs.Chain.encode(), and pcs.Chain.packets.


Member Function Documentation

def pcs.Chain.__copy__ (   self)
def pcs.Chain.__deepcopy__ (   self,
  memo = {} 
)
Return a deep copy of a Chain; used by copy module.

   Chain is derived from list. We can't rely on the default deepcopy
   handler for list, as it doesn't know our representation.

   Chain may contain Packets, and Packets may refer back to their
   parent Chain. Because of this, we need to make deep copies of
   all Packets contained within a Chain to avoid clobbering
   the contents of existing Chains, and set their head pointer
   to point to the newly created Chain.

   Also, the constructor for Chain needs a list of Packet, so we
   pass it an empty list and then append each copied Packet to
   its internal list.

References pcs.Chain.packets.

Referenced by pcs.Chain.__copy__().

def pcs.Chain.__div__ (   self,
  packet,
  rdiscriminate = True 
)
/ operator: Append a packet to the end of a chain.
   The packet's head pointer will be overwritten to point to
   this chain.
   The default behaviour is to fill out the discriminator field
   of the packet in front of the new tail packet.

References pcs.OptionListField.append(), pcs.Chain.append(), and pcs.Chain.packets.

def pcs.Chain.__eq__ (   self,
  other 
)
test two Chain objects for equality

Two chains are equal iff they have the same packets and their
packets have the same data in them.

References pcs.Chain.packets.

Referenced by pcs.packets.igmpv3.GroupRecordField.__eq__(), pcs.packets.rtnetlink.NexthopField.__eq__(), and pcs.Chain.__ne__().

def pcs.Chain.__ne__ (   self,
  other 
)
test two Chain objects for inequality

References pcs.OptionListField.__eq__(), pcs.Packet.__eq__(), and pcs.Chain.__eq__().

def pcs.Chain.__str__ (   self)
return a pretty printed Chain

References pcs.Chain.packets.

def pcs.Chain.append (   self,
  packet 
)
Append a packet to a chain.  Appending a packet requires
that we update the bytes as well.

References pcs.Field.encode(), pcs.StringField.encode(), pcs.LengthValueField.encode(), pcs.TypeValueField.encode(), pcs.TypeLengthValueField.encode(), pcs.OptionListField.encode(), pcs.Packet.encode(), and pcs.Chain.encode().

Referenced by pcs.Chain.__div__().

def pcs.Chain.calc_checksums (   self)
Compute and store checksums for all packets in this chain,
   taking encapsulation into account.

   By default the packets are enumerated in reverse order
   to how they appear on the wire. This is how IETF-style
   protocols are normally dealt with; ITU-style protocols
   may require other quirks.

References pcs.Chain.packets.

Referenced by pcs.Chain.fixup().

def pcs.Chain.calc_lengths (   self)
Compute and store length fields for all packets in this chain,
   taking encapsulation into account. 

References pcs.Chain.packets.

Referenced by pcs.Chain.fixup().

def pcs.Chain.collate_following (   self,
  packet 
)
Given a packet which is part of this chain, return a string
   containing the bytes of all packets following it in this chain.
   Helper method used by Internet transport protocols.

References pcs.Chain.index_of(), and pcs.Chain.packets.

def pcs.Chain.contains (   self,
  packet 
)
If this chain contains a packet which matches the packet provided,
   return its index. Otherwise, return None.

   It is assumed that 'packet' contains any wildcard patterns;
   this is the logical reverse of Field.match() and Packet.match().
   A bitwise comparison is not performed; a structural match
   using the match() function is used instead.

References pcs.Chain.find_first_of().

def pcs.Chain.decode (   self,
  bytes 
)
Decode all the bytes of all the packets in a Chain into the underlying packets

References pcs.Chain.packets.

def pcs.Chain.encode (   self)
Encode all the packets in a chain into a set of bytes for the Chain

References pcs.Packet.bytes, pcs.Chain.bytes, and pcs.Chain.packets.

Referenced by pcs.Chain.__init__(), pcs.Chain.append(), pcs.Chain.fixup(), and pcs.Chain.insert_after().

def pcs.Chain.find_first_of (   self,
  ptype 
)
Find the first packet of type 'ptype' in this chain.
   Return a tuple (packet, index).

References pcs.Chain.packets.

Referenced by pcs.Chain.contains().

def pcs.Chain.find_preceding (   self,
  packet,
  ptype,
  adjacent = True 
)
Given a packet which is part of this chain, return a reference
   to a packet of the given type which precedes this packet,
   and its index in the chain, as a tuple.

   If the 'adjacent' argument is True, then the packet
   immediately preceding 'packet' must be an instance of type.
   Helper method used by Internet transport protocols.

References pcs.Chain.index_of(), and pcs.Chain.packets.

def pcs.Chain.fixup (   self)
def pcs.Chain.index_of (   self,
  packet 
)
Return the index of 'packet' in this chain.

References pcs.Chain.packets.

Referenced by pcs.Chain.collate_following(), and pcs.Chain.find_preceding().

def pcs.Chain.insert_after (   self,
  p1,
  p2,
  rdiscriminate = True 
)
Insert a packet into a chain after a given packet instance.
   Used only by the div operator. The default behaviour is to
   set discriminator fields in p1 based on p2.

References pcs.Field.encode(), pcs.StringField.encode(), pcs.LengthValueField.encode(), pcs.TypeValueField.encode(), pcs.TypeLengthValueField.encode(), pcs.OptionListField.encode(), pcs.Packet.encode(), pcs.Chain.encode(), and pcs.Chain.packets.

def pcs.Chain.matches (   self,
  chain 
)
Return True if this chain matches the chain provided.

   It is assumed that *this* chain contains any wildcard patterns.
   A strict size comparison is not performed.
   A bitwise comparison is not performed; a structural match
   using the match() function is used instead.

References pcs.Chain.packets.

def pcs.Chain.wildcard_mask (   self,
  unmask = True 
)
Mark or unmark all of the fields in each Packet in this Chain
   as a wildcard for match() or contains().

References pcs.Chain.packets.


The documentation for this class was generated from the following file: