瀏覽代碼

Add SPI setter

thegreathir 1 年之前
父節點
當前提交
58e728ae65
共有 1 個文件被更改,包括 11 次插入2 次删除
  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)
+    }
+}