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