Browse Source

Add SPI setter

thegreathir 1 year ago
parent
commit
58e728ae65
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/wire/ipsec_ah.rs

+ 11 - 2
src/wire/ipsec_ah.rs

@@ -100,7 +100,6 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Packet<&'a T> {
     }
 }
 
-
 impl<T: AsRef<[u8]>> AsRef<[u8]> for Packet<T> {
     fn as_ref(&self) -> &[u8] {
         self.buffer.as_ref()
@@ -117,4 +116,14 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
         let data = self.buffer.as_mut();
         data[field::PAYLOAD_LEN] = value
     }
-}
+
+    fn set_security_parameters_index(&mut self, value: u32) {
+        let data = self.buffer.as_mut();
+        NetworkEndian::write_u32(&mut data[field::SPI], value)
+    }
+
+    fn set_sequence_number(&mut self, value: u32) {
+        let data = self.buffer.as_mut();
+        NetworkEndian::write_u32(&mut data[field::SEQUENCE_NUMBER], value)
+    }
+}