@@ -769,6 +769,43 @@ pub enum ControlMessageOwned {
769
769
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
770
770
Ipv6OrigDstAddr ( libc:: sockaddr_in6) ,
771
771
772
+ /// Time-to-Live (TTL) header field of the incoming IPv4 packet.
773
+ ///
774
+ /// [Further reading](https://www.man7.org/linux/man-pages/man7/ip.7.html)
775
+ #[ cfg( linux_android) ]
776
+ #[ cfg( feature = "net" ) ]
777
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
778
+ Ipv4Ttl ( i32 ) ,
779
+
780
+ /// Time-to-Live (TTL) header field of the incoming IPv4 packet.
781
+ ///
782
+ /// [Further reading](https://datatracker.ietf.org/doc/html/rfc3542.html)
783
+ #[ cfg( target_os = "freebsd" ) ]
784
+ #[ cfg( feature = "net" ) ]
785
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
786
+ Ipv4Ttl ( u8 ) ,
787
+
788
+ /// Hop Limit header field of the incoming IPv6 packet.
789
+ ///
790
+ /// [Further reading for Linux](https://www.man7.org/linux/man-pages/man7/ip.7.html)
791
+ /// [Further reading for FreeBSD](https://datatracker.ietf.org/doc/html/rfc3542.html)
792
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
793
+ #[ cfg( feature = "net" ) ]
794
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
795
+ Ipv6HopLimit ( i32 ) ,
796
+
797
+ /// Retrieve the DSCP (ToS) header field of the incoming IPv4 packet.
798
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
799
+ #[ cfg( feature = "net" ) ]
800
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
801
+ Ipv4Tos ( u8 ) ,
802
+
803
+ /// Retrieve the DSCP (Traffic Class) header field of the incoming IPv6 packet.
804
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
805
+ #[ cfg( feature = "net" ) ]
806
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
807
+ Ipv6TClass ( i32 ) ,
808
+
772
809
/// UDP Generic Receive Offload (GRO) allows receiving multiple UDP
773
810
/// packets from a single sender.
774
811
/// Fixed-size payloads are following one by one in a receive buffer.
@@ -987,6 +1024,42 @@ impl ControlMessageOwned {
987
1024
let content_type = unsafe { ptr:: read_unaligned( p as * const u8 ) } ;
988
1025
ControlMessageOwned :: TlsGetRecordType ( content_type. into( ) )
989
1026
} ,
1027
+ #[ cfg( linux_android) ]
1028
+ #[ cfg( feature = "net" ) ]
1029
+ ( libc:: IPPROTO_IP , libc:: IP_TTL ) => {
1030
+ let ttl = unsafe { ptr:: read_unaligned( p as * const i32 ) } ;
1031
+ ControlMessageOwned :: Ipv4Ttl ( ttl)
1032
+ } ,
1033
+ #[ cfg( target_os = "freebsd" ) ]
1034
+ #[ cfg( feature = "net" ) ]
1035
+ ( libc:: IPPROTO_IP , libc:: IP_RECVTTL ) => {
1036
+ let ttl: u8 = unsafe { ptr:: read_unaligned( p as * const u8 ) } ;
1037
+ ControlMessageOwned :: Ipv4Ttl ( ttl)
1038
+ } ,
1039
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1040
+ #[ cfg( feature = "net" ) ]
1041
+ ( libc:: IPPROTO_IPV6 , libc:: IPV6_HOPLIMIT ) => {
1042
+ let ttl = unsafe { ptr:: read_unaligned( p as * const i32 ) } ;
1043
+ ControlMessageOwned :: Ipv6HopLimit ( ttl)
1044
+ } ,
1045
+ #[ cfg( linux_android) ]
1046
+ #[ cfg( feature = "net" ) ]
1047
+ ( libc:: IPPROTO_IP , libc:: IP_TOS ) => {
1048
+ let tos = unsafe { ptr:: read_unaligned( p as * const u8 ) } ;
1049
+ ControlMessageOwned :: Ipv4Tos ( tos)
1050
+ } ,
1051
+ #[ cfg( target_os = "freebsd" ) ]
1052
+ #[ cfg( feature = "net" ) ]
1053
+ ( libc:: IPPROTO_IP , libc:: IP_RECVTOS ) => {
1054
+ let tos = unsafe { ptr:: read_unaligned( p as * const u8 ) } ;
1055
+ ControlMessageOwned :: Ipv4Tos ( tos)
1056
+ } ,
1057
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1058
+ #[ cfg( feature = "net" ) ]
1059
+ ( libc:: IPPROTO_IPV6 , libc:: IPV6_TCLASS ) => {
1060
+ let tc = unsafe { ptr:: read_unaligned( p as * const i32 ) } ;
1061
+ ControlMessageOwned :: Ipv6TClass ( tc)
1062
+ } ,
990
1063
( _, _) => {
991
1064
let sl = unsafe { std:: slice:: from_raw_parts( p, len) } ;
992
1065
let ucmsg = UnknownCmsg ( * header, Vec :: <u8 >:: from( sl) ) ;
@@ -1124,6 +1197,18 @@ pub enum ControlMessage<'a> {
1124
1197
#[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1125
1198
Ipv4SendSrcAddr ( & ' a libc:: in_addr) ,
1126
1199
1200
+ /// Configure the Time-to-Live for v4 traffic.
1201
+ #[ cfg( linux_android) ]
1202
+ #[ cfg( feature = "net" ) ]
1203
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1204
+ Ipv4Ttl ( & ' a libc:: c_int) ,
1205
+
1206
+ /// Configure the Time-to-Live for v4 traffic.
1207
+ #[ cfg( target_os = "freebsd" ) ]
1208
+ #[ cfg( feature = "net" ) ]
1209
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1210
+ Ipv4Ttl ( & ' a libc:: c_uchar) ,
1211
+
1127
1212
/// Configure the hop limit for v6 multicast traffic.
1128
1213
///
1129
1214
/// Set the IPv6 hop limit for this message. The argument is an integer
@@ -1138,9 +1223,9 @@ pub enum ControlMessage<'a> {
1138
1223
Ipv6HopLimit ( & ' a libc:: c_int) ,
1139
1224
1140
1225
/// SO_RXQ_OVFL indicates that an unsigned 32 bit value
1141
- /// ancilliary msg (cmsg) should be attached to recieved
1226
+ /// ancillary msg (cmsg) should be attached to received
1142
1227
/// skbs indicating the number of packets dropped by the
1143
- /// socket between the last recieved packet and this
1228
+ /// socket between the last received packet and this
1144
1229
/// received packet.
1145
1230
#[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
1146
1231
RxqOvfl ( & ' a u32 ) ,
@@ -1152,6 +1237,22 @@ pub enum ControlMessage<'a> {
1152
1237
/// page.
1153
1238
#[ cfg( target_os = "linux" ) ]
1154
1239
TxTime ( & ' a u64 ) ,
1240
+
1241
+ /// Configure DSCP / IP TOS for outgoing v4 packets.
1242
+ ///
1243
+ /// Further information can be found [here](https://en.wikipedia.org/wiki/Differentiated_services).
1244
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1245
+ #[ cfg( feature = "net" ) ]
1246
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1247
+ Ipv4Tos ( & ' a u8 ) ,
1248
+
1249
+ /// Configure DSCP / IPv6 TCLASS for outgoing v6 packets.
1250
+ ///
1251
+ /// Further information can be found [here](https://en.wikipedia.org/wiki/Differentiated_services).
1252
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1253
+ #[ cfg( feature = "net" ) ]
1254
+ #[ cfg_attr( docsrs, doc( cfg( feature = "net" ) ) ) ]
1255
+ Ipv6TClass ( & ' a i32 ) ,
1155
1256
}
1156
1257
1157
1258
// An opaque structure used to prevent cmsghdr from being a public type
@@ -1245,6 +1346,9 @@ impl<'a> ControlMessage<'a> {
1245
1346
#[ cfg( any( freebsdlike, netbsdlike) ) ]
1246
1347
#[ cfg( feature = "net" ) ]
1247
1348
ControlMessage :: Ipv4SendSrcAddr ( addr) => addr as * const _ as * const u8 ,
1349
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1350
+ #[ cfg( feature = "net" ) ]
1351
+ ControlMessage :: Ipv4Ttl ( ttl) => ttl as * const _ as * const u8 ,
1248
1352
#[ cfg( any( linux_android, freebsdlike, apple_targets, target_os = "haiku" ) ) ]
1249
1353
#[ cfg( feature = "net" ) ]
1250
1354
ControlMessage :: Ipv6HopLimit ( limit) => limit as * const _ as * const u8 ,
@@ -1256,6 +1360,16 @@ impl<'a> ControlMessage<'a> {
1256
1360
ControlMessage :: TxTime ( tx_time) => {
1257
1361
tx_time as * const _ as * const u8
1258
1362
} ,
1363
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1364
+ #[ cfg( feature = "net" ) ]
1365
+ ControlMessage :: Ipv4Tos ( tos) => {
1366
+ tos as * const _
1367
+ } ,
1368
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1369
+ #[ cfg( feature = "net" ) ]
1370
+ ControlMessage :: Ipv6TClass ( tclass) => {
1371
+ tclass as * const _ as * const u8
1372
+ } ,
1259
1373
} ;
1260
1374
unsafe {
1261
1375
ptr:: copy_nonoverlapping(
@@ -1307,6 +1421,11 @@ impl<'a> ControlMessage<'a> {
1307
1421
#[ cfg( any( freebsdlike, netbsdlike) ) ]
1308
1422
#[ cfg( feature = "net" ) ]
1309
1423
ControlMessage :: Ipv4SendSrcAddr ( addr) => mem:: size_of_val( addr) ,
1424
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1425
+ #[ cfg( feature = "net" ) ]
1426
+ ControlMessage :: Ipv4Ttl ( ttl) => {
1427
+ mem:: size_of_val( ttl)
1428
+ } ,
1310
1429
#[ cfg( any( linux_android, freebsdlike, apple_targets, target_os = "haiku" ) ) ]
1311
1430
#[ cfg( feature = "net" ) ]
1312
1431
ControlMessage :: Ipv6HopLimit ( limit) => {
@@ -1320,6 +1439,16 @@ impl<'a> ControlMessage<'a> {
1320
1439
ControlMessage :: TxTime ( tx_time) => {
1321
1440
mem:: size_of_val( tx_time)
1322
1441
} ,
1442
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1443
+ #[ cfg( feature = "net" ) ]
1444
+ ControlMessage :: Ipv4Tos ( tos) => {
1445
+ mem:: size_of_val( tos)
1446
+ } ,
1447
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1448
+ #[ cfg( feature = "net" ) ]
1449
+ ControlMessage :: Ipv6TClass ( tclass) => {
1450
+ mem:: size_of_val( tclass)
1451
+ } ,
1323
1452
}
1324
1453
}
1325
1454
@@ -1347,13 +1476,22 @@ impl<'a> ControlMessage<'a> {
1347
1476
#[ cfg( any( freebsdlike, netbsdlike) ) ]
1348
1477
#[ cfg( feature = "net" ) ]
1349
1478
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IPPROTO_IP ,
1479
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1480
+ #[ cfg( feature = "net" ) ]
1481
+ ControlMessage :: Ipv4Ttl ( _) => libc:: IPPROTO_IP ,
1350
1482
#[ cfg( any( linux_android, freebsdlike, apple_targets, target_os = "haiku" ) ) ]
1351
1483
#[ cfg( feature = "net" ) ]
1352
1484
ControlMessage :: Ipv6HopLimit ( _) => libc:: IPPROTO_IPV6 ,
1353
1485
#[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
1354
1486
ControlMessage :: RxqOvfl ( _) => libc:: SOL_SOCKET ,
1355
1487
#[ cfg( target_os = "linux" ) ]
1356
1488
ControlMessage :: TxTime ( _) => libc:: SOL_SOCKET ,
1489
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1490
+ #[ cfg( feature = "net" ) ]
1491
+ ControlMessage :: Ipv4Tos ( _) => libc:: IPPROTO_IP ,
1492
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1493
+ #[ cfg( feature = "net" ) ]
1494
+ ControlMessage :: Ipv6TClass ( _) => libc:: IPPROTO_IPV6 ,
1357
1495
}
1358
1496
}
1359
1497
@@ -1392,6 +1530,9 @@ impl<'a> ControlMessage<'a> {
1392
1530
#[ cfg( any( freebsdlike, netbsdlike) ) ]
1393
1531
#[ cfg( feature = "net" ) ]
1394
1532
ControlMessage :: Ipv4SendSrcAddr ( _) => libc:: IP_SENDSRCADDR ,
1533
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1534
+ #[ cfg( feature = "net" ) ]
1535
+ ControlMessage :: Ipv4Ttl ( _) => libc:: IP_TTL ,
1395
1536
#[ cfg( any( linux_android, freebsdlike, apple_targets, target_os = "haiku" ) ) ]
1396
1537
#[ cfg( feature = "net" ) ]
1397
1538
ControlMessage :: Ipv6HopLimit ( _) => libc:: IPV6_HOPLIMIT ,
@@ -1403,6 +1544,16 @@ impl<'a> ControlMessage<'a> {
1403
1544
ControlMessage :: TxTime ( _) => {
1404
1545
libc:: SCM_TXTIME
1405
1546
} ,
1547
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1548
+ #[ cfg( feature = "net" ) ]
1549
+ ControlMessage :: Ipv4Tos ( _) => {
1550
+ libc:: IP_TOS
1551
+ } ,
1552
+ #[ cfg( any( linux_android, target_os = "freebsd" ) ) ]
1553
+ #[ cfg( feature = "net" ) ]
1554
+ ControlMessage :: Ipv6TClass ( _) => {
1555
+ libc:: IPV6_TCLASS
1556
+ } ,
1406
1557
}
1407
1558
}
1408
1559
0 commit comments