Browse Source
This saves all callers having to handle it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>ppa-0.6.1
Rusty Russell
8 years ago
6 changed files with 82 additions and 3 deletions
@ -0,0 +1,42 @@ |
|||||
|
#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: |
||||
|
case WIRE_ANNOUNCEMENT_SIGNATURES: |
||||
|
case WIRE_CHANNEL_ANNOUNCEMENT: |
||||
|
case WIRE_NODE_ANNOUNCEMENT: |
||||
|
case WIRE_CHANNEL_UPDATE: |
||||
|
return false; |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/* Return true if it's an unknown message. cursor is a tal ptr. */ |
||||
|
bool unknown_msg(const u8 *cursor) |
||||
|
{ |
||||
|
return unknown_type(fromwire_peektype(cursor)); |
||||
|
} |
||||
|
|
||||
|
/* Return true if it's an unknown ODD message. cursor is a tal ptr. */ |
||||
|
bool unknown_msg_discardable(const u8 *cursor) |
||||
|
{ |
||||
|
enum wire_type t = fromwire_peektype(cursor); |
||||
|
return unknown_type(t) && (t & 1); |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
#ifndef LIGHTNING_WIRE_PEER_WIRE_H |
||||
|
#define LIGHTNING_WIRE_PEER_WIRE_H |
||||
|
#include "config.h" |
||||
|
#include <stdbool.h> |
||||
|
#include <wire/gen_peer_wire.h> |
||||
|
|
||||
|
/* BOLT #1:
|
||||
|
* |
||||
|
* A node MUST ignore a received message of unknown type, if that type is odd. |
||||
|
* |
||||
|
* A node MUST fail the channels if it receives a message of unknown type, if |
||||
|
* that type is even. |
||||
|
*/ |
||||
|
|
||||
|
/* Return true if it's an unknown message. cursor is a tal ptr. */ |
||||
|
bool unknown_msg(const u8 *cursor); |
||||
|
/* Return true if it's an unknown ODD message. cursor is a tal ptr. */ |
||||
|
bool unknown_msg_discardable(const u8 *cursor); |
||||
|
|
||||
|
#endif /* LIGHTNING_WIRE_PEER_WIRE_H */ |
Loading…
Reference in new issue