]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #985 in SNORT/snort3 from multi_binder to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 10 Aug 2017 14:42:26 +0000 (10:42 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 10 Aug 2017 14:42:26 +0000 (10:42 -0400)
Squashed commit of the following:

commit 03b16f35970939c4a3ad6acebaa0ed5dca7a5a31
Author: Carter Waxman <cwaxman@cisco.com>
Date:   Fri Aug 4 14:07:32 2017 -0400

    snort2lua: removed excessive newlines from binder output

commit a0d7c06663c85b06a85aa6830ff5b88b20289a5e
Author: Carter Waxman <cwaxman@cisco.com>
Date:   Fri Aug 4 10:39:14 2017 -0400

    snort2lua: bindings now merge and propagate to top level of corresponsing policy

30 files changed:
tools/snort2lua/config_states/config_binding.cc
tools/snort2lua/config_states/config_ignore_ports.cc
tools/snort2lua/data/data_types/dt_option.cc
tools/snort2lua/data/data_types/dt_option.h
tools/snort2lua/data/data_types/dt_table.cc
tools/snort2lua/data/data_types/dt_table.h
tools/snort2lua/data/data_types/dt_var.cc
tools/snort2lua/data/data_types/dt_var.h
tools/snort2lua/data/dt_table_api.cc
tools/snort2lua/data/dt_table_api.h
tools/snort2lua/helpers/converter.cc
tools/snort2lua/helpers/converter.h
tools/snort2lua/helpers/util_binder.cc
tools/snort2lua/helpers/util_binder.h
tools/snort2lua/preprocessor_states/pps_dcerpc_server.cc
tools/snort2lua/preprocessor_states/pps_dnp3.cc
tools/snort2lua/preprocessor_states/pps_dns.cc
tools/snort2lua/preprocessor_states/pps_frag3_engine.cc
tools/snort2lua/preprocessor_states/pps_ftp_telnet_protocol.cc
tools/snort2lua/preprocessor_states/pps_gtp.cc
tools/snort2lua/preprocessor_states/pps_http_inspect_server.cc
tools/snort2lua/preprocessor_states/pps_imap.cc
tools/snort2lua/preprocessor_states/pps_modbus.cc
tools/snort2lua/preprocessor_states/pps_pop.cc
tools/snort2lua/preprocessor_states/pps_rpc_decode.cc
tools/snort2lua/preprocessor_states/pps_sip.cc
tools/snort2lua/preprocessor_states/pps_smtp.cc
tools/snort2lua/preprocessor_states/pps_ssh.cc
tools/snort2lua/preprocessor_states/pps_ssl.cc
tools/snort2lua/preprocessor_states/pps_stream5_tcp.cc

index 7e544a3f4d7e2038fe83237a2dbef0e7fb09265b..2d949fc726e81c926cee2d90928c44f4744f9292 100644 (file)
@@ -148,7 +148,7 @@ bool Binding::convert(std::istringstream& data_stream)
     if (!util::get_string(data_stream, val, ","))
         return false;
 
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bool rc = true;
 
     do
index 7538ba1d290abec391ea272d56b53eca7ac9bdea..09fc4933fb4c49c2a8c96d0d02df39b4f25eab63 100644 (file)
@@ -62,7 +62,7 @@ bool IgnorePorts::convert(std::istringstream& data_stream)
     }
 
     // Only add to the binder once we have validated the configuration.
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bind.set_when_proto(keyword);
 
     while (data_stream >> port)
index 37ce40e85fe20def9f3e5d5dcda092b0400c182c..92ef8ca62806ea03d29798ae042ccc431527174b 100644 (file)
@@ -81,7 +81,9 @@ std::ostream& operator<<(std::ostream& out, const Option& o)
     for (int i = 0; i < o.depth; i++)
         whitespace += "    ";
 
-    out << whitespace;
+    if ( o.print_whitespace )
+        out << whitespace;
+
     if (o.name.size())
         out << o.name << " = ";
 
index 8277e0a280184eac209b791f685fb3d76918d1f5..0260f1c09138e77b81741ddc41cf32d557344c04 100644 (file)
@@ -39,6 +39,9 @@ public:
     inline std::string get_value()
     { return value; }
 
+    void set_print_whitespace(bool w)
+    { print_whitespace = w; }
+
     // overloading operators
     friend std::ostream& operator<<(std::ostream&, const Option&);
     friend bool operator!=(const Option& lhs, const Option& rhs);
@@ -50,6 +53,7 @@ private:
     std::string name;
     std::string value;
     int depth;
