Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldp: decode PW Status TLV #1140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions print-ldp.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ static const struct tok ldp_msg_values[] = {
#define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600
#define LDP_TLV_MTU 0x0601 /* rfc 3988 */
#define LDP_TLV_DUAL_STACK_CAP 0x0701 /* rfc 7552 */
#define LDP_TLV_PW_STATUS 0x096a /* rfc 8077 */

static const struct tok ldp_tlv_values[] = {
{ LDP_TLV_FEC, "FEC" },
Expand All @@ -170,6 +171,7 @@ static const struct tok ldp_tlv_values[] = {
{ LDP_TLV_LABEL_REQUEST_MSG_ID, "Label Request Message ID" },
{ LDP_TLV_MTU, "MTU" },
{ LDP_TLV_DUAL_STACK_CAP, "Dual-Stack Capability" },
{ LDP_TLV_PW_STATUS, "PW Status" },
{ 0, NULL}
};

Expand Down Expand Up @@ -255,6 +257,19 @@ static const struct tok ldp_dual_stack_transport_pref_values[] = {
{ 0, NULL}
};

static const struct tok ldp_pw_status_flags[] = {
/* rfc 8077 */
{ 0x01, "NF" }, /* Pseudowire Not Forwarding */
{ 0x02, "AC-RF" }, /* Local Attachment Circuit (ingress) Receive Fault */
{ 0x04, "AC-TF" }, /* Local Attachment Circuit (egress) Transmit Fault */
{ 0x08, "PSN-RF" }, /* Local PSN-facing PW (ingress) Receive Fault */
{ 0x10, "PSN-TF" }, /* Local PSN-facing PW (egress) Transmit Fault */
/* rfc 6870 */
{ 0x20, "PF" }, /* PW Preferential Forwarding Status */
{ 0x40, "RS" }, /* PW Request Switchover Status */
{ 0, NULL}
};

static u_int ldp_pdu_print(netdissect_options *, const u_char *);

/*
Expand Down Expand Up @@ -589,6 +604,13 @@ ldp_tlv_print(netdissect_options *ndo,
transport_pref));
break;

case LDP_TLV_PW_STATUS:
ND_ICHECKMSG_U("tlv length", tlv_tlen, <, 4);
ND_PRINT("\n\t PW Status: 0x%02x [%s]",
GET_BE_U_4(tptr),
bittok2str(ldp_pw_status_flags, "none", GET_BE_U_4(tptr)));
break;

/*
* FIXME those are the defined TLVs that lack a decoder
* you are welcome to contribute code ;-)
Expand Down
1 change: 1 addition & 0 deletions tests/TESTLIST
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ lmp lmp.pcap lmp.out -T lmp
mpls-ldp-hello mpls-ldp-hello.pcap mpls-ldp-hello.out -v
ldp-common-session ldp-common-session.pcap ldp-common-session.out -v
ldp_infloop ldp-infinite-loop.pcap ldp_infloop.out
ldp-pw-status ldp-pw-status.pcap ldp-pw-status.out -v
lspping-fec-ldp lspping-fec-ldp.pcap lspping-fec-ldp.out
lspping-fec-ldp-v lspping-fec-ldp.pcap lspping-fec-ldp-v.out -v
lspping-fec-ldp-vv lspping-fec-ldp.pcap lspping-fec-ldp-vv.out -vv
Expand Down
10 changes: 10 additions & 0 deletions tests/ldp-pw-status.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 00:30:47.522169 IP (tos 0xc0, ttl 64, id 944, offset 0, flags [DF], proto TCP (6), length 108)
2.2.2.2.45781 > 1.1.1.1.646: Flags [P.], cksum 0xd2d9 (correct), seq 4026114102:4026114158, ack 1839823399, win 128, options [nop,nop,TS val 2533630089 ecr 3448755034], length 56
LDP, Label-Space-ID: 2.2.2.2:0, pdu-length: 52
Notification Message (0x0001), length: 42, Message ID: 0x0000002d, Flags: [ignore if unknown]
Status TLV (0x0300), length: 10, Flags: [ignore and don't forward if unknown]
Status Code: Unknown, Flags: [Advisory Notification and don't forward]
PW Status TLV (0x096a), length: 4, Flags: [continue processing and don't forward if unknown]
PW Status: 0x06 [AC-RF, AC-TF]
FEC TLV (0x0100), length: 12, Flags: [ignore and don't forward if unknown]
Martini VC FEC (0x80): Ethernet, no control word, group-ID 0, VC-ID 1, VC-info-length: 4
Binary file added tests/ldp-pw-status.pcap
Binary file not shown.