#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.24 2001-10-15 23:27:31 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.25 2001-10-16 08:00:37 guy Exp $";
#endif
#include <sys/param.h>
u_int8_t bgpo_optlen;
/* options should follow */
};
+#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
u_int8_t bgpopt_type;
u_int8_t bgpopt_len;
/* variable length */
};
+#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
u_int8_t bgpn_marker[16];
u_int8_t bgpn_minor;
/* data should follow */
};
+#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_attr {
u_int8_t bgpa_flags;
const u_char *opt;
int i;
- TCHECK2(dat[0], sizeof(bgpo));
- memcpy(&bgpo, dat, sizeof(bgpo));
+ TCHECK2(dat[0], BGP_OPEN_SIZE);
+ memcpy(&bgpo, dat, BGP_OPEN_SIZE);
hlen = ntohs(bgpo.bgpo_len);
printf(": Version %d,", bgpo.bgpo_version);
opt++;
for (i = 0; i < bgpo.bgpo_optlen; i++) {
- memcpy(&bgpopt, &opt[i], sizeof(bgpopt));
+ TCHECK2(opt[i], BGP_OPT_SIZE);
+ memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type);
break;
printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type),
bgpopt.bgpopt_len);
- i += sizeof(bgpopt) + bgpopt.bgpopt_len;
+ i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
}
return;
trunc:
int i;
int newline;
- TCHECK2(dat[0], sizeof(bgp));
- memcpy(&bgp, dat, sizeof(bgp));
+ TCHECK2(dat[0], BGP_SIZE);
+ memcpy(&bgp, dat, BGP_SIZE);
hlen = ntohs(bgp.bgp_len);
p = dat + BGP_SIZE; /*XXX*/
printf(":");
struct bgp_notification bgpn;
int hlen;
- TCHECK2(dat[0], sizeof(bgpn));
- memcpy(&bgpn, dat, sizeof(bgpn));
+ TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
+ memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
hlen = ntohs(bgpn.bgpn_len);
printf(": error %s,", bgp_notify_major(bgpn.bgpn_major));
{
struct bgp bgp;
- TCHECK2(dat[0], sizeof(bgp));
- memcpy(&bgp, dat, sizeof(bgp));
+ TCHECK2(dat[0], BGP_SIZE);
+ memcpy(&bgp, dat, BGP_SIZE);
printf("(%s", bgp_type(bgp.bgp_type)); /* ) */
switch (bgp.bgp_type) {
}
/* found BGP header */
- TCHECK2(p[0], sizeof(bgp)); /*XXX*/
- memcpy(&bgp, p, sizeof(bgp));
+ TCHECK2(p[0], BGP_SIZE); /*XXX*/
+ memcpy(&bgp, p, BGP_SIZE);
if (start != p)
printf(" [|BGP]");