@@ -1273,7 +1273,7 @@ impl Payload {
1273
1273
///
1274
1274
/// This PDU differs between version 0 and 1 of RTR. Consequently, this
1275
1275
/// generic version is an enum that can be both, depending on the version
1276
- /// requested.
1276
+ /// requested. For version 2, the PDU is the same as for version 1.
1277
1277
#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
1278
1278
pub enum EndOfData {
1279
1279
V0 ( EndOfDataV0 ) ,
@@ -1317,7 +1317,7 @@ impl EndOfData {
1317
1317
EndOfDataV0 :: read_payload ( header, sock)
1318
1318
. await . map ( EndOfData :: V0 )
1319
1319
}
1320
- 1 => {
1320
+ 1 | 2 => {
1321
1321
EndOfDataV1 :: read_payload ( header, sock)
1322
1322
. await . map ( EndOfData :: V1 )
1323
1323
}
@@ -1334,7 +1334,7 @@ impl EndOfData {
1334
1334
pub fn version ( & self ) -> u8 {
1335
1335
match * self {
1336
1336
EndOfData :: V0 ( _) => 0 ,
1337
- EndOfData :: V1 ( _ ) => 1 ,
1337
+ EndOfData :: V1 ( v1_or_v2 ) => v1_or_v2 . header . version ( )
1338
1338
}
1339
1339
}
1340
1340
@@ -1914,6 +1914,40 @@ mod test {
1914
1914
) ;
1915
1915
}
1916
1916
1917
+ macro_rules! test_eod_pdu_version {
1918
+ ( $version: expr, $raw: expr) => {
1919
+ if let Err ( eod) = Payload :: read( & mut $raw. as_slice( ) ) . await . unwrap( ) {
1920
+ assert_eq!( $version, eod. version( ) ) ;
1921
+ } else {
1922
+ panic!( "expected End of Data PDU" ) ;
1923
+ }
1924
+ }
1925
+ }
1926
+
1927
+ #[ tokio:: test]
1928
+ async fn end_of_data_versions ( ) {
1929
+ test_eod_pdu_version ! (
1930
+ 0 ,
1931
+ vec![ 0 , 7 , 0x12 , 0x34 , 0 , 0 , 0 , 12 , 0xde , 0xad , 0xbe , 0xef ]
1932
+ ) ;
1933
+ test_eod_pdu_version ! (
1934
+ 1 ,
1935
+ vec![
1936
+ 0x01 , 0x07 , 0x8e , 0xef , 0x00 , 0x00 , 0x00 , 0x18 ,
1937
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x8f ,
1938
+ 0x00 , 0x00 , 0x02 , 0x58 , 0x00 , 0x00 , 0x1c , 0x20
1939
+ ]
1940
+ ) ;
1941
+ test_eod_pdu_version ! (
1942
+ 2 ,
1943
+ vec![
1944
+ 0x02 , 0x07 , 0x8e , 0xef , 0x00 , 0x00 , 0x00 , 0x18 ,
1945
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x8f ,
1946
+ 0x00 , 0x00 , 0x02 , 0x58 , 0x00 , 0x00 , 0x1c , 0x20
1947
+ ]
1948
+ ) ;
1949
+ }
1950
+
1917
1951
#[ tokio:: test]
1918
1952
async fn read_write_cache_reset ( ) {
1919
1953
read_write ! (
0 commit comments