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
|
2017-09-26 06:57:31 +02:00
|
|
|
enum dev_disconnect {
|
|
|
|
/* Do nothing. */
|
2017-10-11 12:08:50 +02:00
|
|
|
DEV_DISCONNECT_NORMAL = '=',
|
2017-09-26 06:57:31 +02:00
|
|
|
/* Close connection before sending packet (and fail write). */
|
|
|
|
DEV_DISCONNECT_BEFORE = '-',
|
|
|
|
/* Close connection after sending packet. */
|
|
|
|
DEV_DISCONNECT_AFTER = '+',
|
|
|
|
/* Close connection after dropping packet. */
|
|
|
|
DEV_DISCONNECT_DROPPKT = '@',
|
|
|
|
/* Swallow all writes from now on, and do no more reads. */
|
|
|
|
DEV_DISCONNECT_BLACKHOLE = '0',
|
|
|
|
};
|
2017-05-24 12:10:16 +02:00
|
|
|
|
|
|
|
/* Force a close fd before or after a certain packet type */
|
2017-09-26 06:57:31 +02:00
|
|
|
enum dev_disconnect dev_disconnect(int pkt_type);
|
2017-05-24 12:10:16 +02:00
|
|
|
|
|
|
|
/* Make next write on fd fail as if they'd disconnected. */
|
|
|
|
void dev_sabotage_fd(int fd);
|
|
|
|
|
2017-09-06 03:07:19 +02:00
|
|
|
/* No more data to arrive, what's written is swallowed. */
|
|
|
|
void dev_blackhole_fd(int fd);
|
|
|
|
|
2017-05-24 12:10:16 +02:00
|
|
|
/* For debug code to set in daemon. */
|
|
|
|
void dev_disconnect_init(int fd);
|
|
|
|
|
2017-09-26 06:57:31 +02:00
|
|
|
/* Hack for channeld to do DEV_DISCONNECT_SUPPRESS_COMMIT. */
|
|
|
|
extern bool dev_suppress_commit;
|
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 */
|