1UTILS(3) utils 1.6 UTILS(3)
2
3
4
6 packet.utils - Pktt utilities module
7
9 The Packet trace utilities module has classes which augment functional‐
10 ity of basic data types like displaying integers as their hex equiva‐
11 lent. It also includes an Enum base class which displays the integer
12 as its string representation given by a mapping dictionary. There is
13 also a class to be used as a base class for an RPC payload object.
14 This module also includes some module variables to change how certain
15 objects are displayed.
16
18 class BitmapInval(builtins.Exception)
19 Exception for an invalid bit number
20
21
22 class ByteHex(builtins.int)
23 Byte integer object which is displayed in hex
24
25
26 Methods defined here:
27 ---------------------
28
29 __repr__ = __str__(self)
30
31 __str__(self)
32 Return str(self).
33
34 class DateStr(builtins.float)
35 Floating point object which is displayed as a date
36
37
38 Methods defined here:
39 ---------------------
40
41 __str__(self)
42 Return str(self).
43
44 class Enum(builtins.int)
45 Enum base object
46 This should only be used as a base class where the class attributes
47 should be initialized
48
49
50 Methods defined here:
51 ---------------------
52
53 __repr__(self)
54 Official string representation, display value using the mapping
55 dictionary provided as a class attribute when ENUM_REPR is False
56
57 __str__(self)
58 Informal string representation, display value using the mapping
59 dictionary provided as a class attribute
60
61 Static methods defined here:
62 ----------------------------
63
64 __new__(cls, unpack)
65 Constructor which checks if integer is a valid enum value
66
67 class EnumInval(builtins.Exception)
68 Exception for an invalid enum value
69
70
71 class IntHex(builtins.int)
72 Integer object which is displayed in hex
73
74
75 Methods defined here:
76 ---------------------
77
78 __repr__ = __str__(self)
79
80 __str__(self)
81 Return str(self).
82
83 class LongHex(builtins.int)
84 Long integer object which is displayed in hex
85
86
87 Methods defined here:
88 ---------------------
89
90 __repr__ = __str__(self)
91
92 __str__(self)
93 Return str(self).
94
95 class OptionFlags(baseobj.BaseObj)
96 OptionFlags base object
97
98 This base class is used to have a set of raw flags represented by an
99 integer and splits every bit into an object attribute according to the
100 class attribute _bitnames where the key is the bit number and the value
101 is the attribute name.
102
103 This should only be used as a base class where the class attribute
104 _bitnames should be initialized. The class attribute _reversed can
105 also be initialized to reverse the _bitnames so the first bit becomes
106 the last, e.g., _reversed = 31, bits are reversed on a 32 bit integer
107 so 0 becomes 31, 1 becomes 30, etc.
108
109 Usage:
110 from packet.utils import OptionFlags
111
112 class MyFlags(OptionFlags):
113 _bitnames = {0:"bit0", 1:"bit1", 2:"bit2", 3:"bit3"}
114
115 x = MyFlags(10) # 10 = 0b1010
116
117 The attributes of object are:
118 x.rawflags = 10, # Original raw flags
119 x.bit0 = 0,
120 x.bit1 = 1,
121 x.bit2 = 0,
122 x.bit3 = 1,
123
124
125 Methods defined here:
126 ---------------------
127
128 __init__(self, options)
129 Initialize object's private data.
130
131
132 options:
133 Unsigned integer of raw flags
134
135 str_flags(self)
136 Display the flag names which are set, e.g., in the above example
137 the output will be "bit1,bit3" (bit1=1, bit3=1)
138 Use "__str__ = OptionFlags.str_flags" to have it as the default
139 string representation
140
141 class RDMAbase(baseobj.BaseObj)
142 RDMA base object
143
144 Base class for an RDMA reduced payload object having RDMA write
145 chunks. An application having a DDP (direct data placement) item
146 must inherit this class and use the rdma_opaque method as a
147 dissecting function.
148
149 Usage:
150 from packet.utils import RDMAbase
151
152 # For an original class definition with DDP items
153 class APPobj(BaseObj):
154 def __init__(self, unpack):
155 self.test = nfs_bool(unpack)
156 self.data = unpack.unpack_opaque()
157
158 # Class definition to access RDMA chunk writes
159 class APPobj(RDMAbase):
160 def __init__(self, unpack):
161 self.test = self.rdma_opaque(nfs_bool, unpack)
162 self.data = self.rdma_opaque(unpack.unpack_opaque)
163
164
165 Methods defined here:
166 ---------------------
167
168 rdma_opaque(self, func, *kwts, **kwds)
169 Dissecting method for a DDP item
170 The first positional argument is the original dissecting
171 function to be called when there is no RDMA write chunks.
172 The rest of the arguments (positional or named) are passed
173 directly to the dissecting function.
174
175 Data and other attributes defined here:
176
177 rdma_write_chunks = []
178
179 class RPCload(baseobj.BaseObj)
180 RPC load base object
181 This is used as a base class for an RPC payload object
182
183
184 Methods defined here:
185 ---------------------
186
187 __str__(self)
188 Informal string representation
189
190 main_op(self)
191 Get the main NFS operation
192
193 rpc_str(self, name=None)
194 Display RPC string
195
196 class ShortHex(builtins.int)
197 Short integer object which is displayed in hex
198
199
200 Methods defined here:
201 ---------------------
202
203 __repr__ = __str__(self)
204
205 __str__(self)
206 Return str(self).
207
208 class StrHex(builtins.bytes)
209 String object which is displayed in hex
210
211
212 Methods defined here:
213 ---------------------
214
215 __str__(self)
216 Return str(self).
217
219 bitmap_info(unpack, bitmap, key_enum=None, func_map=None)
220 Returns a list of bits set on the bitmap or a dictionary where the
221 key is the bit number given by bitmap and the value is the decoded
222 value by evaluating the function used for that specific bit number
223
224
225 unpack:
226 Unpack object
227
228 bitmap:
229 Unsigned integer where a value must be decoded for every bit that
230 is set, starting from the least significant bit
231
232 key_enum:
233 Use Enum for bit number so the key could be displayed as the bit
234 name instead of the bit number [default: None]
235
236 func_map:
237 Dictionary which maps a bit number to the function to be used for
238 decoding the value for that bit number. The function must have
239 the "unpack" object as the only argument. If this is None a list
240 of bit attributes is returned instead [default: None]
241
243 baseobj(3), packet.unpack(3)
244
245
247 No known bugs.
248
250 Jorge Mora (mora@netapp.com)
251
252
253
254NFStest 3.2 21 March 2023 UTILS(3)