2019-07-24 01:54:21 +02:00
/* This file was generated by generate-wire.py */
2019-07-15 02:10:01 +02:00
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_${idem}
#define LIGHTNING_${idem}
#include <ccan/tal/tal.h>
2019-07-20 01:21:25 +02:00
#include <wire/tlvstream.h>
2019-07-15 02:10:01 +02:00
#include <wire/wire.h>
% for i in includes:
${i}
% endfor
## Enum sets for wire messages & tlvs
% for enum_set in enum_sets:
enum ${enum_set['name']} {
% for msg in enum_set['set']:
2019-07-18 00:26:21 +02:00
% for comment in msg.msg_comments:
/* ${comment} */
% endfor
2019-07-15 02:10:01 +02:00
${msg.enum_name()} = ${msg.number},
% endfor
};
%endfor
## The 'name' functions for the enums
% for enum_set in enum_sets:
const char *${enum_set['name']}_name(int e);
2019-12-04 16:51:47 +01:00
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool ${enum_set['name']}_is_defined(u16 type);
2019-07-15 02:10:01 +02:00
% endfor
## Structs for subtypes + tlv messages
% for struct in structs:
struct ${struct.struct_name()} {
% for f in struct.fields.values():
2019-07-18 00:26:21 +02:00
% for c in f.field_comments:
/* ${c} */
% endfor
2019-07-18 00:25:44 +02:00
% if bool(f.len_field_of):
2019-07-15 02:10:01 +02:00
<% continue %>
% endif
2019-07-19 18:54:39 +02:00
% if f.is_varlen() and f.type_obj.is_varsize():
${f.type_obj.type_name()} **${f.name};
% elif f.is_varlen():
2019-07-15 02:10:01 +02:00
${f.type_obj.type_name()} *${f.name};
% elif f.is_array():
${f.type_obj.type_name()} ${f.name}[${f.count}];
% else:
${f.type_obj.type_name()} ${f.name};
% endif
% endfor
};
% endfor
2019-07-20 01:21:25 +02:00
## Structs for TLVs
% for tlv in tlvs.values():
struct ${tlv.struct_name()} {
2019-11-18 15:53:27 +01:00
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
2019-07-20 01:21:25 +02:00
% for msg in tlv.messages.values():
2020-05-06 12:41:54 +02:00
% if msg.singleton():
${msg.singleton().type_obj.type_name()} *${msg.name};
% else:
2019-07-20 01:21:25 +02:00
struct ${msg.struct_name()} *${msg.name};
2020-05-06 12:41:54 +02:00
% endif
2019-07-15 02:10:01 +02:00
% endfor
};
% endfor
2019-07-20 01:21:25 +02:00
% for tlv in tlvs.values():
struct ${tlv.struct_name()} *${tlv.struct_name()}_new(const tal_t *ctx);
2019-11-27 15:20:02 +01:00
/**
* Deserialize a TLV stream for the ${tlv.name} namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using ${tlv.name}_is_valid.
*/
bool fromwire_${tlv.name}(const u8 **cursor, size_t *max,
struct ${tlv.struct_name()} * record);
/**
* Serialize a TLV stream for the ${tlv.name} namespace.
*
* This function only considers known fields from the ${tlv.name} namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `${tlv.name}_is_valid`.
*/
void towire_${tlv.name}(u8 **pptr, const void *record);
2019-08-01 06:57:10 +02:00
2019-11-18 20:02:55 +01:00
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
2019-11-25 22:46:55 +01:00
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
2019-11-18 20:02:55 +01:00
*/
2019-11-25 22:46:55 +01:00
bool ${tlv.name}_is_valid(const struct ${tlv.struct_name()} *record,
size_t *err_index);
2019-11-18 20:02:55 +01:00
2019-08-01 06:57:10 +02:00
% if tlv.name in options.expose_tlv_type:
#define TLVS_${tlv.name.upper()}_ARRAY_SIZE ${len(tlv.messages)}
extern const struct tlv_record_type tlvs_${tlv.name}[];
% endif
2019-07-20 01:21:25 +02:00
% endfor
2019-07-15 02:10:01 +02:00
% if options.expose_subtypes and bool(subtypes):
% for subtype in subtypes:
/* SUBTYPE: ${subtype.name.upper()} */
2019-07-18 00:26:21 +02:00
% for c in subtype.type_comments:
/* ${c} */
% endfor
2019-07-19 18:54:39 +02:00
void towire_${subtype.name}(u8 **p, const ${subtype.type_name()} *${subtype.name});
% if subtype.is_varsize():
2020-05-02 12:42:16 +02:00
${subtype.type_name()} *fromwire_${subtype.name}(const tal_t *ctx, const u8 **cursor, size_t *plen);
2019-07-19 18:54:39 +02:00
% else:
void fromwire_${subtype.name}(const u8 **cursor, size_t *plen, ${subtype.type_name()} *${subtype.name});
% endif
2019-07-15 02:10:01 +02:00
% endfor
% endif
% for msg in messages:
2019-09-20 19:49:45 +02:00
% if msg.if_token:
#if ${msg.if_token}
% endif
2019-07-15 02:10:01 +02:00
/* WIRE: ${msg.name.upper()} */
2019-07-18 00:26:21 +02:00
% for c in msg.msg_comments:
/* ${c} */
% endfor
2019-07-19 18:56:39 +02:00
u8 *towire_${msg.name}(const tal_t *ctx${''.join([f.arg_desc_to() for f in msg.fields.values()])});
bool fromwire_${msg.name}(${'const tal_t *ctx, ' if msg.needs_context() else ''}const void *p${''.join([f.arg_desc_from() for f in msg.fields.values()])});
2019-09-20 19:49:45 +02:00
% if msg.if_token:
#endif /* ${msg.if_token} */
% endif
2019-07-15 02:10:01 +02:00
% endfor
2019-08-01 06:57:10 +02:00
2019-07-15 02:10:01 +02:00
#endif /* LIGHTNING_${idem} */