mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
wire: Add common messages that are independent of daemons
These messages may be exchanged between the master and any daemon. For now these are just the daemons that a peer may be attached to at any time since the first example of this is the custommsg infrastructure.
This commit is contained in:
parent
28080b2e69
commit
a8fa55d275
6 changed files with 79 additions and 2 deletions
|
@ -55,6 +55,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <secp256k1.h>
|
#include <secp256k1.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <wire/gen_common_wire.h>
|
||||||
#include <wire/gen_onion_wire.h>
|
#include <wire/gen_onion_wire.h>
|
||||||
#include <wire/peer_wire.h>
|
#include <wire/peer_wire.h>
|
||||||
#include <wire/wire.h>
|
#include <wire/wire.h>
|
||||||
|
@ -2911,6 +2912,21 @@ static void req_in(struct peer *peer, const u8 *msg)
|
||||||
case WIRE_CHANNEL_SEND_ERROR_REPLY:
|
case WIRE_CHANNEL_SEND_ERROR_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now handle common messages. */
|
||||||
|
switch ((enum common_wire_type)t) {
|
||||||
|
#if DEVELOPER
|
||||||
|
case WIRE_CUSTOMMSG_OUT:
|
||||||
|
/* TODO(cdecker) Add handling of custom messages. */
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
case WIRE_CUSTOMMSG_OUT:
|
||||||
|
#endif
|
||||||
|
/* We send these. */
|
||||||
|
case WIRE_CUSTOMMSG_IN:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
master_badmsg(-1, msg);
|
master_badmsg(-1, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
|
#include <wire/gen_common_wire.h>
|
||||||
#include <wire/wire_sync.h>
|
#include <wire/wire_sync.h>
|
||||||
|
|
||||||
static void update_feerates(struct lightningd *ld, struct channel *channel)
|
static void update_feerates(struct lightningd *ld, struct channel *channel)
|
||||||
|
@ -319,6 +320,19 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ((enum common_wire_type)t) {
|
||||||
|
#if DEVELOPER
|
||||||
|
case WIRE_CUSTOMMSG_IN:
|
||||||
|
/* TODO(cdecker) Add handling of custom messages. */
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
case WIRE_CUSTOMMSG_IN:
|
||||||
|
#endif
|
||||||
|
/* We send these. */
|
||||||
|
case WIRE_CUSTOMMSG_OUT:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <lightningd/plugin_hook.h>
|
#include <lightningd/plugin_hook.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
#include <openingd/gen_opening_wire.h>
|
#include <openingd/gen_opening_wire.h>
|
||||||
|
#include <wire/gen_common_wire.h>
|
||||||
#include <wire/wire.h>
|
#include <wire/wire.h>
|
||||||
#include <wire/wire_sync.h>
|
#include <wire/wire_sync.h>
|
||||||
|
|
||||||
|
@ -922,6 +923,20 @@ static unsigned int openingd_msg(struct subd *openingd,
|
||||||
case WIRE_OPENING_DEV_MEMLEAK_REPLY:
|
case WIRE_OPENING_DEV_MEMLEAK_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ((enum common_wire_type)t) {
|
||||||
|
#if DEVELOPER
|
||||||
|
case WIRE_CUSTOMMSG_IN:
|
||||||
|
/* TODO(cdecker) Add handling of custom messages. */
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
case WIRE_CUSTOMMSG_IN:
|
||||||
|
#endif
|
||||||
|
/* We send these. */
|
||||||
|
case WIRE_CUSTOMMSG_OUT:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
log_broken(openingd->log, "Unexpected msg %s: %s",
|
log_broken(openingd->log, "Unexpected msg %s: %s",
|
||||||
opening_wire_type_name(t), tal_hex(tmpctx, msg));
|
opening_wire_type_name(t), tal_hex(tmpctx, msg));
|
||||||
tal_free(openingd);
|
tal_free(openingd);
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <secp256k1.h>
|
#include <secp256k1.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wally_bip32.h>
|
#include <wally_bip32.h>
|
||||||
|
#include <wire/gen_common_wire.h>
|
||||||
#include <wire/gen_peer_wire.h>
|
#include <wire/gen_peer_wire.h>
|
||||||
#include <wire/peer_wire.h>
|
#include <wire/peer_wire.h>
|
||||||
#include <wire/wire.h>
|
#include <wire/wire.h>
|
||||||
|
@ -1413,6 +1414,20 @@ static u8 *handle_master_in(struct state *state)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now handle common messages. */
|
||||||
|
switch ((enum common_wire_type)t) {
|
||||||
|
#if DEVELOPER
|
||||||
|
case WIRE_CUSTOMMSG_OUT:
|
||||||
|
/* TODO(cdecker) Add handling of custom messages. */
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
case WIRE_CUSTOMMSG_OUT:
|
||||||
|
#endif
|
||||||
|
/* We send these. */
|
||||||
|
case WIRE_CUSTOMMSG_IN:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
status_failed(STATUS_FAIL_MASTER_IO,
|
status_failed(STATUS_FAIL_MASTER_IO,
|
||||||
"Unknown msg %s", tal_hex(tmpctx, msg));
|
"Unknown msg %s", tal_hex(tmpctx, msg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ WIRE_HEADERS_NOGEN := wire/onion_defs.h \
|
||||||
wire/wire.h \
|
wire/wire.h \
|
||||||
wire/wire_sync.h \
|
wire/wire_sync.h \
|
||||||
wire/wire_io.h
|
wire/wire_io.h
|
||||||
WIRE_GEN_HEADERS := wire/gen_peer_wire.h wire/gen_onion_wire.h
|
WIRE_GEN_HEADERS := wire/gen_peer_wire.h wire/gen_onion_wire.h wire/gen_common_wire.h
|
||||||
WIRE_GEN_SRC := wire/gen_peer_wire.c
|
WIRE_GEN_SRC := wire/gen_peer_wire.c wire/gen_common_wire.c
|
||||||
WIRE_GEN_ONION_SRC := wire/gen_onion_wire.c
|
WIRE_GEN_ONION_SRC := wire/gen_onion_wire.c
|
||||||
WIRE_SRC := wire/wire_sync.c \
|
WIRE_SRC := wire/wire_sync.c \
|
||||||
wire/wire_io.c \
|
wire/wire_io.c \
|
||||||
|
@ -85,6 +85,13 @@ wire/gen_onion_wire.h: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
|
||||||
wire/gen_onion_wire.c: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
|
wire/gen_onion_wire.c: wire/gen_onion_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
|
||||||
$(BOLT_GEN) -s --expose-tlv-type=tlv_payload --page impl ${@:.c=.h} onion_type < $< > $@
|
$(BOLT_GEN) -s --expose-tlv-type=tlv_payload --page impl ${@:.c=.h} onion_type < $< > $@
|
||||||
|
|
||||||
|
# Some messages that are common among all daemons
|
||||||
|
wire/gen_common_wire.h: wire/common_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
|
||||||
|
$(BOLT_GEN) -s --page header $@ common_wire_type < $< > $@
|
||||||
|
|
||||||
|
wire/gen_common_wire.c: wire/common_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
|
||||||
|
$(BOLT_GEN) -s --page impl ${@:.c=.h} common_wire_type < $< > $@
|
||||||
|
|
||||||
check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%)
|
check-source: $(WIRE_SRC:%=check-src-include-order/%) $(WIRE_HEADERS_NOGEN:%=check-hdr-include-order/%)
|
||||||
|
|
||||||
check-source-bolt: $(WIRE_SRC:%=bolt-check/%) $(WIRE_HEADERS_NOGEN:%=bolt-check/%)
|
check-source-bolt: $(WIRE_SRC:%=bolt-check/%) $(WIRE_HEADERS_NOGEN:%=bolt-check/%)
|
||||||
|
|
10
wire/common_wire_csv
Normal file
10
wire/common_wire_csv
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# A custom message that we got from a peer and don't know how to handle, so we
|
||||||
|
# forward it to the master for further handling.
|
||||||
|
msgtype,custommsg_in,1030
|
||||||
|
msgdata,custommsg_in,msg_len,u16,
|
||||||
|
msgdata,custommsg_in,msg,u8,msg_len
|
||||||
|
|
||||||
|
# A custom message that the master tells us to send to the peer.
|
||||||
|
msgtype,custommsg_out,1031
|
||||||
|
msgdata,custommsg_out,msg_len,u16,
|
||||||
|
msgdata,custommsg_out,msg,u8,msg_len
|
Loading…
Add table
Reference in a new issue