summaryrefslogtreecommitdiff
path: root/print-ldp.c
diff options
context:
space:
mode:
authorhannes <hannes>2006-02-03 08:32:39 +0000
committerhannes <hannes>2006-02-03 08:32:39 +0000
commit6b3e20d2916f8f799c342c4228585f2fe44fe242 (patch)
treecfc66b46df52c787a2ee316c54207a1c7f8a0d13 /print-ldp.c
parentd198f14d386857d08972300e59594e633b8c4da7 (diff)
downloadtcpdump-6b3e20d2916f8f799c342c4228585f2fe44fe242.tar.gz
courtesy rick cheng (rcheng AT juniper dot net):
improve code readability: - LDP_TLV_ADDRESS_LIST printer - BFD_DISCRIMINATOR printer
Diffstat (limited to 'print-ldp.c')
-rw-r--r--print-ldp.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/print-ldp.c b/print-ldp.c
index 39079cb1..f499133a 100644
--- a/print-ldp.c
+++ b/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