1UTILS(3)                           utils 1.3                          UTILS(3)
2
3
4

NAME

6       packet.utils - Pktt utilities module
7

DESCRIPTION

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

CLASSES

18   class BitmapInval(exceptions.Exception)
19       Exception for an invalid bit number
20
21
22   class DateStr(__builtin__.float)
23       Floating point object which is displayed as a date
24
25
26       Methods defined here:
27       ---------------------
28
29       __str__(self)
30
31   class Enum(__builtin__.int)
32       Enum base object
33       This should only be used as a base class where the class attributes
34       should be initialized
35
36
37       Methods defined here:
38       ---------------------
39
40       __str__(self)
41       Informal string representation, display value using the mapping
42       dictionary provided as a class attribute
43
44       Static methods defined here:
45       ----------------------------
46
47       __new__(cls, unpack)
48       Constructor which checks if integer is a valid enum value
49
50   class EnumInval(exceptions.Exception)
51       Exception for an invalid enum value
52
53
54   class IntHex(__builtin__.int)
55       Integer object which is displayed in hex
56
57
58       Methods defined here:
59       ---------------------
60
61       __repr__ = __str__(self)
62
63       __str__(self)
64
65   class LongHex(__builtin__.long)
66       Long integer object which is displayed in hex
67
68
69       Methods defined here:
70       ---------------------
71
72       __repr__ = __str__(self)
73
74       __str__(self)
75
76   class OptionFlags(baseobj.BaseObj)
77       OptionFlags base object
78
79       This base class is used to have a set of raw flags represented by an
80       integer and splits every bit into an object attribute according to the
81       class attribute _bitnames where the key is the bit number and the value
82       is the attribute name.
83
84       This should only be used as a base class where the class attribute
85       _bitnames should be initialized. The class attribute _reversed can
86       also be initialized to reverse the _bitnames so the first bit becomes
87       the last, e.g., _reversed = 31, bits are reversed on a 32 bit integer
88       so 0 becomes 31, 1 becomes 30, etc.
89
90       Usage:
91           from packet.utils import OptionFlags
92
93           class MyFlags(OptionFlags):
94               _bitnames = {0:"bit0", 1:"bit1", 2:"bit2", 3:"bit3"}
95
96           x = MyFlags(10) # 10 = 0b1010
97
98           The attributes of object are:
99               x.rawflags = 10, # Original raw flags
100               x.bit0     = 0,
101               x.bit1     = 1,
102               x.bit2     = 0,
103               x.bit3     = 1,
104
105
106       Methods defined here:
107       ---------------------
108
109       __init__(self, options)
110       Initialize object's private data.
111
112
113              options:
114                     Unsigned integer of raw flags
115
116       str_flags(self)
117       Display the flag names which are set, e.g., in the above example
118       the output will be "bit1,bit3" (bit1=1, bit3=1)
119       Use "__str__ = OptionFlags.str_flags" to have it as the default
120       string representation
121
122   class RPCload(baseobj.BaseObj)
123       RPC load base object
124       This is used as a base class for an RPC payload object
125
126
127       Methods defined here:
128       ---------------------
129
130       __str__(self)
131       Informal string representation
132
133       rpc_str(self, name=None)
134       Display RPC string
135
136   class ShortHex(__builtin__.int)
137       Short integer object which is displayed in hex
138
139
140       Methods defined here:
141       ---------------------
142
143       __repr__ = __str__(self)
144
145       __str__(self)
146
147   class StrHex(__builtin__.str)
148       String object which is displayed in hex
149
150
151       Methods defined here:
152       ---------------------
153
154       __str__(self)
155

FUNCTIONS

157   bitmap_dict(unpack, bitmap, func_map, name_map=None)
158       Returns  a  dictionary  where the key is the bit number given by bitmap
159       and the value is the decoded value by evaluating the function used  for
160       that specific bit number
161
162
163              unpack:
164                     Unpack object
165
166              bitmap:
167                     Unsigned  integer where a value must be decoded for every
168                     bit that is set, starting from the least significant bit
169
170              func_map:
171                     Dictionary which maps a bit number to the function to  be
172                     used  for  decoding  the  value  for that bit number. The
173                     function must have the "unpack" object as the only  argu‐
174                     ment
175
176              name_map:
177                     Dictionary which maps a bit number to a bit name. If this
178                     is given the resulting dictionary will have  a  bit  name
179                     for a key instead of the bit number
180

SEE ALSO

182       baseobj(3)
183
184

BUGS

186       No known bugs.
187

AUTHOR

189       Jorge Mora (mora@netapp.com)
190
191
192
193NFStest 2.1.5                  14 February 2017                       UTILS(3)
Impressum