lokinet/include/llarp/msg_handler.h

57 lines
1.3 KiB
C
Raw Normal View History

2018-01-27 01:18:10 +00:00
#ifndef LLARP_MSG_HANDLER_H_
#define LLARP_MSG_HANDLER_H_
#include <llarp/buffer.h>
2018-02-01 17:06:49 +00:00
#include <llarp/dht.h>
2018-01-27 01:18:10 +00:00
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
2018-02-01 17:07:01 +00:00
/* foward declare */
struct llarp_msg_muxer;
struct llarp_link_session;
struct llarp_router;
2018-02-01 17:06:49 +00:00
2018-02-01 17:07:01 +00:00
struct llarp_frame_handler {
2018-02-01 17:06:49 +00:00
/**
* participating paths
*/
2018-02-01 17:07:01 +00:00
struct llarp_path_context *paths;
2018-02-01 17:06:49 +00:00
/**
* parent muxer
*/
2018-02-01 17:07:01 +00:00
struct llarp_msg_muxer *parent;
2018-02-01 17:06:49 +00:00
/**
handle fully formed frame from link session
*/
2018-01-29 14:27:24 +00:00
bool (*process)(struct llarp_frame_handler *, struct llarp_link_session *,
llarp_buffer_t);
};
2018-01-27 01:18:10 +00:00
2018-01-29 14:27:24 +00:00
struct llarp_msg_handler {
struct llarp_path_context *paths;
2018-02-01 17:06:49 +00:00
struct llarp_dht_context *dht;
bool (*process)(struct llarp_msg_handler *, llarp_buffer_t);
2018-01-29 14:27:24 +00:00
};
2018-01-27 01:18:10 +00:00
2018-01-29 14:27:24 +00:00
struct llarp_msg_muxer {
/** get a message handler for a link level message given msg.a */
2018-02-01 17:07:01 +00:00
struct llarp_frame_handler *(*link_handler_for)(struct llarp_router *,
const char);
2018-01-29 14:27:24 +00:00
/** get a message handler for a routing layer message given msg.A */
2018-02-01 17:07:01 +00:00
struct llarp_msg_handler *(*routing_handler_for)(struct llarp_router *,
const char);
2018-01-29 14:27:24 +00:00
};
/** fill function pointers with default values */
2018-02-01 17:06:49 +00:00
void llarp_msg_muxer_init(struct llarp_msg_muxer *muxer);
2018-01-27 01:18:10 +00:00
#ifdef __cplusplus
}
#endif
#endif