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

Function tlv_field_offset

wire/tlvstream.c:93–117  ·  view source on GitHub ↗

Get the offset of this field: returns size of msg if not found (or * tlv malformed) */

Source from the content-addressed store, hash-verified

91/* Get the offset of this field: returns size of msg if not found (or
92 * tlv malformed) */
93size_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
119static bool tlv_type_is_allowed(const struct tlv_field *f,
120 const u64 *extra_types)

Callers

nothing calls this directly

Calls 1

fromwire_bigsizeFunction · 0.50

Tested by

no test coverage detected