2017-04-01 12:25:59 +02:00
|
|
|
#include <wire/peer_wire.h>
|
|
|
|
|
|
|
|
static bool unknown_type(enum wire_type t)
|
|
|
|
{
|
|
|
|
switch (t) {
|
|
|
|
case WIRE_INIT:
|
|
|
|
case WIRE_ERROR:
|
|
|
|
case WIRE_OPEN_CHANNEL:
|
|
|
|
case WIRE_ACCEPT_CHANNEL:
|
|
|
|
case WIRE_FUNDING_CREATED:
|
|
|
|
case WIRE_FUNDING_SIGNED:
|
|
|
|
case WIRE_FUNDING_LOCKED:
|
|
|
|
case WIRE_SHUTDOWN:
|
|
|
|
case WIRE_CLOSING_SIGNED:
|
|
|
|
case WIRE_UPDATE_ADD_HTLC:
|
|
|
|
case WIRE_UPDATE_FULFILL_HTLC:
|
|
|
|
case WIRE_UPDATE_FAIL_HTLC:
|
|
|
|
case WIRE_UPDATE_FAIL_MALFORMED_HTLC:
|
|
|
|
case WIRE_COMMITMENT_SIGNED:
|
|
|
|
case WIRE_REVOKE_AND_ACK:
|
|
|
|
case WIRE_UPDATE_FEE:
|
2017-06-20 07:40:03 +02:00
|
|
|
case WIRE_CHANNEL_REESTABLISH:
|
2017-04-01 12:25:59 +02:00
|
|
|
case WIRE_ANNOUNCEMENT_SIGNATURES:
|
|
|
|
case WIRE_CHANNEL_ANNOUNCEMENT:
|
|
|
|
case WIRE_NODE_ANNOUNCEMENT:
|
|
|
|
case WIRE_CHANNEL_UPDATE:
|
2017-04-12 18:10:10 +02:00
|
|
|
case WIRE_PING:
|
|
|
|
case WIRE_PONG:
|
2017-04-01 12:25:59 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-06-27 04:50:10 +02:00
|
|
|
bool is_gossip_msg(const u8 *cursor)
|
2017-05-05 08:41:45 +02:00
|
|
|
{
|
|
|
|
switch (fromwire_peektype(cursor)) {
|
|
|
|
case WIRE_CHANNEL_ANNOUNCEMENT:
|
|
|
|
case WIRE_NODE_ANNOUNCEMENT:
|
|
|
|
case WIRE_CHANNEL_UPDATE:
|
|
|
|
return true;
|
|
|
|
case WIRE_INIT:
|
|
|
|
case WIRE_ERROR:
|
|
|
|
case WIRE_OPEN_CHANNEL:
|
|
|
|
case WIRE_ACCEPT_CHANNEL:
|
|
|
|
case WIRE_FUNDING_CREATED:
|
|
|
|
case WIRE_FUNDING_SIGNED:
|
|
|
|
case WIRE_FUNDING_LOCKED:
|
|
|
|
case WIRE_SHUTDOWN:
|
|
|
|
case WIRE_CLOSING_SIGNED:
|
|
|
|
case WIRE_UPDATE_ADD_HTLC:
|
|
|
|
case WIRE_UPDATE_FULFILL_HTLC:
|
|
|
|
case WIRE_UPDATE_FAIL_HTLC:
|
|
|
|
case WIRE_UPDATE_FAIL_MALFORMED_HTLC:
|
|
|
|
case WIRE_COMMITMENT_SIGNED:
|
|
|
|
case WIRE_REVOKE_AND_ACK:
|
|
|
|
case WIRE_UPDATE_FEE:
|
|
|
|
case WIRE_PING:
|
|
|
|
case WIRE_PONG:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-01 12:25:59 +02:00
|
|
|
/* Return true if it's an unknown message. cursor is a tal ptr. */
|
2017-06-27 04:50:10 +02:00
|
|
|
bool is_unknown_msg(const u8 *cursor)
|
2017-04-01 12:25:59 +02:00
|
|
|
{
|
|
|
|
return unknown_type(fromwire_peektype(cursor));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return true if it's an unknown ODD message. cursor is a tal ptr. */
|
2017-06-27 04:50:10 +02:00
|
|
|
bool is_unknown_msg_discardable(const u8 *cursor)
|
2017-04-01 12:25:59 +02:00
|
|
|
{
|
|
|
|
enum wire_type t = fromwire_peektype(cursor);
|
|
|
|
return unknown_type(t) && (t & 1);
|
|
|
|
}
|