mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: Adding an interface to manually control the buffering for generated
parsers. This consists of two parts: 1. The generated Flow classes expose their flow buffers via a new method flow_buffer(). 2. Flow buffers get two new methods: // Interface for delayed parsing. Sometimes BinPAC doesn't get the // buffering right and then one can use these to feed parts // individually and assemble them internally. After calling // FinishBuffer(), one can send the uppper-layer flow an FlowEOF() // to trigger parsing. void BufferData(const_byteptr data, const_byteptr end); void FinishBuffer();
This commit is contained in:
parent
ce2b56751b
commit
61cc83affa
3 changed files with 23 additions and 2 deletions
|
@ -137,6 +137,19 @@ void FlowBuffer::NewFrame(int frame_length, bool chunked)
|
|||
MarkOrCopyFrame();
|
||||
}
|
||||
|
||||
void FlowBuffer::BufferData(const_byteptr data, const_byteptr end)
|
||||
{
|
||||
mode_ = FRAME_MODE;
|
||||
frame_length_ += (end - data);
|
||||
MarkOrCopyFrame();
|
||||
NewData(data, end);
|
||||
}
|
||||
|
||||
void FlowBuffer::FinishBuffer()
|
||||
{
|
||||
message_complete_ = true;
|
||||
}
|
||||
|
||||
void FlowBuffer::GrowFrame(int length)
|
||||
{
|
||||
BINPAC_ASSERT(frame_length_ >= 0);
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace binpac {
|
|||
|
||||
class FlowBuffer {
|
||||
public:
|
||||
enum LineBreakStyle {
|
||||
enum LineBreakStyle {
|
||||
CR_OR_LF, // CR or LF or CRLF
|
||||
STRICT_CRLF, // CR followed by LF
|
||||
CR_LF_NUL, // CR or LF or CR-LF or CR-NUL
|
||||
|
@ -20,6 +20,14 @@ public:
|
|||
void NewData(const_byteptr begin, const_byteptr end);
|
||||
void NewGap(int length);
|
||||
|
||||
// Interface for delayed parsing. Sometimes BinPAC doesn't get the
|
||||
// buffering right and then one can use these to feed parts
|
||||
// individually and assemble them internally. After calling
|
||||
// FinishBuffer(), one can send the uppper-layer flow an FlowEOF() to
|
||||
// trigger parsing.
|
||||
void BufferData(const_byteptr data, const_byteptr end);
|
||||
void FinishBuffer();
|
||||
|
||||
// Discard unprocessed data
|
||||
void DiscardData();
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void FlowDecl::ProcessDataUnitElement(AnalyzerDataUnit *dataunit_elem)
|
|||
{
|
||||
dataunit_->data_type()->MarkIncrementalInput();
|
||||
|
||||
flow_buffer_var_field_ = new PrivVarField(
|
||||
flow_buffer_var_field_ = new PubVarField(
|
||||
flow_buffer_id->clone(),
|
||||
FlowDecl::flow_buffer_type()->Clone());
|
||||
type_->AddField(flow_buffer_var_field_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue