PCS  0.4
Public Member Functions | Public Attributes
pcs.Connector Class Reference
Inheritance diagram for pcs.Connector:
pcs.IP4Connector pcs.IP6Connector pcs.PcapConnector pcs.PcapDumpConnector pcs.TapConnector pcs.SCTP4Connector pcs.TCP4Connector pcs.UDP4Connector pcs.SCTP6Connector pcs.TCP6Connector pcs.UDP6Connector pcs.UmlMcast4Connector

List of all members.

Public Member Functions

def __init__
def accept
def bind
def connect
def listen
def read
def poll_read
def read_packet
def read_chain
def try_read_n_chains
def write
def send
def sendto
def recv
def recvfrom
def close
def expect

Public Attributes

 matches
 match_index

Detailed Description

Connectors are a way of have a very generic socket like
mechanism over which the packets can be sent.  Unlike the current
split between sockets, which work OK down to almost the RAW layer,
and low level stuff like pcap and bpf, connectors will are a
unifying mechanism so you can write packets over any of the
available APIs and the connector will do the right thing.

The Connector class is a virtual base class upon which all the
real classes are based.

Member Function Documentation

def pcs.Connector.expect (   self,
  patterns = [],
  timeout = None,
  limit = None 
)
Read from the Connector and return the index of the
   first pattern which matches the input chain; otherwise,
   raise an exception.

   On return, the matches property will contain a list of matching
   packet chain(s). There may be more than one match if a live
   capture matches more than one before the loop exits.

    * If the 'limit' argument is set, raise an exception after 'limit'
      packets have been read, regardless of match.
    * If 'timeout' is set, raise an exception after the
      timeout expires. This is only supported if the underlying
      Connector fully implements non-blocking I/O.

   The syntax is intentionally similar to that of pexpect:
    * If any of EOF, LIMIT or TIMEOUT are specified, the exceptions
      are not raised but are instead matched as patterns.
    * If a Chain is specified, it is matched against
      the chain using the Chain.match() method.
    * If neither a timeout or a limit is specified, or an EOF
      was not encountered, this function may potentially block forever.
    * NOTE: Packets can no longer be specified on their own as filters.

   TODO: Make this drift and jitter robust (CLOCK_MONOTONIC).

Reimplemented in pcs.TapConnector, and pcs.PcapConnector.

References pcs.Connector.match_index, pcs.Connector.matches, pcs.Connector.poll_read(), and pcs.Connector.try_read_n_chains().

def pcs.Connector.poll_read (   self,
  timeout 
)
Poll the underlying I/O layer for a read.
   Return TIMEOUT if the timeout was reached.

Reimplemented in pcs.UmlMcast4Connector, pcs.TapConnector, and pcs.PcapConnector.

Referenced by pcs.Connector.expect().

def pcs.Connector.read_chain (   self)
Read the next available packet and attempt to decapsulate
   all available layers of encapsulation into Python objects.
   If the underlying packet parsers throw an exception, it
   will propagate here.

References pcs.Connector.read_packet().

def pcs.Connector.read_packet (   self)
Read a packet from the underlying I/O layer, and return
   an instance of a class derived from pcs.Packet appropriate
   to the data-link or transport layer in use.
   If the Connector has multiple data-link layer support, then
   the type returned by this method may vary.
   If the underlying packet parsers throw an exception, it
   will propagate here. 

Reimplemented in pcs.IP6Connector, pcs.UmlMcast4Connector, pcs.IP4Connector, pcs.TapConnector, and pcs.PcapConnector.

Referenced by pcs.Connector.read_chain(), pcs.PcapConnector.read_packet(), pcs.TapConnector.read_packet(), pcs.UmlMcast4Connector.read_packet(), and pcs.Connector.try_read_n_chains().

def pcs.Connector.try_read_n_chains (   self,
  n 
)
Try to read at most n packet chains from the underlying
   I/O layer. If n is None or 0, try to read exactly one packet.
   Connectors with their own buffering semantics should override
   this method (e.g. PcapConnector). Used by expect().

Reimplemented in pcs.TapConnector, and pcs.PcapConnector.

References pcs.Connector.read_packet().

Referenced by pcs.Connector.expect().


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