| 244 | } |
| 245 | |
| 246 | bool 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 | |
| 280 | fail: |
| 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, \ |
nothing calls this directly
no test coverage detected