core-lightning/common/dev_disconnect.h
Rusty Russell 6ceec17943 dev_disconnect: make commit suppression a "-nocommit" modifier.
Useful if we want to drop & suppress, for example.  We change '=' to mean
do nothing to the packet.

We use this to clean up the test_reconnect_sender_add test.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-10-20 18:31:32 +02:00

35 lines
1.0 KiB
C

#ifndef LIGHTNING_COMMON_DEV_DISCONNECT_H
#define LIGHTNING_COMMON_DEV_DISCONNECT_H
#include "config.h"
#include <stdbool.h>
enum dev_disconnect {
/* Do nothing. */
DEV_DISCONNECT_NORMAL = '=',
/* 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',
};
/* Force a close fd before or after a certain packet type */
enum dev_disconnect dev_disconnect(int pkt_type);
/* Make next write on fd fail as if they'd disconnected. */
void dev_sabotage_fd(int fd);
/* No more data to arrive, what's written is swallowed. */
void dev_blackhole_fd(int fd);
/* For debug code to set in daemon. */
void dev_disconnect_init(int fd);
/* Hack for channeld to do DEV_DISCONNECT_SUPPRESS_COMMIT. */
extern bool dev_suppress_commit;
#endif /* LIGHTNING_COMMON_DEV_DISCONNECT_H */