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