Check the PIN when pairing

This commit is contained in:
Guillaume Meunier
2024-12-01 17:25:28 +01:00
parent 6e6cc3cf68
commit fe10178add
8 changed files with 161 additions and 8 deletions
+50 -6
View File
@@ -22,16 +22,17 @@
#include <cmath>
#include <epan/ftypes/ftypes.h>
#include <epan/packet.h>
#include <boost/pfr.hpp>
#include <epan/tvbuff.h>
#include <magic_enum.hpp>
#include "wivrn_packets.h"
#include <epan/proto.h>
#include <epan/tvbuff.h>
#include <epan/unit_strings.h>
#include <ws_version.h>
#include <boost/pfr.hpp>
#include <magic_enum.hpp>
#include "smp.h"
#include "wivrn_packets.h"
#if WIRESHARK_VERSION_MAJOR > 4 || (WIRESHARK_VERSION_MAJOR == 4 && WIRESHARK_VERSION_MINOR >= 4)
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
{
@@ -740,6 +741,49 @@ struct tree_traits<abbrev, data_holder>
}
};
template <details::fixed_string abbrev>
struct tree_traits<abbrev, crypto::bignum>
{
static inline int field_handle = -1;
static void info()
{
hf_register_info hf = {
.p_id = &field_handle,
.hfinfo = {
.name = strdup(details::name_from_abbrev(abbrev.value).c_str()),
.abbrev = abbrev.value,
.type = FT_BYTES,
.display = BASE_NONE,
.strings = nullptr,
.bitmask = 0,
.blurb = "",
}};
HFILL_INIT(hf);
fields.push_back(hf);
}
static void dissect(proto_tree * tree, tvbuff_t * tvb, int & start)
{
size_t string_size = get_uint16(tvb, start, ENC_LITTLE_ENDIAN);
start += sizeof(uint16_t);
proto_tree_add_item(tree, field_handle, tvb, start, string_size, ENC_STRING);
start += string_size;
}
static size_t size(tvbuff_t * tvb, int & start)
{
size_t string_size = get_uint16(tvb, start, ENC_LITTLE_ENDIAN);
start += sizeof(uint16_t);
start += string_size;
return sizeof(uint16_t) + string_size;
}
};
int dissect_wivrn(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, void * data _U_, bool tcp)
{
col_set_str(pinfo->cinfo, COL_PROTOCOL, "WiVRn");