Browse Source

wireaddr: add wireaddr_eq.

We can't STRUCTEQ_DEF() it since addrlen is variable, so open-code it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
fee-tracking2
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
76e7f8aa5c
  1. 9
      common/wireaddr.c
  2. 2
      common/wireaddr.h

9
common/wireaddr.c

@ -17,6 +17,15 @@
#include <unistd.h>
#include <wire/wire.h>
bool wireaddr_eq(const struct wireaddr *a, const struct wireaddr *b)
{
if (a->type != b->type)
return false;
if (a->port != b->port)
return false;
return memeq(a->addr, a->addrlen, b->addr, b->addrlen);
}
/* Returns false if we didn't parse it, and *cursor == NULL if malformed. */
bool fromwire_wireaddr(const u8 **cursor, size_t *max, struct wireaddr *addr)
{

2
common/wireaddr.h

@ -61,6 +61,8 @@ struct wireaddr {
u16 port;
};
bool wireaddr_eq(const struct wireaddr *a, const struct wireaddr *b);
/* We use wireaddr to tell gossipd both what to listen on, and what to
* announce */
enum addr_listen_announce {

Loading…
Cancel
Save