+    bool print_whitespace = false;
     OptionType type;
 };
 
index f891fd6d509f577a4471047175f0b6743984c5a6..318d707dd8471a47abe676a93567b788caa3f95e 100644 (file)
@@ -250,40 +250,90 @@ std::ostream& operator<<(std::ostream& out, const Table& t)
         whitespace += "    ";
 
     if (!t.name.empty())
-        out << whitespace << t.name << " =" << std::endl;
-    out << whitespace << '{' << std::endl;
+    {
+        if ( t.print_whitespace )
+            out << whitespace;
 
-    if (!t.comments->empty() && !DataApi::is_quiet_mode())
-        out << (*t.comments) << std::endl;
+        out << t.name << (t.one_line ? " = " : " =\n");
+    }
+
+    out << (t.print_whitespace ? whitespace : "")
+        << (t.one_line ? "{ " : "{\n");
 
     // if we only want differences, don't print data
     if (!DataApi::is_difference_mode())
     {
         for (Option* o : t.options)
-            out << (*o) << ",\n";
+        {
+            o->set_print_whitespace(!t.one_line);
+            out << (*o) << (t.one_line ? ", " : ",\n");
+        }
 
         for (Variable* v : t.lists)
-            out << (*v) << ",\n";
+        {
+            v->set_print_whitespace(!t.one_line);
+            out << (*v) << (t.one_line ? ", " : ",\n");
+        }
 
         for (Table* sub_t : t.tables)
-            out << (*sub_t) << ",\n";
+        {
+            //If this table is one_lined, it may still print whitespace beforehand
+            //Don't print whitespace within the table if it's one_lined
+            sub_t->set_print_whitespace(!t.one_line);
+
+            if ( t.one_line )
+                sub_t->set_one_line(true);
+
+            out << (*sub_t) << (t.one_line ? ", " : ",\n");
+        }
     }
     else
     {
         for (Table* sub_t : t.tables)
+        {
             if (sub_t->has_differences())
-                out << (*sub_t) << ",\n";
+            {
+                //If this table is one_lined, it may still print whitespace beforehand
+                //Don't print whitespace within the table if it's one_lined
+                sub_t->set_print_whitespace(!t.one_line);
+
+                if ( t.one_line )
+                    sub_t->set_one_line(true);
+
+                out << (*sub_t) << (t.one_line ? ", " : ",\n");
+            }
+        }
+    }
+
+
+    if (!t.comments->empty() && !DataApi::is_quiet_mode())
+    {
+        // Comments need a new line regardless of one_line setting
+        // When one_line is off, this section is already starting on it's own line
+        if ( t.one_line )
+            out << "\n";
+
+        out << (*t.comments) << "\n";
     }
 
-    out << whitespace << "}";
+    if ( !t.one_line && t.print_whitespace )
+        out << whitespace;
+    out << "}";
 
     // Now, print all options which need to be appended/overwrite earlier options
     if (!t.append_options.empty())
     {
-        out << "\n";
+        if ( !t.one_line )
+            out << "\n";
 
         for (Option* a : t.append_options)
-            out << (*a) << "\n";
+        {
+            a->set_print_whitespace(!t.one_line);
+
+            out << (*a);
+            if ( !t.one_line )
+                out << "\n";
+        }
     }
 
     return out;
index db18cd762645f0c95809092e1784338bce6fded5..dabe484d2351bcb1426af876f6b890957c5e66f2 100644 (file)
@@ -36,6 +36,8 @@ public:
     virtual ~Table();
 
     inline std::string get_name() { return name; }
+    void set_one_line(bool o) { one_line = o; }
+    void set_print_whitespace(bool w) { print_whitespace = w; }
     bool has_differences();
     Table* open_table();
     Table* open_table(std::string);
@@ -59,6 +61,9 @@ public:
 
 private:
     std::string name;
+    bool one_line = false;
+    bool print_whitespace = true;
+
     int depth;
     Comments* comments;
     std::vector<Table*> tables;
index 18e59dabec182f9c3ffef444320847147f9173d9..99e346a32333de6847db3f6920ca416fad4caedd 100644 (file)
@@ -145,9 +145,15 @@ std::ostream& operator<<(std::ostream& out, const Variable& var)
     for (int i = 0; i < var.depth; i++)
         whitespace += "    ";
 
