dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / mdb / common / modules / neti / neti.c
blobe18110997ffc3d284d6d64566eae2823d674a150
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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>
30 #include <sys/neti.h>
34 * PROT_LENGTH is the max length. If the true length is bigger
35 * it is truncated.
37 #define PROT_LENGTH 32
40 * List pfhooks netinfo information.
42 /*ARGSUSED*/
43 int
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];
51 if (argc)
52 return (DCMD_USAGE);
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");
57 return (DCMD_ERR);
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");
63 return (DCMD_ERR);
65 mdb_printf("%<u>%?s %?s %10s%</u>\n",
66 "ADDR(netinfo)", "ADDR(hookevent)", "netinfo");
67 p = LIST_FIRST(&nlh);
68 while (p) {
69 if (mdb_vread((void *)&nd, sizeof (nd), (uintptr_t)p) == -1) {
70 mdb_warn("couldn't read netinfo at %p", p);
71 return (DCMD_ERR);
73 if (!nd.netd_info.netp_name) {
74 mdb_warn("netinfo at %p has null protocol",
75 nd.netd_info.netp_name);
76 return (DCMD_ERR);
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);
82 return (DCMD_ERR);
85 mdb_printf("%0?p %0?p %10s\n",
86 (char *)p + (uintptr_t)&((struct net_data *)0)->netd_info,
87 nd.netd_hooks, str);
89 p = LIST_NEXT(&nd, netd_list);
92 return (DCMD_OK);
95 static const mdb_dcmd_t dcmds[] = {
96 { "netinfolist", "", "display netinfo information",
97 netinfolist, NULL },
98 { NULL }
101 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds };
103 const mdb_modinfo_t *
104 _mdb_init(void)
106 return (&modinfo);