12958Sdr146992 /* 22958Sdr146992 * CDDL HEADER START 32958Sdr146992 * 42958Sdr146992 * The contents of this file are subject to the terms of the 52958Sdr146992 * Common Development and Distribution License (the "License"). 62958Sdr146992 * You may not use this file except in compliance with the License. 72958Sdr146992 * 82958Sdr146992 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92958Sdr146992 * or http://www.opensolaris.org/os/licensing. 102958Sdr146992 * See the License for the specific language governing permissions 112958Sdr146992 * and limitations under the License. 122958Sdr146992 * 132958Sdr146992 * When distributing Covered Code, include this CDDL HEADER in each 142958Sdr146992 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152958Sdr146992 * If applicable, add the following below this CDDL HEADER, with the 162958Sdr146992 * fields enclosed by brackets "[]" replaced with your own identifying 172958Sdr146992 * information: Portions Copyright [yyyy] [name of copyright owner] 182958Sdr146992 * 192958Sdr146992 * CDDL HEADER END 202958Sdr146992 */ 212958Sdr146992 /* 22*3448Sdh155122 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 232958Sdr146992 * Use is subject to license terms. 242958Sdr146992 */ 252958Sdr146992 262958Sdr146992 #pragma ident "%Z%%M% %I% %E% SMI" 272958Sdr146992 282958Sdr146992 #include <sys/types.h> 292958Sdr146992 #include <sys/rwlock.h> 302958Sdr146992 #include <mdb/mdb_modapi.h> 312958Sdr146992 #include <sys/queue.h> 322958Sdr146992 #include <sys/neti.h> 332958Sdr146992 342958Sdr146992 352958Sdr146992 /* 362958Sdr146992 * PROT_LENGTH is the max length. If the true length is bigger 372958Sdr146992 * it is truncated. 382958Sdr146992 */ 392958Sdr146992 #define PROT_LENGTH 32 402958Sdr146992 412958Sdr146992 /* 422958Sdr146992 * List pfhooks netinfo information. 432958Sdr146992 */ 442958Sdr146992 /*ARGSUSED*/ 452958Sdr146992 int 462958Sdr146992 netinfolist(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 472958Sdr146992 { 48*3448Sdh155122 struct neti_stack *nts; 492958Sdr146992 struct netd_listhead nlh; 502958Sdr146992 struct net_data nd, *p; 512958Sdr146992 char str[PROT_LENGTH]; 522958Sdr146992 532958Sdr146992 if (argc) 542958Sdr146992 return (DCMD_USAGE); 552958Sdr146992 56*3448Sdh155122 if (mdb_vread((void *)&nts, sizeof (nts), 57*3448Sdh155122 (uintptr_t)(addr + OFFSETOF(netstack_t, netstack_neti))) == -1) { 58*3448Sdh155122 mdb_warn("couldn't read netstack_neti"); 59*3448Sdh155122 return (DCMD_ERR); 60*3448Sdh155122 } 61*3448Sdh155122 62*3448Sdh155122 if (mdb_vread((void *)&nlh, sizeof (nlh), (uintptr_t)((uintptr_t)nts + 63*3448Sdh155122 OFFSETOF(neti_stack_t, nts_netd_head))) == -1) { 64*3448Sdh155122 mdb_warn("couldn't read netd list head"); 652958Sdr146992 return (DCMD_ERR); 662958Sdr146992 } 672958Sdr146992 mdb_printf("%<u>%?s %?s %10s%</u>\n", 682958Sdr146992 "ADDR(netinfo)", "ADDR(hookevent)", "netinfo"); 692958Sdr146992 p = LIST_FIRST(&nlh); 702958Sdr146992 while (p) { 712958Sdr146992 if (mdb_vread((void *)&nd, sizeof (nd), (uintptr_t)p) == -1) { 722958Sdr146992 mdb_warn("couldn't read netinfo at %p", p); 732958Sdr146992 return (DCMD_ERR); 742958Sdr146992 } 752958Sdr146992 if (!nd.netd_info.neti_protocol) { 762958Sdr146992 mdb_warn("netinfo at %p has null protocol", 772958Sdr146992 nd.netd_info.neti_protocol); 782958Sdr146992 return (DCMD_ERR); 792958Sdr146992 } 802958Sdr146992 if (mdb_readstr((char *)str, sizeof (str), 812958Sdr146992 (uintptr_t)nd.netd_info.neti_protocol) == -1) { 822958Sdr146992 mdb_warn("couldn't read protocol at %p", 832958Sdr146992 nd.netd_info.neti_protocol); 842958Sdr146992 return (DCMD_ERR); 852958Sdr146992 } 862958Sdr146992 872958Sdr146992 mdb_printf("%0?p %0?p %10s\n", 882958Sdr146992 (char *)p + (uintptr_t)&((struct net_data *)0)->netd_info, 892958Sdr146992 nd.netd_hooks, str); 902958Sdr146992 912958Sdr146992 p = LIST_NEXT(&nd, netd_list); 922958Sdr146992 } 932958Sdr146992 942958Sdr146992 return (DCMD_OK); 952958Sdr146992 } 962958Sdr146992 972958Sdr146992 static const mdb_dcmd_t dcmds[] = { 982958Sdr146992 { "netinfolist", "", "display netinfo information", 992958Sdr146992 netinfolist, NULL }, 1002958Sdr146992 { NULL } 1012958Sdr146992 }; 1022958Sdr146992 1032958Sdr146992 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds }; 1042958Sdr146992 1052958Sdr146992 const mdb_modinfo_t * 1062958Sdr146992 _mdb_init(void) 1072958Sdr146992 { 1082958Sdr146992 return (&modinfo); 1092958Sdr146992 } 110