@@ -80,6 +80,10 @@ mod field {
80
80
pub const CHECKSUM : Field = 16 ..18 ;
81
81
pub const URGENT : Field = 18 ..20 ;
82
82
83
+ pub fn OPTIONS ( length : u8 ) -> Field {
84
+ URGENT . end ..( length as usize )
85
+ }
86
+
83
87
pub const FLG_FIN : u16 = 0x001 ;
84
88
pub const FLG_SYN : u16 = 0x002 ;
85
89
pub const FLG_RST : u16 = 0x004 ;
@@ -295,9 +299,9 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Packet<&'a T> {
295
299
/// Return a pointer to the options.
296
300
#[ inline]
297
301
pub fn options ( & self ) -> & ' a [ u8 ] {
298
- let header_len = self . header_len ( ) as usize ;
302
+ let header_len = self . header_len ( ) ;
299
303
let data = self . buffer . as_ref ( ) ;
300
- & data[ field:: URGENT . end .. header_len]
304
+ & data[ field:: OPTIONS ( header_len) ]
301
305
}
302
306
303
307
/// Return a pointer to the payload.
@@ -481,9 +485,9 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> {
481
485
/// Return a pointer to the options.
482
486
#[ inline]
483
487
pub fn options_mut ( & mut self ) -> & mut [ u8 ] {
484
- let header_len = self . header_len ( ) as usize ;
488
+ let header_len = self . header_len ( ) ;
485
489
let data = self . buffer . as_mut ( ) ;
486
- & mut data[ field:: URGENT . end .. header_len]
490
+ & mut data[ field:: OPTIONS ( header_len) ]
487
491
}
488
492
489
493
/// Return a mutable pointer to the payload data.
0 commit comments