Makefile: add generated packet names.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
fabdcaf62b
commit
f43cc72d6a
9
Makefile
9
Makefile
|
@ -165,7 +165,8 @@ CORE_HEADERS := close_tx.h \
|
||||||
utils.h \
|
utils.h \
|
||||||
version.h
|
version.h
|
||||||
|
|
||||||
GEN_HEADERS := gen_state_names.h \
|
GEN_HEADERS := gen_pkt_names.h \
|
||||||
|
gen_state_names.h \
|
||||||
gen_version.h \
|
gen_version.h \
|
||||||
lightning.pb-c.h
|
lightning.pb-c.h
|
||||||
|
|
||||||
|
@ -265,6 +266,10 @@ ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDU
|
||||||
gen_state_names.h: state_types.h ccan/ccan/cdump/tools/cdump-enumstr
|
gen_state_names.h: state_types.h ccan/ccan/cdump/tools/cdump-enumstr
|
||||||
ccan/ccan/cdump/tools/cdump-enumstr state_types.h > $@
|
ccan/ccan/cdump/tools/cdump-enumstr state_types.h > $@
|
||||||
|
|
||||||
|
# lightning.pb-c.h doesn't create a named enum, just a typedef. Hack it.
|
||||||
|
gen_pkt_names.h: lightning.pb-c.h ccan/ccan/cdump/tools/cdump-enumstr
|
||||||
|
(echo 'enum PktCase {'; grep '^ PKT__' lightning.pb-c.h; echo '};') | ccan/ccan/cdump/tools/cdump-enumstr - | sed 's/enum PktCase/Pkt__PktCase/' > $@
|
||||||
|
|
||||||
# We build a static libsecpk1, since we need ecdh
|
# We build a static libsecpk1, since we need ecdh
|
||||||
# (and it's not API stable yet!).
|
# (and it's not API stable yet!).
|
||||||
libsecp256k1.a: secp256k1/libsecp256k1.la
|
libsecp256k1.a: secp256k1/libsecp256k1.la
|
||||||
|
@ -327,7 +332,7 @@ distclean: clean
|
||||||
maintainter-clean: distclean
|
maintainter-clean: distclean
|
||||||
@echo 'This command is intended for maintainers to use; it'
|
@echo 'This command is intended for maintainers to use; it'
|
||||||
@echo 'deletes files that may need special tools to rebuild.'
|
@echo 'deletes files that may need special tools to rebuild.'
|
||||||
$(RM) lightning.pb-c.c lightning.pb-c.h ccan/config.h gen_version.h
|
$(RM) lightning.pb-c.c lightning.pb-c.h ccan/config.h $(GEN_HEADERS)
|
||||||
$(RM) doc/deployable-lightning.pdf
|
$(RM) doc/deployable-lightning.pdf
|
||||||
|
|
||||||
clean: daemon-clean
|
clean: daemon-clean
|
||||||
|
|
|
@ -272,7 +272,7 @@ static struct io_plan *decrypt_body(struct io_conn *conn, struct peer *peer)
|
||||||
log_debug(peer->log, "Received packet LEN=%u, type=%s",
|
log_debug(peer->log, "Received packet LEN=%u, type=%s",
|
||||||
le32_to_cpu(iod->hdr_in.length),
|
le32_to_cpu(iod->hdr_in.length),
|
||||||
peer->inpkt->pkt_case == PKT__PKT_AUTH ? "PKT_AUTH"
|
peer->inpkt->pkt_case == PKT__PKT_AUTH ? "PKT_AUTH"
|
||||||
: input_name(peer->inpkt->pkt_case));
|
: pkt_name(peer->inpkt->pkt_case));
|
||||||
|
|
||||||
return iod->cb(conn, peer);
|
return iod->cb(conn, peer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ void queue_pkt_close_signature(struct peer *peer)
|
||||||
|
|
||||||
Pkt *pkt_err_unexpected(struct peer *peer, const Pkt *pkt)
|
Pkt *pkt_err_unexpected(struct peer *peer, const Pkt *pkt)
|
||||||
{
|
{
|
||||||
return pkt_err(peer, "Unexpected packet %s", state_name(pkt->pkt_case));
|
return pkt_err(peer, "Unexpected packet %s", pkt_name(pkt->pkt_case));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process various packets: return an error packet on failure. */
|
/* Process various packets: return an error packet on failure. */
|
||||||
|
|
|
@ -170,7 +170,7 @@ static void state_single(struct peer *peer,
|
||||||
|
|
||||||
if (tal_count(peer->outpkt) > old_outpkts) {
|
if (tal_count(peer->outpkt) > old_outpkts) {
|
||||||
Pkt *outpkt = peer->outpkt[old_outpkts].pkt;
|
Pkt *outpkt = peer->outpkt[old_outpkts].pkt;
|
||||||
log_add(peer->log, " (out %s)", input_name(outpkt->pkt_case));
|
log_add(peer->log, " (out %s)", pkt_name(outpkt->pkt_case));
|
||||||
}
|
}
|
||||||
if (broadcast)
|
if (broadcast)
|
||||||
broadcast_tx(peer, broadcast);
|
broadcast_tx(peer, broadcast);
|
||||||
|
|
11
names.c
11
names.c
|
@ -1,6 +1,7 @@
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
/* Indented for 'check-source' because it has to be included after names.h */
|
/* Indented for 'check-source' because it has to be included after names.h */
|
||||||
#include "gen_state_names.h"
|
#include "gen_state_names.h"
|
||||||
|
#include "gen_pkt_names.h"
|
||||||
|
|
||||||
const char *state_name(enum state s)
|
const char *state_name(enum state s)
|
||||||
{
|
{
|
||||||
|
@ -41,3 +42,13 @@ const char *peercond_name(enum state_peercond peercond)
|
||||||
return enum_state_peercond_names[i].name;
|
return enum_state_peercond_names[i].name;
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *pkt_name(Pkt__PktCase pkt)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; enum_PktCase_names[i].name; i++)
|
||||||
|
if (enum_PktCase_names[i].v == pkt)
|
||||||
|
return enum_PktCase_names[i].name;
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
2
names.h
2
names.h
|
@ -1,10 +1,12 @@
|
||||||
#ifndef LIGHTNING_NAMES_H
|
#ifndef LIGHTNING_NAMES_H
|
||||||
#define LIGHTNING_NAMES_H
|
#define LIGHTNING_NAMES_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "lightning.pb-c.h"
|
||||||
#include "state_types.h"
|
#include "state_types.h"
|
||||||
|
|
||||||
const char *state_name(enum state s);
|
const char *state_name(enum state s);
|
||||||
const char *input_name(enum state_input in);
|
const char *input_name(enum state_input in);
|
||||||
const char *cstatus_name(enum command_status cstatus);
|
const char *cstatus_name(enum command_status cstatus);
|
||||||
const char *peercond_name(enum state_peercond peercond);
|
const char *peercond_name(enum state_peercond peercond);
|
||||||
|
const char *pkt_name(Pkt__PktCase pkt);
|
||||||
#endif /* LIGHTNING_NAMES_H */
|
#endif /* LIGHTNING_NAMES_H */
|
||||||
|
|
Loading…
Reference in New Issue