69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * CDDL HEADER START
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * The contents of this file are subject to the terms of the
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * Common Development and Distribution License (the "License").
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * You may not use this file except in compliance with the License.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * See the License for the specific language governing permissions
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * and limitations under the License.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * When distributing Covered Code, include this CDDL HEADER in each
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * If applicable, add the following below this CDDL HEADER, with the
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * fields enclosed by brackets "[]" replaced with your own identifying
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * information: Portions Copyright [yyyy] [name of copyright owner]
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * CDDL HEADER END
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * Use is subject to license terms.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonjtypedef struct {
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * removed all the ace/arl related stuff. The only thing that remains
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * is code for dealing with ioctls and printing out arp header that
bd670b35a010421b6e1a5536c34453a827007c81Erik Nordmark * should probably be moved into the ip/mdb module.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * Print an ARP hardware and protocol address pair; used when printing an ARP
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonjprint_arp(char field_id, const uchar_t *buf, const arh_t *arh, uint16_t ptype)
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_mac_addr(buf, arh->arh_hlen, macstr, sizeof (macstr));
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_printf("%?s ar$%cha %s\n", "", field_id, macstr);
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_printf("%?s ar$%cpa (unknown)\n", "", field_id);
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj (void) memcpy(&inaddr, buf + arh->arh_hlen, sizeof (inaddr));
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_printf("%?s ar$%cpa %I\n", "", field_id, inaddr);
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_printf("%?s ar$%cpa (malformed IP)\n", "", field_id);
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * Decode an ARP message and display it.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj/* ARGSUSED2 */
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonjarphdr_cmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_warn("address required to print ARP header\n");
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj if (mdb_vread(&arp.arh, sizeof (arp.arh), addr) == -1) {
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_nhconvert(&htype, arp.arh.arh_hardware, sizeof (htype));
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_nhconvert(&ptype, arp.arh.arh_proto, sizeof (ptype));
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_nhconvert(&op, arp.arh.arh_operation, sizeof (op));
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj mdb_printf("%?p: ar$hrd %x (%s)\n", addr, htype, cp);
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * Note that we go to some length to attempt to print out the fixed
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * header data before trying to decode the variable-length data. This
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * is done to maximize the amount of useful information shown when the
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj * buffer is truncated or otherwise corrupt.
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj if (mdb_vread(&arp.addrs, blen, addr + sizeof (arp.arh)) == -1) {
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj print_arp('t', arp.addrs + arp.arh.arh_hlen + arp.arh.arh_plen,
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj { "arphdr", ":", "display an ARP header", arphdr_cmd, NULL },
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonj/* Note: ar_t walker is in genunix.c and net.c; generic MI walker */
69bb4bb45c98da60d21839c4dc3c01ea1be60585carlsonjstatic const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };