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;
|
|
|
|
|
2025-01-25 11:08:11 +10:30
|
|
|
enum dev_disconnect_out {
|
2017-09-26 14:27:31 +09:30
|
|
|
/* Do nothing. */
|
2025-01-25 11:08:11 +10:30
|
|
|
DEV_DISCONNECT_OUT_NORMAL = '=',
|
2021-12-28 09:57:09 +10:30
|
|
|
/* Close connection before sending packet. */
|
2025-01-25 11:08:11 +10:30
|
|
|
DEV_DISCONNECT_OUT_BEFORE = '-',
|
2017-09-26 14:27:31 +09:30
|
|
|
/* Close connection after sending packet. */
|
2025-01-25 11:08:11 +10:30
|
|
|
DEV_DISCONNECT_OUT_AFTER = '+',
|
2023-10-31 18:07:15 -05:00
|
|
|
/* Drop message (don't send to peer) */
|
2025-01-25 11:08:11 +10:30
|
|
|
DEV_DISCONNECT_OUT_DROP = '$',
|
2017-09-26 14:27:31 +09:30
|
|
|
/* Swallow all writes from now on, and do no more reads. */
|
2025-01-25 11:08:11 +10:30
|
|
|
DEV_DISCONNECT_OUT_BLACKHOLE = '0',
|
2021-06-15 06:37:36 +09:30
|
|
|
/* Don't use connection after sending packet, but don't close. */
|
2025-01-25 11:08:11 +10:30
|
|
|
DEV_DISCONNECT_OUT_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 */
|
2025-01-25 11:08:11 +10:30
|
|
|
enum dev_disconnect_out dev_disconnect_out(const struct node_id *id, int pkt_type);
|
2017-05-24 19:40:16 +09:30
|
|
|
|
2025-01-25 11:09:11 +10:30
|
|
|
enum dev_disconnect_in {
|
|
|
|
/* Do nothing. */
|
|
|
|
DEV_DISCONNECT_IN_NORMAL = '=',
|
|
|
|
/* Close connection after receiving packet. */
|
|
|
|
DEV_DISCONNECT_IN_AFTER_RECV = '<',
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Force a close fd after receiving a certain packet type */
|
|
|
|
enum dev_disconnect_in dev_disconnect_in(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 */
|