summaryrefslogtreecommitdiff
path: root/cpputil
diff options
context:
space:
mode:
Diffstat (limited to 'cpputil')
-rw-r--r--cpputil/databuffer.cc41
-rw-r--r--cpputil/databuffer.h6
-rw-r--r--cpputil/tls_parser.h3
3 files changed, 31 insertions, 19 deletions
diff --git a/cpputil/databuffer.cc b/cpputil/databuffer.cc
index 1defde213..d60ebccb3 100644
--- a/cpputil/databuffer.cc
+++ b/cpputil/databuffer.cc
@@ -62,21 +62,6 @@ size_t DataBuffer::Write(size_t index, uint32_t val, size_t count) {
return Write(index, addr + sizeof(uint32_t) - count, count);
}
-// This can't use the same trick as Write(), since we might be reading from a
-// smaller data source.
-bool DataBuffer::Read(size_t index, size_t count, uint32_t* val) const {
- assert(count < sizeof(uint32_t));
- assert(val);
- if ((index > len()) || (count > (len() - index))) {
- return false;
- }
- *val = 0;
- for (size_t i = 0; i < count; ++i) {
- *val = (*val << 8) | data()[index + i];
- }
- return true;
-}
-
void DataBuffer::Splice(const uint8_t* ins, size_t ins_len, size_t index,
size_t remove) {
assert(ins);
@@ -107,6 +92,32 @@ void DataBuffer::Splice(const uint8_t* ins, size_t ins_len, size_t index,
delete[] old_value;
}
+// This can't use the same trick as Write(), since we might be reading from a
+// smaller data source.
+bool DataBuffer::Read(size_t index, size_t count, uint64_t* val) const {
+ assert(count <= sizeof(uint64_t));
+ assert(val);
+ if ((index > len()) || (count > (len() - index))) {
+ return false;
+ }
+ *val = 0;
+ for (size_t i = 0; i < count; ++i) {
+ *val = (*val << 8) | data()[index + i];
+ }
+ return true;
+}
+
+bool DataBuffer::Read(size_t index, size_t count, uint32_t* val) const {
+ assert(count <= sizeof(uint32_t));
+ uint64_t tmp;
+
+ if (!Read(index, count, &tmp)) {
+ return false;
+ }
+ *val = tmp & 0xffffffff;
+ return true;
+}
+
size_t DataBuffer::logging_limit = 32;
/* static */ void DataBuffer::SetLogLimit(size_t limit) {
diff --git a/cpputil/databuffer.h b/cpputil/databuffer.h
index d909f69f6..58e07efe1 100644
--- a/cpputil/databuffer.h
+++ b/cpputil/databuffer.h
@@ -55,9 +55,6 @@ class DataBuffer {
// Returns the offset of the end of the write.
size_t Write(size_t index, uint32_t val, size_t count);
- // This can't use the same trick as Write(), since we might be reading from a
- // smaller data source.
- bool Read(size_t index, size_t count, uint32_t* val) const;
// Starting at |index|, remove |remove| bytes and replace them with the
// contents of |buf|.
void Splice(const DataBuffer& buf, size_t index, size_t remove = 0) {
@@ -68,6 +65,9 @@ class DataBuffer {
size_t remove = 0);
void Append(const DataBuffer& buf) { Splice(buf, len_); }
+ bool Read(size_t index, size_t count, uint64_t* val) const;
+ bool Read(size_t index, size_t count, uint32_t* val) const;
+
const uint8_t* data() const { return data_; }
uint8_t* data() { return data_; }
size_t len() const { return len_; }
diff --git a/cpputil/tls_parser.h b/cpputil/tls_parser.h
index 7a0809165..a5f5771d5 100644
--- a/cpputil/tls_parser.h
+++ b/cpputil/tls_parser.h
@@ -25,6 +25,7 @@ const uint8_t kTlsAlertType = 21;
const uint8_t kTlsHandshakeType = 22;
const uint8_t kTlsApplicationDataType = 23;
const uint8_t kTlsAltHandshakeType = 24;
+const uint8_t kTlsAckType = 25;
const uint8_t kTlsHandshakeClientHello = 1;
const uint8_t kTlsHandshakeServerHello = 2;
@@ -42,7 +43,6 @@ const uint8_t kTlsAlertWarning = 1;
const uint8_t kTlsAlertFatal = 2;
const uint8_t kTlsAlertCloseNotify = 0;
-const uint8_t kTlsAlertEndOfEarlyData = 1;
const uint8_t kTlsAlertUnexpectedMessage = 10;
const uint8_t kTlsAlertBadRecordMac = 20;
const uint8_t kTlsAlertRecordOverflow = 22;
@@ -51,6 +51,7 @@ const uint8_t kTlsAlertIllegalParameter = 47;
const uint8_t kTlsAlertDecodeError = 50;
const uint8_t kTlsAlertDecryptError = 51;
const uint8_t kTlsAlertProtocolVersion = 70;
+const uint8_t kTlsAlertInternalError = 80;
const uint8_t kTlsAlertInappropriateFallback = 86;
const uint8_t kTlsAlertMissingExtension = 109;
const uint8_t kTlsAlertUnsupportedExtension = 110;