2018-01-31 13:23:35 +10:30
|
|
|
#ifndef LIGHTNING_COMMON_READ_PEER_MSG_H
|
|
|
|
#define LIGHTNING_COMMON_READ_PEER_MSG_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
|
|
|
|
|
|
|
struct crypto_state;
|
|
|
|
struct channel_id;
|
2019-06-04 03:41:25 +09:30
|
|
|
struct per_peer_state;
|
2018-01-31 13:23:35 +10:30
|
|
|
|
2018-08-02 16:19:55 +09:30
|
|
|
/**
|
2023-09-12 13:53:14 +09:30
|
|
|
* is_peer_error - if it's an error, describe it.
|
|
|
|
* @ctx: context to allocate return from.
|
|
|
|
* @msg: the peer message.
|
|
|
|
*
|
|
|
|
* If this returns non-NULL, it's usually passed to
|
|
|
|
* peer_failed_received_errmsg().
|
|
|
|
*/
|
|
|
|
const char *is_peer_error(const tal_t *ctx, const u8 *msg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* is_peer_warning - if it's a warning, describe it.
|
2018-08-02 16:19:55 +09:30
|
|
|
* @ctx: context to allocate return from.
|
|
|
|
* @msg: the peer message.
|
|
|
|
*
|
2023-09-12 13:53:14 +09:30
|
|
|
* If this returns non-NULL, it's usually logged.
|
2018-08-02 16:19:55 +09:30
|
|
|
*/
|
2023-09-12 13:53:14 +09:30
|
|
|
const char *is_peer_warning(const tal_t *ctx, const u8 *msg);
|
2018-08-02 16:19:55 +09:30
|
|
|
|
|
|
|
/**
|
2023-09-12 13:53:14 +09:30
|
|
|
* handle_peer_error_or_warning - simple handler for errors / warnings
|
2019-06-04 03:41:25 +09:30
|
|
|
* @pps: per-peer state.
|
2019-05-09 09:28:54 +09:30
|
|
|
* @channel_id: the channel id of the current channel.
|
2018-08-02 16:19:55 +09:30
|
|
|
* @msg: the peer message (only taken if returns true).
|
|
|
|
*
|
2023-09-12 13:53:14 +09:30
|
|
|
* This returns true if it handled the packet (i.e. logs a warning).
|
|
|
|
* Doesn't return if it's an error.
|
2019-06-04 03:49:25 +09:30
|
|
|
*/
|
2023-09-12 13:53:14 +09:30
|
|
|
bool handle_peer_error_or_warning(struct per_peer_state *pps,
|
|
|
|
const u8 *msg TAKES);
|
2019-06-04 03:49:25 +09:30
|
|
|
|
2018-01-31 13:23:35 +10:30
|
|
|
#endif /* LIGHTNING_COMMON_READ_PEER_MSG_H */
|