]>
Commit | Line | Data |
---|---|---|
39236c6e A |
1 | |
2 | """ Please make sure you read the README COMPLETELY BEFORE reading anything below. | |
3 | It is very critical that you read coding guidelines in Section E in README file. | |
4 | """ | |
5 | ||
6 | from xnu import * | |
7 | from utils import * | |
8 | from string import * | |
9 | from socket import * | |
10 | ||
11 | import xnudefines | |
12 | from netdefines import * | |
13 | from routedefines import * | |
14 | ||
15 | def GetIfFlagsAsString(if_flags): | |
16 | """ Return a formatted string description of the interface flags | |
17 | """ | |
18 | out_string = "" | |
19 | flags = (unsigned)(if_flags & 0xffff) | |
20 | i = 0 | |
21 | num = 1 | |
22 | while num <= flags: | |
23 | if flags & num: | |
24 | out_string += if_flags_strings[i] + "," | |
25 | i += 1 | |
26 | num = num << 1 | |
27 | return rstrip(out_string, ",") | |
28 | ||
29 | ||
30 | def ShowIfConfiguration(ifnet): | |
31 | """ Display ifconfig-like output for the ifnet | |
32 | """ | |
33 | iface = Cast(ifnet, 'ifnet *') | |
34 | out_string = "" | |
35 | format_string = "{0: <s}: flags={1: <x} <{2: <s}> index {3: <d} mtu {4: <d}" | |
36 | if iface : | |
37 | out_string += format_string.format(iface.if_xname, (iface.if_flags & 0xffff), GetIfFlagsAsString(iface.if_flags), iface.if_index, iface.if_data.ifi_mtu) | |
38 | out_string += "\n\t(struct ifnet *)" + hex(ifnet) | |
39 | print out_string | |
40 | ||
41 | def GetIfConfiguration(ifname): | |
42 | """ Return ifnet structure corresponding to the ifname passed in | |
43 | """ | |
44 | global kern | |
45 | ifnets = kern.globals.ifnet_head | |
46 | for ifnet in IterateTAILQ_HEAD(ifnets, "if_link") : | |
47 | if str(ifnet.if_xname) == ifname : | |
48 | return ifnet | |
49 | return None | |
50 | ||
51 | # Macro: ifconfig | |
52 | @lldb_command('ifconfig') | |
53 | def ShowIfconfig(cmd_args=None) : | |
54 | """ Display ifconfig-like output, and print the (struct ifnet *) pointers for further inspection | |
55 | """ | |
56 | if cmd_args != None and len(cmd_args) > 0: | |
57 | showall = 1 | |
58 | else: | |
59 | showall = 0 | |
60 | ||
61 | ifnets = kern.globals.ifnet_head | |
62 | for ifnet in IterateTAILQ_HEAD(ifnets, "if_link"): | |
63 | ShowIfConfiguration(ifnet) | |
64 | if (showall == 1): | |
65 | print GetIfaddrs(ifnet) | |
66 | # EndMacro: ifconfig | |
67 | ||
68 | def GetAddressAsStringColonHex(addr, count): | |
69 | out_string = "" | |
70 | i = 0 | |
71 | addr_format_string = "{0:02x}" | |
72 | while (i < count): | |
73 | if (i == 0): | |
74 | out_string += addr_format_string.format(addr[i])[-2:] | |
75 | else: | |
76 | out_string += ":" + addr_format_string.format(addr[i])[-2:] | |
77 | i += 1 | |
78 | return out_string | |
79 | ||
80 | def GetSocketAddrAsStringUnspec(sockaddr): | |
81 | out_string = "" | |
82 | out_string += GetAddressAsStringColonHex(sockaddr.sa_data, sockaddr.sa_len - 2) | |
83 | return out_string | |
84 | ||
85 | def GetSocketAddrAsStringUnix(sockaddr): | |
86 | sock_unix = Cast(sockaddr, 'sockaddr_un *') | |
87 | if (sock_unix == 0): | |
88 | return "(null)" | |
89 | else: | |
90 | if (len(str(sock_unix.sun_path)) > 0): | |
91 | return str(sock_unix.sun_path) | |
92 | else: | |
93 | return "\"\"" | |
94 | ||
95 | def GetInAddrAsString(ia): | |
96 | out_string = "" | |
97 | inaddr = Cast(ia, 'in_addr *') | |
98 | ||
99 | packed_value = struct.pack('I', unsigned(ia.s_addr)) | |
100 | out_string = inet_ntoa(packed_value) | |
101 | return out_string | |
102 | ||
103 | def GetIn6AddrAsString(ia): | |
104 | out_string = "" | |
105 | addr = ia | |
106 | ||
107 | addr_format_string = "{0:02x}:{1:02x}:{2:02x}:{3:02x}{4:02x}:{5:02x}:{6:02x}:{7:02x}{8:02x}:{9:02x}:{10:02x}:{11:02x}{12:02x}:{13:02x}:{14:02x}:{15:02x}" | |
108 | out_string += addr_format_string.format(unsigned(addr[0]), unsigned(addr[1]), unsigned(addr[2]), unsigned(addr[3]), unsigned(addr[4]), unsigned(addr[5]), unsigned(addr[6]), unsigned(addr[7]), unsigned(addr[8]), unsigned(addr[9]), unsigned(addr[10]), unsigned(addr[11]), unsigned(addr[12]), unsigned(addr[13]), unsigned(addr[14]), unsigned(addr[15])) | |
109 | return out_string | |
110 | ||
111 | def GetSocketAddrAsStringInet(sockaddr): | |
112 | sock_in = Cast(sockaddr, 'sockaddr_in *') | |
113 | return GetInAddrAsString(sock_in.sin_addr) | |
114 | ||
115 | def GetSocketAddrAsStringInet6(sockaddr): | |
116 | sock_in6 = Cast(sockaddr, 'sockaddr_in6 *') | |
117 | return GetIn6AddrAsString(sock_in6.sin6_addr.__u6_addr.__u6_addr8) | |
118 | ||
119 | def GetSocketAddrAsStringLink(sockaddr): | |
120 | sock_link = Cast(sockaddr, 'sockaddr_dl *') | |
121 | if sock_link is None: | |
122 | return "(null)" | |
123 | else: | |
124 | out_string = "" | |
125 | if (sock_link.sdl_nlen == 0 and sock_link.sdl_alen == 0 and sock_link.sdl_slen == 0): | |
126 | out_string = "link#" + str(int(sock_link.sdl_index)) | |
127 | else: | |
128 | out_string += GetAddressAsStringColonHex(addressof(sock_link.sdl_data[sock_link.sdl_nlen]), sock_link.sdl_alen) | |
129 | return out_string | |
130 | ||
131 | def GetSocketAddrAsStringAT(sockaddr): | |
132 | out_string = "" | |
133 | sock_addr = Cast(sockaddr, 'sockaddr *') | |
134 | out_string += GetAddressAsStringColonHex(sockaddr.sa_data, sockaddr.sa_len - 2) | |
135 | return out_string | |
136 | ||
137 | def GetSocketAddrAsString(sockaddr): | |
138 | if sockaddr is None : | |
139 | return "(null)" | |
140 | out_string = "" | |
141 | if (sockaddr.sa_family == 0): | |
142 | out_string += "UNSPC " | |
143 | GetSocketAddrAsStringUnspec(sockaddr) | |
144 | elif (sockaddr.sa_family == 1): | |
145 | out_string += "UNIX " | |
146 | out_string += GetSocketAddrAsStringUnix(sockaddr) | |
147 | elif (sockaddr.sa_family == 2): | |
148 | out_string += "INET " | |
149 | out_string += GetSocketAddrAsStringInet(sockaddr) | |
150 | elif (sockaddr.sa_family == 30): | |
151 | out_string += "INET6 " | |
152 | out_string += GetSocketAddrAsStringInet6(sockaddr) | |
153 | elif (sockaddr.sa_family == 18): | |
154 | out_string += "LINK " | |
155 | out_string += GetSocketAddrAsStringLink(sockaddr) | |
156 | elif (sockaddr.sa_family == 16): | |
157 | out_string += "ATLK " | |
158 | out_string += GetSocketAddrAsStringAT(sockaddr) | |
159 | else: | |
160 | out_string += "FAM " + str(sockaddr.sa_family) | |
161 | out_string += GetAddressAsStringColonHex(sockaddr.sa_data, sockaddr.sa_len) | |
162 | return out_string | |
163 | ||
164 | # Macro: showifaddrs | |
165 | @lldb_command('showifaddrs') | |
166 | def ShowIfaddrs(cmd_args=None): | |
167 | """ Show the (struct ifnet).if_addrhead list of addresses for the given ifp | |
168 | """ | |
169 | if cmd_args != None and len(cmd_args) > 0 : | |
170 | ifp = kern.GetValueFromAddress(cmd_args[0], 'ifnet *') | |
171 | if not ifp: | |
172 | print "Unknown value passed as argument." | |
173 | return | |
174 | i = 1 | |
175 | for ifaddr in IterateTAILQ_HEAD(ifp.if_addrhead, "ifa_link"): | |
176 | format_string = "\t{0: <d}: 0x{1: <x} {2: <s} [{3: <d}]" | |
177 | print format_string.format(i, ifaddr, GetSocketAddrAsString(ifaddr.ifa_addr), ifaddr.ifa_refcnt) | |
178 | i += 1 | |
179 | else : | |
180 | print "Missing argument 0 in user function." | |
181 | # EndMacro: showifaddrs | |
182 | ||
183 | def GetIfaddrs(ifp): | |
184 | out_string = "" | |
185 | if (ifp != 0): | |
186 | i = 1 | |
187 | for ifaddr in IterateTAILQ_HEAD(ifp.if_addrhead, "ifa_link"): | |
188 | format_string = "\t{0: <d}: 0x{1: <x} {2: <s} [{3: <d}]" | |
189 | out_string += format_string.format(i, ifaddr, GetSocketAddrAsString(ifaddr.ifa_addr), ifaddr.ifa_refcnt) + "\n" | |
190 | i += 1 | |
191 | else: | |
192 | out_string += "Missing argument 0 in user function." | |
193 | return out_string | |
194 | ||
195 | ||
196 | def GetCapabilitiesAsString(flags): | |
197 | """ Return a formatted string description of the interface flags | |
198 | """ | |
199 | out_string = "" | |
200 | i = 0 | |
201 | num = 1 | |
202 | while num <= flags: | |
203 | if flags & num: | |
204 | out_string += if_capenable_strings[i] + "," | |
205 | i += 1 | |
206 | num = num << 1 | |
207 | return rstrip(out_string, ",") | |
208 | ||
209 | def GetIfEflagsAsString(if_eflags): | |
210 | """ Return a formatted string description of the interface flags | |
211 | """ | |
212 | out_string = "" | |
213 | flags = unsigned(if_eflags) | |
214 | i = 0 | |
215 | num = 1 | |
216 | while num <= flags: | |
217 | if flags & num: | |
218 | out_string += if_eflags_strings[i] + "," | |
219 | i += 1 | |
220 | num = num << 1 | |
221 | return rstrip(out_string, ",") | |
222 | ||
223 | def ShowDlilIfnetConfiguration(dlil_ifnet, show_all) : | |
224 | """ Formatted display of dlil_ifnet structures | |
225 | """ | |
226 | DLIF_INUSE = 0x1 | |
227 | DLIF_REUSE = 0x2 | |
228 | ||
229 | if dlil_ifnet is None : | |
230 | return | |
231 | ||
232 | dlil_iface = Cast(dlil_ifnet, 'dlil_ifnet *') | |
233 | iface = Cast(dlil_ifnet, 'ifnet *') | |
234 | out_string = "" | |
235 | if (dlil_iface.dl_if_flags & DLIF_REUSE) : | |
236 | out_string += "*" | |
237 | format_string = "{0: <s}: flags={1: <x} <{2: <s}> index {3: <d} mtu {4: <d}" | |
238 | extended_flags_format_string = "\n\teflags={0: <x} <{1: <s}>" | |
239 | capenabled_format_string = "\n\toptions={0: <x} <{1: <s}>" | |
240 | if (dlil_iface.dl_if_flags & DLIF_INUSE) : | |
241 | out_string += format_string.format(iface.if_xname, (iface.if_flags & 0xffff), GetIfFlagsAsString(iface.if_flags), iface.if_index, iface.if_data.ifi_mtu) | |
242 | else : | |
243 | out_string += format_string.format("[" + str(iface.if_name) + str(int(iface.if_unit)) + "]", (iface.if_flags & 0xffff), GetIfFlagsAsString(iface.if_flags), iface.if_index, iface.if_data.ifi_mtu) | |
244 | if (iface.if_eflags) : | |
245 | out_string += extended_flags_format_string.format(iface.if_eflags, GetIfEflagsAsString(iface.if_eflags)) | |
246 | if (iface.if_capenable) : | |
247 | out_string += capenabled_format_string.format(iface.if_capenable, GetCapabilitiesAsString(iface.if_capenable)) | |
248 | out_string += "\n\t(struct ifnet *)" + hex(dlil_ifnet) + "\n" | |
249 | if show_all : | |
250 | out_string += GetIfaddrs(iface) | |
251 | out_string += "\n" | |
252 | print out_string | |
253 | ||
254 | # Macro: showifnets | |
255 | @lldb_command('showifnets') | |
256 | def ShowIfnets(cmd_args=None) : | |
257 | """ Display ifconfig-like output for all attached and detached interfaces | |
258 | """ | |
259 | showall = 0 | |
260 | if cmd_args != None and len(cmd_args) > 0 : | |
261 | showall = 1 | |
262 | dlil_ifnets = kern.globals.dlil_ifnet_head | |
263 | for dlil_ifnet in IterateTAILQ_HEAD(dlil_ifnets, "dl_if_link"): | |
264 | ShowDlilIfnetConfiguration(dlil_ifnet, showall) | |
265 | # EndMacro: showifnets | |
266 | ||
267 | # Macro: showifmultiaddrs | |
268 | @lldb_command('showifmultiaddrs') | |
269 | def ShowIfMultiAddrs(cmd_args=None) : | |
270 | """ Show the list of multicast addresses for the given ifp | |
271 | """ | |
272 | out_string = "" | |
273 | if cmd_args != None and len(cmd_args) > 0 : | |
274 | ifp = kern.GetValueFromAddress(cmd_args[0], 'ifnet *') | |
275 | if not ifp: | |
276 | print "Unknown value passed as argument." | |
277 | return | |
278 | ifmulti = cast(ifp.if_multiaddrs.lh_first, 'ifmultiaddr *') | |
279 | i = 0 | |
280 | while ifmulti != 0: | |
281 | ifma_format_string = "\t{0: <d}: 0x{1: <x} " | |
282 | out_string += (ifma_format_string.format(i + 1, ifmulti)) | |
283 | if (ifmulti.ifma_addr.sa_family == 2): | |
284 | if (ifmulti.ifma_ll != 0): | |
285 | out_string += GetSocketAddrAsStringLink(ifmulti.ifma_ll.ifma_addr) + " " | |
286 | out_string += GetSocketAddrAsStringInet(ifmulti.ifma_addr) | |
287 | if (ifmulti.ifma_addr.sa_family == 30): | |
288 | if (ifmulti.ifma_ll != 0): | |
289 | out_string += GetSocketAddrAsStringLink(ifmulti.ifma_ll.ifma_addr) + " " | |
290 | out_string += GetSocketAddrAsStringInet6(ifmulti.ifma_addr) + " " | |
291 | if (ifmulti.ifma_addr.sa_family == 18): | |
292 | out_string += GetSocketAddrAsStringLink(ifmulti.ifma_addr) + " " | |
293 | if (ifmulti.ifma_addr.sa_family == 0): | |
294 | out_string += GetSocketAddrAsStringUnspec(ifmulti.ifma_addr) + " " | |
295 | out_string += "[" + str(int(ifmulti.ifma_refcount)) + "]\n" | |
296 | ifmulti = cast(ifmulti.ifma_link.le_next, 'ifmultiaddr *') | |
297 | i += 1 | |
298 | print out_string | |
299 | else : | |
300 | print "Missing argument 0 in user function." | |
301 | # EndMacro: showifmultiaddrs | |
302 | ||
303 | # Macro: showinmultiaddrs | |
304 | @lldb_command('showinmultiaddrs') | |
305 | def ShowInMultiAddrs(cmd_args=None) : | |
306 | """ Show the contents of IPv4 multicast address records | |
307 | """ | |
308 | out_string = "" | |
309 | inmultihead = kern.globals.in_multihead | |
310 | inmulti = cast(inmultihead.lh_first, 'in_multi *') | |
311 | i = 0 | |
312 | while inmulti != 0: | |
313 | ifp = inmulti.inm_ifp | |
314 | inma_format_string = "\t{0: <d}: 0x{1: <x} " | |
315 | out_string += inma_format_string.format(i + 1, inmulti) + " " | |
316 | out_string += GetInAddrAsString(addressof(inmulti.inm_addr)) + " " | |
317 | ifma_format_string = "(ifp 0x{0: <x} [{1: <s}] ifma {2: <x})" | |
318 | out_string += ifma_format_string.format(ifp, ifp.if_xname, inmulti.inm_ifma) + "\n" | |
319 | inmulti = cast(inmulti.inm_link.le_next, 'in_multi *') | |
320 | i += 1 | |
321 | print out_string | |
322 | # EndMacro: showinmultiaddrs | |
323 | ||
324 | # Macro: showin6multiaddrs | |
325 | @lldb_command('showin6multiaddrs') | |
326 | def ShowIn6MultiAddrs(cmd_args=None) : | |
327 | """ Show the contents of IPv6 multicast address records | |
328 | """ | |
329 | out_string = "" | |
330 | in6multihead = kern.globals.in6_multihead | |
331 | in6multi = cast(in6multihead.lh_first, 'in6_multi *') | |
332 | i = 0 | |
333 | while in6multi != 0: | |
334 | ifp = in6multi.in6m_ifp | |
335 | inma_format_string = "\t{0: <d}: 0x{1: <x} " | |
336 | out_string += inma_format_string.format(i + 1, in6multi) + " " | |
337 | out_string += GetIn6AddrAsString((in6multi.in6m_addr.__u6_addr.__u6_addr8)) + " " | |
338 | ifma_format_string = "(ifp 0x{0: <x} [{1: <s}] ifma {2: <x})" | |
339 | out_string += ifma_format_string.format(ifp, ifp.if_xname, in6multi.in6m_ifma) + "\n" | |
340 | in6multi = cast(in6multi.in6m_entry.le_next, 'in6_multi *') | |
341 | i += 1 | |
342 | print out_string | |
343 | # EndMacro: showin6multiaddrs | |
344 | ||
345 | def GetTcpState(tcpcb): | |
346 | out_string = "" | |
347 | tp = Cast(tcpcb, 'tcpcb *') | |
348 | if (int(tp) != 0): | |
349 | if tp.t_state == 0: | |
350 | out_string += "CLOSED\t" | |
351 | if tp.t_state == 1: | |
352 | out_string += "LISTEN\t" | |
353 | if tp.t_state == 2: | |
354 | out_string += "SYN_SENT\t" | |
355 | if tp.t_state == 3: | |
356 | out_string += "SYN_RCVD\t" | |
357 | if tp.t_state == 4: | |
358 | out_string += "ESTABLISHED\t" | |
359 | if tp.t_state == 5: | |
360 | out_string += "CLOSE_WAIT\t" | |
361 | if tp.t_state == 6: | |
362 | out_string += "FIN_WAIT_1\t" | |
363 | if tp.t_state == 7: | |
364 | out_string += "CLOSING\t" | |
365 | if tp.t_state == 8: | |
366 | out_string += "LAST_ACK\t" | |
367 | if tp.t_state == 9: | |
368 | out_string += "FIN_WAIT_2\t" | |
369 | if tp.t_state == 10: | |
370 | out_string += "TIME_WAIT\t" | |
371 | return out_string | |
372 | ||
373 | def GetSocketProtocolAsString(sock): | |
374 | out_string = "" | |
375 | inpcb = Cast(sock.so_pcb, 'inpcb *') | |
376 | if sock.so_proto.pr_protocol == 6: | |
377 | out_string += " TCP " | |
378 | out_string += GetTcpState(inpcb.inp_ppcb) | |
379 | if sock.so_proto.pr_protocol == 17: | |
380 | out_string += " UDP " | |
381 | if sock.so_proto.pr_protocol == 1: | |
382 | out_string += " ICMP " | |
383 | if sock.so_proto.pr_protocol == 254: | |
384 | out_string += " DIVERT " | |
385 | if sock.so_proto.pr_protocol == 255: | |
386 | out_string += " RAW " | |
387 | return out_string | |
388 | ||
389 | def GetInAddr4to6AsString(inaddr): | |
390 | out_string = "" | |
391 | if (inaddr is not None): | |
392 | ia = Cast(inaddr, 'char *') | |
393 | inaddr_format_string = "{0: <d}.{1: <d}.{2: <d}.{3: <d}" | |
394 | out_string += inaddr_format_string.format(ia[0], ia[1], ia[2], ia[3]) | |
395 | return out_string | |
396 | ||
397 | def GetInPortAsString(port): | |
398 | out_string = "" | |
399 | port_string = Cast(port, 'char *') | |
400 | port_unsigned = dereference(Cast(port, 'unsigned short *')) | |
401 | ||
402 | if ((((port_unsigned & 0xff00) >> 8) == port_string[0])) and (((port_unsigned & 0x00ff) == port_string[1])): | |
403 | out_string += ":" + str(int(port_unsigned)) | |
404 | else: | |
405 | out_string += ":" + str(int(((port_unsigned & 0xff00) >> 8) | ((port_unsigned & 0x00ff) << 8))) | |
406 | ||
407 | return out_string | |
408 | ||
409 | def GetIPv4SocketAsString(sock) : | |
410 | out_string = "" | |
411 | pcb = Cast(sock.so_pcb, 'inpcb *') | |
412 | if (pcb == 0): | |
413 | out_string += "inpcb: (null) " | |
414 | else: | |
415 | out_string += "inpcb: " + hex(pcb) | |
416 | out_string += GetSocketProtocolAsString(sock) | |
417 | ||
418 | out_string += GetInAddr4to6AsString(addressof(pcb.inp_dependladdr.inp46_local)) | |
419 | out_string += GetInPortAsString(addressof(pcb.inp_lport)) | |
420 | out_string += " -> " | |
421 | out_string += GetInAddr4to6AsString(addressof(pcb.inp_dependfaddr.inp46_foreign)) | |
422 | out_string += GetInPortAsString(addressof(pcb.inp_fport)) | |
423 | return out_string | |
424 | ||
425 | def GetIPv6SocketAsString(sock) : | |
426 | out_string = "" | |
427 | pcb = Cast(sock.so_pcb, 'inpcb *') | |
428 | if (pcb == 0): | |
429 | out_string += "inpcb: (null) " | |
430 | else: | |
431 | out_string += "inpcb: " + hex(pcb) + " " | |
432 | out_string += GetSocketProtocolAsString(sock) | |
433 | ||
434 | out_string += GetIn6AddrAsString((pcb.inp_dependladdr.inp6_local.__u6_addr.__u6_addr8)) | |
435 | out_string += GetInPortAsString(addressof(pcb.inp_lport)) | |
436 | out_string += " -> " | |
437 | out_string += GetIn6AddrAsString((pcb.inp_dependfaddr.inp6_foreign.__u6_addr.__u6_addr8)) | |
438 | out_string += GetInPortAsString(addressof(pcb.inp_fport)) | |
439 | return out_string | |
440 | ||
441 | def GetUnixDomainSocketAsString(sock) : | |
442 | out_string = "" | |
443 | pcb = Cast(sock.so_pcb, 'unpcb *') | |
444 | if (pcb == 0): | |
445 | out_string += "unpcb: (null) " | |
446 | else: | |
447 | out_string += "unpcb: " + hex(pcb) + " " | |
448 | out_string += "unp_vnode: " + hex(pcb.unp_vnode) + " " | |
449 | out_string += "unp_conn: " + hex(pcb.unp_conn) + " " | |
450 | out_string += "unp_addr: " + GetSocketAddrAsStringUnix(pcb.unp_addr) | |
451 | return out_string | |
452 | ||
453 | def GetSocket(socket) : | |
454 | """ Show the contents of a socket | |
455 | """ | |
456 | so = kern.GetValueFromAddress(unsigned(socket), 'socket *') | |
457 | if (so): | |
458 | out_string = "" | |
459 | sock_format_string = "so: 0x{0:<x}" | |
460 | out_string += sock_format_string.format(so) | |
461 | domain = so.so_proto.pr_domain | |
462 | domain_name_format_string = " {0:<s} " | |
463 | out_string += domain_name_format_string.format(domain.dom_name) | |
464 | if (domain.dom_family == 1): | |
465 | out_string += GetUnixDomainSocketAsString(so) | |
466 | if (domain.dom_family == 2): | |
467 | out_string += GetIPv4SocketAsString(so) | |
468 | if (domain.dom_family == 30): | |
469 | out_string += GetIPv6SocketAsString(so) | |
470 | else: | |
471 | out_string += "(null)" | |
472 | return out_string | |
473 | # EndMacro: showsocket | |
474 | ||
475 | ||
476 | # Macro: showsocket | |
477 | @lldb_command('showsocket') | |
478 | def ShowSocket(cmd_args=None) : | |
479 | """ Show the contents of a socket | |
480 | """ | |
481 | if (cmd_args == None or len(cmd_args) == 0): | |
482 | print "Missing argument 0 in user function." | |
483 | return | |
484 | so = kern.GetValueFromAddress(cmd_args[0], 'socket *') | |
485 | if (len(str(cmd_args[0])) > 0): | |
486 | out_string = "" | |
487 | sock_format_string = "so: 0x{0:<x}" | |
488 | out_string += sock_format_string.format(so) | |
489 | domain = so.so_proto.pr_domain | |
490 | domain_name_format_string = " {0:<s} " | |
491 | out_string += domain_name_format_string.format(domain.dom_name) | |
492 | if (domain.dom_family == 1): | |
493 | out_string += GetUnixDomainSocketAsString(so) | |
494 | if (domain.dom_family == 2): | |
495 | out_string += GetIPv4SocketAsString(so) | |
496 | if (domain.dom_family == 30): | |
497 | out_string += GetIPv6SocketAsString(so) | |
498 | print out_string | |
499 | else: | |
500 | print "Unknown value passed as argument." | |
501 | return | |
502 | # EndMacro: showsocket | |
503 | ||
504 | # Macro: showprocsockets | |
505 | @lldb_command('showprocsockets') | |
506 | def ShowProcSockets(cmd_args=None): | |
507 | """ Given a proc_t pointer, display information about its sockets | |
508 | """ | |
509 | out_string = "" | |
510 | ||
511 | if cmd_args != None and len(cmd_args) > 0 : | |
512 | proc = kern.GetValueFromAddress(cmd_args[0], 'proc *') | |
513 | proc_fd = proc.p_fd | |
514 | ||
515 | if not proc: | |
516 | print "Unknown value passed as argument." | |
517 | return | |
518 | else: | |
519 | count = 0 | |
520 | fpp = Cast(proc_fd.fd_ofiles, 'fileproc **') | |
521 | while (count < proc_fd.fd_nfiles): | |
522 | fp = Cast(dereference(fpp), 'fileproc *') | |
523 | if (fp != 0): | |
524 | fg = Cast(fp.f_fglob, 'fileglob *') | |
525 | if (int(fg.fg_ops.fo_type) == 2): | |
526 | if (proc_fd.fd_ofileflags[count] & 4): | |
527 | out_string += "U: " | |
528 | else: | |
529 | out_string += " " | |
530 | out_string += "fd = " + str(count) + " " | |
531 | if (fg.fg_data != 0): | |
532 | out_string += GetSocket(unsigned(fg.fg_data)) | |
533 | out_string += "\n" | |
534 | else: | |
535 | out_string += "" | |
536 | fpp = kern.GetValueFromAddress(unsigned(fpp + 8), 'fileproc **') | |
537 | count += 1 | |
538 | print out_string | |
539 | else: | |
540 | print "Missing argument 0 in user function." | |
541 | # EndMacro: showprocsockets | |
542 | ||
543 | def GetProcSockets(proc): | |
544 | """ Given a proc_t pointer, display information about its sockets | |
545 | """ | |
546 | out_string = "" | |
547 | proc_fd = proc.p_fd | |
548 | ||
549 | if proc is None: | |
550 | out_string += "Unknown value passed as argument." | |
551 | else: | |
552 | count = 0 | |
553 | fpp = Cast(proc_fd.fd_ofiles, 'fileproc **') | |
554 | while (count < proc_fd.fd_nfiles): | |
555 | fp = Cast(dereference(fpp), 'fileproc *') | |
556 | if (fp != 0): | |
557 | fg = Cast(fp.f_fglob, 'fileglob *') | |
558 | if (int(fg.fg_ops.fo_type) == 2): | |
559 | if (proc_fd.fd_ofileflags[count] & 4): | |
560 | out_string += "U: " | |
561 | else: | |
562 | out_string += " " | |
563 | out_string += "fd = " + str(count) + " " | |
564 | if (fg.fg_data != 0): | |
565 | out_string += GetSocket(unsigned(fg.fg_data)) | |
566 | out_string += "\n" | |
567 | else: | |
568 | out_string += "" | |
569 | fpp = kern.GetValueFromAddress(unsigned(fpp + 8), 'fileproc **') | |
570 | count += 1 | |
571 | return out_string | |
572 | ||
573 | ||
574 | # Macro: showallprocsockets | |
575 | @lldb_command('showallprocsockets') | |
576 | def ShowAllProcSockets(cmd_args=None): | |
577 | """Display information about the sockets of all the processes | |
578 | """ | |
579 | for proc in kern.procs: | |
580 | print "================================================================================" | |
581 | print GetProcInfo(proc) | |
582 | print GetProcSockets(proc) | |
583 | # EndMacro: showallprocsockets | |
584 | ||
585 | ||
586 | def GetRtEntryPrDetailsAsString(rte): | |
587 | out_string = "" | |
588 | rt = Cast(rte, 'rtentry *') | |
589 | dst = Cast(rt.rt_nodes[0].rn_u.rn_leaf.rn_Key, 'sockaddr *') | |
590 | isv6 = 0 | |
591 | dst_string_format = "{0:<18s}" | |
592 | if (dst.sa_family == AF_INET): | |
593 | out_string += dst_string_format.format(GetSocketAddrAsStringInet(dst)) + " " | |
594 | else: | |
595 | if (dst.sa_family == AF_INET6): | |
596 | out_string += dst_string_format.format(GetSocketAddrAsStringInet6(dst)) + " " | |
597 | isv6 = 1 | |
598 | else: | |
599 | if (dst.sa_family == AF_LINK): | |
600 | out_string += dst_string_format.format(GetSocketAddrAsStringLink(dst)) | |
601 | if (isv6 == 1): | |
602 | out_string += " " | |
603 | else: | |
604 | out_string += " " | |
605 | else: | |
606 | out_string += dst_string_format.format(GetSocketAddrAsStringUnspec(dst)) + " " | |
607 | ||
608 | gw = Cast(rt.rt_gateway, 'sockaddr *') | |
609 | if (gw.sa_family == AF_INET): | |
610 | out_string += dst_string_format.format(GetSocketAddrAsStringInet(gw)) + " " | |
611 | else: | |
612 | if (gw.sa_family == 30): | |
613 | out_string += dst_string_format.format(GetSocketAddrAsStringInet6(gw)) + " " | |
614 | isv6 = 1 | |
615 | else: | |
616 | if (gw.sa_family == 18): | |
617 | out_string += dst_string_format.format(GetSocketAddrAsStringLink(gw)) + " " | |
618 | if (isv6 == 1): | |
619 | out_string += " " | |
620 | else: | |
621 | out_string += " " | |
622 | else: | |
623 | dst_string_format.format(GetSocketAddrAsStringUnspec(gw)) | |
624 | ||
625 | if (rt.rt_flags & RTF_WASCLONED): | |
626 | if (kern.ptrsize == 8): | |
627 | rt_flags_string_format = "0x{0:<16x}" | |
628 | out_string += rt_flags_string_format.format(rt.rt_parent) + " " | |
629 | else: | |
630 | rt_flags_string_format = "0x{0:<8x}" | |
631 | out_string += rt_flags_string_format.format(rt.rt_parent) + " " | |
632 | else: | |
633 | if (kern.ptrsize == 8): | |
634 | out_string += " " | |
635 | else: | |
636 | out_string += " " | |
637 | ||
638 | rt_refcnt_rmx_string_format = "{0:<d} {1:>10d} " | |
639 | out_string += rt_refcnt_rmx_string_format.format(rt.rt_refcnt, rt.rt_rmx.rmx_pksent) + " " | |
640 | ||
641 | rtf_string_format = "{0:>s}" | |
642 | if (rt.rt_flags & RTF_UP): | |
643 | out_string += rtf_string_format.format("U") | |
644 | if (rt.rt_flags & RTF_GATEWAY): | |
645 | out_string += rtf_string_format.format("G") | |
646 | if (rt.rt_flags & RTF_HOST): | |
647 | out_string += rtf_string_format.format("H") | |
648 | if (rt.rt_flags & RTF_REJECT): | |
649 | out_string += rtf_string_format.format("R") | |
650 | if (rt.rt_flags & RTF_DYNAMIC): | |
651 | out_string += rtf_string_format.format("D") | |
652 | if (rt.rt_flags & RTF_MODIFIED): | |
653 | out_string += rtf_string_format.format("M") | |
654 | if (rt.rt_flags & RTF_CLONING): | |
655 | out_string += rtf_string_format.format("C") | |
656 | if (rt.rt_flags & RTF_PRCLONING): | |
657 | out_string += rtf_string_format.format("c") | |
658 | if (rt.rt_flags & RTF_LLINFO): | |
659 | out_string += rtf_string_format.format("L") | |
660 | if (rt.rt_flags & RTF_STATIC): | |
661 | out_string += rtf_string_format.format("S") | |
662 | if (rt.rt_flags & RTF_PROTO1): | |
663 | out_string += rtf_string_format.format("1") | |
664 | if (rt.rt_flags & RTF_PROTO2): | |
665 | out_string += rtf_string_format.format("2") | |
666 | if (rt.rt_flags & RTF_PROTO3): | |
667 | out_string += rtf_string_format.format("3") | |
668 | if (rt.rt_flags & RTF_WASCLONED): | |
669 | out_string += rtf_string_format.format("W") | |
670 | if (rt.rt_flags & RTF_BROADCAST): | |
671 | out_string += rtf_string_format.format("b") | |
672 | if (rt.rt_flags & RTF_MULTICAST): | |
673 | out_string += rtf_string_format.format("m") | |
674 | if (rt.rt_flags & RTF_XRESOLVE): | |
675 | out_string += rtf_string_format.format("X") | |
676 | if (rt.rt_flags & RTF_BLACKHOLE): | |
677 | out_string += rtf_string_format.format("B") | |
678 | if (rt.rt_flags & RTF_IFSCOPE): | |
679 | out_string += rtf_string_format.format("I") | |
680 | if (rt.rt_flags & RTF_CONDEMNED): | |
681 | out_string += rtf_string_format.format("Z") | |
682 | if (rt.rt_flags & RTF_IFREF): | |
683 | out_string += rtf_string_format.format("i") | |
684 | if (rt.rt_flags & RTF_PROXY): | |
685 | out_string += rtf_string_format.format("Y") | |
686 | if (rt.rt_flags & RTF_ROUTER): | |
687 | out_string += rtf_string_format.format("r") | |
688 | ||
689 | out_string += "/" | |
690 | out_string += str(rt.rt_ifp.if_name) | |
691 | out_string += str(int(rt.rt_ifp.if_unit)) | |
692 | out_string += "\n" | |
693 | return out_string | |
694 | ||
695 | ||
696 | RNF_ROOT = 2 | |
697 | def GetRtTableAsString(rt_tables): | |
698 | out_string = "" | |
699 | rn = Cast(rt_tables.rnh_treetop, 'radix_node *') | |
700 | rnh_cnt = rt_tables.rnh_cnt | |
701 | ||
702 | while (rn.rn_bit >= 0): | |
703 | rn = rn.rn_u.rn_node.rn_L | |
704 | ||
705 | while 1: | |
706 | base = Cast(rn, 'radix_node *') | |
707 | while ((rn.rn_parent.rn_u.rn_node.rn_R == rn) and (rn.rn_flags & RNF_ROOT == 0)): | |
708 | rn = rn.rn_parent | |
709 | rn = rn.rn_parent.rn_u.rn_node.rn_R | |
710 | while (rn.rn_bit >= 0): | |
711 | rn = rn.rn_u.rn_node.rn_L | |
712 | next_rn = rn | |
713 | while (base != 0): | |
714 | rn = base | |
715 | base = rn.rn_u.rn_leaf.rn_Dupedkey | |
716 | if ((rn.rn_flags & RNF_ROOT) == 0): | |
717 | rt = Cast(rn, 'rtentry *') | |
718 | if (kern.ptrsize == 8): | |
719 | rtentry_string_format = "0x{0:<18x}" | |
720 | out_string += rtentry_string_format.format(rt) + " " | |
721 | else: | |
722 | rtentry_string_format = "0x{0:<10x}" | |
723 | out_string += rtentry_string_format.format(rt) + " " | |
724 | out_string += GetRtEntryPrDetailsAsString(rt) + " " | |
725 | ||
726 | rn = next_rn | |
727 | if ((rn.rn_flags & RNF_ROOT) != 0): | |
728 | break | |
729 | return out_string | |
730 | ||
731 | def GetRtInetAsString(): | |
732 | rt_tables = kern.globals.rt_tables[2] | |
733 | if (kern.ptrsize == 8): | |
734 | rt_table_header_format_string = "{0:<18s} {1: <16s} {2:<20s} {3:<16s} {4:<8s} {5:<8s} {6:<8s}" | |
735 | print rt_table_header_format_string.format("rtentry", " dst", "gw", "parent", "Refs", "Use", "flags/if") | |
736 | print rt_table_header_format_string.format("-" * 18, "-" * 16, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8) | |
737 | print GetRtTableAsString(rt_tables) | |
738 | else: | |
739 | rt_table_header_format_string = "{0:<8s} {1:<16s} {2:<18s} {3:<8s} {4:<8s} {5:<8s} {6:<8s}" | |
740 | print rt_table_header_format_string.format("rtentry", "dst", "gw", "parent", "Refs", "Use", "flags/if") | |
741 | print rt_table_header_format_string.format("-" * 8, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8, "-" * 8) | |
742 | print GetRtTableAsString(rt_tables) | |
743 | ||
744 | def GetRtInet6AsString(): | |
745 | rt_tables = kern.globals.rt_tables[30] | |
746 | if (kern.ptrsize == 8): | |
747 | rt_table_header_format_string = "{0:<18s} {1: <16s} {2:<20s} {3:<16s} {4:<8s} {5:<8s} {6:<8s}" | |
748 | print rt_table_header_format_string.format("rtentry", " dst", "gw", "parent", "Refs", "Use", "flags/if") | |
749 | print rt_table_header_format_string.format("-" * 18, "-" * 16, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8) | |
750 | print GetRtTableAsString(rt_tables) | |
751 | else: | |
752 | rt_table_header_format_string = "{0:<8s} {1:<16s} {2:<18s} {3:<8s} {4:<8s} {5:<8s} {6:<8s}" | |
753 | print rt_table_header_format_string.format("rtentry", "dst", "gw", "parent", "Refs", "Use", "flags/if") | |
754 | print rt_table_header_format_string.format("-" * 8, "-" * 16, "-" * 18, "-" * 8, "-" * 8, "-" * 8, "-" * 8) | |
755 | print GetRtTableAsString(rt_tables) | |
756 | ||
757 | # Macro: show_rt_inet | |
758 | @lldb_command('show_rt_inet') | |
759 | def ShowRtInet(cmd_args=None): | |
760 | """ Display the IPv4 routing table | |
761 | """ | |
762 | print GetRtInetAsString() | |
763 | # EndMacro: show_rt_inet | |
764 | ||
765 | # Macro: show_rt_inet6 | |
766 | @lldb_command('show_rt_inet6') | |
767 | def ShowRtInet6(cmd_args=None): | |
768 | """ Display the IPv6 routing table | |
769 | """ | |
770 | print GetRtInet6AsString() | |
771 | # EndMacro: show_rt_inet6 | |
772 | ||
773 | # Macro: rtentry_showdbg | |
774 | @lldb_command('rtentry_showdbg') | |
775 | def ShowRtEntryDebug(cmd_args=None): | |
776 | """ Print the debug information of a route entry | |
777 | """ | |
778 | if (cmd_args == None or len(cmd_args) == 0): | |
779 | print "Missing argument 0 in user function." | |
780 | return | |
781 | out_string = "" | |
782 | cnt = 0 | |
783 | rtd = kern.GetValueFromAddress(cmd_args[0], 'rtentry_dbg *') | |
784 | rtd_summary_format_string = "{0:s} {1:d}" | |
785 | out_string += rtd_summary_format_string.format("Total holds : ", rtd.rtd_refhold_cnt) + "\n" | |
786 | out_string += rtd_summary_format_string.format("Total releases : ", rtd.rtd_refrele_cnt) + "\n" | |
787 | ||
788 | ix = 0 | |
789 | while (ix < CTRACE_STACK_SIZE): | |
790 | kgm_pc = rtd.rtd_alloc.pc[ix] | |
791 | if (kgm_pc != 0): | |
792 | if (ix == 0): | |
793 | out_string += "\nAlloc: (thread " + hex(rtd.rtd_alloc.th) + "):\n" | |
794 | out_string += str(int(ix + 1)) + ": " | |
795 | out_string += GetSourceInformationForAddress(kgm_pc) | |
796 | out_string += "\n" | |
797 | ix += 1 | |
798 | ||
799 | ix = 0 | |
800 | while (ix < CTRACE_STACK_SIZE): | |
801 | kgm_pc = rtd.rtd_free.pc[ix] | |
802 | if (kgm_pc != 0): | |
803 | if (ix == 0): | |
804 | out_string += "\nFree: (thread " + hex(rtd.rtd_free.th) + "):\n" | |
805 | out_string += str(int(ix + 1)) + ": " | |
806 | out_string += GetSourceInformationForAddress(kgm_pc) | |
807 | out_string += "\n" | |
808 | ix += 1 | |
809 | ||
810 | while (cnt < RTD_TRACE_HIST_SIZE): | |
811 | ix = 0 | |
812 | while (ix < CTRACE_STACK_SIZE): | |
813 | kgm_pc = rtd.rtd_refhold[cnt].pc[ix] | |
814 | if (kgm_pc != 0): | |
815 | if (ix == 0): | |
816 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(rtd.rtd_refhold[cnt].th) + "):\n" | |
817 | out_string += str(int(ix + 1)) + ": " | |
818 | out_string += GetSourceInformationForAddress(kgm_pc) | |
819 | out_string += "\n" | |
820 | ix += 1 | |
821 | cnt += 1 | |
822 | ||
823 | cnt = 0 | |
824 | while (cnt < RTD_TRACE_HIST_SIZE): | |
825 | ix = 0 | |
826 | while (ix < CTRACE_STACK_SIZE): | |
827 | kgm_pc = rtd.rtd_refrele[cnt].pc[ix] | |
828 | if (kgm_pc != 0): | |
829 | if (ix == 0): | |
830 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(rtd.rtd_refrele[cnt].th) + "):\n" | |
831 | out_string += str(int(ix + 1)) + ": " | |
832 | out_string += GetSourceInformationForAddress(kgm_pc) | |
833 | out_string += "\n" | |
834 | ix += 1 | |
835 | cnt += 1 | |
836 | ||
837 | out_string += "\nTotal locks : " + str(int(rtd.rtd_lock_cnt)) | |
838 | out_string += "\nTotal unlocks : " + str(int(rtd.rtd_unlock_cnt)) | |
839 | ||
840 | cnt = 0 | |
841 | while (cnt < RTD_TRACE_HIST_SIZE): | |
842 | ix = 0 | |
843 | while (ix < CTRACE_STACK_SIZE): | |
844 | kgm_pc = rtd.rtd_lock[cnt].pc[ix] | |
845 | if (kgm_pc != 0): | |
846 | if (ix == 0): | |
847 | out_string += "\nLock [" + str(int(cnt)) + "] (thread " + hex(rtd.rtd_lock[cnt].th) + "):\n" | |
848 | out_string += str(int(ix + 1)) + ": " | |
849 | out_string += GetSourceInformationForAddress(kgm_pc) | |
850 | out_string += "\n" | |
851 | ix += 1 | |
852 | cnt += 1 | |
853 | ||
854 | cnt = 0 | |
855 | while (cnt < RTD_TRACE_HIST_SIZE): | |
856 | ix = 0 | |
857 | while (ix < CTRACE_STACK_SIZE): | |
858 | kgm_pc = rtd.rtd_unlock[cnt].pc[ix] | |
859 | if (kgm_pc != 0): | |
860 | if (ix == 0): | |
861 | out_string += "\nUnlock [" + str(int(cnt)) + "] (thread " + hex(rtd.rtd_unlock[cnt].th) + "):\n" | |
862 | out_string += str(int(ix + 1)) + ": " | |
863 | out_string += GetSourceInformationForAddress(kgm_pc) | |
864 | out_string += "\n" | |
865 | ix += 1 | |
866 | cnt += 1 | |
867 | ||
868 | print out_string | |
869 | # EndMacro: rtentry_showdbg | |
870 | ||
871 | # Macro: inifa_showdbg | |
872 | @lldb_command('inifa_showdbg') | |
873 | def InIfaShowDebug(cmd_args=None): | |
874 | """ Print the debug information of an IPv4 interface address | |
875 | """ | |
876 | if (cmd_args == None or len(cmd_args) == 0): | |
877 | print "Missing argument 0 in user function." | |
878 | return | |
879 | out_string = "" | |
880 | cnt = 0 | |
881 | inifa = kern.GetValueFromAddress(cmd_args[0], 'in_ifaddr_dbg *') | |
882 | in_ifaddr_summary_format_string = "{0:s} {1:d}" | |
883 | out_string += in_ifaddr_summary_format_string.format("Total holds : ", inifa.inifa_refhold_cnt) + "\n" | |
884 | out_string += in_ifaddr_summary_format_string.format("Total releases : ", inifa.inifa_refrele_cnt) + "\n" | |
885 | ||
886 | ix = 0 | |
887 | while (ix < CTRACE_STACK_SIZE): | |
888 | kgm_pc = inifa.inifa_alloc.pc[ix] | |
889 | if (kgm_pc != 0): | |
890 | if (ix == 0): | |
891 | out_string += "\nAlloc: (thread " + hex(inifa.inifa_alloc.th) + "):\n" | |
892 | out_string += str(int(ix + 1)) + ": " | |
893 | out_string += GetSourceInformationForAddress(kgm_pc) | |
894 | out_string += "\n" | |
895 | ix += 1 | |
896 | ||
897 | ix = 0 | |
898 | while (ix < CTRACE_STACK_SIZE): | |
899 | kgm_pc = inifa.inifa_free.pc[ix] | |
900 | if (kgm_pc != 0): | |
901 | if (ix == 0): | |
902 | out_string += "\nFree: (thread " + hex(inifa.inifa_free.th) + "):\n" | |
903 | out_string += str(int(ix + 1)) + ": " | |
904 | out_string += GetSourceInformationForAddress(kgm_pc) | |
905 | out_string += "\n" | |
906 | ix += 1 | |
907 | ||
908 | while (cnt < INIFA_TRACE_HIST_SIZE): | |
909 | ix = 0 | |
910 | while (ix < CTRACE_STACK_SIZE): | |
911 | kgm_pc = inifa.inifa_refhold[cnt].pc[ix] | |
912 | if (kgm_pc != 0): | |
913 | if (ix == 0): | |
914 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(inifa.inifa_refhold[cnt].th) + "):\n" | |
915 | out_string += str(int(ix + 1)) + ": " | |
916 | out_string += GetSourceInformationForAddress(kgm_pc) | |
917 | out_string += "\n" | |
918 | ix += 1 | |
919 | cnt += 1 | |
920 | cnt = 0 | |
921 | ||
922 | while (cnt < INIFA_TRACE_HIST_SIZE): | |
923 | ix = 0 | |
924 | while (ix < CTRACE_STACK_SIZE): | |
925 | kgm_pc = inifa.inifa_refrele[cnt].pc[ix] | |
926 | if (kgm_pc != 0): | |
927 | if (ix == 0): | |
928 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(inifa.inifa_refrele[cnt].th) + "):\n" | |
929 | out_string += str(int(ix + 1)) + ": " | |
930 | out_string += GetSourceInformationForAddress(kgm_pc) | |
931 | out_string += "\n" | |
932 | ix += 1 | |
933 | cnt += 1 | |
934 | print out_string | |
935 | # EndMacro: inifa_showdbg | |
936 | ||
937 | # Macro: in6ifa_showdbg | |
938 | @lldb_command('in6ifa_showdbg') | |
939 | def In6IfaShowDebug(cmd_args=None): | |
940 | """ Print the debug information of an IPv6 interface address | |
941 | """ | |
942 | if (cmd_args == None or len(cmd_args) == 0): | |
943 | print "Missing argument 0 in user function." | |
944 | return | |
945 | out_string = "" | |
946 | cnt = 0 | |
947 | in6ifa = kern.GetValueFromAddress(cmd_args[0], 'in6_ifaddr_dbg *') | |
948 | in6_ifaddr_summary_format_string = "{0:s} {1:d}" | |
949 | print in6_ifaddr_summary_format_string.format("Total holds : ", in6ifa.in6ifa_refhold_cnt) | |
950 | print in6_ifaddr_summary_format_string.format("Total releases : ", in6ifa.in6ifa_refrele_cnt) | |
951 | ||
952 | ix = 0 | |
953 | while (ix < CTRACE_STACK_SIZE): | |
954 | kgm_pc = in6ifa.in6ifa_alloc.pc[ix] | |
955 | if (kgm_pc != 0): | |
956 | if (ix == 0): | |
957 | out_string += "\nAlloc: (thread " + hex(in6ifa.in6ifa_alloc.th) + "):\n" | |
958 | out_string += str(int(ix + 1)) + ": " | |
959 | out_string += GetSourceInformationForAddress(kgm_pc) | |
960 | out_string += "\n" | |
961 | ix += 1 | |
962 | ||
963 | ix = 0 | |
964 | while (ix < CTRACE_STACK_SIZE): | |
965 | kgm_pc = in6ifa.in6ifa_free.pc[ix] | |
966 | if (kgm_pc != 0): | |
967 | if (ix == 0): | |
968 | out_string += "\nFree: (thread " + hex(in6ifa.in6ifa_free.th) + "):\n" | |
969 | out_string += str(int(ix + 1)) + ": " | |
970 | out_string += GetSourceInformationForAddress(kgm_pc) | |
971 | out_string += "\n" | |
972 | ix += 1 | |
973 | ||
974 | while (cnt < IN6IFA_TRACE_HIST_SIZE): | |
975 | ix = 0 | |
976 | while (ix < CTRACE_STACK_SIZE): | |
977 | kgm_pc = in6ifa.in6ifa_refhold[cnt].pc[ix] | |
978 | if (kgm_pc != 0): | |
979 | if (ix == 0): | |
980 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(in6ifa.in6ifa_refhold[cnt].th) + "):\n" | |
981 | out_string += str(int(ix + 1)) + ": " | |
982 | out_string += GetSourceInformationForAddress(kgm_pc) | |
983 | out_string += "\n" | |
984 | ix += 1 | |
985 | cnt += 1 | |
986 | cnt = 0 | |
987 | ||
988 | while (cnt < IN6IFA_TRACE_HIST_SIZE): | |
989 | ix = 0 | |
990 | while (ix < CTRACE_STACK_SIZE): | |
991 | kgm_pc = in6ifa.in6ifa_refrele[cnt].pc[ix] | |
992 | if (kgm_pc != 0): | |
993 | if (ix == 0): | |
994 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(in6ifa.in6ifa_refrele[cnt].th) + "):\n" | |
995 | out_string += str(int(ix + 1)) + ": " | |
996 | out_string += GetSourceInformationForAddress(kgm_pc) | |
997 | out_string += "\n" | |
998 | ix += 1 | |
999 | cnt += 1 | |
1000 | print out_string | |
1001 | # EndMacro: in6ifa_showdbg | |
1002 | ||
1003 | # Macro: inm_showdbg | |
1004 | @lldb_command('inm_showdbg') | |
1005 | def InmShowDebug(cmd_args=None): | |
1006 | """ Print the debug information of an IPv4 multicast address | |
1007 | """ | |
1008 | if (cmd_args == None or len(cmd_args) == 0): | |
1009 | print "Missing argument 0 in user function." | |
1010 | return | |
1011 | out_string = "" | |
1012 | cnt = 0 | |
1013 | inm = kern.GetValueFromAddress(cmd_args[0], 'in_multi_dbg *') | |
1014 | in_multi_summary_format_string = "{0:s} {1:d}" | |
1015 | out_string += in_multi_summary_format_string.format("Total holds : ", inm.inm_refhold_cnt) | |
1016 | out_string += in_multi_summary_format_string.format("Total releases : ", inm.inm_refrele_cnt) | |
1017 | ||
1018 | while (cnt < INM_TRACE_HIST_SIZE): | |
1019 | ix = 0 | |
1020 | while (ix < CTRACE_STACK_SIZE): | |
1021 | kgm_pc = inm.inm_refhold[cnt].pc[ix] | |
1022 | if (kgm_pc != 0): | |
1023 | if (ix == 0): | |
1024 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(inm.inm_refhold[cnt].th) + "):\n" | |
1025 | out_string += str(int(ix + 1)) + ": " | |
1026 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1027 | out_string += "\n" | |
1028 | ix += 1 | |
1029 | cnt += 1 | |
1030 | cnt = 0 | |
1031 | while (cnt < INM_TRACE_HIST_SIZE): | |
1032 | ix = 0 | |
1033 | while (ix < CTRACE_STACK_SIZE): | |
1034 | kgm_pc = inm.inm_refrele[cnt].pc[ix] | |
1035 | if (kgm_pc != 0): | |
1036 | if (ix == 0): | |
1037 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(inm.inm_refrele[cnt].th) + "):\n" | |
1038 | out_string += str(int(ix + 1)) + ": " | |
1039 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1040 | out_string += "\n" | |
1041 | ix += 1 | |
1042 | cnt += 1 | |
1043 | print out_string | |
1044 | # EndMacro: inm_showdbg | |
1045 | ||
1046 | # Macro: ifma_showdbg | |
1047 | @lldb_command('ifma_showdbg') | |
1048 | def IfmaShowDebug(cmd_args=None): | |
1049 | """ Print the debug information of a link multicast address | |
1050 | """ | |
1051 | if (cmd_args == None or len(cmd_args) == 0): | |
1052 | print "Missing argument 0 in user function." | |
1053 | return | |
1054 | out_string = "" | |
1055 | cnt = 0 | |
1056 | ifma = kern.GetValueFromAddress(cmd_args[0], 'ifmultiaddr_dbg *') | |
1057 | link_multi_summary_format_string = "{0:s} {1:d}" | |
1058 | out_string += link_multi_summary_format_string.format("Total holds : ", ifma.ifma_refhold_cnt) + "\n" | |
1059 | out_string += link_multi_summary_format_string.format("Total releases : ", ifma.ifma_refrele_cnt) + "\n" | |
1060 | ||
1061 | while (cnt < IFMA_TRACE_HIST_SIZE): | |
1062 | ix = 0 | |
1063 | while (ix < CTRACE_STACK_SIZE): | |
1064 | kgm_pc = ifma.ifma_refhold[cnt].pc[ix] | |
1065 | if (kgm_pc != 0): | |
1066 | if (ix == 0): | |
1067 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(ifma.ifma_refhold[cnt].th) + "):\n" | |
1068 | out_string += str(int(ix + 1)) + ": " | |
1069 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1070 | out_string += "\n" | |
1071 | ix += 1 | |
1072 | cnt += 1 | |
1073 | cnt = 0 | |
1074 | while (cnt < IFMA_TRACE_HIST_SIZE): | |
1075 | ix = 0 | |
1076 | while (ix < CTRACE_STACK_SIZE): | |
1077 | kgm_pc = ifma.ifma_refrele[cnt].pc[ix] | |
1078 | if (kgm_pc != 0): | |
1079 | if (ix == 0): | |
1080 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(ifma.ifma_refrele[cnt].th) + "):\n" | |
1081 | out_string += str(int(ix + 1)) + ": " | |
1082 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1083 | out_string += "\n" | |
1084 | ix += 1 | |
1085 | cnt += 1 | |
1086 | print out_string | |
1087 | # EndMacro: ifma_showdbg | |
1088 | ||
1089 | # Macro: ifpref_showdbg | |
1090 | @lldb_command('ifpref_showdbg') | |
1091 | def IfpRefShowDebug(cmd_args=None): | |
1092 | """ Print the debug information of an interface ref count | |
1093 | """ | |
1094 | if (cmd_args == None or len(cmd_args) == 0): | |
1095 | print "Missing argument 0 in user function." | |
1096 | return | |
1097 | out_string = "" | |
1098 | cnt = 0 | |
1099 | dl_if = kern.GetValueFromAddress(cmd_args[0], 'dlil_ifnet_dbg *') | |
1100 | dl_if_summary_format_string = "{0:s} {1:d}" | |
1101 | out_string += dl_if_summary_format_string.format("Total holds : ", dl_if.dldbg_if_refhold_cnt) | |
1102 | out_string += dl_if_summary_format_string.format("Total releases : ", dl_if.dldbg_if_refrele_cnt) | |
1103 | ||
1104 | while (cnt < IF_REF_TRACE_HIST_SIZE): | |
1105 | ix = 0 | |
1106 | while (ix < CTRACE_STACK_SIZE): | |
1107 | kgm_pc = dl_if.dldbg_if_refhold[cnt].pc[ix] | |
1108 | if (kgm_pc != 0): | |
1109 | if (ix == 0): | |
1110 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(dl_if.dldbg_if_refhold[cnt].th) + "):\n" | |
1111 | out_string += str(int(ix + 1)) + ": " | |
1112 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1113 | out_string += "\n" | |
1114 | ix += 1 | |
1115 | cnt += 1 | |
1116 | cnt = 0 | |
1117 | while (cnt < IF_REF_TRACE_HIST_SIZE): | |
1118 | ix = 0 | |
1119 | while (ix < CTRACE_STACK_SIZE): | |
1120 | kgm_pc = dl_if.dldbg_if_refrele[cnt].pc[ix] | |
1121 | if (kgm_pc != 0): | |
1122 | if (ix == 0): | |
1123 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(dl_if.dldbg_if_refrele[cnt].th) + "):\n" | |
1124 | out_string += str(int(ix + 1)) + ": " | |
1125 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1126 | out_string += "\n" | |
1127 | ix += 1 | |
1128 | cnt += 1 | |
1129 | print out_string | |
1130 | # EndMacro: ifpref_showdbg | |
1131 | ||
1132 | # Macro: ndpr_showdbg | |
1133 | @lldb_command('ndpr_showdbg') | |
1134 | def ndprShowDebug(cmd_args=None): | |
1135 | """ Print the debug information of a nd_prefix structure | |
1136 | """ | |
1137 | if (cmd_args == None or len(cmd_args) == 0): | |
1138 | print "Missing argument 0 in user function." | |
1139 | return | |
1140 | out_string = "" | |
1141 | cnt = 0 | |
1142 | ndpr = kern.GetValueFromAddress(cmd_args[0], 'nd_prefix_dbg *') | |
1143 | ndpr_summary_format_string = "{0:s} {1:d}" | |
1144 | out_string += ndpr_summary_format_string.format("Total holds : ", ndpr.ndpr_refhold_cnt) | |
1145 | out_string += ndpr_summary_format_string.format("Total releases : ", ndpr.ndpr_refrele_cnt) | |
1146 | ||
1147 | while (cnt < NDPR_TRACE_HIST_SIZE): | |
1148 | ix = 0 | |
1149 | while (ix < CTRACE_STACK_SIZE): | |
1150 | kgm_pc = ndpr.ndpr_refhold[cnt].pc[ix] | |
1151 | if (kgm_pc != 0): | |
1152 | if (ix == 0): | |
1153 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(ndpr.ndpr_refhold[cnt].th) + "):\n" | |
1154 | out_string += str(int(ix + 1)) + ": " | |
1155 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1156 | out_string += "\n" | |
1157 | ix += 1 | |
1158 | cnt += 1 | |
1159 | cnt = 0 | |
1160 | while (cnt < NDPR_TRACE_HIST_SIZE): | |
1161 | ix = 0 | |
1162 | while (ix < CTRACE_STACK_SIZE): | |
1163 | kgm_pc = ndpr.ndpr_refrele[cnt].pc[ix] | |
1164 | if (kgm_pc != 0): | |
1165 | if (ix == 0): | |
1166 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(ndpr.ndpr_refrele[cnt].th) + "):\n" | |
1167 | out_string += str(int(ix + 1)) + ": " | |
1168 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1169 | out_string += "\n" | |
1170 | ix += 1 | |
1171 | cnt += 1 | |
1172 | print out_string | |
1173 | # EndMacro: ndpr_showdbg | |
1174 | ||
1175 | # Macro: nddr_showdbg | |
1176 | @lldb_command('nddr_showdbg') | |
1177 | def nddrShowDebug(cmd_args=None): | |
1178 | """ Print the debug information of a nd_defrouter structure | |
1179 | """ | |
1180 | if (cmd_args == None or len(cmd_args) == 0): | |
1181 | print "Missing argument 0 in user function." | |
1182 | return | |
1183 | out_string = "" | |
1184 | cnt = 0 | |
1185 | nddr = kern.GetValueFromAddress(cmd_args[0], 'nd_defrouter_dbg *') | |
1186 | nddr_summary_format_string = "{0:s} {1:d}" | |
1187 | out_string += nddr_summary_format_string.format("Total holds : ", nddr.nddr_refhold_cnt) | |
1188 | out_string += nddr_summary_format_string.format("Total releases : ", nddr.nddr_refrele_cnt) | |
1189 | ||
1190 | while (cnt < NDDR_TRACE_HIST_SIZE): | |
1191 | ix = 0 | |
1192 | while (ix < CTRACE_STACK_SIZE): | |
1193 | kgm_pc = nddr.nddr_refhold[cnt].pc[ix] | |
1194 | if (kgm_pc != 0): | |
1195 | if (ix == 0): | |
1196 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(nddr.nddr_refhold[cnt].th) + "):\n" | |
1197 | out_string += str(int(ix + 1)) + ": " | |
1198 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1199 | out_string += "\n" | |
1200 | ix += 1 | |
1201 | cnt += 1 | |
1202 | cnt = 0 | |
1203 | while (cnt < NDDR_TRACE_HIST_SIZE): | |
1204 | ix = 0 | |
1205 | while (ix < CTRACE_STACK_SIZE): | |
1206 | kgm_pc = nddr.nddr_refrele[cnt].pc[ix] | |
1207 | if (kgm_pc != 0): | |
1208 | if (ix == 0): | |
1209 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(nddr.nddr_refrele[cnt].th) + "):\n" | |
1210 | out_string += str(int(ix + 1)) + ": " | |
1211 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1212 | out_string += "\n" | |
1213 | ix += 1 | |
1214 | cnt += 1 | |
1215 | print out_string | |
1216 | # EndMacro: nddr_showdbg | |
1217 | ||
1218 | # Macro: imo_showdbg | |
1219 | @lldb_command('imo_showdbg') | |
1220 | def IpmOptions(cmd_args=None): | |
1221 | """ Print the debug information of a ip_moptions structure | |
1222 | """ | |
1223 | if (cmd_args == None or len(cmd_args) == 0): | |
1224 | print "Missing argument 0 in user function." | |
1225 | return | |
1226 | out_string = "" | |
1227 | cnt = 0 | |
1228 | imo = kern.GetValueFromAddress(cmd_args[0], 'ip_moptions_dbg *') | |
1229 | imo_summary_format_string = "{0:s} {1:d}" | |
1230 | out_string += imo_summary_format_string.format("Total holds : ", imo.imo_refhold_cnt) | |
1231 | out_string += imo_summary_format_string.format("Total releases : ", imo.imo_refrele_cnt) | |
1232 | ||
1233 | while (cnt < IMO_TRACE_HIST_SIZE): | |
1234 | ix = 0 | |
1235 | while (ix < CTRACE_STACK_SIZE): | |
1236 | kgm_pc = imo.imo_refhold[cnt].pc[ix] | |
1237 | if (kgm_pc != 0): | |
1238 | if (ix == 0): | |
1239 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(imo.imo_refhold[cnt].th) + "):\n" | |
1240 | out_string += str(int(ix + 1)) + ": " | |
1241 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1242 | out_string += "\n" | |
1243 | ix += 1 | |
1244 | cnt += 1 | |
1245 | cnt = 0 | |
1246 | while (cnt < IMO_TRACE_HIST_SIZE): | |
1247 | ix = 0 | |
1248 | while (ix < CTRACE_STACK_SIZE): | |
1249 | kgm_pc = imo.imo_refrele[cnt].pc[ix] | |
1250 | if (kgm_pc != 0): | |
1251 | if (ix == 0): | |
1252 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(imo.imo_refrele[cnt].th) + "):\n" | |
1253 | out_string += str(int(ix + 1)) + ": " | |
1254 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1255 | out_string += "\n" | |
1256 | ix += 1 | |
1257 | cnt += 1 | |
1258 | print out_string | |
1259 | # EndMacro: imo_showdbg | |
1260 | ||
1261 | # Macro: im6o_showdbg | |
1262 | @lldb_command('im6o_showdbg') | |
1263 | def IpmOptions(cmd_args=None): | |
1264 | """ Print the debug information of a ip6_moptions structure | |
1265 | """ | |
1266 | if (cmd_args == None or len(cmd_args) == 0): | |
1267 | print "Missing argument 0 in user function." | |
1268 | return | |
1269 | out_string = "" | |
1270 | cnt = 0 | |
1271 | im6o = kern.GetValueFromAddress(cmd_args[0], 'ip6_moptions_dbg *') | |
1272 | im6o_summary_format_string = "{0:s} {1:d}" | |
1273 | out_string += im6o_summary_format_string.format("Total holds : ", im6o.im6o_refhold_cnt) | |
1274 | out_string += im6o_summary_format_string.format("Total releases : ", im6o.im6o_refrele_cnt) | |
1275 | ||
1276 | while (cnt < IM6O_TRACE_HIST_SIZE): | |
1277 | ix = 0 | |
1278 | while (ix < CTRACE_STACK_SIZE): | |
1279 | kgm_pc = im6o.im6o_refhold[cnt].pc[ix] | |
1280 | if (kgm_pc != 0): | |
1281 | if (ix == 0): | |
1282 | out_string += "\nHold [" + str(int(cnt)) + "] (thread " + hex(im6o.im6o_refhold[cnt].th) + "):\n" | |
1283 | out_string += str(int(ix + 1)) + ": " | |
1284 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1285 | out_string += "\n" | |
1286 | ix += 1 | |
1287 | cnt += 1 | |
1288 | cnt = 0 | |
1289 | while (cnt < IM6O_TRACE_HIST_SIZE): | |
1290 | ix = 0 | |
1291 | while (ix < CTRACE_STACK_SIZE): | |
1292 | kgm_pc = im6o.im6o_refrele[cnt].pc[ix] | |
1293 | if (kgm_pc != 0): | |
1294 | if (ix == 0): | |
1295 | out_string += "\nRelease [" + str(int(cnt)) + "] (thread " + hex(im6o.im6o_refrele[cnt].th) + "):\n" | |
1296 | out_string += str(int(ix + 1)) + ": " | |
1297 | out_string += GetSourceInformationForAddress(kgm_pc) | |
1298 | out_string += "\n" | |
1299 | ix += 1 | |
1300 | cnt += 1 | |
1301 | print out_string | |
1302 | # EndMacro: im6o_showdbg | |
1303 | ||
1304 | # Macro: rtentry_trash | |
1305 | @lldb_command('rtentry_trash') | |
1306 | def RtEntryTrash(cmd_args=None): | |
1307 | """ Walk the list of trash route entries | |
1308 | """ | |
1309 | out_string = "" | |
1310 | rt_trash_head = kern.globals.rttrash_head | |
1311 | rtd = Cast(rt_trash_head.tqh_first, 'rtentry_dbg *') | |
1312 | rt_trash_format_string = "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}" | |
1313 | cnt = 0 | |
1314 | while (int(rtd) != 0): | |
1315 | if (cnt == 0): | |
1316 | if (kern.ptrsize == 8): | |
1317 | print " rtentry ref hold rele dst gw parent flags/if\n" | |
1318 | print " ----------------- --- ------ ------ --------------- ----- ------------------ -----------\n" | |
1319 | else: | |
1320 | print " rtentry ref hold rele dst gw parent flags/if\n" | |
1321 | print " --------- --- ------ ------ --------------- ----- ---------- -----------\n" | |
1322 | out_string += rt_trash_format_string.format(cnt, rtd, rtd.rtd_refhold_cnt - rtd.rtd_refrele_cnt, rtd.rtd_refhold_cnt, rtd.rtd_refrele_cnt) + " " | |
1323 | out_string += GetRtEntryPrDetailsAsString(rtd) + "\n" | |
1324 | rtd = rtd.rtd_trash_link.tqe_next | |
1325 | cnt += 1 | |
1326 | print out_string | |
1327 | # EndMacro: rtentry_trash | |
1328 | ||
1329 | # Macro: inifa_trash | |
1330 | @lldb_command('inifa_trash') | |
1331 | def InIfaTrash(cmd_args=None): | |
1332 | """ Walk the list of trash in_ifaddr entries | |
1333 | """ | |
1334 | out_string = "" | |
1335 | ifa_trash_head = kern.globals.inifa_trash_head | |
1336 | ifa = Cast(ifa_trash_head.tqh_first, 'in_ifaddr_dbg *') | |
1337 | inifa_trash_format_string = "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}" | |
1338 | cnt = 0 | |
1339 | while (int(ifa) != 0): | |
1340 | if (cnt == 0): | |
1341 | if (kern.ptrsize == 8): | |
1342 | print " in_ifa ref hold rele" | |
1343 | print " ------------------ --- ------ ----" | |
1344 | else: | |
1345 | print " in_ifa ref hold rele" | |
1346 | print " ---------- --- ----- ------" | |
1347 | out_string += inifa_trash_format_string.format(cnt + 1, ifa, ifa.inifa_refhold_cnt - ifa.inifa_refrele_cnt, ifa.inifa_refhold_cnt, ifa.inifa_refrele_cnt) + " " | |
1348 | out_string += GetSocketAddrAsStringInet(ifa.inifa.ia_ifa.ifa_addr) + "\n" | |
1349 | ifa = ifa.inifa_trash_link.tqe_next | |
1350 | cnt += 1 | |
1351 | print out_string | |
1352 | # EndMacro: inifa_trash | |
1353 | ||
1354 | # Macro: in6ifa_trash | |
1355 | @lldb_command('in6ifa_trash') | |
1356 | def In6IfaTrash(cmd_args=None): | |
1357 | """ Walk the list of trash in6_ifaddr entries | |
1358 | """ | |
1359 | out_string = "" | |
1360 | in6ifa_trash_head = kern.globals.in6ifa_trash_head | |
1361 | ifa = Cast(in6ifa_trash_head.tqh_first, 'in6_ifaddr_dbg *') | |
1362 | in6ifa_trash_format_string = "{0:4d}: 0x{1:x} {2:3d} {3:6d} {4:6d}" | |
1363 | cnt = 0 | |
1364 | while (int(ifa) != 0): | |
1365 | if (cnt == 0): | |
1366 | if (kern.ptrsize == 8): | |
1367 | print " in6_ifa ref hold rele" | |
1368 | print " ------------------ --- ------ ------" | |
1369 | else: | |
1370 | print " in6_ifa ref hold rele" | |
1371 | print " ---------- --- ------ ------" | |
1372 | out_string += in6ifa_trash_format_string.format(cnt + 1, ifa, ifa.in6ifa_refhold_cnt - ifa.in6ifa_refrele_cnt, ifa.in6ifa_refhold_cnt, ifa.in6ifa_refrele_cnt) + " " | |
1373 | out_string += GetSocketAddrAsStringInet6(ifa.in6ifa.ia_ifa.ifa_addr) + "\n" | |
1374 | ifa = ifa.in6ifa_trash_link.tqe_next | |
1375 | cnt += 1 | |
1376 | print out_string | |
1377 | # EndMacro: in6ifa_trash | |
1378 | ||
1379 | # Macro: inm_trash | |
1380 | @lldb_command('inm_trash') | |
1381 | def InmTrash(cmd_args=None): | |
1382 | """ Walk the list of trash in_multi entries | |
1383 | """ | |
1384 | out_string = "" | |
1385 | inm_trash_head = kern.globals.inm_trash_head | |
1386 | inm = Cast(inm_trash_head.tqh_first, 'in_multi_dbg *') | |
1387 | inm_trash_format_string = "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}" | |
1388 | cnt = 0 | |
1389 | while (int(inm) != 0): | |
1390 | if (cnt == 0): | |
1391 | if (kern.ptrsize == 8): | |
1392 | print " inm ref hold rele" | |
1393 | print " ------------------ --- ------ ------" | |
1394 | else: | |
1395 | print " inm ref hold rele" | |
1396 | print " ---------- --- ------ ------" | |
1397 | out_string += inm_trash_format_string.format(cnt + 1, inm, inm.inm_refhold_cnt - inm.inm_refrele_cnt, inm.inm_refhold_cnt, inm.inm_refrele_cnt) + " " | |
1398 | out_string += GetInAddrAsString(addressof(inm.inm.inm_addr)) + "\n" | |
1399 | inm = inm.inm_trash_link.tqe_next | |
1400 | cnt += 1 | |
1401 | print out_string | |
1402 | # EndMacro: inm_trash | |
1403 | ||
1404 | # Macro: in6m_trash | |
1405 | @lldb_command('in6m_trash') | |
1406 | def In6mTrash(cmd_args=None): | |
1407 | """ Walk the list of trash in6_multi entries | |
1408 | """ | |
1409 | out_string = "" | |
1410 | in6m_trash_head = kern.globals.in6m_trash_head | |
1411 | in6m = Cast(in6m_trash_head.tqh_first, 'in6_multi_dbg *') | |
1412 | in6m_trash_format_string = "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}" | |
1413 | cnt = 0 | |
1414 | while (int(in6m) != 0): | |
1415 | if (cnt == 0): | |
1416 | if (kern.ptrsize == 8): | |
1417 | print " in6m ref hold rele" | |
1418 | print " ------------------ --- ------ ------" | |
1419 | else: | |
1420 | print " in6m ref hold rele" | |
1421 | print " ---------- --- ------ ------" | |
1422 | out_string += in6m_trash_format_string.format(cnt + 1, in6m, in6m.in6m_refhold_cnt - in6m.in6m_refrele_cnt, in6m.in6m_refhold_cnt, in6m.in6m_refrele_cnt) + " " | |
1423 | out_string += GetIn6AddrAsString(addressof(in6m.in6m.in6m_addr)) + "\n" | |
1424 | in6m = in6m.in6m_trash_link.tqe_next | |
1425 | cnt += 1 | |
1426 | print out_string | |
1427 | # EndMacro: in6m_trash | |
1428 | ||
1429 | # Macro: ifma_trash | |
1430 | @lldb_command('ifma_trash') | |
1431 | def IfmaTrash(cmd_args=None): | |
1432 | """ Walk the list of trash ifmultiaddr entries | |
1433 | """ | |
1434 | out_string = "" | |
1435 | ifma_trash_head = kern.globals.ifma_trash_head | |
1436 | ifma = Cast(ifma_trash_head.tqh_first, 'ifmultiaddr_dbg *') | |
1437 | ifma_trash_format_string = "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}" | |
1438 | cnt = 0 | |
1439 | while (int(ifma) != 0): | |
1440 | if (cnt == 0): | |
1441 | if (kern.ptrsize == 8): | |
1442 | print " ifma ref hold rele" | |
1443 | print " ------------------ --- ------ ------" | |
1444 | else: | |
1445 | print " ifma ref hold rele" | |
1446 | print " ---------- --- ------ ------" | |
1447 | out_string += ifma_trash_format_string.format(cnt + 1, ifma, ifma.ifma_refhold_cnt - ifma.ifma_refrele_cnt, ifma.ifma_refhold_cnt, ifma.ifma_refrele_cnt) + " " | |
1448 | out_string += GetSocketAddrAsString(ifma.ifma.ifma_addr) + "\n" | |
1449 | out_string += " @ " + ifma.ifma.ifma_ifp.if_xname | |
1450 | ifma = ifma.ifma_trash_link.tqe_next | |
1451 | cnt += 1 | |
1452 | print out_string | |
1453 | # EndMacro: ifma_trash | |
1454 | ||
1455 | def GetInPcb(pcb, proto): | |
1456 | out_string = "" | |
1457 | out_string += hex(pcb) | |
1458 | ||
1459 | if (proto == IPPROTO_TCP): | |
1460 | out_string += " tcp" | |
1461 | else: | |
1462 | if (proto == IPPROTO_UDP): | |
1463 | out_string += " udp" | |
1464 | else: | |
1465 | out_string += str(proto) + "." | |
1466 | if (pcb.inp_vflag & INP_IPV4): | |
1467 | out_string += "4 " | |
1468 | if (pcb.inp_vflag & INP_IPV6): | |
1469 | out_string += "6 " | |
1470 | ||
1471 | if (pcb.inp_vflag & INP_IPV4): | |
1472 | out_string += " " | |
1473 | out_string += GetInAddrAsString(addressof(pcb.inp_dependladdr.inp46_local.ia46_addr4)) | |
1474 | else: | |
1475 | out_string += GetIn6AddrAsString((pcb.inp_dependladdr.inp6_local.__u6_addr.__u6_addr8)) | |
1476 | ||
1477 | out_string += " " | |
1478 | out_string += Getntohs(pcb.inp_lport) | |
1479 | out_string += " " | |
1480 | ||
1481 | if (pcb.inp_vflag & INP_IPV4): | |
1482 | out_string += " " | |
1483 | out_string += GetInAddrAsString(addressof(pcb.inp_dependfaddr.inp46_foreign.ia46_addr4)) | |
1484 | else: | |
1485 | out_string += GetIn6AddrAsString((pcb.inp_dependfaddr.inp6_foreign.__u6_addr.__u6_addr8)) | |
1486 | ||
1487 | out_string += " " | |
1488 | out_string += Getntohs(pcb.inp_fport) | |
1489 | out_string += " " | |
1490 | ||
1491 | if (proto == IPPROTO_TCP): | |
1492 | out_string += GetTcpState(pcb.inp_ppcb) | |
1493 | ||
1494 | if (pcb.inp_flags & INP_RECVOPTS): | |
1495 | out_string += "recvopts " | |
1496 | if (pcb.inp_flags & INP_RECVRETOPTS): | |
1497 | out_string += "recvretopts " | |
1498 | if (pcb.inp_flags & INP_RECVDSTADDR): | |
1499 | out_string += "recvdstaddr " | |
1500 | if (pcb.inp_flags & INP_HDRINCL): | |
1501 | out_string += "hdrincl " | |
1502 | if (pcb.inp_flags & INP_HIGHPORT): | |
1503 | out_string += "highport " | |
1504 | if (pcb.inp_flags & INP_LOWPORT): | |
1505 | out_string += "lowport " | |
1506 | if (pcb.inp_flags & INP_ANONPORT): | |
1507 | out_string += "anonport " | |
1508 | if (pcb.inp_flags & INP_RECVIF): | |
1509 | out_string += "recvif " | |
1510 | if (pcb.inp_flags & INP_MTUDISC): | |
1511 | out_string += "mtudisc " | |
1512 | if (pcb.inp_flags & INP_STRIPHDR): | |
1513 | out_string += "striphdr " | |
1514 | if (pcb.inp_flags & INP_RECV_ANYIF): | |
1515 | out_string += "recv_anyif " | |
1516 | if (pcb.inp_flags & INP_INADDR_ANY): | |
1517 | out_string += "inaddr_any " | |
1518 | if (pcb.inp_flags & INP_RECVTTL): | |
1519 | out_string += "recvttl " | |
1520 | if (pcb.inp_flags & INP_UDP_NOCKSUM): | |
1521 | out_string += "nocksum " | |
1522 | if (pcb.inp_flags & INP_BOUND_IF): | |
1523 | out_string += "boundif " | |
1524 | if (pcb.inp_flags & IN6P_IPV6_V6ONLY): | |
1525 | out_string += "v6only " | |
1526 | if (pcb.inp_flags & IN6P_PKTINFO): | |
1527 | out_string += "pktinfo " | |
1528 | if (pcb.inp_flags & IN6P_HOPLIMIT): | |
1529 | out_string += "hoplimit " | |
1530 | if (pcb.inp_flags & IN6P_HOPOPTS): | |
1531 | out_string += "hopopts " | |
1532 | if (pcb.inp_flags & IN6P_DSTOPTS): | |
1533 | out_string += "dstopts " | |
1534 | if (pcb.inp_flags & IN6P_RTHDR): | |
1535 | out_string += "rthdr " | |
1536 | if (pcb.inp_flags & IN6P_RTHDRDSTOPTS): | |
1537 | out_string += "rthdrdstopts " | |
1538 | if (pcb.inp_flags & IN6P_TCLASS): | |
1539 | out_string += "rcv_tclass " | |
1540 | if (pcb.inp_flags & IN6P_AUTOFLOWLABEL): | |
1541 | out_string += "autoflowlabel " | |
1542 | if (pcb.inp_flags & IN6P_BINDV6ONLY): | |
1543 | out_string += "bindv6only " | |
1544 | if (pcb.inp_flags & IN6P_RFC2292): | |
1545 | out_string += "RFC2292 " | |
1546 | if (pcb.inp_flags & IN6P_MTU): | |
1547 | out_string += "rcv_pmtu " | |
1548 | if (pcb.inp_flags & INP_PKTINFO): | |
1549 | out_string += "pktinfo " | |
1550 | if (pcb.inp_flags & INP_FLOW_SUSPENDED): | |
1551 | out_string += "suspended " | |
1552 | if (pcb.inp_flags & INP_NO_IFT_CELLULAR): | |
1553 | out_string += "nocellular " | |
1554 | if (pcb.inp_flags & INP_FLOW_CONTROLLED): | |
1555 | out_string += "flowctld " | |
1556 | if (pcb.inp_flags & INP_FC_FEEDBACK): | |
1557 | out_string += "fcfeedback " | |
1558 | if (pcb.inp_flags2 & INP2_TIMEWAIT): | |
1559 | out_string += "timewait " | |
1560 | if (pcb.inp_flags2 & INP2_IN_FCTREE): | |
1561 | out_string += "in_fctree " | |
1562 | if (pcb.inp_flags2 & INP2_WANT_FLOW_DIVERT): | |
1563 | out_string += "want_flow_divert " | |
1564 | ||
1565 | so = pcb.inp_socket | |
1566 | if (so != 0): | |
1567 | out_string += "[so=" + str(so) + " s=" + str(int(so.so_snd.sb_cc)) + " r=" + str(int(so.so_rcv.sb_cc)) + " usecnt=" + str(int(so.so_usecount)) + "] " | |
1568 | ||
1569 | if (pcb.inp_state == 0 or pcb.inp_state == INPCB_STATE_INUSE): | |
1570 | out_string += "inuse, " | |
1571 | else: | |
1572 | if (pcb.inp_state == INPCB_STATE_DEAD): | |
1573 | out_string += "dead, " | |
1574 | else: | |
1575 | out_string += "unknown (" + str(int(pcb.inp_state)) + "), " | |
1576 | ||
1577 | return out_string | |
1578 | ||
1579 | def GetPcbInfo(pcbi, proto): | |
1580 | out_string = "" | |
1581 | snd_cc = 0 | |
1582 | snd_buf = unsigned(0) | |
1583 | rcv_cc = 0 | |
1584 | rcv_buf = unsigned(0) | |
1585 | pcbseen = 0 | |
1586 | out_string += "lastport " + str(int(pcbi.ipi_lastport)) + " lastlow " + str(int(pcbi.ipi_lastlow)) + " lasthi " + str(int(pcbi.ipi_lasthi)) + "\n" | |
1587 | out_string += "active pcb count is " + str(int(pcbi.ipi_count)) + "\n" | |
1588 | hashsize = pcbi.ipi_hashmask + 1 | |
1589 | out_string += "hash size is " + str(int(hashsize)) + "\n" | |
1590 | out_string += str(pcbi.ipi_hashbase) + " has the following inpcb(s):\n" | |
1591 | if (kern.ptrsize == 8): | |
1592 | out_string += "pcb proto source address port destination address port\n" | |
1593 | else: | |
1594 | out_string += "pcb proto source address port destination address port\n\n" | |
1595 | ||
1596 | i = 0 | |
1597 | hashbase = pcbi.ipi_hashbase | |
1598 | while (i < hashsize): | |
1599 | head = hashbase[i] | |
1600 | pcb = cast(head.lh_first, 'inpcb *') | |
1601 | while pcb != 0: | |
1602 | pcbseen += 1 | |
1603 | out_string += GetInPcb(pcb, proto) + "\n" | |
1604 | so = pcb.inp_socket | |
1605 | if so != 0: | |
1606 | snd_cc += so.so_snd.sb_cc | |
1607 | mp = so.so_snd.sb_mb | |
1608 | while mp != 0: | |
1609 | snd_buf += 256 | |
1610 | if (mp.m_hdr.mh_flags & 0x01): | |
1611 | snd_buf = mp.M_dat.MH.MH_dat.MH_ext.ext_size | |
1612 | mp = mp.m_hdr.mh_next | |
1613 | rcv_cc += so.so_rcv.sb_cc | |
1614 | mp = so.so_rcv.sb_mb | |
1615 | while mp != 0: | |
1616 | rcv_buf += 256 | |
1617 | if (mp.m_hdr.mh_flags & 0x01): | |
1618 | rcv_buf += mp.M_dat.MH.MH_dat.MH_ext.ext_size | |
1619 | mp = mp.m_hdr.mh_next | |
1620 | pcb = cast(pcb.inp_hash.le_next, 'inpcb *') | |
1621 | i += 1 | |
1622 | ||
1623 | out_string += "total seen " + str(int(pcbseen)) + " snd_cc " + str(int(snd_cc)) + " rcv_cc " + str(int(rcv_cc)) + "\n" | |
1624 | out_string += "total snd_buf " + str(int(snd_buf)) + " rcv_buf " + str(int(rcv_buf)) + "\n" | |
1625 | out_string += "port hash base is " + hex(pcbi.ipi_porthashbase) + "\n" | |
1626 | ||
1627 | i = 0 | |
1628 | hashbase = pcbi.ipi_porthashbase | |
1629 | while (i < hashsize): | |
1630 | head = hashbase[i] | |
1631 | pcb = cast(head.lh_first, 'inpcbport *') | |
1632 | while pcb != 0: | |
1633 | out_string += "\t" | |
1634 | out_string += GetInPcbPort(pcb) | |
1635 | out_string += "\n" | |
1636 | pcb = cast(pcb.phd_hash.le_next, 'inpcbport *') | |
1637 | i += 1 | |
1638 | ||
1639 | return out_string | |
1640 | ||
1641 | def GetInPcbPort(ppcb): | |
1642 | out_string = "" | |
1643 | out_string += hex(ppcb) + ": lport " | |
1644 | out_string += Getntohs(ppcb.phd_port) | |
1645 | return out_string | |
1646 | ||
1647 | ||
1648 | def Getntohs(port): | |
1649 | out_string = "" | |
1650 | #p = unsigned(int(port) & 0x0000ffff) | |
1651 | p = ((port & 0x0000ff00) >> 8) | |
1652 | p |= ((port & 0x000000ff) << 8) | |
1653 | return str(p) | |
1654 | ||
1655 | # Macro: show_kern_event_pcbinfo | |
1656 | def GetKernEventPcbInfo(kev_pcb_head): | |
1657 | out_string = "" | |
1658 | pcb = Cast(kev_pcb_head.lh_first, 'kern_event_pcb *') | |
1659 | if (kern.ptrsize == 8): | |
1660 | kev_pcb_format_string = "0x{0:<16x} {1:12d} {2:16d} {3:16d}" | |
1661 | out_string += " evp socket vendor code class filter subclass filter\n" | |
1662 | out_string += "-------------- ----------- ------------ ---------------\n" | |
1663 | else: | |
1664 | kev_pcb_format_string = "0x{0:<8x} {1:12d} {2:16d} {3:16d}" | |
1665 | out_string += "evp socket vendor code class filter subclass filter\n" | |
1666 | out_string += "---------- ----------- ------------ ---------------\n" | |
1667 | while (pcb != 0): | |
1668 | out_string += kev_pcb_format_string.format(pcb.evp_socket, pcb.evp_vendor_code_filter, pcb.evp_class_filter, pcb.evp_subclass_filter) | |
1669 | out_string += "\n" | |
1670 | pcb = pcb.evp_link.le_next | |
1671 | return out_string | |
1672 | ||
1673 | @lldb_command('show_kern_event_pcbinfo') | |
1674 | def ShowKernEventPcbInfo(cmd_args=None): | |
1675 | """ Display the list of Kernel Event protocol control block information | |
1676 | """ | |
1677 | print GetKernEventPcbInfo(addressof(kern.globals.kern_event_head)) | |
1678 | # EndMacro: show_kern_event_pcbinfo | |
1679 | ||
1680 | # Macro: show_kern_control_pcbinfo | |
1681 | def GetKernControlPcbInfo(ctl_head): | |
1682 | out_string = "" | |
1683 | kctl = Cast(ctl_head.tqh_first, 'kctl *') | |
1684 | if (kern.ptrsize == 8): | |
1685 | kcb_format_string = "0x{0:<16x} {1:4d} {2:10d}\n" | |
1686 | else: | |
1687 | kcb_format_string = "0x{0:<8x} {1:4d} {2:10d}\n" | |
1688 | while unsigned(kctl) != 0: | |
1689 | kctl_name = "controller: " + str(kctl.name) + "\n" | |
1690 | out_string += kctl_name | |
1691 | kcb = Cast(kctl.kcb_head.tqh_first, 'ctl_cb *') | |
1692 | if unsigned(kcb) != 0: | |
1693 | if (kern.ptrsize == 8): | |
1694 | out_string += "socket unit usecount\n" | |
1695 | out_string += "------ ---- --------\n" | |
1696 | else: | |
1697 | out_string += "socket unit usecount\n" | |
1698 | out_string += "------ ---- --------\n" | |
1699 | while unsigned(kcb) != 0: | |
1700 | out_string += kcb_format_string.format(kcb.so, kcb.unit, kcb.usecount) | |
1701 | kcb = kcb.next.tqe_next | |
1702 | out_string += "\n" | |
1703 | kctl = kctl.next.tqe_next | |
1704 | return out_string | |
1705 | ||
1706 | @lldb_command('show_kern_control_pcbinfo') | |
1707 | def ShowKernControlPcbInfo(cmd_args=None): | |
1708 | """ Display the list of Kernel Control protocol control block information | |
1709 | """ | |
1710 | print GetKernControlPcbInfo(addressof(kern.globals.ctl_head)) | |
1711 | # EndMacro: show_kern_control_pcbinfo | |
1712 | ||
1713 | # Macro: show_tcp_pcbinfo | |
1714 | @lldb_command('show_tcp_pcbinfo') | |
1715 | def ShowTcpPcbInfo(cmd_args=None): | |
1716 | """ Display the list of TCP protocol control block information | |
1717 | """ | |
1718 | print GetPcbInfo(addressof(kern.globals.tcbinfo), IPPROTO_TCP) | |
1719 | # EndMacro: show_tcp_pcbinfo | |
1720 | ||
1721 | # Macro: show_udp_pcbinfo | |
1722 | @lldb_command('show_udp_pcbinfo') | |
1723 | def ShowUdpPcbInfo(cmd_args=None): | |
1724 | """ Display the list of UDP protocol control block information | |
1725 | """ | |
1726 | print GetPcbInfo(addressof(kern.globals.udbinfo), IPPROTO_UDP) | |
1727 | # EndMacro: show_udp_pcbinfo | |
1728 | ||
1729 | # Macro: show_tcp_timewaitslots | |
1730 | @lldb_command('show_tcp_timewaitslots') | |
1731 | def ShowTcpTimeWaitSlots(cmd_args=None): | |
1732 | """ Display the list of the TCP protocol control blocks in TIMEWAIT | |
1733 | """ | |
1734 | out_string = "" | |
1735 | slot = -1 | |
1736 | _all = 0 | |
1737 | ||
1738 | if len(cmd_args) > 0: | |
1739 | if (int(cmd_args[0]) == -1): | |
1740 | _all = 1 | |
1741 | else: | |
1742 | slot = int(cmd_args[0]) | |
1743 | ||
1744 | out_string += "time wait slot size " + str(N_TIME_WAIT_SLOTS) + " cur_tw_slot " + str(int(kern.globals.cur_tw_slot)) + "\n" | |
1745 | i = 0 | |
1746 | ||
1747 | while (i < N_TIME_WAIT_SLOTS): | |
1748 | perslot = 0 | |
1749 | head = kern.globals.time_wait_slots[i] | |
1750 | if (i == slot or slot == -1): | |
1751 | pcb0 = cast(head.lh_first, 'inpcb *') | |
1752 | while (pcb0 != 0): | |
1753 | perslot += 1 | |
1754 | pcb0 = pcb0.inp_list.le_next | |
1755 | ||
1756 | out_string += " slot " + str(i) + " count " + str(perslot) + "\n" | |
1757 | ||
1758 | if (_all or i == slot): | |
1759 | pcb0 = cast(head.lh_first, 'inpcb *') | |
1760 | while (pcb0 != 0): | |
1761 | out_string += "\t" | |
1762 | out_string += GetInPcb(pcb0, IPPROTO_TCP) | |
1763 | out_string += "\n" | |
1764 | pcb0 = pcb0.inp_list.le_next | |
1765 | ||
1766 | i += 1 | |
1767 | print out_string | |
1768 | # EndMacro: show_tcp_timewaitslots | |
1769 | ||
1770 | # Macro: show_domains | |
1771 | @lldb_command('show_domains') | |
1772 | def ShowDomains(cmd_args=None): | |
1773 | """ Display the list of the domains | |
1774 | """ | |
1775 | out_string = "" | |
1776 | domains = kern.globals.domains | |
1777 | dp = Cast(domains.tqh_first, 'domain *') | |
1778 | ifma_trash_format_string = "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}" | |
1779 | cnt = 0 | |
1780 | while (dp != 0): | |
1781 | out_string += "\"" + str(dp.dom_name) + "\"" + "[" + str(int(dp.dom_refs)) + " refs] domain " + hex(dp) + "\n" | |
1782 | out_string += " family:\t" + str(int(dp.dom_family)) + "\n" | |
1783 | out_string += " flags:0x\t" + str(int(dp.dom_flags)) + "\n" | |
1784 | out_string += " rtparams:\toff=" + str(int(dp.dom_rtoffset)) + ", maxrtkey=" + str(int(dp.dom_maxrtkey)) + "\n" | |
1785 | ||
1786 | if (dp.dom_init): | |
1787 | out_string += " init:\t" | |
1788 | out_string += GetSourceInformationForAddress(dp.dom_init) + "\n" | |
1789 | if (dp.dom_externalize): | |
1790 | out_string += " externalize:\t" | |
1791 | out_string += GetSourceInformationForAddress(dp.dom_externalize) + "\n" | |
1792 | if (dp.dom_dispose): | |
1793 | out_string += " dispose:\t" | |
1794 | out_string += GetSourceInformationForAddress(dp.dom_dispose) + "\n" | |
1795 | if (dp.dom_rtattach): | |
1796 | out_string += " rtattach:\t" | |
1797 | out_string += GetSourceInformationForAddress(dp.dom_rtattach) + "\n" | |
1798 | if (dp.dom_old): | |
1799 | out_string += " old:\t" | |
1800 | out_string += GetSourceInformationForAddress(dp.dom_old) + "\n" | |
1801 | ||
1802 | pr = Cast(dp.dom_protosw.tqh_first, 'protosw *') | |
1803 | while pr != 0: | |
1804 | pru = pr.pr_usrreqs | |
1805 | out_string += "\ttype " + str(int(pr.pr_type)) + ", protocol " + str(int(pr.pr_protocol)) + ", protosw " + hex(pr) + "\n" | |
1806 | out_string += "\t flags:0x\t" + hex(pr.pr_flags) + "\n" | |
1807 | if (pr.pr_input): | |
1808 | out_string += "\t input:\t" | |
1809 | out_string += GetSourceInformationForAddress(pr.pr_input) + "\n" | |
1810 | if (pr.pr_output): | |
1811 | out_string += "\t output:\t" | |
1812 | out_string += GetSourceInformationForAddress(pr.pr_output) + "\n" | |
1813 | if (pr.pr_ctlinput): | |
1814 | out_string += "\t ctlinput:\t" | |
1815 | out_string += GetSourceInformationForAddress(pr.pr_ctlinput) + "\n" | |
1816 | if (pr.pr_ctloutput): | |
1817 | out_string += "\t ctloutput:\t" | |
1818 | out_string += GetSourceInformationForAddress(pr.pr_ctloutput) + "\n" | |
1819 | if (pr.pr_init): | |
1820 | out_string += "\t init:\t" | |
1821 | out_string += GetSourceInformationForAddress(pr.pr_init) + "\n" | |
1822 | if (pr.pr_drain): | |
1823 | out_string += "\t drain:\t" | |
1824 | out_string += GetSourceInformationForAddress(pr.pr_drain) + "\n" | |
1825 | if (pr.pr_sysctl): | |
1826 | out_string += "\t sysctl:\t" | |
1827 | out_string += GetSourceInformationForAddress(pr.pr_sysctl) + "\n" | |
1828 | if (pr.pr_lock): | |
1829 | out_string += "\t lock:\t" | |
1830 | out_string += GetSourceInformationForAddress(pr.pr_lock) + "\n" | |
1831 | if (pr.pr_unlock): | |
1832 | out_string += "\t unlock:\t" | |
1833 | out_string += GetSourceInformationForAddress(pr.pr_unlock) + "\n" | |
1834 | if (pr.pr_getlock): | |
1835 | out_string += "\t getlock:\t" | |
1836 | out_string += GetSourceInformationForAddress(pr.pr_getlock) + "\n" | |
1837 | if (pr.pr_old): | |
1838 | out_string += "\t old:\t" | |
1839 | out_string += GetSourceInformationForAddress(pr.pr_old) + "\n" | |
1840 | ||
1841 | out_string += "\t pru_flags:0x\t" + hex(pru.pru_flags) + "\n" | |
1842 | out_string += "\t abort:\t" | |
1843 | out_string += GetSourceInformationForAddress(pru.pru_abort) + "\n" | |
1844 | out_string += "\t accept:\t" | |
1845 | out_string += GetSourceInformationForAddress(pru.pru_accept) + "\n" | |
1846 | out_string += "\t attach:\t" | |
1847 | out_string += GetSourceInformationForAddress(pru.pru_attach) + "\n" | |
1848 | out_string += "\t bind:\t" | |
1849 | out_string += GetSourceInformationForAddress(pru.pru_bind) + "\n" | |
1850 | out_string += "\t connect:\t" | |
1851 | out_string += GetSourceInformationForAddress(pru.pru_connect) + "\n" | |
1852 | out_string += "\t connect2:\t" | |
1853 | out_string += GetSourceInformationForAddress(pru.pru_connect2) + "\n" | |
1854 | out_string += "\t connectx:\t" | |
1855 | out_string += GetSourceInformationForAddress(pru.pru_connectx) + "\n" | |
1856 | out_string += "\t control:\t" | |
1857 | out_string += GetSourceInformationForAddress(pru.pru_control) + "\n" | |
1858 | out_string += "\t detach:\t" | |
1859 | out_string += GetSourceInformationForAddress(pru.pru_detach) + "\n" | |
1860 | out_string += "\t disconnect:\t" | |
1861 | out_string += GetSourceInformationForAddress(pru.pru_disconnect) + "\n" | |
1862 | out_string += "\t listen:\t" | |
1863 | out_string += GetSourceInformationForAddress(pru.pru_listen) + "\n" | |
1864 | out_string += "\t peeloff:\t" | |
1865 | out_string += GetSourceInformationForAddress(pru.pru_peeloff) + "\n" | |
1866 | out_string += "\t peeraddr:\t" | |
1867 | out_string += GetSourceInformationForAddress(pru.pru_peeraddr) + "\n" | |
1868 | out_string += "\t rcvd:\t" | |
1869 | out_string += GetSourceInformationForAddress(pru.pru_rcvd) + "\n" | |
1870 | out_string += "\t rcvoob:\t" | |
1871 | out_string += GetSourceInformationForAddress(pru.pru_rcvoob) + "\n" | |
1872 | out_string += "\t send:\t" | |
1873 | out_string += GetSourceInformationForAddress(pru.pru_send) + "\n" | |
1874 | out_string += "\t sense:\t" | |
1875 | out_string += GetSourceInformationForAddress(pru.pru_sense) + "\n" | |
1876 | out_string += "\t shutdown:\t" | |
1877 | out_string += GetSourceInformationForAddress(pru.pru_shutdown) + "\n" | |
1878 | out_string += "\t sockaddr:\t" | |
1879 | out_string += GetSourceInformationForAddress(pru.pru_sockaddr) + "\n" | |
1880 | out_string += "\t sopoll:\t" | |
1881 | out_string += GetSourceInformationForAddress(pru.pru_sopoll) + "\n" | |
1882 | out_string += "\t soreceive:\t" | |
1883 | out_string += GetSourceInformationForAddress(pru.pru_soreceive) + "\n" | |
1884 | out_string += "\t sosend:\t" | |
1885 | out_string += GetSourceInformationForAddress(pru.pru_sosend) + "\n" | |
1886 | pr = pr.pr_entry.tqe_next | |
1887 | dp = dp.dom_entry.tqe_next | |
1888 | ||
1889 | print out_string | |
1890 | # EndMacro: show_domains |