From: hannes Date: Wed, 22 Oct 2003 17:08:45 +0000 (+0000) Subject: - fix a compiler padding issue in the LS-Request structure X-Git-Tag: tcpdump-3.8-bp~27 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/c8196a5940afd4b1cc05899e5e7fe6455ddabc20 - fix a compiler padding issue in the LS-Request structure u_int32_t ls_type becomes u_int8_t ls_type[4]; - teach the LS-Request decoder howto properly print Opaque LSAs --- diff --git a/ospf.h b/ospf.h index 66fe0d84..17b8d778 100644 --- a/ospf.h +++ b/ospf.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.10 2003-10-04 14:29:52 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.11 2003-10-22 17:08:46 hannes Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -255,8 +255,14 @@ struct ospfhdr { /* Link State Request */ struct lsr { - u_int32_t ls_type; - struct in_addr ls_stateid; + u_int8_t ls_type[4]; + union { + struct in_addr ls_stateid; + struct { /* opaque LSAs change the LSA-ID field */ + u_int8_t opaque_type; + u_int8_t opaque_id[3]; + } opaque_field; + } un_ls_stateid; struct in_addr ls_router; } un_lsr[1]; /* may repeat */ diff --git a/print-ospf.c b/print-ospf.c index 6ba3176c..9eeadfc5 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.43 2003-10-22 16:29:18 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.44 2003-10-22 17:08:45 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -629,14 +629,30 @@ ospf_decode_v2(register const struct ospfhdr *op, case OSPF_TYPE_LS_REQ: lsrp = op->ospf_lsr; while ((u_char *)lsrp < dataend) { - TCHECK(*lsrp); - - printf("\n\t %s LSA (%d), LSA-ID: %s, Advertising Router: %s", - tok2str(lsa_values,"unknown",lsrp->ls_type), - lsrp->ls_type, - ipaddr_string(&lsrp->ls_stateid), - ipaddr_string(&lsrp->ls_router)); - ++lsrp; + TCHECK(*lsrp); + + printf("\n\t Advertising Router: %s, %s LSA (%u)", + ipaddr_string(&lsrp->ls_router), + tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)), + EXTRACT_32BITS(&lsrp->ls_type)); + + switch (EXTRACT_32BITS(lsrp->ls_type)) { + /* the LSA header for opaque LSAs was slightly changed */ + case LS_TYPE_OPAQUE_LL: + case LS_TYPE_OPAQUE_AL: + case LS_TYPE_OPAQUE_DW: + printf(", Opaque-Type: %s LSA (%u), Opaque-ID: %u", + tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type), + lsrp->un_ls_stateid.opaque_field.opaque_type, + EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id)); + break; + default: + printf(", LSA-ID: %s", + ipaddr_string(&lsrp->un_ls_stateid.ls_stateid)); + break; + } + + ++lsrp; } break;