1c3b162d5SRobert Watson /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
38a36da99SPedro F. Giffuni *
4c3b162d5SRobert Watson * Copyright (c) 2007 Robert N. M. Watson
5c3b162d5SRobert Watson * All rights reserved.
6c3b162d5SRobert Watson *
7c3b162d5SRobert Watson * Redistribution and use in source and binary forms, with or without
8c3b162d5SRobert Watson * modification, are permitted provided that the following conditions
9c3b162d5SRobert Watson * are met:
10c3b162d5SRobert Watson * 1. Redistributions of source code must retain the above copyright
11c3b162d5SRobert Watson * notice, this list of conditions and the following disclaimer.
12c3b162d5SRobert Watson * 2. Redistributions in binary form must reproduce the above copyright
13c3b162d5SRobert Watson * notice, this list of conditions and the following disclaimer in the
14c3b162d5SRobert Watson * documentation and/or other materials provided with the distribution.
15c3b162d5SRobert Watson *
16c3b162d5SRobert Watson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17c3b162d5SRobert Watson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18c3b162d5SRobert Watson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19c3b162d5SRobert Watson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20c3b162d5SRobert Watson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21c3b162d5SRobert Watson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22c3b162d5SRobert Watson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23c3b162d5SRobert Watson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24c3b162d5SRobert Watson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25c3b162d5SRobert Watson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26c3b162d5SRobert Watson * SUCH DAMAGE.
27c3b162d5SRobert Watson */
28c3b162d5SRobert Watson
29c3b162d5SRobert Watson /*
30c3b162d5SRobert Watson * Debugger routines relating to sockets, protocols, etc, for use in DDB.
31c3b162d5SRobert Watson */
32c3b162d5SRobert Watson
33c3b162d5SRobert Watson #include <sys/cdefs.h>
34c3b162d5SRobert Watson #include "opt_ddb.h"
35c3b162d5SRobert Watson
36c3b162d5SRobert Watson #include <sys/param.h>
37c3b162d5SRobert Watson #include <sys/domain.h>
38c3b162d5SRobert Watson #include <sys/kernel.h>
39c3b162d5SRobert Watson #include <sys/protosw.h>
40c3b162d5SRobert Watson #include <sys/socket.h>
41c3b162d5SRobert Watson #include <sys/socketvar.h>
42c3b162d5SRobert Watson
43c3b162d5SRobert Watson #ifdef DDB
44c3b162d5SRobert Watson #include <ddb/ddb.h>
45c3b162d5SRobert Watson
46c3b162d5SRobert Watson static void
db_print_sotype(short so_type)47c3b162d5SRobert Watson db_print_sotype(short so_type)
48c3b162d5SRobert Watson {
49c3b162d5SRobert Watson
50c3b162d5SRobert Watson switch (so_type) {
51c3b162d5SRobert Watson case SOCK_STREAM:
52c3b162d5SRobert Watson db_printf("SOCK_STREAM");
53c3b162d5SRobert Watson break;
54c3b162d5SRobert Watson
55c3b162d5SRobert Watson case SOCK_DGRAM:
56c3b162d5SRobert Watson db_printf("SOCK_DGRAM");
57c3b162d5SRobert Watson break;
58c3b162d5SRobert Watson
59c3b162d5SRobert Watson case SOCK_RAW:
60c3b162d5SRobert Watson db_printf("SOCK_RAW");
61c3b162d5SRobert Watson break;
62c3b162d5SRobert Watson
63c3b162d5SRobert Watson case SOCK_RDM:
64c3b162d5SRobert Watson db_printf("SOCK_RDM");
65c3b162d5SRobert Watson break;
66c3b162d5SRobert Watson
67c3b162d5SRobert Watson case SOCK_SEQPACKET:
68c3b162d5SRobert Watson db_printf("SOCK_SEQPACKET");
69c3b162d5SRobert Watson break;
70c3b162d5SRobert Watson
71c3b162d5SRobert Watson default:
72c3b162d5SRobert Watson db_printf("unknown");
73c3b162d5SRobert Watson break;
74c3b162d5SRobert Watson }
75c3b162d5SRobert Watson }
76c3b162d5SRobert Watson
77c3b162d5SRobert Watson static void
db_print_sooptions(int so_options)781a43cff9SSean Bruno db_print_sooptions(int so_options)
79c3b162d5SRobert Watson {
80c3b162d5SRobert Watson int comma;
81c3b162d5SRobert Watson
82c3b162d5SRobert Watson comma = 0;
83c3b162d5SRobert Watson if (so_options & SO_DEBUG) {
84c3b162d5SRobert Watson db_printf("%sSO_DEBUG", comma ? ", " : "");
85c3b162d5SRobert Watson comma = 1;
86c3b162d5SRobert Watson }
87c3b162d5SRobert Watson if (so_options & SO_ACCEPTCONN) {
88c3b162d5SRobert Watson db_printf("%sSO_ACCEPTCONN", comma ? ", " : "");
89c3b162d5SRobert Watson comma = 1;
90c3b162d5SRobert Watson }
91c3b162d5SRobert Watson if (so_options & SO_REUSEADDR) {
92c3b162d5SRobert Watson db_printf("%sSO_REUSEADDR", comma ? ", " : "");
93c3b162d5SRobert Watson comma = 1;
94c3b162d5SRobert Watson }
95c3b162d5SRobert Watson if (so_options & SO_KEEPALIVE) {
96c3b162d5SRobert Watson db_printf("%sSO_KEEPALIVE", comma ? ", " : "");
97c3b162d5SRobert Watson comma = 1;
98c3b162d5SRobert Watson }
99c3b162d5SRobert Watson if (so_options & SO_DONTROUTE) {
100c3b162d5SRobert Watson db_printf("%sSO_DONTROUTE", comma ? ", " : "");
101c3b162d5SRobert Watson comma = 1;
102c3b162d5SRobert Watson }
103c3b162d5SRobert Watson if (so_options & SO_BROADCAST) {
104c3b162d5SRobert Watson db_printf("%sSO_BROADCAST", comma ? ", " : "");
105c3b162d5SRobert Watson comma = 1;
106c3b162d5SRobert Watson }
107c3b162d5SRobert Watson if (so_options & SO_USELOOPBACK) {
108c3b162d5SRobert Watson db_printf("%sSO_USELOOPBACK", comma ? ", " : "");
109c3b162d5SRobert Watson comma = 1;
110c3b162d5SRobert Watson }
111c3b162d5SRobert Watson if (so_options & SO_LINGER) {
112c3b162d5SRobert Watson db_printf("%sSO_LINGER", comma ? ", " : "");
113c3b162d5SRobert Watson comma = 1;
114c3b162d5SRobert Watson }
115c3b162d5SRobert Watson if (so_options & SO_OOBINLINE) {
116c3b162d5SRobert Watson db_printf("%sSO_OOBINLINE", comma ? ", " : "");
117c3b162d5SRobert Watson comma = 1;
118c3b162d5SRobert Watson }
119c3b162d5SRobert Watson if (so_options & SO_REUSEPORT) {
120c3b162d5SRobert Watson db_printf("%sSO_REUSEPORT", comma ? ", " : "");
121c3b162d5SRobert Watson comma = 1;
122c3b162d5SRobert Watson }
1231a43cff9SSean Bruno if (so_options & SO_REUSEPORT_LB) {
1241a43cff9SSean Bruno db_printf("%sSO_REUSEPORT_LB", comma ? ", " : "");
1251a43cff9SSean Bruno comma = 1;
1261a43cff9SSean Bruno }
127c3b162d5SRobert Watson if (so_options & SO_TIMESTAMP) {
128c3b162d5SRobert Watson db_printf("%sSO_TIMESTAMP", comma ? ", " : "");
129c3b162d5SRobert Watson comma = 1;
130c3b162d5SRobert Watson }
131c3b162d5SRobert Watson if (so_options & SO_NOSIGPIPE) {
132c3b162d5SRobert Watson db_printf("%sSO_NOSIGPIPE", comma ? ", " : "");
133c3b162d5SRobert Watson comma = 1;
134c3b162d5SRobert Watson }
135c3b162d5SRobert Watson if (so_options & SO_ACCEPTFILTER) {
136c3b162d5SRobert Watson db_printf("%sSO_ACCEPTFILTER", comma ? ", " : "");
137c3b162d5SRobert Watson comma = 1;
138c3b162d5SRobert Watson }
139c3b162d5SRobert Watson if (so_options & SO_BINTIME) {
140c3b162d5SRobert Watson db_printf("%sSO_BINTIME", comma ? ", " : "");
141c3b162d5SRobert Watson comma = 1;
142c3b162d5SRobert Watson }
143ce332f1eSPawel Jakub Dawidek if (so_options & SO_NO_OFFLOAD) {
144ce332f1eSPawel Jakub Dawidek db_printf("%sSO_NO_OFFLOAD", comma ? ", " : "");
145ce332f1eSPawel Jakub Dawidek comma = 1;
146ce332f1eSPawel Jakub Dawidek }
147ce332f1eSPawel Jakub Dawidek if (so_options & SO_NO_DDP) {
148ce332f1eSPawel Jakub Dawidek db_printf("%sSO_NO_DDP", comma ? ", " : "");
149ce332f1eSPawel Jakub Dawidek comma = 1;
150ce332f1eSPawel Jakub Dawidek }
151c3b162d5SRobert Watson }
152c3b162d5SRobert Watson
153c3b162d5SRobert Watson static void
db_print_sostate(short so_state)154c3b162d5SRobert Watson db_print_sostate(short so_state)
155c3b162d5SRobert Watson {
156c3b162d5SRobert Watson int comma;
157c3b162d5SRobert Watson
158c3b162d5SRobert Watson comma = 0;
159c3b162d5SRobert Watson if (so_state & SS_ISCONNECTED) {
160c3b162d5SRobert Watson db_printf("%sSS_ISCONNECTED", comma ? ", " : "");
161c3b162d5SRobert Watson comma = 1;
162c3b162d5SRobert Watson }
163c3b162d5SRobert Watson if (so_state & SS_ISCONNECTING) {
164c3b162d5SRobert Watson db_printf("%sSS_ISCONNECTING", comma ? ", " : "");
165c3b162d5SRobert Watson comma = 1;
166c3b162d5SRobert Watson }
167c3b162d5SRobert Watson if (so_state & SS_ISDISCONNECTING) {
168c3b162d5SRobert Watson db_printf("%sSS_ISDISCONNECTING", comma ? ", " : "");
169c3b162d5SRobert Watson comma = 1;
170c3b162d5SRobert Watson }
171c3b162d5SRobert Watson if (so_state & SS_NBIO) {
172c3b162d5SRobert Watson db_printf("%sSS_NBIO", comma ? ", " : "");
173c3b162d5SRobert Watson comma = 1;
174c3b162d5SRobert Watson }
175c3b162d5SRobert Watson if (so_state & SS_ASYNC) {
176c3b162d5SRobert Watson db_printf("%sSS_ASYNC", comma ? ", " : "");
177c3b162d5SRobert Watson comma = 1;
178c3b162d5SRobert Watson }
179c3b162d5SRobert Watson }
180c3b162d5SRobert Watson
181c3b162d5SRobert Watson static void
db_print_soqstate(int so_qstate)182c3b162d5SRobert Watson db_print_soqstate(int so_qstate)
183c3b162d5SRobert Watson {
184c3b162d5SRobert Watson int comma;
185c3b162d5SRobert Watson
186c3b162d5SRobert Watson comma = 0;
187c3b162d5SRobert Watson if (so_qstate & SQ_INCOMP) {
188c3b162d5SRobert Watson db_printf("%sSQ_INCOMP", comma ? ", " : "");
189c3b162d5SRobert Watson comma = 1;
190c3b162d5SRobert Watson }
191c3b162d5SRobert Watson if (so_qstate & SQ_COMP) {
192c3b162d5SRobert Watson db_printf("%sSQ_COMP", comma ? ", " : "");
193c3b162d5SRobert Watson comma = 1;
194c3b162d5SRobert Watson }
195c3b162d5SRobert Watson }
196c3b162d5SRobert Watson
197c3b162d5SRobert Watson static void
db_print_sbstate(short sb_state)198c3b162d5SRobert Watson db_print_sbstate(short sb_state)
199c3b162d5SRobert Watson {
200c3b162d5SRobert Watson int comma;
201c3b162d5SRobert Watson
202c3b162d5SRobert Watson comma = 0;
203c3b162d5SRobert Watson if (sb_state & SBS_CANTSENDMORE) {
20494df6fadSSergey Kandaurov db_printf("%sSBS_CANTSENDMORE", comma ? ", " : "");
205c3b162d5SRobert Watson comma = 1;
206c3b162d5SRobert Watson }
207c3b162d5SRobert Watson if (sb_state & SBS_CANTRCVMORE) {
20894df6fadSSergey Kandaurov db_printf("%sSBS_CANTRCVMORE", comma ? ", " : "");
209c3b162d5SRobert Watson comma = 1;
210c3b162d5SRobert Watson }
211c3b162d5SRobert Watson if (sb_state & SBS_RCVATMARK) {
21294df6fadSSergey Kandaurov db_printf("%sSBS_RCVATMARK", comma ? ", " : "");
213c3b162d5SRobert Watson comma = 1;
214c3b162d5SRobert Watson }
215c3b162d5SRobert Watson }
216c3b162d5SRobert Watson
217c3b162d5SRobert Watson static void
db_print_indent(int indent)218c3b162d5SRobert Watson db_print_indent(int indent)
219c3b162d5SRobert Watson {
220c3b162d5SRobert Watson int i;
221c3b162d5SRobert Watson
222c3b162d5SRobert Watson for (i = 0; i < indent; i++)
223c3b162d5SRobert Watson db_printf(" ");
224c3b162d5SRobert Watson }
225c3b162d5SRobert Watson
226c3b162d5SRobert Watson static void
db_print_domain(struct domain * d,const char * domain_name,int indent)227f44e6e2eSJulian Elischer db_print_domain(struct domain *d, const char *domain_name, int indent)
228c3b162d5SRobert Watson {
229c3b162d5SRobert Watson
230c3b162d5SRobert Watson db_print_indent(indent);
231f44e6e2eSJulian Elischer db_printf("%s at %p\n", domain_name, d);
232c3b162d5SRobert Watson
233c3b162d5SRobert Watson indent += 2;
234c3b162d5SRobert Watson
235c3b162d5SRobert Watson db_print_indent(indent);
236c3b162d5SRobert Watson db_printf("dom_family: %d ", d->dom_family);
237c3b162d5SRobert Watson db_printf("dom_name: %s\n", d->dom_name);
238c3b162d5SRobert Watson
239c3b162d5SRobert Watson db_print_indent(indent);
240c3b162d5SRobert Watson db_printf("dom_externalize: %p ", d->dom_externalize);
241c3b162d5SRobert Watson
242c3b162d5SRobert Watson db_print_indent(indent);
243c3b162d5SRobert Watson db_printf("dom_protosw: %p ", d->dom_protosw);
244e18c5816SGleb Smirnoff db_printf("dom_next: %p\n", d->dom_next.sle_next);
245c3b162d5SRobert Watson
246c3b162d5SRobert Watson db_print_indent(indent);
247c3b162d5SRobert Watson db_printf("dom_rtattach: %p ", d->dom_rtattach);
248c3b162d5SRobert Watson
249c3b162d5SRobert Watson db_print_indent(indent);
250c3b162d5SRobert Watson db_printf("dom_ifattach: %p ", d->dom_ifattach);
251c3b162d5SRobert Watson db_printf("dom_ifdetach: %p\n", d->dom_ifdetach);
252c3b162d5SRobert Watson }
253c3b162d5SRobert Watson
254c3b162d5SRobert Watson static void
db_print_prflags(short pr_flags)255c3b162d5SRobert Watson db_print_prflags(short pr_flags)
256c3b162d5SRobert Watson {
257c3b162d5SRobert Watson int comma;
258c3b162d5SRobert Watson
259c3b162d5SRobert Watson comma = 0;
260c3b162d5SRobert Watson if (pr_flags & PR_ATOMIC) {
261c3b162d5SRobert Watson db_printf("%sPR_ATOMIC", comma ? ", " : "");
262c3b162d5SRobert Watson comma = 1;
263c3b162d5SRobert Watson }
264c3b162d5SRobert Watson if (pr_flags & PR_ADDR) {
265c3b162d5SRobert Watson db_printf("%sPR_ADDR", comma ? ", " : "");
266c3b162d5SRobert Watson comma = 1;
267c3b162d5SRobert Watson }
268c3b162d5SRobert Watson if (pr_flags & PR_CONNREQUIRED) {
269c3b162d5SRobert Watson db_printf("%sPR_CONNREQUIRED", comma ? ", " : "");
270c3b162d5SRobert Watson comma = 1;
271c3b162d5SRobert Watson }
272c3b162d5SRobert Watson if (pr_flags & PR_WANTRCVD) {
273c3b162d5SRobert Watson db_printf("%sPR_WANTRCVD", comma ? ", " : "");
274c3b162d5SRobert Watson comma = 1;
275c3b162d5SRobert Watson }
276c3b162d5SRobert Watson if (pr_flags & PR_IMPLOPCL) {
277c3b162d5SRobert Watson db_printf("%sPR_IMPLOPCL", comma ? ", " : "");
278c3b162d5SRobert Watson comma = 1;
279c3b162d5SRobert Watson }
280c3b162d5SRobert Watson }
281c3b162d5SRobert Watson
282c3b162d5SRobert Watson static void
db_print_protosw(struct protosw * pr,const char * prname,int indent)283c3b162d5SRobert Watson db_print_protosw(struct protosw *pr, const char *prname, int indent)
284c3b162d5SRobert Watson {
285c3b162d5SRobert Watson
286c3b162d5SRobert Watson db_print_indent(indent);
287c3b162d5SRobert Watson db_printf("%s at %p\n", prname, pr);
288c3b162d5SRobert Watson
289c3b162d5SRobert Watson indent += 2;
290c3b162d5SRobert Watson
291c3b162d5SRobert Watson db_print_indent(indent);
292c3b162d5SRobert Watson db_printf("pr_type: %d ", pr->pr_type);
293c3b162d5SRobert Watson db_printf("pr_domain: %p\n", pr->pr_domain);
294c3b162d5SRobert Watson if (pr->pr_domain != NULL)
295c3b162d5SRobert Watson db_print_domain(pr->pr_domain, "pr_domain", indent);
296c3b162d5SRobert Watson
297c3b162d5SRobert Watson db_print_indent(indent);
298c3b162d5SRobert Watson db_printf("pr_protocol: %d\n", pr->pr_protocol);
299c3b162d5SRobert Watson
300c3b162d5SRobert Watson db_print_indent(indent);
301c3b162d5SRobert Watson db_printf("pr_flags: %d (", pr->pr_flags);
302c3b162d5SRobert Watson db_print_prflags(pr->pr_flags);
303c3b162d5SRobert Watson db_printf(")\n");
304c3b162d5SRobert Watson
305c3b162d5SRobert Watson db_print_indent(indent);
306c3b162d5SRobert Watson db_printf("pr_ctloutput: %p ", pr->pr_ctloutput);
307c3b162d5SRobert Watson }
308c3b162d5SRobert Watson
309c3b162d5SRobert Watson static void
db_print_sbflags(short sb_flags)310c3b162d5SRobert Watson db_print_sbflags(short sb_flags)
311c3b162d5SRobert Watson {
312c3b162d5SRobert Watson int comma;
313c3b162d5SRobert Watson
314c3b162d5SRobert Watson comma = 0;
315c3b162d5SRobert Watson if (sb_flags & SB_WAIT) {
316c3b162d5SRobert Watson db_printf("%sSB_WAIT", comma ? ", " : "");
317c3b162d5SRobert Watson comma = 1;
318c3b162d5SRobert Watson }
319c3b162d5SRobert Watson if (sb_flags & SB_SEL) {
320c3b162d5SRobert Watson db_printf("%sSB_SEL", comma ? ", " : "");
321c3b162d5SRobert Watson comma = 1;
322c3b162d5SRobert Watson }
323c3b162d5SRobert Watson if (sb_flags & SB_ASYNC) {
324c3b162d5SRobert Watson db_printf("%sSB_ASYNC", comma ? ", " : "");
325c3b162d5SRobert Watson comma = 1;
326c3b162d5SRobert Watson }
327c3b162d5SRobert Watson if (sb_flags & SB_UPCALL) {
328c3b162d5SRobert Watson db_printf("%sSB_UPCALL", comma ? ", " : "");
329c3b162d5SRobert Watson comma = 1;
330c3b162d5SRobert Watson }
331c3b162d5SRobert Watson if (sb_flags & SB_AIO) {
332c3b162d5SRobert Watson db_printf("%sSB_AIO", comma ? ", " : "");
333c3b162d5SRobert Watson comma = 1;
334c3b162d5SRobert Watson }
335c3b162d5SRobert Watson if (sb_flags & SB_KNOTE) {
336c3b162d5SRobert Watson db_printf("%sSB_KNOTE", comma ? ", " : "");
337c3b162d5SRobert Watson comma = 1;
338c3b162d5SRobert Watson }
339c3b162d5SRobert Watson if (sb_flags & SB_AUTOSIZE) {
340c3b162d5SRobert Watson db_printf("%sSB_AUTOSIZE", comma ? ", " : "");
341c3b162d5SRobert Watson comma = 1;
342c3b162d5SRobert Watson }
343c3b162d5SRobert Watson }
344c3b162d5SRobert Watson
345c3b162d5SRobert Watson static void
db_print_sockbuf(struct sockbuf * sb,const char * sockbufname,int indent)346c3b162d5SRobert Watson db_print_sockbuf(struct sockbuf *sb, const char *sockbufname, int indent)
347c3b162d5SRobert Watson {
348c3b162d5SRobert Watson
349c3b162d5SRobert Watson db_print_indent(indent);
350c3b162d5SRobert Watson db_printf("%s at %p\n", sockbufname, sb);
351c3b162d5SRobert Watson
352c3b162d5SRobert Watson indent += 2;
353c3b162d5SRobert Watson
354c3b162d5SRobert Watson db_print_indent(indent);
355c3b162d5SRobert Watson db_printf("sb_state: 0x%x (", sb->sb_state);
356c3b162d5SRobert Watson db_print_sbstate(sb->sb_state);
357c3b162d5SRobert Watson db_printf(")\n");
358c3b162d5SRobert Watson
359c3b162d5SRobert Watson db_print_indent(indent);
360c3b162d5SRobert Watson db_printf("sb_mb: %p ", sb->sb_mb);
361c3b162d5SRobert Watson db_printf("sb_mbtail: %p ", sb->sb_mbtail);
362c3b162d5SRobert Watson db_printf("sb_lastrecord: %p\n", sb->sb_lastrecord);
363c3b162d5SRobert Watson
364c3b162d5SRobert Watson db_print_indent(indent);
365a82be55dSBjoern A. Zeeb db_printf("sb_sndptr: %p ", sb->sb_sndptr);
366a82be55dSBjoern A. Zeeb db_printf("sb_sndptroff: %u\n", sb->sb_sndptroff);
367c3b162d5SRobert Watson
368c3b162d5SRobert Watson db_print_indent(indent);
3690f9d0a73SGleb Smirnoff db_printf("sb_acc: %u ", sb->sb_acc);
3700f9d0a73SGleb Smirnoff db_printf("sb_ccc: %u ", sb->sb_ccc);
371a82be55dSBjoern A. Zeeb db_printf("sb_hiwat: %u ", sb->sb_hiwat);
372a82be55dSBjoern A. Zeeb db_printf("sb_mbcnt: %u ", sb->sb_mbcnt);
373a82be55dSBjoern A. Zeeb db_printf("sb_mbmax: %u\n", sb->sb_mbmax);
374a82be55dSBjoern A. Zeeb
375a82be55dSBjoern A. Zeeb db_print_indent(indent);
376a82be55dSBjoern A. Zeeb db_printf("sb_ctl: %u ", sb->sb_ctl);
377c3b162d5SRobert Watson db_printf("sb_lowat: %d ", sb->sb_lowat);
3787729cbf1SDavide Italiano db_printf("sb_timeo: %jd\n", sb->sb_timeo);
379c3b162d5SRobert Watson
380c3b162d5SRobert Watson db_print_indent(indent);
381c3b162d5SRobert Watson db_printf("sb_flags: 0x%x (", sb->sb_flags);
382c3b162d5SRobert Watson db_print_sbflags(sb->sb_flags);
383c3b162d5SRobert Watson db_printf(")\n");
384f3215338SJohn Baldwin
385f3215338SJohn Baldwin db_print_indent(indent);
386f3215338SJohn Baldwin db_printf("sb_aiojobq first: %p\n", TAILQ_FIRST(&sb->sb_aiojobq));
387c3b162d5SRobert Watson }
388c3b162d5SRobert Watson
389c3b162d5SRobert Watson static void
db_print_socket(struct socket * so,const char * socketname,int indent)390c3b162d5SRobert Watson db_print_socket(struct socket *so, const char *socketname, int indent)
391c3b162d5SRobert Watson {
392c3b162d5SRobert Watson
393c3b162d5SRobert Watson db_print_indent(indent);
394c3b162d5SRobert Watson db_printf("%s at %p\n", socketname, so);
395c3b162d5SRobert Watson
396c3b162d5SRobert Watson indent += 2;
397c3b162d5SRobert Watson
398c3b162d5SRobert Watson db_print_indent(indent);
399c3b162d5SRobert Watson db_printf("so_count: %d ", so->so_count);
400c3b162d5SRobert Watson db_printf("so_type: %d (", so->so_type);
401c3b162d5SRobert Watson db_print_sotype(so->so_type);
402c3b162d5SRobert Watson db_printf(")\n");
403c3b162d5SRobert Watson
404c3b162d5SRobert Watson db_print_indent(indent);
405c3b162d5SRobert Watson db_printf("so_options: 0x%x (", so->so_options);
406c3b162d5SRobert Watson db_print_sooptions(so->so_options);
407c3b162d5SRobert Watson db_printf(")\n");
408c3b162d5SRobert Watson
409c3b162d5SRobert Watson db_print_indent(indent);
410c3b162d5SRobert Watson db_printf("so_linger: %d ", so->so_linger);
411c3b162d5SRobert Watson db_printf("so_state: 0x%x (", so->so_state);
412c3b162d5SRobert Watson db_print_sostate(so->so_state);
413c3b162d5SRobert Watson db_printf(")\n");
414c3b162d5SRobert Watson
415c3b162d5SRobert Watson db_print_indent(indent);
416c3b162d5SRobert Watson db_printf("so_pcb: %p ", so->so_pcb);
417c3b162d5SRobert Watson db_printf("so_proto: %p\n", so->so_proto);
418c3b162d5SRobert Watson
419c3b162d5SRobert Watson if (so->so_proto != NULL)
420c3b162d5SRobert Watson db_print_protosw(so->so_proto, "so_proto", indent);
421c3b162d5SRobert Watson
422c3b162d5SRobert Watson db_print_indent(indent);
423779f106aSGleb Smirnoff if (so->so_options & SO_ACCEPTCONN) {
424779f106aSGleb Smirnoff db_printf("sol_incomp first: %p ",
425779f106aSGleb Smirnoff TAILQ_FIRST(&so->sol_incomp));
426779f106aSGleb Smirnoff db_printf("sol_comp first: %p\n", TAILQ_FIRST(&so->sol_comp));
427779f106aSGleb Smirnoff db_printf("sol_qlen: %d ", so->sol_qlen);
428779f106aSGleb Smirnoff db_printf("sol_incqlen: %d ", so->sol_incqlen);
429779f106aSGleb Smirnoff db_printf("sol_qlimit: %d ", so->sol_qlimit);
430779f106aSGleb Smirnoff } else {
431779f106aSGleb Smirnoff db_printf("so_qstate: 0x%x (", so->so_qstate);
432779f106aSGleb Smirnoff db_print_soqstate(so->so_qstate);
433c74ae2caSRyan Libby db_printf(") ");
434779f106aSGleb Smirnoff db_printf("so_listen: %p ", so->so_listen);
435c3b162d5SRobert Watson /* so_list skipped */
436c3b162d5SRobert Watson db_printf("so_timeo: %d ", so->so_timeo);
437c3b162d5SRobert Watson db_printf("so_error: %d\n", so->so_error);
438c3b162d5SRobert Watson
439c3b162d5SRobert Watson db_print_indent(indent);
440c3b162d5SRobert Watson db_printf("so_sigio: %p ", so->so_sigio);
441c74ae2caSRyan Libby db_printf("so_oobmark: %lu\n", so->so_oobmark);
442c3b162d5SRobert Watson
443c3b162d5SRobert Watson db_print_sockbuf(&so->so_rcv, "so_rcv", indent);
444c3b162d5SRobert Watson db_print_sockbuf(&so->so_snd, "so_snd", indent);
445c3b162d5SRobert Watson }
446779f106aSGleb Smirnoff }
447c3b162d5SRobert Watson
DB_SHOW_COMMAND(socket,db_show_socket)448c3b162d5SRobert Watson DB_SHOW_COMMAND(socket, db_show_socket)
449c3b162d5SRobert Watson {
450c3b162d5SRobert Watson struct socket *so;
451c3b162d5SRobert Watson
452c3b162d5SRobert Watson if (!have_addr) {
453c3b162d5SRobert Watson db_printf("usage: show socket <addr>\n");
454c3b162d5SRobert Watson return;
455c3b162d5SRobert Watson }
456c3b162d5SRobert Watson so = (struct socket *)addr;
457c3b162d5SRobert Watson
458c3b162d5SRobert Watson db_print_socket(so, "socket", 0);
459c3b162d5SRobert Watson }
460c3b162d5SRobert Watson
DB_SHOW_COMMAND(sockbuf,db_show_sockbuf)461c3b162d5SRobert Watson DB_SHOW_COMMAND(sockbuf, db_show_sockbuf)
462c3b162d5SRobert Watson {
463c3b162d5SRobert Watson struct sockbuf *sb;
464c3b162d5SRobert Watson
465c3b162d5SRobert Watson if (!have_addr) {
466c3b162d5SRobert Watson db_printf("usage: show sockbuf <addr>\n");
467c3b162d5SRobert Watson return;
468c3b162d5SRobert Watson }
469c3b162d5SRobert Watson sb = (struct sockbuf *)addr;
470c3b162d5SRobert Watson
471c3b162d5SRobert Watson db_print_sockbuf(sb, "sockbuf", 0);
472c3b162d5SRobert Watson }
473c3b162d5SRobert Watson
DB_SHOW_COMMAND(protosw,db_show_protosw)474c3b162d5SRobert Watson DB_SHOW_COMMAND(protosw, db_show_protosw)
475c3b162d5SRobert Watson {
476c3b162d5SRobert Watson struct protosw *pr;
477c3b162d5SRobert Watson
478c3b162d5SRobert Watson if (!have_addr) {
479c3b162d5SRobert Watson db_printf("usage: show protosw <addr>\n");
480c3b162d5SRobert Watson return;
481c3b162d5SRobert Watson }
482c3b162d5SRobert Watson pr = (struct protosw *)addr;
483c3b162d5SRobert Watson
484c3b162d5SRobert Watson db_print_protosw(pr, "protosw", 0);
485c3b162d5SRobert Watson }
486c3b162d5SRobert Watson
DB_SHOW_COMMAND(domain,db_show_domain)487c3b162d5SRobert Watson DB_SHOW_COMMAND(domain, db_show_domain)
488c3b162d5SRobert Watson {
489c3b162d5SRobert Watson struct domain *d;
490c3b162d5SRobert Watson
491c3b162d5SRobert Watson if (!have_addr) {
492c3b162d5SRobert Watson db_printf("usage: show protosw <addr>\n");
493c3b162d5SRobert Watson return;
494c3b162d5SRobert Watson }
495c3b162d5SRobert Watson d = (struct domain *)addr;
496c3b162d5SRobert Watson
497c3b162d5SRobert Watson db_print_domain(d, "domain", 0);
498c3b162d5SRobert Watson }
499c3b162d5SRobert Watson #endif
500