-    out << whitespace << var.name << " = ";
-    count += whitespace.size() + var.name.size() + 3;
-    whitespace += "    ";
+    out << (var.print_whitespace ? whitespace : "") << var.name << " = ";
+
+    if ( var.print_whitespace )
+        count += whitespace.size();
+
+    count += var.name.size() + 3;
+
+    if ( var.print_whitespace )
+        whitespace += "    ";
 
     for (Variable::VarData* v : var.vars)
     {
@@ -165,15 +171,15 @@ std::ostream& operator<<(std::ostream& out, const Variable& var)
             first_var = false;
 
         // print string
-        if (v->type == Variable::VarType::VARIABLE)
+        if ( v->type == Variable::VarType::VARIABLE )
         {
-            if (v->data.size() + count > var.max_line_length)
+            if ( var.print_whitespace && v->data.size() + count > var.max_line_length )
                 print_newline(out, count, whitespace);
 
             out << v->data;
             count += v->data.size();
         }
-        else if ((count + v->data.size()) < var.max_line_length)
+        else if ( !var.print_whitespace || (count + v->data.size()) < var.max_line_length )
         {
             out << "'" << v->data << "'";
             count += v->data.size() + 2;
index 5e114e5ccb5625e8363eba6565dccb37dae44fe7..35240d94c053a3e45e34c9ef9715c84df24e15ad 100644 (file)
@@ -36,6 +36,10 @@ public:
     inline std::string get_name() { return name; }
     std::string get_value(DataApi*);
     bool add_value(std::string);
+    
+    void set_print_whitespace(bool w)
+    { print_whitespace = w; }
+
     friend std::ostream& operator<<(std::ostream&, const Variable&);
 
 private:
@@ -50,6 +54,7 @@ private:
     std::vector<VarData*> vars;
     std::string name;
     int depth;
+    bool print_whitespace = true;
     static const std::size_t max_line_length = 77; // leave room for additional text
 };
 
index f933d587b7119fc91f0f1915fd98b93b38b41915..6a6c653dbd725bf22d09e11ce9927ba22dfc0f44 100644 (file)
@@ -47,7 +47,7 @@ void TableApi::reset_state()
     curr_data_bad = false;
 }
 
-void TableApi::open_top_level_table(std::string table_name)
+void TableApi::open_top_level_table(std::string table_name, bool one_line)
 {
     Table* t = util::find_table(tables, table_name);
 
@@ -57,6 +57,7 @@ void TableApi::open_top_level_table(std::string table_name)
         tables.push_back(t);
     }
 
+    t->set_one_line(one_line);
     open_tables.push(t);
 
     // ignore the initial table
@@ -64,7 +65,7 @@ void TableApi::open_top_level_table(std::string table_name)
         top_level_tables.push(open_tables.size());
 }
 
-void TableApi::open_table(std::string table_name)
+void TableApi::open_table(std::string table_name, bool one_line)
 {
     Table* t;
 
@@ -84,10 +85,11 @@ void TableApi::open_table(std::string table_name)
         }
     }
 
+    t->set_one_line(one_line);
     open_tables.push(t);
 }
 
-void TableApi::open_table()
+void TableApi::open_table(bool one_line)
 {
     // if no open tables, create a top-level table
     if (open_tables.size() == 0)
@@ -97,6 +99,7 @@ void TableApi::open_table()
     else
     {
         Table* t = open_tables.top()->open_table();
+        t->set_one_line(one_line);
         open_tables.push(t);
     }
 }
index 265f4a7c75dab8b586ff5926b16fc758f97be77d..2c874fff9fb88e4f199d20e61f6b61566178621f 100644 (file)
@@ -66,11 +66,20 @@ public:
  */
 
 // open a table at the topmost layer. i.e., the table will not be nested inside any other table.
-    void open_top_level_table(std::string name);
+    void open_top_level_table(const char* name, bool one_line = false)
+    { open_top_level_table(std::string(name), one_line); }
+
+    void open_top_level_table(std::string name, bool one_line = false);
+
 // open a nested named table --> 'name = {...}')
-    void open_table(std::string name);
+    void open_table(std::string name, bool one_line = false);
+
+    void open_table(const char* name, bool one_line = false)
+    { open_table(std::string(name), one_line); }
+
 // open a nested table that does not contain a name --> {...})
-    void open_table();
+    void open_table(bool one_line = false);
+
 // close the nested table.  go to previous table level
     void close_table();
 
index e1ed55ba0a86331a63665d496a99876467fb8771..a8de1ce55e9e02d5da7365809e6980b0990c52a4 100644 (file)
@@ -256,6 +256,18 @@ bool Converter::initialize()
     return true;
 }
 
