2003-10-27 18:13:44 +08:00
|
|
|
/*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code
|
|
|
|
* distributions retain the above copyright notice and this paragraph
|
|
|
|
* in its entirety, and (2) distributions including binary code include
|
|
|
|
* the above copyright notice and this paragraph in its entirety in
|
|
|
|
* the documentation or other materials provided with the distribution.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND
|
|
|
|
* WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
|
|
|
|
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
2017-07-28 23:44:12 +08:00
|
|
|
* Original code by Hannes Gredler (hannes@gredler.at)
|
2003-10-27 18:13:44 +08:00
|
|
|
*/
|
|
|
|
|
2016-08-15 21:27:28 +08:00
|
|
|
/* \summary: Bidirectional Forwarding Detection (BFD) printer */
|
|
|
|
|
2018-07-10 16:01:15 +08:00
|
|
|
/*
|
|
|
|
* specification: draft-ietf-bfd-base-01 for version 0,
|
|
|
|
* RFC 5880 for version 1, and RFC 5881
|
|
|
|
*/
|
2016-08-16 21:46:47 +08:00
|
|
|
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
2003-10-27 18:13:44 +08:00
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
2003-10-27 18:13:44 +08:00
|
|
|
|
2020-10-13 03:10:20 +08:00
|
|
|
#define ND_LONGJMP_FROM_TCHECK
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2003-10-27 18:13:44 +08:00
|
|
|
#include "extract.h"
|
|
|
|
|
2003-10-28 06:44:37 +08:00
|
|
|
#include "udp.h"
|
|
|
|
|
2003-10-27 18:13:44 +08:00
|
|
|
/*
|
2018-07-10 16:01:15 +08:00
|
|
|
* Control packet, BFDv0, draft-ietf-bfd-base-01
|
2003-10-27 18:13:44 +08:00
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2018-07-10 16:01:15 +08:00
|
|
|
* |Vers | Diag |H|D|P|F|C|A|Rsv| Detect Mult | Length |
|
2003-10-27 18:13:44 +08:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | My Discriminator |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Your Discriminator |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Desired Min TX Interval |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Required Min RX Interval |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Required Min Echo RX Interval |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
2014-01-02 10:27:54 +08:00
|
|
|
/*
|
2016-08-16 21:46:47 +08:00
|
|
|
* Control packet, BFDv1, RFC 5880
|
2005-04-28 07:00:53 +08:00
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2016-08-16 21:46:47 +08:00
|
|
|
* |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length |
|
2005-04-28 07:00:53 +08:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | My Discriminator |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Your Discriminator |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Desired Min TX Interval |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Required Min RX Interval |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Required Min Echo RX Interval |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
2003-10-27 18:13:44 +08:00
|
|
|
struct bfd_header_t {
|
2017-12-30 11:17:33 +08:00
|
|
|
nd_uint8_t version_diag;
|
|
|
|
nd_uint8_t flags;
|
|
|
|
nd_uint8_t detect_time_multiplier;
|
|
|
|
nd_uint8_t length;
|
|
|
|
nd_uint32_t my_discriminator;
|
|
|
|
nd_uint32_t your_discriminator;
|
|
|
|
nd_uint32_t desired_min_tx_interval;
|
|
|
|
nd_uint32_t required_min_rx_interval;
|
|
|
|
nd_uint32_t required_min_echo_interval;
|
2003-10-27 18:13:44 +08:00
|
|
|
};
|
|
|
|
|
2005-04-28 07:00:53 +08:00
|
|
|
/*
|
|
|
|
* An optional Authentication Header may be present
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Auth Type | Auth Len | Authentication Data... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct bfd_auth_header_t {
|
2017-12-30 11:17:33 +08:00
|
|
|
nd_uint8_t auth_type;
|
|
|
|
nd_uint8_t auth_len;
|
|
|
|
nd_uint8_t auth_data;
|
|
|
|
nd_uint8_t dummy; /* minimum 4 bytes */
|
2016-08-17 17:04:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum auth_type {
|
|
|
|
AUTH_PASSWORD = 1,
|
|
|
|
AUTH_MD5 = 2,
|
|
|
|
AUTH_MET_MD5 = 3,
|
|
|
|
AUTH_SHA1 = 4,
|
|
|
|
AUTH_MET_SHA1 = 5
|
2005-04-28 07:00:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct tok bfd_v1_authentication_values[] = {
|
2016-08-17 17:04:27 +08:00
|
|
|
{ AUTH_PASSWORD, "Simple Password" },
|
|
|
|
{ AUTH_MD5, "Keyed MD5" },
|
|
|
|
{ AUTH_MET_MD5, "Meticulous Keyed MD5" },
|
|
|
|
{ AUTH_SHA1, "Keyed SHA1" },
|
|
|
|
{ AUTH_MET_SHA1, "Meticulous Keyed SHA1" },
|
2005-04-28 07:00:53 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2016-08-17 17:04:27 +08:00
|
|
|
enum auth_length {
|
|
|
|
AUTH_PASSWORD_FIELD_MIN_LEN = 4, /* header + password min: 3 + 1 */
|
|
|
|
AUTH_PASSWORD_FIELD_MAX_LEN = 19, /* header + password max: 3 + 16 */
|
|
|
|
AUTH_MD5_FIELD_LEN = 24,
|
|
|
|
AUTH_MD5_HASH_LEN = 16,
|
|
|
|
AUTH_SHA1_FIELD_LEN = 28,
|
|
|
|
AUTH_SHA1_HASH_LEN = 20
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
|
|
|
|
#define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
|
2003-10-27 18:13:44 +08:00
|
|
|
|
|
|
|
static const struct tok bfd_diag_values[] = {
|
|
|
|
{ 0, "No Diagnostic" },
|
|
|
|
{ 1, "Control Detection Time Expired" },
|
|
|
|
{ 2, "Echo Function Failed" },
|
|
|
|
{ 3, "Neighbor Signaled Session Down" },
|
|
|
|
{ 4, "Forwarding Plane Reset" },
|
|
|
|
{ 5, "Path Down" },
|
|
|
|
{ 6, "Concatenated Path Down" },
|
|
|
|
{ 7, "Administratively Down" },
|
2005-04-28 07:00:53 +08:00
|
|
|
{ 8, "Reverse Concatenated Path Down" },
|
2003-10-27 18:13:44 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2019-04-27 02:03:34 +08:00
|
|
|
static const struct tok bfd_port_values[] = {
|
|
|
|
{ BFD_CONTROL_PORT, "Control" },
|
|
|
|
{ BFD_MULTIHOP_PORT, "Multihop" },
|
2021-02-16 08:59:17 +08:00
|
|
|
{ BFD_LAG_PORT, "LAG" },
|
|
|
|
{ SBFD_PORT, "S-BFD" },
|
2019-04-27 02:03:34 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2018-07-10 16:01:15 +08:00
|
|
|
#define BFD_FLAG_AUTH 0x04
|
|
|
|
|
2005-04-28 07:00:53 +08:00
|
|
|
static const struct tok bfd_v0_flag_values[] = {
|
2016-08-17 17:04:27 +08:00
|
|
|
{ 0x80, "I Hear You" },
|
|
|
|
{ 0x40, "Demand" },
|
|
|
|
{ 0x20, "Poll" },
|
|
|
|
{ 0x10, "Final" },
|
2018-07-10 16:01:15 +08:00
|
|
|
{ 0x08, "Control Plane Independent" },
|
|
|
|
{ BFD_FLAG_AUTH, "Authentication Present" },
|
2016-08-17 17:04:27 +08:00
|
|
|
{ 0x02, "Reserved" },
|
|
|
|
{ 0x01, "Reserved" },
|
2003-10-27 18:13:44 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2005-04-28 07:00:53 +08:00
|
|
|
static const struct tok bfd_v1_flag_values[] = {
|
|
|
|
{ 0x20, "Poll" },
|
|
|
|
{ 0x10, "Final" },
|
|
|
|
{ 0x08, "Control Plane Independent" },
|
|
|
|
{ BFD_FLAG_AUTH, "Authentication Present" },
|
|
|
|
{ 0x02, "Demand" },
|
2016-08-16 21:46:47 +08:00
|
|
|
{ 0x01, "Multipoint" },
|
2005-04-28 07:00:53 +08:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct tok bfd_v1_state_values[] = {
|
|
|
|
{ 0, "AdminDown" },
|
|
|
|
{ 1, "Down" },
|
|
|
|
{ 2, "Init" },
|
|
|
|
{ 3, "Up" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2020-10-13 03:10:20 +08:00
|
|
|
static void
|
2017-12-14 02:17:47 +08:00
|
|
|
auth_print(netdissect_options *ndo, const u_char *pptr)
|
2016-08-17 17:04:27 +08:00
|
|
|
{
|
|
|
|
const struct bfd_auth_header_t *bfd_auth_header;
|
2017-12-30 11:17:33 +08:00
|
|
|
uint8_t auth_type, auth_len;
|
2016-08-17 17:04:27 +08:00
|
|
|
int i;
|
|
|
|
|
2017-09-13 20:26:02 +08:00
|
|
|
pptr += sizeof (struct bfd_header_t);
|
2016-08-17 17:04:27 +08:00
|
|
|
bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
|
2018-01-04 04:32:07 +08:00
|
|
|
ND_TCHECK_SIZE(bfd_auth_header);
|
2018-06-16 23:23:21 +08:00
|
|
|
auth_type = GET_U_1(bfd_auth_header->auth_type);
|
|
|
|
auth_len = GET_U_1(bfd_auth_header->auth_len);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n\tAuthentication: %s (%u), length: %u",
|
2017-12-30 11:17:33 +08:00
|
|
|
tok2str(bfd_v1_authentication_values,"Unknown",auth_type),
|
2018-01-07 18:47:30 +08:00
|
|
|
auth_type, auth_len);
|
2016-08-17 17:04:27 +08:00
|
|
|
pptr += 2;
|
2018-06-16 23:23:21 +08:00
|
|
|
ND_PRINT("\n\t Auth Key ID: %u", GET_U_1(pptr));
|
2016-08-17 17:04:27 +08:00
|
|
|
|
2017-12-30 11:17:33 +08:00
|
|
|
switch(auth_type) {
|
2016-08-17 17:04:27 +08:00
|
|
|
case AUTH_PASSWORD:
|
|
|
|
/*
|
|
|
|
* Simple Password Authentication Section Format
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Auth Type | Auth Len | Auth Key ID | Password... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | ... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
2017-12-30 11:17:33 +08:00
|
|
|
if (auth_len < AUTH_PASSWORD_FIELD_MIN_LEN ||
|
|
|
|
auth_len > AUTH_PASSWORD_FIELD_MAX_LEN) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("[invalid length %u]",
|
|
|
|
auth_len);
|
2016-08-17 17:04:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
pptr++;
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(", Password: ");
|
2016-08-17 17:04:27 +08:00
|
|
|
/* the length is equal to the password length plus three */
|
2021-01-08 23:21:39 +08:00
|
|
|
nd_printjn(ndo, pptr, auth_len - 3);
|
2016-08-17 17:04:27 +08:00
|
|
|
break;
|
|
|
|
case AUTH_MD5:
|
|
|
|
case AUTH_MET_MD5:
|
|
|
|
/*
|
|
|
|
* Keyed MD5 and Meticulous Keyed MD5 Authentication Section Format
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Auth Type | Auth Len | Auth Key ID | Reserved |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Sequence Number |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Auth Key/Digest... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | ... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
2017-12-30 11:17:33 +08:00
|
|
|
if (auth_len != AUTH_MD5_FIELD_LEN) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("[invalid length %u]",
|
|
|
|
auth_len);
|
2016-08-17 17:04:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
pptr += 2;
|
2018-06-16 23:23:21 +08:00
|
|
|
ND_PRINT(", Sequence Number: 0x%08x", GET_BE_U_4(pptr));
|
2016-08-17 17:04:27 +08:00
|
|
|
pptr += 4;
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(pptr, AUTH_MD5_HASH_LEN);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n\t Digest: ");
|
2016-08-17 17:04:27 +08:00
|
|
|
for(i = 0; i < AUTH_MD5_HASH_LEN; i++)
|
2018-06-16 23:23:21 +08:00
|
|
|
ND_PRINT("%02x", GET_U_1(pptr + i));
|
2016-08-17 17:04:27 +08:00
|
|
|
break;
|
|
|
|
case AUTH_SHA1:
|
|
|
|
case AUTH_MET_SHA1:
|
|
|
|
/*
|
|
|
|
* Keyed SHA1 and Meticulous Keyed SHA1 Authentication Section Format
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Auth Type | Auth Len | Auth Key ID | Reserved |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Sequence Number |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Auth Key/Hash... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | ... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
2017-12-30 11:17:33 +08:00
|
|
|
if (auth_len != AUTH_SHA1_FIELD_LEN) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("[invalid length %u]",
|
|
|
|
auth_len);
|
2016-08-17 17:04:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
pptr += 2;
|
2018-06-16 23:23:21 +08:00
|
|
|
ND_PRINT(", Sequence Number: 0x%08x", GET_BE_U_4(pptr));
|
2016-08-17 17:04:27 +08:00
|
|
|
pptr += 4;
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(pptr, AUTH_SHA1_HASH_LEN);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n\t Hash: ");
|
2016-08-17 17:04:27 +08:00
|
|
|
for(i = 0; i < AUTH_SHA1_HASH_LEN; i++)
|
2018-06-16 23:23:21 +08:00
|
|
|
ND_PRINT("%02x", GET_U_1(pptr + i));
|
2016-08-17 17:04:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-27 18:13:44 +08:00
|
|
|
void
|
2017-12-14 02:17:47 +08:00
|
|
|
bfd_print(netdissect_options *ndo, const u_char *pptr,
|
|
|
|
u_int len, u_int port)
|
2003-10-27 18:13:44 +08:00
|
|
|
{
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "bfd";
|
2019-04-27 02:03:34 +08:00
|
|
|
if (port == BFD_CONTROL_PORT ||
|
|
|
|
port == BFD_MULTIHOP_PORT ||
|
2021-02-05 13:10:31 +08:00
|
|
|
port == BFD_LAG_PORT ||
|
|
|
|
port == SBFD_PORT) {
|
2018-07-10 16:01:15 +08:00
|
|
|
/*
|
|
|
|
* Control packet.
|
|
|
|
*/
|
|
|
|
const struct bfd_header_t *bfd_header;
|
|
|
|
uint8_t version_diag;
|
|
|
|
uint8_t version = 0;
|
|
|
|
uint8_t flags;
|
|
|
|
|
|
|
|
bfd_header = (const struct bfd_header_t *)pptr;
|
2018-01-04 04:32:07 +08:00
|
|
|
ND_TCHECK_SIZE(bfd_header);
|
2018-06-16 23:23:21 +08:00
|
|
|
version_diag = GET_U_1(bfd_header->version_diag);
|
2017-12-30 11:17:33 +08:00
|
|
|
version = BFD_EXTRACT_VERSION(version_diag);
|
2018-06-16 23:23:21 +08:00
|
|
|
flags = GET_U_1(bfd_header->flags);
|
2018-07-10 16:01:15 +08:00
|
|
|
|
|
|
|
switch (version) {
|
|
|
|
|
|
|
|
/* BFDv0 */
|
|
|
|
case 0:
|
2023-04-20 03:19:44 +08:00
|
|
|
if (ndo->ndo_vflag < 1) {
|
2018-07-10 16:01:15 +08:00
|
|
|
ND_PRINT("BFDv0, Control, Flags: [%s], length: %u",
|
|
|
|
bittok2str(bfd_v0_flag_values, "none", flags),
|
|
|
|
len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ND_PRINT("BFDv0, length: %u\n\tControl, Flags: [%s], Diagnostic: %s (0x%02x)",
|
|
|
|
len,
|
2017-12-30 11:17:33 +08:00
|
|
|
bittok2str(bfd_v0_flag_values, "none", flags),
|
2018-07-10 16:01:15 +08:00
|
|
|
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)),
|
|
|
|
BFD_EXTRACT_DIAG(version_diag));
|
2014-01-02 10:27:54 +08:00
|
|
|
|
2018-07-10 16:01:15 +08:00
|
|
|
ND_PRINT("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
2018-06-16 23:23:21 +08:00
|
|
|
GET_U_1(bfd_header->detect_time_multiplier),
|
|
|
|
GET_U_1(bfd_header->detect_time_multiplier) * GET_BE_U_4(bfd_header->desired_min_tx_interval)/1000,
|
|
|
|
GET_U_1(bfd_header->length));
|
|
|
|
|
|
|
|
|
|
|
|
ND_PRINT("\n\tMy Discriminator: 0x%08x",
|
|
|
|
GET_BE_U_4(bfd_header->my_discriminator));
|
|
|
|
ND_PRINT(", Your Discriminator: 0x%08x",
|
|
|
|
GET_BE_U_4(bfd_header->your_discriminator));
|
|
|
|
ND_PRINT("\n\t Desired min Tx Interval: %4u ms",
|
|
|
|
GET_BE_U_4(bfd_header->desired_min_tx_interval)/1000);
|
|
|
|
ND_PRINT("\n\t Required min Rx Interval: %4u ms",
|
|
|
|
GET_BE_U_4(bfd_header->required_min_rx_interval)/1000);
|
|
|
|
ND_PRINT("\n\t Required min Echo Interval: %4u ms",
|
|
|
|
GET_BE_U_4(bfd_header->required_min_echo_interval)/1000);
|
2018-07-10 16:01:15 +08:00
|
|
|
|
|
|
|
if (flags & BFD_FLAG_AUTH) {
|
2020-10-13 03:10:20 +08:00
|
|
|
auth_print(ndo, pptr);
|
2018-07-10 16:01:15 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* BFDv1 */
|
|
|
|
case 1:
|
2023-04-20 03:19:44 +08:00
|
|
|
if (ndo->ndo_vflag < 1) {
|
2019-04-27 02:03:34 +08:00
|
|
|
ND_PRINT("BFDv1, %s, State %s, Flags: [%s], length: %u",
|
|
|
|
tok2str(bfd_port_values, "unknown (%u)", port),
|
2018-07-10 16:01:15 +08:00
|
|
|
tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6),
|
|
|
|
bittok2str(bfd_v1_flag_values, "none", flags & 0x3f),
|
|
|
|
len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-27 02:03:34 +08:00
|
|
|
ND_PRINT("BFDv1, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
|
2018-07-10 16:01:15 +08:00
|
|
|
len,
|
2019-04-27 02:03:34 +08:00
|
|
|
tok2str(bfd_port_values, "unknown (%u)", port),
|
2017-12-30 11:17:33 +08:00
|
|
|
tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6),
|
|
|
|
bittok2str(bfd_v1_flag_values, "none", flags & 0x3f),
|
2018-07-10 16:01:15 +08:00
|
|
|
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)),
|
|
|
|
BFD_EXTRACT_DIAG(version_diag));
|
2014-01-02 10:27:54 +08:00
|
|
|
|
2018-07-10 16:01:15 +08:00
|
|
|
ND_PRINT("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
|
2018-06-16 23:23:21 +08:00
|
|
|
GET_U_1(bfd_header->detect_time_multiplier),
|
|
|
|
GET_U_1(bfd_header->detect_time_multiplier) * GET_BE_U_4(bfd_header->desired_min_tx_interval)/1000,
|
|
|
|
GET_U_1(bfd_header->length));
|
|
|
|
|
|
|
|
|
|
|
|
ND_PRINT("\n\tMy Discriminator: 0x%08x",
|
|
|
|
GET_BE_U_4(bfd_header->my_discriminator));
|
|
|
|
ND_PRINT(", Your Discriminator: 0x%08x",
|
|
|
|
GET_BE_U_4(bfd_header->your_discriminator));
|
|
|
|
ND_PRINT("\n\t Desired min Tx Interval: %4u ms",
|
|
|
|
GET_BE_U_4(bfd_header->desired_min_tx_interval)/1000);
|
|
|
|
ND_PRINT("\n\t Required min Rx Interval: %4u ms",
|
|
|
|
GET_BE_U_4(bfd_header->required_min_rx_interval)/1000);
|
|
|
|
ND_PRINT("\n\t Required min Echo Interval: %4u ms",
|
|
|
|
GET_BE_U_4(bfd_header->required_min_echo_interval)/1000);
|
2018-07-10 16:01:15 +08:00
|
|
|
|
|
|
|
if (flags & BFD_FLAG_AUTH) {
|
2020-10-13 03:10:20 +08:00
|
|
|
auth_print(ndo, pptr);
|
2018-07-10 16:01:15 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ND_PRINT("BFDv%u, Control, length: %u",
|
|
|
|
version,
|
|
|
|
len);
|
|
|
|
if (ndo->ndo_vflag >= 1) {
|
|
|
|
if(!print_unknown_data(ndo, pptr,"\n\t",len))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (port == BFD_ECHO_PORT) {
|
|
|
|
/*
|
|
|
|
* Echo packet.
|
|
|
|
*/
|
|
|
|
ND_PRINT("BFD, Echo, length: %u",
|
|
|
|
len);
|
|
|
|
if (ndo->ndo_vflag >= 1) {
|
|
|
|
if(!print_unknown_data(ndo, pptr,"\n\t",len))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Unknown packet type.
|
|
|
|
*/
|
|
|
|
ND_PRINT("BFD, unknown (%u), length: %u",
|
|
|
|
port,
|
2018-01-07 18:47:30 +08:00
|
|
|
len);
|
2014-03-11 20:08:24 +08:00
|
|
|
if (ndo->ndo_vflag >= 1) {
|
|
|
|
if(!print_unknown_data(ndo, pptr,"\n\t",len))
|
2014-01-02 09:43:45 +08:00
|
|
|
return;
|
2003-10-28 06:44:37 +08:00
|
|
|
}
|
|
|
|
}
|
2003-10-27 18:13:44 +08:00
|
|
|
}
|