diff --git a/src/SerialTypes.h b/src/SerialTypes.h index a18c9bcc65..52ef1651de 100644 --- a/src/SerialTypes.h +++ b/src/SerialTypes.h @@ -179,6 +179,7 @@ SERIAL_TYPE(SUBNET_TYPE, 8) SERIAL_TYPE(FILE_TYPE, 9) SERIAL_TYPE(ENUM_TYPE, 10) SERIAL_TYPE(VECTOR_TYPE, 11) +SERIAL_TYPE(OPAQUE_TYPE, 12) SERIAL_CONST2(ATTRIBUTES) SERIAL_CONST2(EVENT_HANDLER) diff --git a/src/Type.cc b/src/Type.cc index 34ad207842..8b4cfca88c 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1278,26 +1278,26 @@ void OpaqueType::Describe(ODesc* d) const d->Add(name.c_str()); } -// TODO: Serialization semantics not yet defined. -// -// IMPLEMENT_SERIAL(OpaqueType, SER_OPAQUE_TYPE); -// -// bool OpaqueType::DoSerialize(SerialInfo* info) const -// { -// DO_SERIALIZE(SER_OPAQUE_TYPE, BroType); -// return SERIALIZE(name); -// } -// -// bool OpaqueType::DoUnserialize(UnserialInfo* info) -// { -// DO_UNSERIALIZE(BroType); -// -// char const* n; -// if ( ! UNSERIALIZE_STR(&n, 0) ); -// return false; -// name = n; -// return true; -// } +IMPLEMENT_SERIAL(OpaqueType, SER_OPAQUE_TYPE); + +bool OpaqueType::DoSerialize(SerialInfo* info) const + { + DO_SERIALIZE(SER_OPAQUE_TYPE, BroType); + + // For now we only serialize the name of the type but will add type-specific + // serialization code here when necessary. + return SERIALIZE(name); + } + +bool OpaqueType::DoUnserialize(UnserialInfo* info) + { + DO_UNSERIALIZE(BroType); + char const* n; + if ( ! UNSERIALIZE_STR(&n, 0) ); + return false; + name = n; + return true; + } EnumType::EnumType(const string& arg_name) : BroType(TYPE_ENUM) diff --git a/src/Type.h b/src/Type.h index 21b4bc2023..0f356dca31 100644 --- a/src/Type.h +++ b/src/Type.h @@ -512,10 +512,9 @@ public: protected: OpaqueType() { } - // TODO: Serialization semantics not yet defined. - //DECLARE_SERIAL(OpaqueType) + DECLARE_SERIAL(OpaqueType) - const string name; + string name; }; class EnumType : public BroType {