Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/netinet/in_debug.c
102901 views
1
/*-
2
* SPDX-License-Identifier: BSD-2-Clause
3
*
4
* Copyright (c) 2010 Bjoern A. Zeeb <[email protected]>
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
* SUCH DAMAGE.
27
*/
28
29
#include "opt_ddb.h"
30
31
#include <sys/param.h>
32
#include <sys/systm.h>
33
#include <sys/socket.h>
34
35
#ifdef DDB
36
#include <ddb/ddb.h>
37
#endif
38
39
#include <net/if.h>
40
#include <net/if_var.h>
41
42
#include <netinet/in.h>
43
#include <netinet/in_var.h>
44
45
#ifdef DDB
46
static void
47
in_show_sockaddr_in(struct sockaddr_in *sin)
48
{
49
50
#define SIN_DB_RPINTF(f, e) db_printf("\t %s = " f "\n", #e, sin->e);
51
db_printf("\tsockaddr_in = %p\n", sin);
52
SIN_DB_RPINTF("%u", sin_len);
53
SIN_DB_RPINTF("%u", sin_family);
54
SIN_DB_RPINTF("%u", sin_port);
55
SIN_DB_RPINTF("0x%08x", sin_addr.s_addr);
56
db_printf("\t %s = %02x%02x%02x%02x%02x%02x%02x%02x\n",
57
"sin_zero[8]",
58
sin->sin_zero[0], sin->sin_zero[1],
59
sin->sin_zero[2], sin->sin_zero[3],
60
sin->sin_zero[4], sin->sin_zero[5],
61
sin->sin_zero[6], sin->sin_zero[7]);
62
#undef SIN_DB_RPINTF
63
}
64
65
DB_SHOW_COMMAND(sin, db_show_sin)
66
{
67
struct sockaddr_in *sin;
68
69
sin = (struct sockaddr_in *)addr;
70
if (sin == NULL) {
71
/* usage: No need to confess if you didn't sin. */
72
db_printf("usage: show sin <struct sockaddr_in *>\n");
73
return;
74
}
75
76
in_show_sockaddr_in(sin);
77
}
78
79
static void
80
in_show_in_ifaddr(struct in_ifaddr *ia)
81
{
82
83
#define IA_DB_RPINTF(f, e) db_printf("\t %s = " f "\n", #e, ia->e);
84
#define IA_DB_RPINTF_PTR(f, e) db_printf("\t %s = " f "\n", #e, &ia->e);
85
#define IA_DB_RPINTF_DPTR(f, e) db_printf("\t *%s = " f "\n", #e, *ia->e);
86
db_printf("\tin_ifaddr = %p\n", ia);
87
IA_DB_RPINTF_PTR("%p", ia_ifa);
88
IA_DB_RPINTF("0x%08lx", ia_subnet);
89
IA_DB_RPINTF("0x%08lx", ia_subnetmask);
90
IA_DB_RPINTF("%p", ia_hash.cle_next);
91
IA_DB_RPINTF("%p", ia_hash.cle_prev);
92
IA_DB_RPINTF_DPTR("%p", ia_hash.cle_prev);
93
IA_DB_RPINTF("%p", ia_link.cstqe_next);
94
IA_DB_RPINTF_PTR("%p", ia_addr);
95
IA_DB_RPINTF_PTR("%p", ia_dstaddr);
96
IA_DB_RPINTF_PTR("%p", ia_sockmask);
97
#undef IA_DB_RPINTF_DPTR
98
#undef IA_DB_RPINTF_PTR
99
#undef IA_DB_RPINTF
100
}
101
102
DB_SHOW_COMMAND(in_ifaddr, db_show_in_ifaddr)
103
{
104
struct in_ifaddr *ia;
105
106
ia = (struct in_ifaddr *)addr;
107
if (ia == NULL) {
108
db_printf("usage: show in_ifaddr <struct in_ifaddr *>\n");
109
return;
110
}
111
112
in_show_in_ifaddr(ia);
113
}
114
#endif
115
116