diff --git a/CMakeLists.txt b/CMakeLists.txt index c2d4161..ca98de8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,8 @@ file(GLOB PROTOCOL_JE_SOURCES "./protocol_je/*.c") file(GLOB PROTOCOL_JE_HEADERS "./protocol_je/*.h") file(GLOB PROTOCOL_BE_SOURCES "./protocol_be/*.c") file(GLOB PROTOCOL_BE_HEADERS "./protocol_be/*.h") -file(GLOB PROTOCOL_SOURCES "./protocols/*.c") -file(GLOB PROTOCOL_HEADERS "./protocols/*.h") +file(GLOB_RECURSE PROTOCOL_SOURCES "./protocol/*.c") +file(GLOB_RECURSE PROTOCOL_HEADERS "./protocol/*.h") file(GLOB UTILS_SOURCES "./utils/*.c") file(GLOB UTILS_HEADERS "./utils/*.h") file(GLOB LIBRARY_CJSON_SOURCES "./cJSON/cJSON*.c") diff --git a/mc_dissector.c b/mc_dissector.c index 8ed189d..b48e594 100644 --- a/mc_dissector.c +++ b/mc_dissector.c @@ -4,7 +4,7 @@ #include #include "mc_dissector.h" -#include "protocol_data.h" +#include "protocol/protocol_data.h" #include "protocol_je/je_dissect.h" #include "protocol_be/be_dissect.h" @@ -17,18 +17,22 @@ WS_DLL_PUBLIC _U_ void plugin_register(); int proto_mcje = -1; int proto_mcbe = -1; +void proto_register() { + proto_register_mcje(); + proto_register_mcbe(); +} + +void proto_reg_handoff() { + proto_reg_handoff_mcje(); + proto_reg_handoff_mcbe(); +} + _U_ void plugin_register() { - if (proto_mcje == -1) { - static proto_plugin plugMCJE; - plugMCJE.register_protoinfo = proto_register_mcje; - plugMCJE.register_handoff = proto_reg_handoff_mcje; - proto_register_plugin(&plugMCJE); - } - if (proto_mcbe == -1) { - static proto_plugin plugMCBE; - plugMCBE.register_protoinfo = proto_register_mcbe; - plugMCBE.register_handoff = proto_reg_handoff_mcbe; - proto_register_plugin(&plugMCBE); + static proto_plugin plugin; + if (proto_mcje == -1 || proto_mcbe == -1) { + plugin.register_protoinfo = proto_register; + plugin.register_handoff = proto_reg_handoff; + proto_register_plugin(&plugin); } init_schema_data(); } \ No newline at end of file diff --git a/mc_dissector.h b/mc_dissector.h index 42961d8..451040b 100644 --- a/mc_dissector.h +++ b/mc_dissector.h @@ -16,6 +16,11 @@ #define MCJE_FILTER "mcje" #define MCBE_FILTER "mcbe" +#define DATA_FILE_PATH "mc_dissector" +#define DATA_FILE_PATH_JE_DATA "mc_dissector/je" +#define DATA_FILE_PATH_BE_DATA "mc_dissector/be" +#define DATA_FILE_PATH_PROTOCOL_VERSIONS "mc_dissector/protocol_versions.json" + #define DEFINE_HF(name, desc, key, type, dis) {&name, {desc, key, FT_##type, BASE_##dis, NULL, 0x0, NULL, HFILL}}, #if defined(DEBUG) diff --git a/protocol_data.c b/protocol/protocol_data.c similarity index 100% rename from protocol_data.c rename to protocol/protocol_data.c diff --git a/protocol_data.h b/protocol/protocol_data.h similarity index 97% rename from protocol_data.h rename to protocol/protocol_data.h index 665f680..eeebb6f 100644 --- a/protocol_data.h +++ b/protocol/protocol_data.h @@ -7,7 +7,7 @@ #include #include -#include "protocols/protocols.h" +#include "protocol/schema/protocols.h" #define INVALID_DATA (-1) #define is_invalid(x) ((x) == INVALID_DATA) diff --git a/protocols/protocol_functions.c b/protocol/schema/protocol_functions.c similarity index 100% rename from protocols/protocol_functions.c rename to protocol/schema/protocol_functions.c diff --git a/protocols/protocol_functions.h b/protocol/schema/protocol_functions.h similarity index 100% rename from protocols/protocol_functions.h rename to protocol/schema/protocol_functions.h diff --git a/protocols/protocol_schema.c b/protocol/schema/protocol_schema.c similarity index 99% rename from protocols/protocol_schema.c rename to protocol/schema/protocol_schema.c index 7ae422c..84454ea 100644 --- a/protocols/protocol_schema.c +++ b/protocol/schema/protocol_schema.c @@ -4,7 +4,7 @@ #include #include "protocol_schema.h" -#include "protocol_data.h" +#include "protocol/protocol_data.h" #include "protocol_je/je_dissect.h" #include "protocol_be/be_dissect.h" #include "protocol_functions.h" diff --git a/protocols/protocol_schema.h b/protocol/schema/protocol_schema.h similarity index 100% rename from protocols/protocol_schema.h rename to protocol/schema/protocol_schema.h diff --git a/protocols/protocols.c b/protocol/schema/protocols.c similarity index 100% rename from protocols/protocols.c rename to protocol/schema/protocols.c diff --git a/protocols/protocols.h b/protocol/schema/protocols.h similarity index 100% rename from protocols/protocols.h rename to protocol/schema/protocols.h diff --git a/protocol_be/be_dissect.c b/protocol_be/be_dissect.c index 804e565..2c33656 100644 --- a/protocol_be/be_dissect.c +++ b/protocol_be/be_dissect.c @@ -3,31 +3,12 @@ // #include "be_dissect.h" -#include "../protocol_data.h" +#include "protocol/protocol_data.h" #include "../mc_dissector.h" dissector_handle_t mcbe_boot_handle, mcbe_handle, ignore_be_handle; -int hf_unknown_int_be = -1; -int hf_unknown_uint_be = -1; -int hf_unknown_int64_be = -1; -int hf_unknown_uint64_be = -1; -int hf_unknown_float_be = -1; -int hf_unknown_double_be = -1; -int hf_unknown_bytes_be = -1; -int hf_unknown_string_be = -1; -int hf_unknown_boolean_be = -1; -int hf_unknown_uuid_be = -1; -int hf_array_length_be = -1; -int hf_text_be = -1; - int ett_sub_be = -1; -wmem_map_t *name_hf_map_be = NULL; -wmem_map_t *complex_name_map_be = NULL; -wmem_map_t *complex_hf_map_be = NULL; -wmem_map_t *unknown_hf_map_be = NULL; -wmem_map_t *bitmask_hf_map_be = NULL; -wmem_map_t *component_map_be = NULL; void proto_register_mcbe() { proto_mcbe = proto_register_protocol(MCBE_NAME, MCBE_SHORT_NAME, MCBE_FILTER); diff --git a/protocol_je/je_dissect.h b/protocol_je/je_dissect.h index ab22fc7..7f4596c 100644 --- a/protocol_je/je_dissect.h +++ b/protocol_je/je_dissect.h @@ -6,7 +6,7 @@ #define MC_DISSECTOR_JE_DISSECT_H #include -#include "protocol_data.h" +#include "protocol/protocol_data.h" extern dissector_handle_t mcje_handle; extern gchar *pref_ignore_packets_je; diff --git a/protocol_je/je_protocol.h b/protocol_je/je_protocol.h index 0feade8..035a4fc 100644 --- a/protocol_je/je_protocol.h +++ b/protocol_je/je_protocol.h @@ -6,7 +6,7 @@ #define MC_DISSECTOR_JE_PROTOCOL_H #include -#include "protocol_data.h" +#include "protocol/protocol_data.h" #define PACKET_ID_HANDSHAKE 0x00 #define PACKET_ID_LEGACY_SERVER_LIST_PING 0xFE