Lines Matching full:self
57 def __init__(self, obj_type): argument
59 self.obj_type = obj_type.value
60 self._enum = obj_type
62 self.obj_type = obj_type
63 self._enum = enum_from_int(self.obj_enum_class, obj_type)
64 self.obj_list = []
66 def add_obj(self, obj): argument
67 self.obj_list.append(obj)
70 def len(self): argument
71 return len(bytes(self))
74 def obj_name(self): argument
75 if self._enum is not None:
76 return self._enum.name
78 return "tlv#{}".format(self.obj_type)
80 def print_hdr(self, prepend=""): argument
83 prepend, self.len, self.obj_name, self.obj_type, self._print_obj_value()
87 def print_obj(self, prepend=""): argument
88 self.print_hdr(prepend)
90 for obj in self.obj_list:
93 def print_obj_hex(self, prepend=""): argument
96 print(" ".join(["x{:02X}".format(b) for b in bytes(self)]))
117 def __bytes__(self): argument
120 def _print_obj_value(self): argument
122 ["x{:02X}".format(b) for b in self._data[sizeof(IpFwObjTlv) :]]
125 def as_hexdump(self): argument
126 return " ".join(["x{:02X}".format(b) for b in bytes(self)])
130 def __init__(self, obj_type, data): argument
132 self._data = data
145 self = cls(hdr.n_type, data)
146 return self
148 def __bytes__(self): argument
149 return self._data
191 def __init__(self, obj_type, idx=0, n_set=0, n_type=0, name=None): argument
193 self.n_idx = idx
194 self.n_set = n_set
195 self.n_type = n_type
196 self.n_name = name
210 self = cls(hdr.head.n_type, hdr.idx, hdr.n_set, hdr.n_type, name)
211 return self
213 def __bytes__(self): argument
214 name_bytes = self.n_name.encode("utf-8")
218 head=IpFwObjTlv(n_type=self.obj_type, length=sizeof(IpFwObjNTlv)),
219 idx=self.n_idx,
220 n_set=self.n_set,
221 n_type=self.n_type,
226 def _print_obj_value(self): argument
228 self.n_type, self.n_set, self.n_idx, self.n_name
243 def __init__(self, obj_type, obj_list=[]): argument
246 self.obj_list.extend(obj_list)
262 self = cls(hdr.head.n_type, obj_list=tlv_list)
263 return self
265 def __bytes__(self): argument
267 for obj in self.obj_list:
270 if self.obj_list:
271 objsize = len(bytes(self.obj_list[0]))
275 head=IpFwObjTlv(n_type=self.obj_type, length=sizeof(IpFwObjNTlv)),
276 count=len(self.obj_list),
281 def _print_obj_value(self): argument
298 def __init__(self, obj_type=0, n_set=0, rulenum=0, obj_list=[]): argument
300 self.n_set = n_set
301 self.rulenum = rulenum
303 self.obj_list.extend(obj_list)
317 self = cls(
322 return self
324 def __bytes__(self): argument
328 for obj in self.obj_list:
338 n_set=self.n_set,
339 rulenum=self.rulenum,
344 def obj_name(self): argument
345 return "rule#{}".format(self.rulenum)
347 def _print_obj_value(self): argument
348 cmd_len = sum([len(bytes(obj)) for obj in self.obj_list]) // 4
349 return " set={} cmd_len={}".format(self.n_set, cmd_len)
353 def __init__(self, obj_type=IpFwTlvType.IPFW_TLV_RULE_LIST, obj_list=[]): argument
376 def __bytes__(self): argument
378 for rule in self.obj_list:
386 n_type=self.obj_type, length=len(ret) + sizeof(IpFwObjCTlv)
388 count=len(self.obj_list),
396 def __init__(self, msg_type, obj_list=[]): argument
398 self.obj_type = msg_type.value
399 self._enum = msg_type
401 self.obj_type = msg_type
402 self._enum = enum_from_int(self.messages, self.obj_type)
403 self.obj_list = []
405 self.obj_list.extend(obj_list)
407 def add_obj(self, obj): argument
408 self.obj_list.append(obj)
410 def get_obj(self, obj_type): argument
412 for obj in self.obj_list:
423 def parse_obj_list(self, data: bytes): argument
432 self.add_obj(tlv)
435 def is_type(self, msg_type): argument
436 return enum_or_int(msg_type) == self.msg_type
439 def obj_name(self): argument
440 if self._enum is not None:
441 return self._enum.name
443 return "msg#{}".format(self.obj_type)
445 def print_hdr(self, prepend=""): argument
446 print("{}len={}, type={}".format(prepend, len(bytes(self)), self.obj_name))
452 self = cls(hdr.opcode)
453 self._orig_data = data
458 tlv_list = Tlv.parse_tlvs(data[hdrlen:], self.attr_map)
459 self.obj_list.extend(tlv_list)
460 return self
462 def __bytes__(self): argument
463 ret = bytes(IpFw3OpHeader(opcode=self.obj_type))
464 for obj in self.obj_list:
468 def print_obj(self): argument
469 self.print_hdr()
470 for obj in self.obj_list: