2017-03-15 10:43:03 +01:00
|
|
|
#include <lightningd/gossip_msg.h>
|
|
|
|
#include <wire/wire.h>
|
|
|
|
|
2017-03-18 15:50:56 +01:00
|
|
|
void fromwire_gossip_getnodes_entry(const tal_t *ctx, const u8 **pptr, size_t *max, struct gossip_getnodes_entry *entry)
|
2017-03-15 10:43:03 +01:00
|
|
|
{
|
|
|
|
u8 hostnamelen;
|
|
|
|
fromwire_pubkey(pptr, max, &entry->nodeid);
|
|
|
|
hostnamelen = fromwire_u8(pptr, max);
|
2017-03-18 15:50:56 +01:00
|
|
|
entry->hostname = tal_arr(ctx, char, hostnamelen);
|
2017-03-15 10:43:03 +01:00
|
|
|
fromwire_u8_array(pptr, max, (u8*)entry->hostname, hostnamelen);
|
|
|
|
entry->port = fromwire_u16(pptr, max);
|
|
|
|
}
|
|
|
|
void towire_gossip_getnodes_entry(u8 **pptr, const struct gossip_getnodes_entry *entry)
|
|
|
|
{
|
|
|
|
u8 hostnamelen;
|
|
|
|
towire_pubkey(pptr, &entry->nodeid);
|
|
|
|
if (entry->hostname) {
|
|
|
|
hostnamelen = strlen(entry->hostname);
|
|
|
|
towire_u8(pptr, hostnamelen);
|
|
|
|
towire_u8_array(pptr, (u8*)entry->hostname, hostnamelen);
|
|
|
|
}else {
|
|
|
|
/* If we don't have a hostname just write an empty string */
|
|
|
|
hostnamelen = 0;
|
|
|
|
towire_u8(pptr, hostnamelen);
|
|
|
|
}
|
|
|
|
towire_u16(pptr, entry->port);
|
|
|
|
}
|
2017-03-15 13:36:35 +01:00
|
|
|
|
|
|
|
void fromwire_route_hop(const u8 **pptr, size_t *max, struct route_hop *entry)
|
|
|
|
{
|
|
|
|
fromwire_pubkey(pptr, max, &entry->nodeid);
|
|
|
|
entry->amount = fromwire_u32(pptr, max);
|
|
|
|
entry->delay = fromwire_u32(pptr, max);
|
|
|
|
}
|
|
|
|
void towire_route_hop(u8 **pptr, const struct route_hop *entry)
|
|
|
|
{
|
|
|
|
towire_pubkey(pptr, &entry->nodeid);
|
|
|
|
towire_u32(pptr, entry->amount);
|
|
|
|
towire_u32(pptr, entry->delay);
|
|
|
|
}
|
|
|
|
|