diff options
author | lloyd <[email protected]> | 2010-03-30 16:52:10 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-30 16:52:10 +0000 |
commit | e79a7cad4770905a8ae8142a5d658f7fc02ae76e (patch) | |
tree | bfb1c541fd81beb790ff77bfb4dabbf4ad7a69a1 | |
parent | 0ab987031a950575cad8364ab2029b730b479f53 (diff) |
Constify assert_at_least. Add some helpers
-rw-r--r-- | src/ssl/tls_reader.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ssl/tls_reader.h b/src/ssl/tls_reader.h index d2f21a90f..ff3e63ae8 100644 --- a/src/ssl/tls_reader.h +++ b/src/ssl/tls_reader.h @@ -19,6 +19,22 @@ class TLS_Data_Reader TLS_Data_Reader(const MemoryRegion<byte>& buf_in) : buf(buf_in), offset(0) {} + u32bit remaining_bytes() const + { + return buf.size() - offset; + } + + bool has_remaining() const + { + return (remaining_bytes() > 0); + } + + void discard_next(u32bit bytes) + { + assert_at_least(bytes); + offset += bytes; + } + u16bit get_u16bit() { assert_at_least(2); @@ -109,7 +125,7 @@ class TLS_Data_Reader return num_elems; } - void assert_at_least(u32bit n) + void assert_at_least(u32bit n) const { if(buf.size() - offset < n) throw Decoding_Error("TLS_Data_Reader: Corrupt packet"); |