mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-24 02:23:27 +08:00
courtesy rick cheng (rcheng AT juniper dot net):
improve code readability: - LDP_TLV_ADDRESS_LIST printer - BFD_DISCRIMINATOR printer
This commit is contained in:
parent
d198f14d38
commit
6b3e20d291
1
CREDITS
1
CREDITS
@ -115,6 +115,7 @@ Additional people who have contributed patches:
|
||||
Phil Wood <cpw@lanl.gov>
|
||||
Rafal Maszkowski <rzm@icm.edu.pl>
|
||||
Raphael Raimbault <raphael.raimbault@netasq.com>
|
||||
Rick Cheng <rcheng@juniper.net>
|
||||
Rick Jones <rick.jones2@hp.com>
|
||||
Rick Watson <watsonrick@users.sourceforge.net>
|
||||
Rob Braun <bbraun@synack.net>
|
||||
|
17
print-ldp.c
17
print-ldp.c
@ -16,7 +16,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.16 2006-02-01 14:56:25 hannes Exp $";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.17 2006-02-03 08:32:39 hannes Exp $";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -215,8 +215,10 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
|
||||
};
|
||||
|
||||
/* RFC1700 address family numbers, same definition in print-bgp.c */
|
||||
/* FIXME: move all AF stuff into dedicated files */
|
||||
#define AFNUM_INET 1
|
||||
#define AFNUM_INET6 2
|
||||
#define AFNUM_LEN 2
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
@ -296,21 +298,24 @@ ldp_tlv_print(register const u_char *tptr) {
|
||||
|
||||
case LDP_TLV_ADDRESS_LIST:
|
||||
af = EXTRACT_16BITS(tptr);
|
||||
tptr+=2;
|
||||
tptr+=AFNUM_LEN;
|
||||
tlv_tlen -= AFNUM_LEN;
|
||||
printf("\n\t Address Family: ");
|
||||
if (af == AFNUM_INET) {
|
||||
printf("IPv4, addresses:");
|
||||
for (i=0; i<(tlv_tlen-2)/4; i++) {
|
||||
while(tlv_tlen >= sizeof(struct in_addr)) {
|
||||
printf(" %s",ipaddr_string(tptr));
|
||||
tptr+=sizeof(struct in_addr);
|
||||
tlv_tlen-=sizeof(struct in_addr);
|
||||
tptr+=sizeof(struct in_addr);
|
||||
}
|
||||
}
|
||||
#ifdef INET6
|
||||
else if (af == AFNUM_INET6) {
|
||||
printf("IPv6, addresses:");
|
||||
for (i=0; i<(tlv_tlen-2)/16; i++) {
|
||||
while(tlv_tlen >= sizeof(struct in6_addr)) {
|
||||
printf(" %s",ip6addr_string(tptr));
|
||||
tptr+=sizeof(struct in6_addr);
|
||||
tlv_tlen-=sizeof(struct in6_addr);
|
||||
tptr+=sizeof(struct in6_addr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.16 2006-02-01 14:37:26 hannes Exp $";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.17 2006-02-03 08:33:12 hannes Exp $";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -138,6 +138,7 @@ struct lspping_tlv_header {
|
||||
#define LSPPING_TLV_PAD 3
|
||||
#define LSPPING_TLV_ERROR_CODE 4
|
||||
#define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
|
||||
#define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
|
||||
#define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
|
||||
|
||||
static const struct tok lspping_tlv_values[] = {
|
||||
@ -836,7 +837,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
|
||||
|
||||
case LSPPING_TLV_BFD_DISCRIMINATOR:
|
||||
tptr += sizeof(struct lspping_tlv_header);
|
||||
if (!TTEST2(*tptr, 4))
|
||||
if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN))
|
||||
goto trunc;
|
||||
printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr));
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user