0
0
mirror of https://github.com/cjdelisle/cjdns synced 2025-10-06 00:32:50 +02:00
Files
cjdns/subnode/MsgCore.h
2024-09-28 14:43:16 +00:00

81 lines
2.5 KiB
C

/* vim: set expandtab ts=4 sw=4: */
/*
* You may redistribute this program and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MsgCore_H
#define MsgCore_H
#include "interface/Iface.h"
#include "crypto/random/Random.h"
#include "util/events/EventBase.h"
#include "memory/Allocator.h"
#include "dht/Address.h"
#include "switch/EncodingScheme.h"
#include "util/log/Log.h"
#include "util/Linker.h"
Linker_require("subnode/MsgCore.c")
struct MsgCore_Handler;
struct MsgCore;
typedef struct RTypes_Error_t* (* MsgCore_HandlerCb)(Dict* msg,
struct Address* src,
struct Allocator* tmpAlloc,
struct MsgCore_Handler* handler);
struct MsgCore_Handler
{
MsgCore_HandlerCb cb;
void* userData;
};
void MsgCore_sendResponse(struct MsgCore* core,
Dict* msgDict,
struct Address* target,
struct Allocator* alloc);
struct MsgCore_Promise;
typedef void (* MsgCore_PromiseCb)(Dict* msg, struct Address* src, struct MsgCore_Promise* promise);
struct MsgCore_Promise
{
Dict* msg;
struct Address* target;
struct Allocator* alloc;
void* userData;
MsgCore_PromiseCb cb;
uint32_t lag;
};
struct MsgCore_Promise* MsgCore_createQuery(struct MsgCore* core,
uint32_t timeoutMilliseconds,
struct Allocator* alloc);
struct MsgCore_Handler* MsgCore_onQuery(struct MsgCore* core,
char* queryType,
struct Allocator* alloc);
struct MsgCore
{
struct Iface interRouterIf;
};
struct MsgCore* MsgCore_new(EventBase_t* base,
struct Random* rand,
struct Allocator* allocator,
struct Log* log,
struct EncodingScheme* scheme);
#endif