cxgbe/t4_tom: Read the chip's DDP page sizes and save them in a
[freebsd-src.git] / sys / netinet / in_debug.c
blob0795fa88ef453a1248feb36409be6e9eb9fac8da
1 /*-
2 * Copyright (c) 2010 Bjoern A. Zeeb <bz@FreeBSD.org>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include "opt_ddb.h"
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/socket.h>
36 #ifdef DDB
37 #include <ddb/ddb.h>
38 #endif
40 #include <net/if.h>
41 #include <net/if_var.h>
43 #include <netinet/in.h>
44 #include <netinet/in_var.h>
46 #ifdef DDB
47 static void
48 in_show_sockaddr_in(struct sockaddr_in *sin)
51 #define SIN_DB_RPINTF(f, e) db_printf("\t %s = " f "\n", #e, sin->e);
52 db_printf("\tsockaddr_in = %p\n", sin);
53 SIN_DB_RPINTF("%u", sin_len);
54 SIN_DB_RPINTF("%u", sin_family);
55 SIN_DB_RPINTF("%u", sin_port);
56 SIN_DB_RPINTF("0x%08x", sin_addr.s_addr);
57 db_printf("\t %s = %02x%02x%02x%02x%02x%02x%02x%02x\n",
58 "sin_zero[8]",
59 sin->sin_zero[0], sin->sin_zero[1],
60 sin->sin_zero[2], sin->sin_zero[3],
61 sin->sin_zero[4], sin->sin_zero[5],
62 sin->sin_zero[6], sin->sin_zero[7]);
63 #undef SIN_DB_RPINTF
66 DB_SHOW_COMMAND(sin, db_show_sin)
68 struct sockaddr_in *sin;
70 sin = (struct sockaddr_in *)addr;
71 if (sin == NULL) {
72 /* usage: No need to confess if you didn't sin. */
73 db_printf("usage: show sin <struct sockaddr_in *>\n");
74 return;
77 in_show_sockaddr_in(sin);
80 static void
81 in_show_in_ifaddr(struct in_ifaddr *ia)
84 #define IA_DB_RPINTF(f, e) db_printf("\t %s = " f "\n", #e, ia->e);
85 #define IA_DB_RPINTF_PTR(f, e) db_printf("\t %s = " f "\n", #e, &ia->e);
86 #define IA_DB_RPINTF_DPTR(f, e) db_printf("\t *%s = " f "\n", #e, *ia->e);
87 db_printf("\tin_ifaddr = %p\n", ia);
88 IA_DB_RPINTF_PTR("%p", ia_ifa);
89 IA_DB_RPINTF("0x%08lx", ia_subnet);
90 IA_DB_RPINTF("0x%08lx", ia_subnetmask);
91 IA_DB_RPINTF("%p", ia_hash.le_next);
92 IA_DB_RPINTF("%p", ia_hash.le_prev);
93 IA_DB_RPINTF_DPTR("%p", ia_hash.le_prev);
94 IA_DB_RPINTF("%p", ia_link.tqe_next);
95 IA_DB_RPINTF("%p", ia_link.tqe_prev);
96 IA_DB_RPINTF_DPTR("%p", ia_link.tqe_prev);
97 IA_DB_RPINTF_PTR("%p", ia_addr);
98 IA_DB_RPINTF_PTR("%p", ia_dstaddr);
99 IA_DB_RPINTF_PTR("%p", ia_sockmask);
100 #undef IA_DB_RPINTF_DPTR
101 #undef IA_DB_RPINTF_PTR
102 #undef IA_DB_RPINTF
105 DB_SHOW_COMMAND(in_ifaddr, db_show_in_ifaddr)
107 struct in_ifaddr *ia;
109 ia = (struct in_ifaddr *)addr;
110 if (ia == NULL) {
111 db_printf("usage: show in_ifaddr <struct in_ifaddr *>\n");
112 return;
115 in_show_in_ifaddr(ia);
117 #endif