Get the offset of this field: returns size of msg if not found (or * tlv malformed) */
| 90 | /* Get the offset of this field: returns size of msg if not found (or |
| 91 | * tlv malformed) */ |
| 92 | size_t tlv_field_offset(const u8 *tlvstream, size_t tlvlen, u64 fieldtype) |
| 93 | { |
| 94 | size_t max = tlvlen; |
| 95 | while (max > 0) { |
| 96 | u64 type, length; |
| 97 | size_t field_off = tlvlen - max; |
| 98 | |
| 99 | type = fromwire_bigsize(&tlvstream, &max); |
| 100 | length = fromwire_bigsize(&tlvstream, &max); |
| 101 | |
| 102 | if (!tlvstream) |
| 103 | break; |
| 104 | |
| 105 | /* Found it! */ |
| 106 | if (type == fieldtype) |
| 107 | return field_off; |
| 108 | |
| 109 | if (length > max) |
| 110 | break; |
| 111 | |
| 112 | max -= length; |
| 113 | tlvstream += length; |
| 114 | } |
| 115 | return tlvlen; |
| 116 | } |
| 117 | |
| 118 | static bool tlv_type_is_allowed(const struct tlv_field *f, |
| 119 | const u64 *extra_types) |
nothing calls this directly
no test coverage detected