diff --git a/wire/fromwire.c b/wire/fromwire.c index 8e81c8157..9fded589e 100644 --- a/wire/fromwire.c +++ b/wire/fromwire.c @@ -41,10 +41,9 @@ const u8 *fromwire(const u8 **cursor, size_t *max, void *copy, size_t n) return memcheck(p, n); } -int fromwire_peektype(const u8 *cursor) +int fromwire_peektypen(const u8 *cursor, size_t max) { be16 be_type; - size_t max = tal_count(cursor); fromwire(&cursor, &max, &be_type, sizeof(be_type)); if (!cursor) @@ -52,6 +51,11 @@ int fromwire_peektype(const u8 *cursor) return be16_to_cpu(be_type); } +int fromwire_peektype(const u8 *cursor) +{ + return fromwire_peektypen(cursor, tal_count(cursor)); +} + u8 fromwire_u8(const u8 **cursor, size_t *max) { u8 ret; diff --git a/wire/wire.h b/wire/wire.h index 8e8f12ac6..da3858cc4 100644 --- a/wire/wire.h +++ b/wire/wire.h @@ -15,6 +15,8 @@ typedef char utf8; /* Read the type; returns -1 if not long enough. cursor is a tal ptr. */ int fromwire_peektype(const u8 *cursor); +/* Same, but doesn't need to be a tal ptr */ +int fromwire_peektypen(const u8 *cursor, size_t len); void *fromwire_fail(const u8 **cursor, size_t *max); void towire(u8 **pptr, const void *data, size_t len);