MCPcopy Create free account
hub / github.com/ElementsProject/lightning / printwire_tlvs

Function printwire_tlvs

devtools/print_wire.c:246–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246bool printwire_tlvs(const char *fieldname, const u8 **cursor, size_t *plen,
247 const struct tlv_print_record_type types[],
248 size_t num_types)
249{
250 while (*plen > 0) {
251 u64 type, length;
252 const struct tlv_print_record_type *ptype;
253
254 type = fromwire_bigsize(cursor, plen);
255 if (!*cursor)
256 goto fail;
257 length = fromwire_bigsize(cursor, plen);
258 if (!*cursor)
259 goto fail;
260
261 if (length > *plen) {
262 *plen = 0;
263 goto fail;
264 }
265
266 ptype = find_print_record_type(type, types, num_types);
267 if (ptype) {
268 size_t tlvlen = length;
269 printf("{\ntype=%"PRIu64"\nlen=%"PRIu64"\n", type, length);
270 ptype->print(fieldname, cursor, &tlvlen);
271 if (!*cursor)
272 goto fail;
273 printf("}\n");
274 } else
275 printf("**TYPE #%"PRIu64" UNKNOWN for TLV %s**\n", type, fieldname);
276 *plen -= length;
277 }
278 return true;
279
280fail:
281 printf("**TRUNCATED TLV %s**\n", fieldname);
282 return false;
283}
284
285#define PRINTWIRE_TYPE_TO_STRING(T, N) \
286 bool printwire_##N(const char *fieldname, const u8 **cursor, \

Callers

nothing calls this directly

Calls 2

find_print_record_typeFunction · 0.85
fromwire_bigsizeFunction · 0.50

Tested by

no test coverage detected