Skip to content

Commit

Permalink
refactor directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickid2018 committed Jun 24, 2024
1 parent 5eb380a commit 52b49fc
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 38 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 16 additions & 12 deletions mc_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ws_version.h>

#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"

Expand All @@ -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();
}
5 changes: 5 additions & 0 deletions mc_dissector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion protocol_data.h → protocol/protocol_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <epan/proto.h>
#include <gcrypt.h>
#include "protocols/protocols.h"
#include "protocol/schema/protocols.h"

#define INVALID_DATA (-1)
#define is_invalid(x) ((x) == INVALID_DATA)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <stdlib.h>
#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"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 1 addition & 20 deletions protocol_be/be_dissect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion protocol_je/je_dissect.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define MC_DISSECTOR_JE_DISSECT_H

#include <epan/packet.h>
#include "protocol_data.h"
#include "protocol/protocol_data.h"

extern dissector_handle_t mcje_handle;
extern gchar *pref_ignore_packets_je;
Expand Down
2 changes: 1 addition & 1 deletion protocol_je/je_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define MC_DISSECTOR_JE_PROTOCOL_H

#include <epan/proto.h>
#include "protocol_data.h"
#include "protocol/protocol_data.h"

#define PACKET_ID_HANDSHAKE 0x00
#define PACKET_ID_LEGACY_SERVER_LIST_PING 0xFE
Expand Down

0 comments on commit 52b49fc

Please sign in to comment.