Skip to content

Commit

Permalink
Fix last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbette committed Jan 22, 2021
1 parent 928e8e8 commit d52d472
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 12 additions & 9 deletions elements/standard/search.cc
Expand Up @@ -55,13 +55,12 @@ Search::configure(Vector<String> &conf, ErrorHandler *errh)
return 0;
}

void
Search::push(int, Packet *p) {

int
Search::action(Packet* p) {
const char* f = String::make_stable((const char*)p->data(), p->length()).search(_pattern);
if (f == 0) {
output(1).push(p);
return;
return 1;
}

unsigned n = (f - (const char*)p->data());
Expand All @@ -70,16 +69,20 @@ Search::push(int, Packet *p) {
p->pull(n);
if (_set_anno)
p->set_anno_u16(_anno, p->anno_u16(_anno) + n);
output(0).push(p);
return 0;
}

void
Search::push(int, Packet *p) {

int o = action(p);
output(o).push(p);
}

#if HAVE_BATCH
void
Search::push_batch(int port, PacketBatch *batch) {
FOR_EACH_PACKET(batch, p) {
Search::push(port,p);
}
output(0).push_batch(batch);
CLASSIFY_EACH_PACKET(2, action, batch, checked_output_push_batch);
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions elements/standard/search.hh
Expand Up @@ -55,6 +55,8 @@ class Search : public BatchElement { public:
void push_batch(int, PacketBatch *) override;
#endif

int action(Packet* p);

private:

int _anno;
Expand Down

0 comments on commit d52d472

Please sign in to comment.