4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/types.h>
27 #include <sys/rwlock.h>
28 #include <mdb/mdb_modapi.h>
29 #include <sys/queue.h>
34 * PROT_LENGTH is the max length. If the true length is bigger
37 #define PROT_LENGTH 32
40 * List pfhooks netinfo information.
44 netinfolist(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
46 struct neti_stack
*nts
;
47 struct netd_listhead nlh
;
48 struct net_data nd
, *p
;
49 char str
[PROT_LENGTH
];
54 if (mdb_vread((void *)&nts
, sizeof (nts
),
55 (uintptr_t)(addr
+ OFFSETOF(netstack_t
, netstack_neti
))) == -1) {
56 mdb_warn("couldn't read netstack_neti");
60 if (mdb_vread((void *)&nlh
, sizeof (nlh
), (uintptr_t)((uintptr_t)nts
+
61 OFFSETOF(neti_stack_t
, nts_netd_head
))) == -1) {
62 mdb_warn("couldn't read netd list head");
65 mdb_printf("%<u>%?s %?s %10s%</u>\n",
66 "ADDR(netinfo)", "ADDR(hookevent)", "netinfo");
69 if (mdb_vread((void *)&nd
, sizeof (nd
), (uintptr_t)p
) == -1) {
70 mdb_warn("couldn't read netinfo at %p", p
);
73 if (!nd
.netd_info
.netp_name
) {
74 mdb_warn("netinfo at %p has null protocol",
75 nd
.netd_info
.netp_name
);
78 if (mdb_readstr((char *)str
, sizeof (str
),
79 (uintptr_t)nd
.netd_info
.netp_name
) == -1) {
80 mdb_warn("couldn't read protocol at %p",
81 nd
.netd_info
.netp_name
);
85 mdb_printf("%0?p %0?p %10s\n",
86 (char *)p
+ (uintptr_t)&((struct net_data
*)0)->netd_info
,
89 p
= LIST_NEXT(&nd
, netd_list
);
95 static const mdb_dcmd_t dcmds
[] = {
96 { "netinfolist", "", "display netinfo information",
101 static const mdb_modinfo_t modinfo
= { MDB_API_VERSION
, dcmds
};
103 const mdb_modinfo_t
*