Merge remote-tracking branch 'origin/master' into topic/bernhard/sqlite

Conflicts:
	src/threading/AsciiFormatter.cc
This commit is contained in:
Bernhard Amann 2013-03-11 11:47:10 -07:00
commit 8cb91de93a
203 changed files with 3278 additions and 1284 deletions

View file

@ -372,7 +372,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval)
streams[idx]->id = id->Ref()->AsEnumVal();
streams[idx]->enabled = true;
streams[idx]->name = id->Type()->AsEnumType()->Lookup(idx);
streams[idx]->event = event ? event_registry->Lookup(event->GetID()->Name()) : 0;
streams[idx]->event = event ? event_registry->Lookup(event->Name()) : 0;
streams[idx]->columns = columns->Ref()->AsRecordType();
DBG_LOG(DBG_LOGGING, "Created new logging stream '%s', raising event %s",

View file

@ -52,7 +52,7 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
desc.EnableEscaping();
desc.AddEscapeSequence(separator);
io = new AsciiInputOutput(this, AsciiInputOutput::SeparatorInfo(set_separator, unset_field, empty_field));
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo(set_separator, unset_field, empty_field));
}
Ascii::~Ascii()
@ -63,7 +63,7 @@ Ascii::~Ascii()
abort();
}
delete io;
delete ascii;
}
bool Ascii::WriteHeaderField(const string& key, const string& val)
@ -170,7 +170,7 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const Field* const *
&& WriteHeaderField("types", types)) )
goto write_error;
}
return true;
write_error:
@ -212,7 +212,7 @@ bool Ascii::DoWrite(int num_fields, const Field* const * fields,
if ( i > 0 )
desc.AddRaw(separator);
if ( ! io->ValToODesc(&desc, vals[i], fields[i]) )
if ( ! ascii->Describe(&desc, vals[i], fields[i]->name) )
return false;
}

View file

@ -6,7 +6,7 @@
#define LOGGING_WRITER_ASCII_H
#include "../WriterBackend.h"
#include "../../threading/AsciiInputOutput.h"
#include "threading/AsciiFormatter.h"
namespace logging { namespace writer {
@ -53,7 +53,7 @@ private:
string unset_field;
string meta_prefix;
AsciiInputOutput* io;
AsciiFormatter* ascii;
};
}

View file

@ -46,10 +46,10 @@ std::string DataSeries::LogValueToString(threading::Value *val)
}
case TYPE_SUBNET:
return AsciiInputOutput::Render(val->val.subnet_val);
return ascii->Render(val->val.subnet_val);
case TYPE_ADDR:
return AsciiInputOutput::Render(val->val.addr_val);
return ascii->Render(val->val.addr_val);
// Note: These two cases are relatively special. We need to convert
// these values into their integer equivalents to maximize precision.
@ -69,10 +69,10 @@ std::string DataSeries::LogValueToString(threading::Value *val)
return ostr.str();
}
else
return AsciiInputOutput::Render(val->val.double_val);
return ascii->Render(val->val.double_val);
case TYPE_DOUBLE:
return AsciiInputOutput::Render(val->val.double_val);
return ascii->Render(val->val.double_val);
case TYPE_ENUM:
case TYPE_STRING:
@ -167,7 +167,7 @@ string DataSeries::BuildDSSchemaFromFieldTypes(const vector<SchemaValue>& vals,
string xmlschema = "<ExtentType name=\""
+ sTitle
+ "\" version=\"1.0\" namespace=\"bro-ids.org\">\n";
+ "\" version=\"1.0\" namespace=\"bro.org\">\n";
for( size_t i = 0; i < vals.size(); ++i )
{
@ -231,11 +231,14 @@ DataSeries::DataSeries(WriterFrontend* frontend) : WriterBackend(frontend)
ds_num_threads = BifConst::LogDataSeries::num_threads;
ds_use_integer_for_time = BifConst::LogDataSeries::use_integer_for_time;
ds_set_separator = ",";
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
}
DataSeries::~DataSeries()
{
}
{
delete ascii;
}
bool DataSeries::OpenLog(string path)
{

View file

@ -12,6 +12,7 @@
#include <DataSeries/GeneralField.hpp>
#include "../WriterBackend.h"
#include "threading/AsciiFormatter.h"
namespace logging { namespace writer {
@ -116,6 +117,8 @@ private:
bool ds_dump_schema;
bool ds_use_integer_for_time;
string ds_set_separator;
AsciiFormatter* ascii;
};
}

View file

@ -16,7 +16,7 @@
#include "BroString.h"
#include "NetVar.h"
#include "threading/SerialTypes.h"
#include "../../threading/AsciiInputOutput.h"
#include "threading/AsciiFormatter.h"
#include <curl/curl.h>
#include <curl/easy.h>
@ -52,11 +52,14 @@ ElasticSearch::ElasticSearch(WriterFrontend* frontend) : WriterBackend(frontend)
transfer_timeout = static_cast<long>(BifConst::LogElasticSearch::transfer_timeout);
curl_handle = HTTPSetup();
ascii = new AsciiFormatter(this, AsciiFormatter::SeparatorInfo());
}
ElasticSearch::~ElasticSearch()
{
delete [] cluster_name;
delete ascii;
}
bool ElasticSearch::DoInit(const WriterInfo& info, int num_fields, const threading::Field* const* fields)
@ -125,13 +128,13 @@ bool ElasticSearch::AddValueToBuffer(ODesc* b, Value* val)
case TYPE_SUBNET:
b->AddRaw("\"", 1);
b->Add(AsciiInputOutput::Render(val->val.subnet_val));
b->Add(ascii->Render(val->val.subnet_val));
b->AddRaw("\"", 1);
break;
case TYPE_ADDR:
b->AddRaw("\"", 1);
b->Add(AsciiInputOutput::Render(val->val.addr_val));
b->Add(ascii->Render(val->val.addr_val));
b->AddRaw("\"", 1);
break;
@ -403,7 +406,7 @@ bool ElasticSearch::HTTPSend(CURL *handle)
case CURLE_OK:
{
uint http_code = 0;
long http_code = 0;
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &http_code);
if ( http_code == 200 )
// Hopefully everything goes through here.

View file

@ -72,6 +72,8 @@ private:
bool failing;
uint64 batch_size;
AsciiFormatter* ascii;
};
}