packet.utils man page

packet.utils ā€” Pktt utilities module

Description

The Packet trace utilities module has classes which augment functionality of basic data types like displaying integers as their hex equivalent. It also includes an Enum base class which displays the integer as its string representation given by a mapping dictionary. There is also a class to be used as a base class for an RPC payload object. This module also includes some module variables to change how certain objects are displayed.

Classes

class BitmapInval(exceptions.Exception)

Exception for an invalid bit number

class DateStr(__builtin__.float)

Floating point object which is displayed as a date


Methods defined here:
---------------------

__str__(self)

class Enum(__builtin__.int)

Enum base object
This should only be used as a base class where the class attributes
should be initialized


Methods defined here:
---------------------

__str__(self)
Informal string representation, display value using the mapping
dictionary provided as a class attribute

Static methods defined here:
----------------------------

__new__(cls, unpack)
Constructor which checks if integer is a valid enum value

class EnumInval(exceptions.Exception)

Exception for an invalid enum value

class IntHex(__builtin__.int)

Integer object which is displayed in hex


Methods defined here:
---------------------

__repr__ = __str__(self)

__str__(self)

class LongHex(__builtin__.long)

Long integer object which is displayed in hex


Methods defined here:
---------------------

__repr__ = __str__(self)

__str__(self)

class OptionFlags(baseobj.BaseObj)

OptionFlags base object

This base class is used to have a set of raw flags represented by an
integer and splits every bit into an object attribute according to the
class attribute _bitnames where the key is the bit number and the value
is the attribute name.

This should only be used as a base class where the class attribute
_bitnames should be initialized. The class attribute _reversed can
also be initialized to reverse the _bitnames so the first bit becomes
the last, e.g., _reversed = 31, bits are reversed on a 32 bit integer
so 0 becomes 31, 1 becomes 30, etc.

Usage:
    from packet.utils import OptionFlags

    class MyFlags(OptionFlags):
        _bitnames = {0:"bit0", 1:"bit1", 2:"bit2", 3:"bit3"}

    x = MyFlags(10) # 10 = 0b1010

    The attributes of object are:
        x.rawflags = 10, # Original raw flags
        x.bit0     = 0,
        x.bit1     = 1,
        x.bit2     = 0,
        x.bit3     = 1,


Methods defined here:
---------------------

__init__(self, options)
Initialize object's private data.

        options:
    Unsigned integer of raw flags

str_flags(self)
Display the flag names which are set, e.g., in the above example
the output will be "bit1,bit3" (bit1=1, bit3=1)
Use "__str__ = OptionFlags.str_flags" to have it as the default
string representation

class RPCload(baseobj.BaseObj)

RPC load base object
This is used as a base class for an RPC payload object


Methods defined here:
---------------------

__str__(self)
Informal string representation

rpc_str(self, name=None)
Display RPC string

class ShortHex(__builtin__.int)

Short integer object which is displayed in hex


Methods defined here:
---------------------

__repr__ = __str__(self)

__str__(self)

class StrHex(__builtin__.str)

String object which is displayed in hex


Methods defined here:
---------------------

__str__(self)

Functions

bitmap_dict(unpack, bitmap, func_map, name_map=None)

Returns a dictionary where the key is the bit number given by bitmap and the value is the decoded value by evaluating the function used for that specific bit number

unpack:

Unpack object

bitmap:

Unsigned integer where a value must be decoded for every bit that is set, starting from the least significant bit

func_map:

Dictionary which maps a bit number to the function to be used for decoding the value for that bit number. The function must have the "unpack" object as the only argument

name_map:

Dictionary which maps a bit number to a bit name. If this is given the resulting dictionary will have a bit name for a key instead of the bit number

See Also

baseobj(3)

Bugs

No known bugs.

Author

Jorge Mora (mora@netapp.com)

Referenced By

nfstest_file(1), nfstest_pkt(1), nfstest_xid(1), packet.application.dns(3), packet.application.gss(3), packet.application.krb5(3), packet.application.ntp4(3), packet.application.rpc(3), packet.application.rpc_creds(3), packet.internet.arp(3), packet.internet.ipv4(3), packet.nfs.mount3(3), packet.nfs.nfs(3), packet.nfs.nfs3(3), packet.nfs.nfs4(3), packet.nfs.nfsbase(3), packet.nfs.nlm4(3), packet.nfs.portmap2(3), packet.transport.tcp(3), packet.transport.udp(3).

14 February 2017 NFStest 2.1.5 utils 1.3