mirror of
https://github.com/Green-Sky/tox_ngc_ext.git
synced 2025-07-05 10:06:45 +02:00
Compare commits
3 Commits
c947915389
...
master
Author | SHA1 | Date | |
---|---|---|---|
026bf080c3 | |||
2b186a3071 | |||
fc13d93d42 |
@ -1,8 +1,13 @@
|
|||||||
#include "./ngc_ext.hpp"
|
#include "./ngc_ext.hpp"
|
||||||
|
|
||||||
//#include <cstdint>
|
//#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#ifndef EXTRA_LOGGING
|
||||||
|
#define EXTRA_LOGGING 0
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace NGC_EXT;
|
using namespace NGC_EXT;
|
||||||
|
|
||||||
// global scope
|
// global scope
|
||||||
@ -42,7 +47,9 @@ void NGC_EXT_handle_group_custom_packet(
|
|||||||
PacketType pkg_type = static_cast<PacketType>(*(data + curser));
|
PacketType pkg_type = static_cast<PacketType>(*(data + curser));
|
||||||
curser++;
|
curser++;
|
||||||
|
|
||||||
|
#if defined(EXTRA_LOGGING) && EXTRA_LOGGING == 1
|
||||||
fprintf(stderr, "EX: custom_packet [%s] %lu\n", pkgid2str(pkg_type), length);
|
fprintf(stderr, "EX: custom_packet [%s] %lu\n", pkgid2str(pkg_type), length);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pkg_type == INVALID) {
|
if (pkg_type == INVALID) {
|
||||||
fprintf(stderr, "(invalid)\n");
|
fprintf(stderr, "(invalid)\n");
|
||||||
@ -52,7 +59,9 @@ void NGC_EXT_handle_group_custom_packet(
|
|||||||
auto handle_fn = ngc_ext_ctx->callbacks[pkg_type];
|
auto handle_fn = ngc_ext_ctx->callbacks[pkg_type];
|
||||||
auto handle_ud = ngc_ext_ctx->user_data[pkg_type]; // can be null
|
auto handle_ud = ngc_ext_ctx->user_data[pkg_type]; // can be null
|
||||||
if (handle_fn == nullptr) {
|
if (handle_fn == nullptr) {
|
||||||
|
#if defined(EXTRA_LOGGING) && EXTRA_LOGGING == 1
|
||||||
fprintf(stderr, "EX: !!! no handler for packet\n");
|
fprintf(stderr, "EX: !!! no handler for packet\n");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ struct NGC_EXT_CTX {
|
|||||||
|
|
||||||
namespace NGC_EXT {
|
namespace NGC_EXT {
|
||||||
|
|
||||||
|
// start with first bit set, to avoid collisions (this will have to change, since those will be standadized?)
|
||||||
enum PacketType : uint8_t {
|
enum PacketType : uint8_t {
|
||||||
// TODO: why?
|
// TODO: why?
|
||||||
INVALID = 0u,
|
INVALID = 0u,
|
||||||
@ -35,7 +36,7 @@ enum PacketType : uint8_t {
|
|||||||
// request last (few) message_ids for a peer
|
// request last (few) message_ids for a peer
|
||||||
// - peer_key bytes (peer key we want to know ids for)
|
// - peer_key bytes (peer key we want to know ids for)
|
||||||
// - 1 byte (uint8_t count ids, atleast 1)
|
// - 1 byte (uint8_t count ids, atleast 1)
|
||||||
HS1_REQUEST_LAST_IDS = 1u,
|
HS1_REQUEST_LAST_IDS = 0x80 | 1u,
|
||||||
|
|
||||||
// respond to a request with 0 or more message ids, sorted by newest first
|
// respond to a request with 0 or more message ids, sorted by newest first
|
||||||
// - peer_key bytes (the msg_ids are from)
|
// - peer_key bytes (the msg_ids are from)
|
||||||
@ -48,7 +49,7 @@ enum PacketType : uint8_t {
|
|||||||
// request the other side to initiate a FT
|
// request the other side to initiate a FT
|
||||||
// - 1 byte (file_kind)
|
// - 1 byte (file_kind)
|
||||||
// - X bytes (file_kind dependent id, differnt sizes)
|
// - X bytes (file_kind dependent id, differnt sizes)
|
||||||
FT1_REQUEST = 8u,
|
FT1_REQUEST = 0x80 | 8u,
|
||||||
|
|
||||||
// TODO: request result negative, speed up not found
|
// TODO: request result negative, speed up not found
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user