Lines Matching refs:self
25 def __init__(self, attr_type, data, *values): argument
26 self._type = attr_type
28 self._data = struct.pack(data, *values)
30 self._data = data
32 def _dump(self): argument
33 hdr = struct.pack("HH", len(self._data) + 4, self._type)
34 length = len(self._data)
36 return hdr + self._data + b'\x00' * pad
38 def __repr__(self): argument
39 return '<Attr type %d, data "%s">' % (self._type, repr(self._data))
41 def u16(self): argument
42 return struct.unpack('H', self._data)[0]
43 def s16(self): argument
44 return struct.unpack('h', self._data)[0]
45 def u32(self): argument
46 return struct.unpack('I', self._data)[0]
47 def s32(self): argument
48 return struct.unpack('i', self._data)[0]
49 def str(self): argument
50 return self._data
51 def nulstr(self): argument
52 return self._data.split('\0')[0]
53 def nested(self): argument
54 return parse_attributes(self._data)
57 def __init__(self, attr_type, data): argument
58 Attr.__init__(self, attr_type, "%ds" % len(data), data)
61 def __init__(self, attr_type, data): argument
62 Attr.__init__(self, attr_type, "%dsB" % len(data), data, 0)
65 def __init__(self, attr_type, val): argument
66 Attr.__init__(self, attr_type, "I", val)
69 def __init__(self, attr_type, val): argument
70 Attr.__init__(self, attr_type, "B", val)
73 def __init__(self, attr_type): argument
74 Attr.__init__(self, attr_type, b"")
77 def __init__(self, attr_type, attrs): argument
78 self.attrs = attrs
79 self.type = attr_type
81 def _dump(self): argument
83 for attr in self.attrs:
87 hdr = struct.pack("HH", length+4, self.type)
109 def __init__(self, msg_type, flags=0, seq=-1, payload=None): argument
110 self.type = msg_type
111 self.flags = flags
112 self.seq = seq
113 self.pid = -1
116 self.payload = bytes()
118 self.payload += attr._dump()
120 self.payload = payload
122 def send(self, conn): argument
123 if self.seq == -1:
124 self.seq = conn.seq()
126 self.pid = conn.pid
127 length = len(self.payload)
129 hdr = struct.pack("IHHII", length + 4*4, self.type,
130 self.flags, self.seq, self.pid)
131 conn.send(hdr + self.payload)
133 def __repr__(self): argument
135 self.type, self.pid, self.seq, self.flags, repr(self.payload))
138 def ret(self): argument
139 assert self.type == NLMSG_ERROR
140 return struct.unpack("i", self.payload[:4])[0]
142 def send_and_recv(self, conn): argument
143 self.send(conn)
146 if m.seq == self.seq:
150 def __init__(self, nltype, groups=0, unexpected_msg_handler=None): argument
151 self.descriptor = socket.socket(socket.AF_NETLINK,
153 self.descriptor.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 65536)
154 self.descriptor.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 65536)
155 self.descriptor.bind((0, groups))
156 self.pid, self.groups = self.descriptor.getsockname()
157 self._seq = 0
158 self.unexpected = unexpected_msg_handler
159 def send(self, msg): argument
160 self.descriptor.send(msg)
161 def recv(self): argument
162 contents = self.descriptor.recv(16384)
178 def seq(self): argument
179 self._seq += 1
180 return self._seq
210 def __init__(self, cmd, version=0): argument
211 self.cmd = cmd
212 self.version = version
213 def _dump(self): argument
214 return struct.pack("BBxx", self.cmd, self.version)
222 def __init__(self, family, cmd, attrs=[], flags=0): argument
223 Message.__init__(self, family, flags=flags, payload=[GenlHdr(cmd)] + attrs)
226 def __init__(self, conn): argument
227 self.conn = conn
228 def get_family_id(self, family): argument
231 m.send(self.conn)
232 m = self.conn.recv()