+Binder& Converter::make_binder(Binder& b)
+{
+    binders.push_back(std::unique_ptr<Binder>(new Binder(b)));
+    return *binders.back();
+}
+
+Binder& Converter::make_binder()
+{
+    binders.push_back(std::unique_ptr<Binder>(new Binder(table_api)));
+    return *binders.back();
+}
+
 int Converter::convert(std::string input,
     std::string output_file,
     std::string rule_file,
@@ -266,6 +278,11 @@ int Converter::convert(std::string input,
 
     rc = parse_file(input);
 
+    // vector::clear()'s ordering isn't deterministic but this is
+    // keep in place for stable regressions
+    while ( binders.size() )
+        binders.pop_back();
+
     if (rule_file.empty())
         rule_file = output_file;
 
index 4ed65a8a6b4f01db80cdb9ec43fbb43f9af3bc47..489e5a72b9c5d589e5ec2b0554e1efe1c3d6e4bd 100644 (file)
 #ifndef UTILS_CONVERTER_H
 #define UTILS_CONVERTER_H
 
+#include <memory>
 #include <string>
 #include "conversion_defines.h"
 #include "data/dt_data.h"
 #include "data/dt_table_api.h"
 #include "data/dt_rule_api.h"
+#include "util_binder.h"
 
 class Converter
 {
@@ -56,6 +58,9 @@ public:
     inline static void set_empty_args(bool val)
     { empty_args = val; }
 
+    Binder& make_binder(Binder&);
+    Binder& make_binder();
+
     int convert(std::string input,
         std::string output,
         std::string rules,         // defaults to output_file
@@ -98,6 +103,7 @@ private:
     DataApi data_api;
     TableApi table_api;
     RuleApi rule_api;
+    std::vector<std::unique_ptr<Binder>> binders;
 
     // the current parsing state.
     ConversionState* state;
index 99eaa5cabc031ce2d153416c3f23e87e9f561f87..1973832e45d0bce60078c53bd25ba3622386f7af 100644 (file)
@@ -35,9 +35,9 @@ void Binder::add_to_configuration()
 {
     printed = true;
     table_api.open_top_level_table("binder");
-    table_api.open_table();
+    table_api.open_table(true);
 
-    table_api.open_table("when");
+    table_api.open_table("when", true);
 
     if (when_policy_id >= 0)
         table_api.add_option("policy_id", when_policy_id);
@@ -48,7 +48,7 @@ void Binder::add_to_configuration()
     if (!when_proto.empty())
         table_api.add_option("proto", when_proto);
 
-    if (!when_role.empty())
+    if (!when_role.empty() && when_role != "any")
         table_api.add_option("role", when_role);
 
     for (auto p : ports)
@@ -62,7 +62,7 @@ void Binder::add_to_configuration()
 
     table_api.close_table(); // "when"
 
-    table_api.open_table("use");
+    table_api.open_table("use", true);
 
     if (!use_policy_id.empty())
         table_api.add_option("policy_id", use_policy_id);
index 27eaf589bfa7c41f39d39f5d013e0727847afe8e..5bc8a175e0ecc236528c3db60bc8041f81a5faf7 100644 (file)
@@ -27,10 +27,13 @@ class TableApi;
 
 // The Binders destructor will add the Objects configuration to the
 //   table_api.
+class Converter;
 class Binder
 {
+    //Only use Converter to instantiate Binders through make_binder()
+    //This ensures only one binder tables is created per policy
+    friend class Converter;
 public:
-    Binder(TableApi&);
     ~Binder();
 
     //  By calling add_to_configuration(), you are adding this Binder Object
@@ -41,6 +44,9 @@ public:
     void print_binding(bool should_print)
     { printed = !should_print; }
 
+    bool will_print()
+    { return !printed; }
+
     void set_when_policy_id(int id);
     void set_when_service(std::string service);
     void set_when_role(std::string role);
@@ -58,6 +64,8 @@ public:
     void set_use_policy_id(std::string id);
 
 private:
+    Binder(TableApi&);
+
     TableApi& table_api;
     bool printed; // ensures that the binding is added once,
                   // by either the destructor or user
index ee02a343b0b81e47c6958c6a92ebc740ef328139..8ba75f2ca216c12de2988ddb272ff12dd2c9bb07 100644 (file)
@@ -638,11 +638,11 @@ bool DcerpcServer::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
 
-    Binder bind_tcp(table_api);
-    Binder bind_smb(table_api);
-    Binder bind_udp(table_api);
-    Binder bind_http_proxy(table_api);
-    Binder bind_http_server(table_api);
+    auto& bind_tcp = cv.make_binder();
+    auto& bind_smb = cv.make_binder();
+    auto& bind_udp = cv.make_binder();
+    auto& bind_http_proxy = cv.make_binder();
+    auto& bind_http_server = cv.make_binder();
 
     std::map<std::string, Binder*> bind;
 
index 5bfc910f2cb032482b02a85ad950141d47af9a93..56efe396dc4815b3617b9c7a3d3a4fd31c766972 100644 (file)
@@ -47,12 +47,12 @@ Dnp3::~Dnp3()
     if (converted_args)
         return;
 
-    Binder tcp_bind(table_api);
+    auto& tcp_bind = cv.make_binder();
     tcp_bind.set_when_proto("tcp");
     tcp_bind.add_when_port("20000");
     tcp_bind.set_use_type("dnp3");
 
-    Binder udp_bind(table_api);
+    auto& udp_bind = cv.make_binder();
     udp_bind.set_when_proto("udp");
     udp_bind.add_when_port("20000");
     udp_bind.set_use_type("dnp3");
@@ -66,8 +66,8 @@ bool Dnp3::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder tcp_bind(table_api);
-    Binder udp_bind(table_api);
+    auto& tcp_bind = cv.make_binder();
+    auto& udp_bind = cv.make_binder();
 
     converted_args = true;
 
index aed821af81dbb79be70ab9efed39d59e781b6b91..3ee456a644545f5c7f7615dfaa8070d5c7f6fd12 100644 (file)
@@ -43,7 +43,7 @@ bool Dns::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("dns");
index 0c00e2a5d01e875187365f2eb75bc76843647063..b4bc5242b947e8351826ab4bd6c2b691960d58c7 100644 (file)
@@ -91,7 +91,7 @@ bool Frag3Engine::convert(std::istringstream& data_stream)
             }
             else
             {
-                Binder b(table_api);
+                auto& b = cv.make_binder();
                 b.set_when_proto("ip");
                 b.add_when_net(ip_list);
                 b.set_use_type("stream_ip");
index a7f53dcd83d9dec5d92b85966d1478194b0a348d..5222f6399fa612c264af209d285e0bc680ff8459 100644 (file)
@@ -177,7 +177,7 @@ bool FtpServer::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bind.set_use_type("ftp_server");
     bind.set_when_proto("tcp");
 
@@ -361,7 +361,7 @@ bool FtpClient::convert(std::istringstream& data_stream)
 {
     std::string keyword;
     bool retval = true;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bind.set_use_type("ftp_client");
     bind.set_when_proto("tcp");
 
@@ -494,7 +494,7 @@ bool Telnet::convert(std::istringstream& data_stream)
     std::string keyword;
     bool ports_set = false;
     bool retval = true;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("telnet");
index 4d59196692a31fb81b3b548db45a2c40033e450f..763b08a04c2190f5c8edc6a0120212f93ab48edf 100644 (file)
@@ -48,7 +48,7 @@ Gtp::~Gtp()
     if (converted_args)
         return;
 
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bind.set_when_proto("udp");
     bind.add_when_port("2123");
     bind.add_when_port("3386");
@@ -63,7 +63,7 @@ bool Gtp::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("udp");
     bind.set_use_type("gtp_inspect");
index f8456f094e09ffc406cd54a52f66ab72ed016ecc..92a63f296e1906c70401d3feaf815f31a89d24e7 100644 (file)
@@ -64,7 +64,7 @@ bool HttpInspectServer::convert(std::istringstream& data_stream)
     bool ports_set = false;
     bool simplify = false;
     bool slash_dir_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("http_inspect");
index f3383bdc1789a6f88c7aa0abb388e700b0c1e20a..7b829f4c0e8b5d53d450e1eab0ac08b00cc46bde 100644 (file)
@@ -43,7 +43,7 @@ bool Imap::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("imap");
index 7cfec9d059203612ae776854deacb5bd3df243f1..e9f31b0af50f697a283cb25944c5f8233bb6f1f8 100644 (file)
@@ -47,7 +47,7 @@ Modbus::~Modbus()
     if (converted_args)
         return;
 
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bind.set_when_proto("tcp");
     bind.add_when_port("502");
     bind.set_use_type("modbus");
@@ -61,7 +61,7 @@ bool Modbus::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("modbus");
index 8d1ff7cc4686b6e02644cd8c78756f3d38b2cb29..42011ea37d2cd82f850a83f64207c69a27dabfd8 100644 (file)
@@ -43,7 +43,7 @@ bool Pop::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("pop");
index 7bb5e06659a5ae35be93994d0a2ed99b967ee806..c44cc0a1aace04d11628ed548013b24c07f6eaff 100644 (file)
@@ -50,7 +50,7 @@ RpcDecode::~RpcDecode()
 {
     if (!converted_args)
     {
-        Binder bind(table_api);
+        auto& bind = cv.make_binder();
         bind.set_when_proto("tcp");
         bind.add_when_port("111");
         bind.add_when_port("32271");
@@ -68,7 +68,7 @@ bool RpcDecode::convert(std::istringstream& data_stream)
     std::string keyword;
 
     // adding the binder entry
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
     bind.set_when_proto("tcp");
     bind.set_use_type("rpc_decode");
 
index fbf3619d4017bd54a7b9b3ec6f361868d5ad950d..a0fa754f0c9b6a7dace48268c1b351087d6b5989 100644 (file)
@@ -43,7 +43,7 @@ bool Sip::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("udp");
     bind.set_use_type("sip");
index 3eb730a6e0b1db5ef3a879c3d2f740f75c244ae2..0250a0b33923cf9135f34480a1638da503e5624e 100644 (file)
@@ -114,7 +114,7 @@ bool Smtp::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("smtp");
index a3db49d4aa1eb7be2061c89a7af42e3aeba4d396..a440c1b75b9a197679246b0a217acfa517bba261 100644 (file)
@@ -43,7 +43,7 @@ bool Ssh::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("ssh");
index e3cf834bfacac4bfe2b272beadc326d4b9292b1c..49e6076256318c4d41260910ffef7ef4362c11d0 100644 (file)
@@ -42,7 +42,7 @@ bool Ssl::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
     bool ports_set = false;
-    Binder bind(table_api);
+    auto& bind = cv.make_binder();
 
     bind.set_when_proto("tcp");
     bind.set_use_type("ssl");
index ed30ca12914ed36bc6b8769f320995ec5bbb20ec..c54158e5fbd329c5fdb7f922fa07efd600519733 100644 (file)
@@ -260,9 +260,9 @@ bool StreamTcp::convert(std::istringstream& data_stream)
     std::string keyword;
     bool retval = true;
 
-    Binder client(table_api);
-    Binder server(table_api);
-    Binder any(table_api);
+    auto& client = cv.make_binder();
+    auto& server = cv.make_binder();
+    auto& any = cv.make_binder();
 
     // by default, only print one binding
     client.print_binding(true);
@@ -493,20 +493,14 @@ bool StreamTcp::convert(std::istringstream& data_stream)
     //  Add the port bindings separately from the protocol bindings since 
     //  in 2.9.x they are OR'd not AND'd. Clear the ports so they're not 
     //  included with the protocol bindings.
-    {
-        Binder b = client;      //  Binding is added during destructor.
-        client.clear_ports();
-    }
+    cv.make_binder(client);
+    client.clear_ports();
 
-    {
-        Binder b = server;
-        server.clear_ports();
-    }
+    cv.make_binder(server);
+    server.clear_ports();
 
-    {
-        Binder b = any;
-        any.clear_ports();
-    }
+    cv.make_binder(any);
+    any.clear_ports();
 
     if (!protos_set)
     {
@@ -519,7 +513,7 @@ bool StreamTcp::convert(std::istringstream& data_stream)
 
         for (const std::string& s : default_protos)
         {
-            Binder b = *bind_default; // Binding is added during destructor.
+            auto& b = cv.make_binder(*bind_default);
             b.set_when_service(s);
         }
     }
@@ -528,7 +522,7 @@ bool StreamTcp::convert(std::istringstream& data_stream)
     {
         for (std::string s : client_protocols)
         {
-            Binder b = client;
+            auto& b = cv.make_binder(client);
             b.set_when_service(s);
         }
     }
@@ -537,7 +531,7 @@ bool StreamTcp::convert(std::istringstream& data_stream)
     {
         for (std::string s : server_protocols)
         {
-            Binder b = server;
+            auto& b = cv.make_binder(server);
             b.set_when_service(s);
         }
     }
@@ -546,7 +540,7 @@ bool StreamTcp::convert(std::istringstream& data_stream)
     {
         for (std::string s : any_protocols)
         {
-            Binder b = any;
+            auto& b = cv.make_binder(any);
             b.set_when_service(s);
         }
     }