2018-01-31 03:53:35 +01:00
|
|
|
#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-03 20:11:25 +02:00
|
|
|
struct per_peer_state;
|
2018-01-31 03:53:35 +01:00
|
|
|
|
2018-08-02 08:49:55 +02:00
|
|
|
/**
|
|
|
|
* is_peer_error - if it's an error, describe if it applies to this channel.
|
|
|
|
* @ctx: context to allocate return from.
|
|
|
|
* @msg: the peer message.
|
|
|
|
* @channel_id: the channel id of the current channel.
|
|
|
|
* @desc: set to non-NULL if this describes a channel we care about.
|
2021-02-02 13:46:01 +01:00
|
|
|
* @warning: set to true if this is a warning, not an error.
|
2018-08-02 08:49:55 +02:00
|
|
|
*
|
|
|
|
* If @desc is NULL, ignore this message. Otherwise, that's usually passed
|
|
|
|
* to peer_failed_received_errmsg().
|
|
|
|
*/
|
|
|
|
bool is_peer_error(const tal_t *ctx, const u8 *msg,
|
|
|
|
const struct channel_id *channel_id,
|
2021-02-02 13:47:01 +01:00
|
|
|
char **desc, bool *warning);
|
2018-08-02 08:49:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* is_wrong_channel - if it's a message about a different channel, return true
|
|
|
|
* @msg: the peer message.
|
|
|
|
* @channel_id: the channel id of the current channel.
|
|
|
|
* @actual: set to the actual channel id if this returns false.
|
|
|
|
*
|
|
|
|
* Note that this only handles some message types, returning false for others.
|
|
|
|
*/
|
|
|
|
bool is_wrong_channel(const u8 *msg, const struct channel_id *expected,
|
|
|
|
struct channel_id *actual);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2022-01-29 04:33:05 +01:00
|
|
|
* handle_peer_error - simple handler for errors
|
2019-06-03 20:11:25 +02:00
|
|
|
* @pps: per-peer state.
|
2019-05-09 01:58:54 +02:00
|
|
|
* @channel_id: the channel id of the current channel.
|
2018-08-02 08:49:55 +02:00
|
|
|
* @msg: the peer message (only taken if returns true).
|
|
|
|
*
|
2022-01-29 04:33:05 +01:00
|
|
|
* This returns true if it handled the packet.
|
2019-06-03 20:19:25 +02:00
|
|
|
*/
|
2022-01-29 04:33:05 +01:00
|
|
|
bool handle_peer_error(struct per_peer_state *pps,
|
|
|
|
const struct channel_id *channel_id,
|
|
|
|
const u8 *msg TAKES);
|
2019-06-03 20:19:25 +02:00
|
|
|
|
2018-01-31 03:53:35 +01:00
|
|
|
#endif /* LIGHTNING_COMMON_READ_PEER_MSG_H */
|