2017-08-29 01:36:01 +09:30
|
|
|
#ifndef LIGHTNING_COMMON_DEV_DISCONNECT_H
|
|
|
|
#define LIGHTNING_COMMON_DEV_DISCONNECT_H
|
2017-05-24 19:40:16 +09:30
|
|
|
#include "config.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-01-08 23:55:29 +10:30
|
|
|
struct node_id;
|
|
|
|
|
2017-09-26 14:27:31 +09:30
|
|
|
enum dev_disconnect {
|
|
|
|
/* Do nothing. */
|
2017-10-11 20:38:50 +10:30
|
|
|
DEV_DISCONNECT_NORMAL = '=',
|
2021-12-28 09:57:09 +10:30
|
|
|
/* Close connection before sending packet. */
|
2017-09-26 14:27:31 +09:30
|
|
|
DEV_DISCONNECT_BEFORE = '-',
|
|
|
|
/* Close connection after sending packet. */
|
|
|
|
DEV_DISCONNECT_AFTER = '+',
|
2023-10-31 18:07:15 -05:00
|
|
|
/* Drop message (don't send to peer) */
|
|
|
|
DEV_DISCONNECT_DROP = '$',
|
2017-09-26 14:27:31 +09:30
|
|
|
/* Swallow all writes from now on, and do no more reads. */
|
|
|
|
DEV_DISCONNECT_BLACKHOLE = '0',
|
2021-06-15 06:37:36 +09:30
|
|
|
/* Don't use connection after sending packet, but don't close. */
|
|
|
|
DEV_DISCONNECT_DISABLE_AFTER = 'x',
|
2017-09-26 14:27:31 +09:30
|
|
|
};
|
2017-05-24 19:40:16 +09:30
|
|
|
|
|
|
|
/* Force a close fd before or after a certain packet type */
|
2022-01-08 23:55:29 +10:30
|
|
|
enum dev_disconnect dev_disconnect(const struct node_id *id, int pkt_type);
|
2017-05-24 19:40:16 +09:30
|
|
|
|
|
|
|
/* Make next write on fd fail as if they'd disconnected. */
|
2021-06-15 06:37:36 +09:30
|
|
|
void dev_sabotage_fd(int fd, bool close_fd);
|
2017-05-24 19:40:16 +09:30
|
|
|
|
|
|
|
/* For debug code to set in daemon. */
|
|
|
|
void dev_disconnect_init(int fd);
|
|
|
|
|
2017-08-29 01:36:01 +09:30
|
|
|
#endif /* LIGHTNING_COMMON_DEV_DISCONNECT_H */
|