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