25 expectMore_(expectMore)
39#define BinaryTokenizer_tail(size, start) \
40 " occupying " << (size) << " bytes @" << (start) << " in " << this << \
41 (expectMore_ ? ';' : '.');
47 if (parsed_ +
size > data_.length()) {
48 debugs(24, 5, (parsed_ +
size - data_.length()) <<
" more bytes for " <<
58 debugs(24, 7, context << description <<
66 debugs(24, 7, context << description <<
'=' << value <<
74 debugs(24, 7, context << description <<
'=' <<
84 debugs(24, 7, context << description <<
'=' << value <<
104 return static_cast<uint8_t
>(data_[parsed_++]);
116 parsed_ = syncPoint_;
122 syncPoint_ = parsed_;
128 return parsed_ >= data_.length();
134 want(1, description);
135 const uint8_t result = octet();
136 got(result, 1, description);
143 want(2, description);
144 const uint16_t result = (octet() << 8) | octet();
145 got(result, 2, description);
152 want(3, description);
153 const uint32_t result = (octet() << 16) | (octet() << 8) | octet();
154 got(result, 3, description);
161 want(4, description);
162 const uint32_t result = (octet() << 24) | (octet() << 16) | (octet() << 8) | octet();
163 got(result, 4, description);
170 want(
size, description);
173 got(result,
size, description);
177template <
class InAddr>
182 const auto size =
sizeof(addr);
183 want(
size, description);
184 memcpy(&addr, data_.rawContent() + parsed_,
size);
187 got(result,
size, description);
194 return inetAny<struct in_addr>(description);
200 return inetAny<struct in6_addr>(description);
206 want(
size, description);
208 skipped(
size, description);
220 if (
const uint8_t length = uint8(
".length"))
221 return area(length,
".octets");
229 if (
const uint16_t length = uint16(
".length"))
230 return area(length,
".octets");
238 if (
const uint32_t length = uint24(
".length"))
239 return area(length,
".octets");
#define BinaryTokenizer_tail(size, start)
debugging helper that prints a "standard" debugs() trailer
static std::ostream & operator<<(std::ostream &os, const acl_httpstatus_data *status)
reports acl_httpstatus_data using squid.conf http_status ACL value format
enables efficient debugging with concise field names: Hello.version.major
const char *const name
this context description or nullptr
const BinaryTokenizerContext *const parent
enclosing context or nullptr
SBuf area(uint64_t size, const char *description)
parse size consecutive bytes as an opaque blob
Ip::Address inet4(const char *description)
interpret the next 4 bytes as a raw in_addr structure
void got(uint64_t size, const char *description) const
debugging helper for parsed multi-field structures
SBuf pstring8(const char *description)
up to 255 byte-long p-string
void commit()
make progress: future parsing failures will not rollback beyond this point
bool atEnd() const
no more bytes to parse or skip
void skip(uint64_t size, const char *description)
ignore the next size bytes
void reset(const SBuf &data, const bool expectMore)
uint32_t uint32(const char *description)
parse a four-byte unsigned integer
uint32_t uint24(const char *description)
parse a three-byte unsigned integer (returned as uint32_t)
void want(uint64_t size, const char *description) const
logs and throws if fewer than size octets remain; no other side effects
uint16_t uint16(const char *description)
parse a two-byte unsigned integer
void rollback()
resume [incremental] parsing from the last commit point
Ip::Address inet6(const char *description)
interpret the next 16 bytes as a raw in6_addr structure
uint8_t uint8(const char *description)
parse a single-byte unsigned integer
void skipped(uint64_t size, const char *description) const
debugging helper for skipped fields
Ip::Address inetAny(const char *description)
SBuf pstring16(const char *description)
up to 64 KiB-long p-string
SBuf pstring24(const char *description)
up to 16 MiB-long p-string!
Raw & hex()
print data using two hex digits per byte (decoder: xxd -r -p)
const char * rawContent() const
size_type length() const
Returns the number of bytes stored in SBuf.
SBuf substr(size_type pos, size_type n=npos) const
#define debugs(SECTION, LEVEL, CONTENT)