Lines Matching full:self

12     def __init__(self, nla_type, data):  argument
14 self._nla_type = nla_type.value
15 self._enum = nla_type
17 self._nla_type = nla_type
18 self._enum = None
19 self.nla_list = []
20 self._data = data
23 def nla_type(self): argument
24 return self._nla_type & 0x3FFF
27 def nla_len(self): argument
28 return len(self._data) + 4
30 def add_nla(self, nla): argument
31 self.nla_list.append(nla)
33 def print_attr(self, prepend=""): argument
34 if self._enum is not None:
35 type_str = self._enum.name
37 type_str = "nla#{}".format(self.nla_type)
40 prepend, self.nla_len, type_str, self.nla_type, self._print_attr_value()
66 def _to_bytes(self, data: bytes): argument
70 return struct.pack("@HH", len(data) + 4, self._nla_type) + ret
72 def __bytes__(self): argument
73 return self._to_bytes(self._data)
75 def _print_attr_value(self): argument
76 return " " + " ".join(["x{:02X}".format(b) for b in self._data])
80 def __init__(self, nla_type, val): argument
82 self.nla_list = val
84 def get_nla(self, nla_type): argument
86 for nla in self.nla_list:
92 def nla_len(self): argument
93 return align4(len(b"".join([bytes(nla) for nla in self.nla_list]))) + 4
95 def print_attr(self, prepend=""): argument
96 if self._enum is not None:
97 type_str = self._enum.name
99 type_str = "nla#{}".format(self.nla_type)
102 prepend, self.nla_len, type_str, self.nla_type
105 for nla in self.nla_list:
109 def __bytes__(self): argument
110 return self._to_bytes(b"".join([bytes(nla) for nla in self.nla_list]))
114 def __init__(self, nla_type, val): argument
115 self.u32 = enum_or_int(val)
119 def nla_len(self): argument
122 def _print_attr_value(self): argument
123 return " val={}".format(self.u32)
136 def __bytes__(self): argument
137 return self._to_bytes(struct.pack("@I", self.u32))
141 def __init__(self, nla_type, val): argument
142 self.s32 = enum_or_int(val)
146 def nla_len(self): argument
149 def _print_attr_value(self): argument
150 return " val={}".format(self.s32)
163 def __bytes__(self): argument
164 return self._to_bytes(struct.pack("@i", self.s32))
168 def __init__(self, nla_type, val): argument
169 self.u16 = enum_or_int(val)
173 def nla_len(self): argument
176 def _print_attr_value(self): argument
177 return " val={}".format(self.u16)
190 def __bytes__(self): argument
191 return self._to_bytes(struct.pack("@H", self.u16))
195 def __init__(self, nla_type, val): argument
196 self.u8 = enum_or_int(val)
200 def nla_len(self): argument
203 def _print_attr_value(self): argument
204 return " val={}".format(self.u8)
217 def __bytes__(self): argument
218 return self._to_bytes(struct.pack("@B", self.u8))
222 def __init__(self, nla_type, addr: str): argument
224 self.addr = addr
225 if ":" in self.addr:
226 self.family = socket.AF_INET6
228 self.family = socket.AF_INET
242 def nla_len(self): argument
243 if self.family == socket.AF_INET6:
247 return align4(len(self._data)) + 4
259 def __bytes__(self): argument
260 return self._to_bytes(socket.inet_pton(self.family, self.addr))
262 def _print_attr_value(self): argument
263 return " addr={}".format(self.addr)
267 def __init__(self, nla_type, addr: str): argument
269 assert self.family == socket.AF_INET
273 def __init__(self, nla_type, addr: str): argument
275 assert self.family == socket.AF_INET6
279 def __init__(self, nla_type, text): argument
281 self.text = text
292 def nla_len(self): argument
293 return len(self.text) + 5
301 def __bytes__(self): argument
302 return self._to_bytes(bytes(self.text, encoding="utf-8") + bytes(1))
304 def _print_attr_value(self): argument
305 return ' val="{}"'.format(self.text)
309 def __init__(self, nla_type, text): argument
311 self.text = text
322 def nla_len(self): argument
323 return len(self.text) + 4
331 def __bytes__(self): argument
332 return self._to_bytes(bytes(self.text, encoding="utf-8"))
334 def _print_attr_value(self): argument
335 return ' val="{}"'.format(self.text)