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

RFC 9229: Babel v4-via-v6 #986

Open
wants to merge 3 commits 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
61 changes: 42 additions & 19 deletions print-babel.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
/* \summary: Babel Routing Protocol printer */
/* Specifications:
*
* RFC 6126
* RFC 7298
* RFC 7557
* draft-ietf-babel-rfc6126bis-17
* draft-ietf-babel-hmac-10
* draft-ietf-babel-source-specific-0
* RFC 8966
* RFC 8967
* RFC 9079
* RFC 9229
*/

#ifdef HAVE_CONFIG_H
Expand Down Expand Up @@ -209,7 +207,7 @@ network_prefix(int ae, int plen, unsigned int omitted,

if(plen >= 0)
pb = (plen + 7) / 8;
else if(ae == 1)
else if(ae == 1 || ae == 4)
pb = 4;
else
pb = 16;
Expand All @@ -222,6 +220,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
switch(ae) {
case 0: break;
case 1:
case 4:
if(omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted))
return -1;
memcpy(prefix, v4prefix, 12);
Expand Down Expand Up @@ -384,6 +383,8 @@ babel_print_v2_tlvs(netdissect_options *ndo,
u_char v4_prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
u_char v6_prefix[16] = {0};
u_char v4viav6_prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };

i = 0;
while(i < tlvs_length) {
Expand Down Expand Up @@ -538,31 +539,45 @@ babel_print_v2_tlvs(netdissect_options *ndo,
u_char ae, plen;
int rc;
u_char prefix[16];
u_char *update_prefix;
ND_PRINT("\n\tUpdate");
if(len < 10) goto invalid;
ae = GET_U_1(message + 2);
plen = GET_U_1(message + 4) + (GET_U_1(message + 2) == 1 ? 96 : 0);
switch(ae) {
case 0:
case 2:
case 3:
update_prefix = v6_prefix;
break;
case 1:
update_prefix = v4_prefix;
break;
case 4:
update_prefix = v4viav6_prefix;
break;
default:
goto invalid;
}
plen = GET_U_1(message + 4) + ((ae == 1 || ae == 4) ? 96 : 0);
rc = network_prefix(ae,
GET_U_1(message + 4),
GET_U_1(message + 5),
message + 12,
GET_U_1(message + 2) == 1 ? v4_prefix : v6_prefix,
update_prefix,
len - 10, prefix);
if(rc < 0) goto invalid;
interval = GET_BE_U_2(message + 6);
seqno = GET_BE_U_2(message + 8);
metric = GET_BE_U_2(message + 10);
ND_PRINT("%s%s%s %s metric %u seqno %u interval %s",
ND_PRINT("%s%s%s %s metric %u seqno %u interval %s%s",
(GET_U_1(message + 3) & 0x80) ? "/prefix": "",
(GET_U_1(message + 3) & 0x40) ? "/id" : "",
(GET_U_1(message + 3) & 0x3f) ? "/unknown" : "",
ae == 0 ? "any" : format_prefix(ndo, prefix, plen),
metric, seqno, format_interval_update(interval));
metric, seqno, format_interval_update(interval),
ae == 4 ? " (v4-via-v6)" : "");
if(GET_U_1(message + 3) & 0x80) {
if(GET_U_1(message + 2) == 1)
memcpy(v4_prefix, prefix, 16);
else
memcpy(v6_prefix, prefix, 16);
memcpy(update_prefix, prefix, 16);
}
/* extra data? */
if((u_int)rc < len - 10)
Expand All @@ -585,8 +600,9 @@ babel_print_v2_tlvs(netdissect_options *ndo,
GET_U_1(message + 3), 0,
message + 4, NULL, len - 2, prefix);
if(rc < 0) goto invalid;
ND_PRINT("for %s",
ae == 0 ? "any" : format_prefix(ndo, prefix, plen));
ND_PRINT("for %s%s",
ae == 0 ? "any" : format_prefix(ndo, prefix, plen),
ae == 4 ? " (v4-via-v6)" : "");
}
}
break;
Expand All @@ -607,10 +623,11 @@ babel_print_v2_tlvs(netdissect_options *ndo,
message + 16, NULL, len - 14, prefix);
if(rc < 0) goto invalid;
plen = GET_U_1(message + 3) + (GET_U_1(message + 2) == 1 ? 96 : 0);
ND_PRINT("(%u hops) for %s seqno %u id %s",
ND_PRINT("(%u hops) for %s seqno %u id %s%s",
GET_U_1(message + 6),
ae == 0 ? "invalid AE 0" : format_prefix(ndo, prefix, plen),
seqno, format_id(ndo, message + 8));
seqno, format_id(ndo, message + 8),
ae == 4 ? " (v4-via-v6)" : "");
}
}
break;
Expand Down Expand Up @@ -713,6 +730,9 @@ babel_print_v2_tlvs(netdissect_options *ndo,
ND_PRINT("for (%s, ", format_prefix(ndo, prefix, plen));
ND_PRINT("%s)", format_prefix(ndo, src_prefix, src_plen));
}
if(ae == 4) {
ND_PRINT(" (v4-via-v6)");
}
}
}
break;
Expand Down Expand Up @@ -749,6 +769,9 @@ babel_print_v2_tlvs(netdissect_options *ndo,
ND_PRINT("%s) seqno %u id %s",
format_prefix(ndo, src_prefix, src_plen),
seqno, format_id(ndo, router_id));
if(ae == 4) {
ND_PRINT(" (v4-via-v6)");
}
}
}
break;
Expand Down
1 change: 1 addition & 0 deletions tests/TESTLIST
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ babel_auth babel_auth.pcap babel_auth.out -v
babel_pad1 babel_pad1.pcap babel_pad1.out
babel_rtt babel_rtt.pcap babel_rtt.out -v
babel_rfc6126bis babel_rfc6126bis.pcap babel_rfc6126bis.out -v
babel_v4viav6 babel_v4viav6.pcap babel_v4viav6.out -v

# PPPoE tests
pppoe pppoe.pcap pppoe.out
Expand Down
7 changes: 7 additions & 0 deletions tests/babel_v4viav6.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1 22:48:47.963276 IP6 (class 0xc0, flowlabel 0xad6f7, hlim 1, next-header UDP (17) payload length: 96) fe80::e2e5:cfff:fe7e:4d5e.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (84)
Hello seqno 7855 interval 4.00s
IHU fe80::1bd9:58fb:b1bf:915e rxcost 409 interval 12.00s
Router Id b2:d5:cc:ff:fe:47:02:a9
Update 192.168.6.2/32 metric 0 seqno 39228 interval 16.00s (v4-via-v6)
Update 192.168.7.2/32 metric 0 seqno 39228 interval 16.00s (v4-via-v6)
Update 192.168.8.1/32 metric 0 seqno 39228 interval 16.00s (v4-via-v6)
Binary file added tests/babel_v4viav6.pcap
Binary file not shown.