X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/5d2a060ede22c14d8c2d80db88196dc05e81b4a4..4254cbe7d10a03bb4ab5e1d98cc1c1d25202adee:/print-bootp.c diff --git a/print-bootp.c b/print-bootp.c index ac9609af..605103c0 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.71 2003-03-16 23:43:41 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.73 2003-05-01 18:02:12 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -49,38 +49,28 @@ static char tstr[] = " [|bootp]"; * Print bootp requests */ void -bootp_print(register const u_char *cp, u_short sport, u_short dport, u_int length) +bootp_print(register const u_char *cp, u_int length) { register const struct bootp *bp; static const u_char vm_cmu[4] = VM_CMU; static const u_char vm_rfc1048[4] = VM_RFC1048; - printf("BOOTP/DHCP, length: %u",length); - - if (!vflag) - return; - bp = (const struct bootp *)cp; TCHECK(bp->bp_op); - switch (bp->bp_op) { - - case BOOTREQUEST: - /* Usually, a request goes from a client to a server */ - if (sport == IPPORT_BOOTPC && dport == IPPORT_BOOTPS) - printf("\n\tRequest"); - break; - - case BOOTREPLY: - /* Usually, a reply goes from a server to a client */ - if (sport == IPPORT_BOOTPS && dport == IPPORT_BOOTPC) - printf("\n\tReply"); - break; - - default: - printf("\n\tbootp-#%d", bp->bp_op); - break; + + printf("BOOTP/DHCP, %s", + tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)); + + if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) { + TCHECK2(bp->bp_chaddr[0], 6); + printf(" from %s", etheraddr_string(bp->bp_chaddr)); } + printf(", length: %u", length); + + if (!vflag) + return; + TCHECK(bp->bp_secs); /* The usual hardware address type is 1 (10Mb Ethernet) */ @@ -98,8 +88,11 @@ bootp_print(register const u_char *cp, u_short sport, u_short dport, u_int lengt printf(", xid:0x%x", EXTRACT_32BITS(&bp->bp_xid)); if (bp->bp_secs) printf(", secs:%d", EXTRACT_16BITS(&bp->bp_secs)); - if (bp->bp_flags) - printf(", flags:0x%x", EXTRACT_16BITS(&bp->bp_flags)); + + printf(", flags: [%s]", + bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))); + if (vflag>1) + printf( " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)); /* Client's ip address */ TCHECK(bp->bp_ciaddr);