.\" DO NOT MODIFY THIS FILE! It was generated by setup.py 1.2. .TH UTILS 3 "21 March 2023" "NFStest 3.2" "utils 1.6" .SH NAME packet.utils - Pktt utilities module .SH 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. .SH CLASSES .SS class BitmapInval(builtins.Exception) .nf Exception for an invalid bit number .fi .SS class ByteHex(builtins.int) .nf Byte integer object which is displayed in hex .P .B Methods defined here: --------------------- .P .B __repr__ = __str__(self) .P .B __str__(self) Return str(self). .fi .SS class DateStr(builtins.float) .nf Floating point object which is displayed as a date .P .B Methods defined here: --------------------- .P .B __str__(self) Return str(self). .fi .SS class Enum(builtins.int) .nf Enum base object This should only be used as a base class where the class attributes should be initialized .P .B Methods defined here: --------------------- .P .B __repr__(self) Official string representation, display value using the mapping dictionary provided as a class attribute when ENUM_REPR is False .P .B __str__(self) Informal string representation, display value using the mapping dictionary provided as a class attribute .P .B Static methods defined here: ---------------------------- .P .B __new__(cls, unpack) Constructor which checks if integer is a valid enum value .fi .SS class EnumInval(builtins.Exception) .nf Exception for an invalid enum value .fi .SS class IntHex(builtins.int) .nf Integer object which is displayed in hex .P .B Methods defined here: --------------------- .P .B __repr__ = __str__(self) .P .B __str__(self) Return str(self). .fi .SS class LongHex(builtins.int) .nf Long integer object which is displayed in hex .P .B Methods defined here: --------------------- .P .B __repr__ = __str__(self) .P .B __str__(self) Return str(self). .fi .SS class OptionFlags(baseobj.BaseObj) .nf 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, .P .B Methods defined here: --------------------- .P .B __init__(self, options) Initialize object's private data. .RS .TP .B options: Unsigned integer of raw flags .RE .P .B 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 .fi .SS class RDMAbase(baseobj.BaseObj) .nf RDMA base object Base class for an RDMA reduced payload object having RDMA write chunks. An application having a DDP (direct data placement) item must inherit this class and use the rdma_opaque method as a dissecting function. Usage: from packet.utils import RDMAbase # For an original class definition with DDP items class APPobj(BaseObj): def __init__(self, unpack): self.test = nfs_bool(unpack) self.data = unpack.unpack_opaque() # Class definition to access RDMA chunk writes class APPobj(RDMAbase): def __init__(self, unpack): self.test = self.rdma_opaque(nfs_bool, unpack) self.data = self.rdma_opaque(unpack.unpack_opaque) .P .B Methods defined here: --------------------- .P .B rdma_opaque(self, func, *kwts, **kwds) Dissecting method for a DDP item The first positional argument is the original dissecting function to be called when there is no RDMA write chunks. The rest of the arguments (positional or named) are passed directly to the dissecting function. Data and other attributes defined here: rdma_write_chunks = [] .fi .SS class RPCload(baseobj.BaseObj) .nf RPC load base object This is used as a base class for an RPC payload object .P .B Methods defined here: --------------------- .P .B __str__(self) Informal string representation .P .B main_op(self) Get the main NFS operation .P .B rpc_str(self, name=None) Display RPC string .fi .SS class ShortHex(builtins.int) .nf Short integer object which is displayed in hex .P .B Methods defined here: --------------------- .P .B __repr__ = __str__(self) .P .B __str__(self) Return str(self). .fi .SS class StrHex(builtins.bytes) .nf String object which is displayed in hex .P .B Methods defined here: --------------------- .P .B __str__(self) Return str(self). .fi .SH FUNCTIONS .nf .B bitmap_info(unpack, bitmap, key_enum=None, func_map=None) Returns a list of bits set on the bitmap or 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 .RS .TP .B unpack: Unpack object .TP .B bitmap: Unsigned integer where a value must be decoded for every bit that is set, starting from the least significant bit .TP .B key_enum: Use Enum for bit number so the key could be displayed as the bit name instead of the bit number [default: None] .TP .B 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. If this is None a list of bit attributes is returned instead [default: None] .RE .SH SEE ALSO .BR baseobj(3), .BR packet.unpack(3) .SH BUGS No known bugs. .SH AUTHOR Jorge Mora (mora@netapp.com)