/src/spicy/build/ci/fuzz/TFTP_Packet_TFTP.cc
Line | Count | Source |
1 | | // Begin of TFTP (from "/src/spicy/spicy-tftp/analyzer/tftp.spicy") |
2 | | // Compiled by HILTI version 1.17.0-dev.249 |
3 | | |
4 | | #include <hilti/rt/compiler-setup.h> |
5 | | |
6 | | #include <spicy/rt/libspicy.h> |
7 | | #include <hilti/rt/libhilti.h> |
8 | | |
9 | | extern uint64_t hlt_internal_TFTP_Packet_hlto_scope; |
10 | | |
11 | | namespace hlt_internal_TFTP_Packet::type_info { namespace { |
12 | | extern const ::hilti::rt::TypeInfo _t_ti_TFTP__Acknowledgement_namex2aTFTP__Acknowledgementx2b; |
13 | | extern const ::hilti::rt::TypeInfo _t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b; |
14 | | extern const ::hilti::rt::TypeInfo _t_ti_hilti__RecoverableFailure_namex2ahilti__RecoverableFailurex2b; |
15 | | extern const ::hilti::rt::TypeInfo _t_ti_TFTP__Data_namex2aTFTP__Datax2b; |
16 | | extern const ::hilti::rt::TypeInfo _t_ti_TFTP__Error_namex2aTFTP__Errorx2b; |
17 | | extern const ::hilti::rt::TypeInfo _t_ti_TFTP__Opcode_namex2aTFTP__Opcodex2b; |
18 | | extern const ::hilti::rt::TypeInfo _t_ti_TFTP__Request_namex2aTFTP__Requestx2b; |
19 | | extern const ::hilti::rt::TypeInfo _t_ti_TFTP__Packet_namex2aTFTP__Packetx2b; |
20 | | extern const ::hilti::rt::TypeInfo _t_ti_value_ref_TFTP__Packet__value_refx2anamex2aTFTP__Packetx2bx2b; |
21 | | extern const ::hilti::rt::TypeInfo _t_ti_strong_ref_const_TFTP__Packet__strong_refx2anamex2aTFTP__Packetx2bx2b; |
22 | | } } |
23 | | |
24 | | namespace hlt_internal_TFTP_Packet::TFTP { |
25 | | struct Acknowledgement; |
26 | | struct Data; |
27 | | struct Error; |
28 | | struct Request; |
29 | | struct Packet; |
30 | | struct Acknowledgement : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable<Acknowledgement> { |
31 | 116 | auto _t_self() { return ::hilti::rt::ValueReference<Acknowledgement>::self(this); } |
32 | | // ::hilti::rt::Optional<::hilti::rt::integer::safe<uint16_t>> num{}; |
33 | | auto _t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View; |
34 | | auto _t_parse_TFTP__Acknowledgement_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View; |
35 | | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error{}; |
36 | | Acknowledgement(); |
37 | | Acknowledgement(const Acknowledgement&) = default; |
38 | 0 | Acknowledgement(Acknowledgement&&) = default; |
39 | | Acknowledgement& operator=(const Acknowledgement&) = default; |
40 | 58 | Acknowledgement& operator=(Acknowledgement&&) = default; |
41 | | |
42 | 0 | std::string __to_string() const { |
43 | 0 | return "["s + hilti::rt::to_string_for_print("$num=(optimized out)"_hs) + "]"; |
44 | 0 | } |
45 | | }; |
46 | | |
47 | | struct Data : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable<Data> { |
48 | 186 | auto _t_self() { return ::hilti::rt::ValueReference<Data>::self(this); } |
49 | | // ::hilti::rt::Optional<::hilti::rt::integer::safe<uint16_t>> num{}; |
50 | | // ::hilti::rt::Optional<::hilti::rt::Bytes> data{}; |
51 | | auto _t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View; |
52 | | auto _t_parse_TFTP__Data_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View; |
53 | | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error{}; |
54 | | Data(); |
55 | | Data(const Data&) = default; |
56 | 0 | Data(Data&&) = default; |
57 | | Data& operator=(const Data&) = default; |
58 | 93 | Data& operator=(Data&&) = default; |
59 | | |
60 | 0 | std::string __to_string() const { |
61 | 0 | return "["s + hilti::rt::to_string_for_print("$num=(optimized out)"_hs) + ", "s + hilti::rt::to_string_for_print("$data=(optimized out)"_hs) + "]"; |
62 | 0 | } |
63 | | }; |
64 | | |
65 | | struct Error : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable<Error> { |
66 | 316 | auto _t_self() { return ::hilti::rt::ValueReference<Error>::self(this); } |
67 | | // ::hilti::rt::Optional<::hilti::rt::integer::safe<uint16_t>> code{}; |
68 | | ::hilti::rt::Optional<::hilti::rt::Bytes> msg{}; |
69 | | auto _t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View; |
70 | | auto _t_parse_TFTP__Error_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View; |
71 | | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error{}; |
72 | | Error(); |
73 | | Error(const Error&) = default; |
74 | 0 | Error(Error&&) = default; |
75 | | Error& operator=(const Error&) = default; |
76 | 158 | Error& operator=(Error&&) = default; |
77 | | explicit Error(::hilti::rt::struct_::tag::Inits, ::hilti::rt::Optional<::hilti::rt::Optional<::hilti::rt::Bytes>> msg); |
78 | | |
79 | 0 | std::string __to_string() const { |
80 | 0 | return "["s + hilti::rt::to_string_for_print("$code=(optimized out)"_hs) + ", "s + "$msg=" + hilti::rt::to_string(msg) + "]"; |
81 | 0 | } |
82 | | }; |
83 | | |
84 | | HILTI_RT_ENUM_TYPE(Opcode, RRQ = 1, WRQ = 2, DATA = 3, ACK = 4, ERROR = 5); |
85 | | struct Request : ::hilti::rt::trait::isStruct, hilti::rt::trait::hasParameters, ::hilti::rt::Controllable<Request> { |
86 | 792 | auto _t_self() { return ::hilti::rt::ValueReference<Request>::self(this); } |
87 | | ::hilti::rt::Optional<::hilti::rt::Bytes> filename{}; |
88 | | ::hilti::rt::Optional<::hilti::rt::Bytes> mode{}; |
89 | | void _t_on_0x25_done(); |
90 | | auto _t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim, const ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>& _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>>; |
91 | | auto _t_parse_TFTP__Request_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>>; |
92 | | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error{}; |
93 | | ::hilti::rt::Bool _t_p_is_read{}; |
94 | | Request(); |
95 | | Request(const Request&) = default; |
96 | 0 | Request(Request&&) = default; |
97 | | Request& operator=(const Request&) = default; |
98 | 317 | Request& operator=(Request&&) = default; |
99 | | explicit Request(::hilti::rt::struct_::tag::Inits, ::hilti::rt::Optional<::hilti::rt::Optional<::hilti::rt::Bytes>> filename, ::hilti::rt::Optional<::hilti::rt::Optional<::hilti::rt::Bytes>> mode); |
100 | | explicit Request(::hilti::rt::struct_::tag::Parameters, const ::hilti::rt::Bool& _t_p_is_read); |
101 | | |
102 | 0 | std::string __to_string() const { |
103 | 0 | return "["s + "$filename=" + hilti::rt::to_string(filename) + ", "s + "$mode=" + hilti::rt::to_string(mode) + "]"; |
104 | 0 | } |
105 | | }; |
106 | | |
107 | | struct Packet : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable<Packet> { |
108 | 1.91k | auto _t_self() { return ::hilti::rt::ValueReference<Packet>::self(this); } |
109 | | ::hilti::rt::Optional<TFTP::Opcode> op{}; |
110 | | ::hilti::rt::Optional<Request> rrq{}; |
111 | | ::hilti::rt::Optional<Request> wrq{}; |
112 | | ::hilti::rt::Optional<Data> data{}; |
113 | | ::hilti::rt::Optional<Acknowledgement> ack{}; |
114 | | ::hilti::rt::Optional<Error> error{}; |
115 | | inline static ::spicy::rt::Parser _t_parser{}; |
116 | | auto _t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim, const ::hilti::rt::integer::safe<int64_t>& _t_lah, const ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>& _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::integer::safe<int64_t>, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>>; |
117 | | static auto parse1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::stream::View; |
118 | | static auto parse2(::hilti::rt::ValueReference<Packet>& _t_unit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::stream::View; |
119 | | static auto parse3(::hilti::rt::ValueReference<::spicy::rt::ParsedUnit>& _t_gunit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::stream::View; |
120 | | auto _t_parse_switch_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, ::hilti::rt::Bool _t_trim, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>>; |
121 | | auto _t_parse_TFTP__Packet_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, ::hilti::rt::Bool _t_trim, const ::hilti::rt::integer::safe<int64_t>& _t_lah, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::integer::safe<int64_t>, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>>; |
122 | | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error{}; |
123 | | Packet(); |
124 | | Packet(const Packet&) = default; |
125 | 1.28k | Packet(Packet&&) = default; |
126 | | Packet& operator=(const Packet&) = default; |
127 | | Packet& operator=(Packet&&) = default; |
128 | | explicit Packet(::hilti::rt::struct_::tag::Inits, ::hilti::rt::Optional<::hilti::rt::Optional<TFTP::Opcode>> op, ::hilti::rt::Optional<::hilti::rt::Optional<Request>> rrq, ::hilti::rt::Optional<::hilti::rt::Optional<Request>> wrq, ::hilti::rt::Optional<::hilti::rt::Optional<Data>> data, ::hilti::rt::Optional<::hilti::rt::Optional<Acknowledgement>> ack, ::hilti::rt::Optional<::hilti::rt::Optional<Error>> error); |
129 | | |
130 | 0 | std::string __to_string() const { |
131 | 0 | return "["s + "$op=" + hilti::rt::to_string(op) + ", "s + "$rrq=" + hilti::rt::to_string(rrq) + ", "s + "$wrq=" + hilti::rt::to_string(wrq) + ", "s + "$data=" + hilti::rt::to_string(data) + ", "s + "$ack=" + hilti::rt::to_string(ack) + ", "s + "$error=" + hilti::rt::to_string(error) + "]"; |
132 | 0 | } |
133 | | }; |
134 | | |
135 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25is_filter = ::hilti::rt::Bool{false}; |
136 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25supports_filters = ::hilti::rt::Bool{false}; |
137 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25supports_sinks = ::hilti::rt::Bool{false}; |
138 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25synchronization = ::hilti::rt::Bool{false}; |
139 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25uses_offset = ::hilti::rt::Bool{false}; |
140 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25uses_random_access = ::hilti::rt::Bool{false}; |
141 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25uses_stream = ::hilti::rt::Bool{false}; |
142 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Acknowledgement0x25uses_sync_advance = ::hilti::rt::Bool{false}; |
143 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25is_filter = ::hilti::rt::Bool{false}; |
144 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25supports_filters = ::hilti::rt::Bool{false}; |
145 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25supports_sinks = ::hilti::rt::Bool{false}; |
146 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25synchronization = ::hilti::rt::Bool{false}; |
147 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25uses_offset = ::hilti::rt::Bool{false}; |
148 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25uses_random_access = ::hilti::rt::Bool{false}; |
149 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25uses_stream = ::hilti::rt::Bool{false}; |
150 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Data0x25uses_sync_advance = ::hilti::rt::Bool{false}; |
151 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25is_filter = ::hilti::rt::Bool{false}; |
152 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25supports_filters = ::hilti::rt::Bool{false}; |
153 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25supports_sinks = ::hilti::rt::Bool{false}; |
154 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25synchronization = ::hilti::rt::Bool{false}; |
155 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25uses_offset = ::hilti::rt::Bool{false}; |
156 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25uses_random_access = ::hilti::rt::Bool{false}; |
157 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25uses_stream = ::hilti::rt::Bool{false}; |
158 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Error0x25uses_sync_advance = ::hilti::rt::Bool{false}; |
159 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25is_filter = ::hilti::rt::Bool{false}; |
160 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25supports_filters = ::hilti::rt::Bool{false}; |
161 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25supports_sinks = ::hilti::rt::Bool{false}; |
162 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25synchronization = ::hilti::rt::Bool{false}; |
163 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25uses_offset = ::hilti::rt::Bool{false}; |
164 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25uses_random_access = ::hilti::rt::Bool{false}; |
165 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25uses_stream = ::hilti::rt::Bool{false}; |
166 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Packet0x25uses_sync_advance = ::hilti::rt::Bool{false}; |
167 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25is_filter = ::hilti::rt::Bool{false}; |
168 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25supports_filters = ::hilti::rt::Bool{false}; |
169 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25supports_sinks = ::hilti::rt::Bool{false}; |
170 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25synchronization = ::hilti::rt::Bool{false}; |
171 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25uses_offset = ::hilti::rt::Bool{false}; |
172 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25uses_random_access = ::hilti::rt::Bool{false}; |
173 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25uses_stream = ::hilti::rt::Bool{false}; |
174 | | const ::hilti::rt::Bool _t_feat0x25TFTP0x400x40Request0x25uses_sync_advance = ::hilti::rt::Bool{false}; |
175 | | } |
176 | | |
177 | | namespace hlt_TFTP_Packet::TFTP::Packet { |
178 | | using Type = hlt_internal_TFTP_Packet::TFTP::Packet; |
179 | | } |
180 | | |
181 | | namespace hlt_internal_TFTP_Packet::TFTP { |
182 | | extern auto operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Acknowledgement& x) -> std::ostream&; |
183 | 116 | Acknowledgement::Acknowledgement() { |
184 | 116 | } |
185 | | |
186 | | |
187 | | extern auto operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Data& x) -> std::ostream&; |
188 | 186 | Data::Data() { |
189 | 186 | } |
190 | | |
191 | | |
192 | | extern auto operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Error& x) -> std::ostream&; |
193 | 316 | Error::Error() { |
194 | 316 | } |
195 | | |
196 | 0 | Error::Error(::hilti::rt::struct_::tag::Inits, ::hilti::rt::Optional<::hilti::rt::Optional<::hilti::rt::Bytes>> msg) : Error() { |
197 | 0 | if ( msg ) this->msg = std::move(*msg); |
198 | 0 | } |
199 | | |
200 | | |
201 | | } |
202 | | |
203 | | namespace hilti::rt::detail::adl { |
204 | | inline auto to_string(hlt_internal_TFTP_Packet::TFTP::Opcode x, adl::tag) -> std::string; |
205 | | } |
206 | | |
207 | | namespace hlt_internal_TFTP_Packet::TFTP { |
208 | | inline auto operator<<(std::ostream& o, Opcode x) -> std::ostream&; |
209 | | extern auto operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Request& x) -> std::ostream&; |
210 | | extern void _t_hook_Request__t_on_0x25_done(::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Request>& _t_self); |
211 | 317 | Request::Request() { |
212 | 317 | } |
213 | | |
214 | 317 | Request::Request(::hilti::rt::struct_::tag::Parameters, const ::hilti::rt::Bool& _t_p_is_read) : _t_p_is_read(_t_p_is_read) { |
215 | 317 | } |
216 | | |
217 | 0 | Request::Request(::hilti::rt::struct_::tag::Inits, ::hilti::rt::Optional<::hilti::rt::Optional<::hilti::rt::Bytes>> filename, ::hilti::rt::Optional<::hilti::rt::Optional<::hilti::rt::Bytes>> mode) : Request() { |
218 | 0 | if ( filename ) this->filename = std::move(*filename); |
219 | 0 | if ( mode ) this->mode = std::move(*mode); |
220 | 0 | } |
221 | | |
222 | | |
223 | | extern auto operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Packet& x) -> std::ostream&; |
224 | 641 | Packet::Packet() { |
225 | 641 | } |
226 | | |
227 | 0 | Packet::Packet(::hilti::rt::struct_::tag::Inits, ::hilti::rt::Optional<::hilti::rt::Optional<TFTP::Opcode>> op, ::hilti::rt::Optional<::hilti::rt::Optional<hlt_internal_TFTP_Packet::TFTP::Request>> rrq, ::hilti::rt::Optional<::hilti::rt::Optional<hlt_internal_TFTP_Packet::TFTP::Request>> wrq, ::hilti::rt::Optional<::hilti::rt::Optional<hlt_internal_TFTP_Packet::TFTP::Data>> data, ::hilti::rt::Optional<::hilti::rt::Optional<hlt_internal_TFTP_Packet::TFTP::Acknowledgement>> ack, ::hilti::rt::Optional<::hilti::rt::Optional<hlt_internal_TFTP_Packet::TFTP::Error>> error) : Packet() { |
228 | 0 | if ( op ) this->op = std::move(*op); |
229 | 0 | if ( rrq ) this->rrq = std::move(*rrq); |
230 | 0 | if ( wrq ) this->wrq = std::move(*wrq); |
231 | 0 | if ( data ) this->data = std::move(*data); |
232 | 0 | if ( ack ) this->ack = std::move(*ack); |
233 | 0 | if ( error ) this->error = std::move(*error); |
234 | 0 | } |
235 | | |
236 | | |
237 | | } |
238 | | |
239 | | namespace hlt_TFTP_Packet::TFTP::Packet { |
240 | | auto parse1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::Resumable; |
241 | | auto parse2(::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Packet>& _t_unit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::Resumable; |
242 | | auto parse3(::hilti::rt::ValueReference<::spicy::rt::ParsedUnit>& _t_gunit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::Resumable; |
243 | | } |
244 | | |
245 | | namespace spicy::rt { |
246 | | extern void accept_input(); |
247 | | } |
248 | | |
249 | | namespace hlt_internal_TFTP_Packet::TFTP { |
250 | | extern void _t_hook_Request__t_on_0x25_done_5389954716048438864(::hilti::rt::ValueReference<Request>& _t_self); |
251 | | extern void _t_hook_Request__t_on_0x25_done(::hilti::rt::ValueReference<Request>& _t_self); |
252 | | extern void _t_hook_Request__t_on_0x25_done_5389954716048438864(::hilti::rt::ValueReference<Request>& _t_self); |
253 | | extern void _t_register_TFTP_Acknowledgement(); |
254 | | extern void _t_register_TFTP_Data(); |
255 | | extern void _t_register_TFTP_Error(); |
256 | | extern void _t_register_TFTP_Packet(); |
257 | | extern void _t_register_TFTP_Request(); |
258 | | extern void _t_init_module(); |
259 | | extern void _t_register_module(); |
260 | | } |
261 | | |
262 | | namespace hlt_internal_TFTP_Packet::type_info { namespace { |
263 | 0 | const ::hilti::rt::TypeInfo _t_ti_hilti__RecoverableFailure_namex2ahilti__RecoverableFailurex2b = { "hilti::RecoverableFailure", "hilti::RecoverableFailure", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const ::hilti::rt::RecoverableFailure*>(self)); }, new ::hilti::rt::type_info::Exception() }; |
264 | 0 | const ::hilti::rt::TypeInfo _t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b = { {}, "optional<spicy::RecoverableFailure>", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>*>(self)); }, new ::hilti::rt::type_info::Optional(&type_info::_t_ti_hilti__RecoverableFailure_namex2ahilti__RecoverableFailurex2b, ::hilti::rt::type_info::Optional::accessor<::hilti::rt::RecoverableFailure>()) }; |
265 | 0 | const ::hilti::rt::TypeInfo _t_ti_TFTP__Acknowledgement_namex2aTFTP__Acknowledgementx2b = { "TFTP::Acknowledgement", "TFTP::Acknowledgement", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const hlt_internal_TFTP_Packet::TFTP::Acknowledgement*>(self)); }, new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "num", &::hilti::rt::type_info::uint16, std::ptrdiff_t{-1}, false, false, false }, ::hilti::rt::type_info::struct_::Field{ "_t_error", &type_info::_t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Acknowledgement, _t_error)), true, false, true }})) }; |
266 | 0 | const ::hilti::rt::TypeInfo _t_ti_TFTP__Data_namex2aTFTP__Datax2b = { "TFTP::Data", "TFTP::Data", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const hlt_internal_TFTP_Packet::TFTP::Data*>(self)); }, new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "num", &::hilti::rt::type_info::uint16, std::ptrdiff_t{-1}, false, false, false }, ::hilti::rt::type_info::struct_::Field{ "data", &::hilti::rt::type_info::bytes, std::ptrdiff_t{-1}, false, false, false }, ::hilti::rt::type_info::struct_::Field{ "_t_error", &type_info::_t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Data, _t_error)), true, false, true }})) }; |
267 | 0 | const ::hilti::rt::TypeInfo _t_ti_TFTP__Error_namex2aTFTP__Errorx2b = { "TFTP::Error", "TFTP::Error", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const hlt_internal_TFTP_Packet::TFTP::Error*>(self)); }, new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "code", &::hilti::rt::type_info::uint16, std::ptrdiff_t{-1}, false, false, false }, ::hilti::rt::type_info::struct_::Field{ "msg", &::hilti::rt::type_info::bytes, static_cast<std::ptrdiff_t>(offsetof(TFTP::Error, msg)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<::hilti::rt::Bytes>() }, ::hilti::rt::type_info::struct_::Field{ "_t_error", &type_info::_t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Error, _t_error)), true, false, true }})) }; |
268 | 0 | const ::hilti::rt::TypeInfo _t_ti_TFTP__Opcode_namex2aTFTP__Opcodex2b = { "TFTP::Opcode", "TFTP::Opcode", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const TFTP::Opcode*>(self)); }, new ::hilti::rt::type_info::Enum(std::vector<::hilti::rt::type_info::enum_::Label>({::hilti::rt::type_info::enum_::Label{ "RRQ", 1 }, ::hilti::rt::type_info::enum_::Label{ "WRQ", 2 }, ::hilti::rt::type_info::enum_::Label{ "DATA", 3 }, ::hilti::rt::type_info::enum_::Label{ "ACK", 4 }, ::hilti::rt::type_info::enum_::Label{ "ERROR", 5 }, ::hilti::rt::type_info::enum_::Label{ "Undef", -1 }})) }; |
269 | 0 | const ::hilti::rt::TypeInfo _t_ti_TFTP__Request_namex2aTFTP__Requestx2b = { "TFTP::Request", "TFTP::Request", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const hlt_internal_TFTP_Packet::TFTP::Request*>(self)); }, new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "filename", &::hilti::rt::type_info::bytes, static_cast<std::ptrdiff_t>(offsetof(TFTP::Request, filename)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<::hilti::rt::Bytes>() }, ::hilti::rt::type_info::struct_::Field{ "mode", &::hilti::rt::type_info::bytes, static_cast<std::ptrdiff_t>(offsetof(TFTP::Request, mode)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<::hilti::rt::Bytes>() }, ::hilti::rt::type_info::struct_::Field{ "_t_error", &type_info::_t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Request, _t_error)), true, false, true }})) }; |
270 | 0 | const ::hilti::rt::TypeInfo _t_ti_TFTP__Packet_namex2aTFTP__Packetx2b = { "TFTP::Packet", "TFTP::Packet", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const hlt_internal_TFTP_Packet::TFTP::Packet*>(self)); }, new ::hilti::rt::type_info::Struct(std::vector<::hilti::rt::type_info::struct_::Field>({::hilti::rt::type_info::struct_::Field{ "op", &type_info::_t_ti_TFTP__Opcode_namex2aTFTP__Opcodex2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, op)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<TFTP::Opcode>() }, ::hilti::rt::type_info::struct_::Field{ "rrq", &type_info::_t_ti_TFTP__Request_namex2aTFTP__Requestx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, rrq)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<hlt_internal_TFTP_Packet::TFTP::Request>() }, ::hilti::rt::type_info::struct_::Field{ "wrq", &type_info::_t_ti_TFTP__Request_namex2aTFTP__Requestx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, wrq)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<hlt_internal_TFTP_Packet::TFTP::Request>() }, ::hilti::rt::type_info::struct_::Field{ "data", &type_info::_t_ti_TFTP__Data_namex2aTFTP__Datax2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, data)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<hlt_internal_TFTP_Packet::TFTP::Data>() }, ::hilti::rt::type_info::struct_::Field{ "ack", &type_info::_t_ti_TFTP__Acknowledgement_namex2aTFTP__Acknowledgementx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, ack)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<hlt_internal_TFTP_Packet::TFTP::Acknowledgement>() }, ::hilti::rt::type_info::struct_::Field{ "error", &type_info::_t_ti_TFTP__Error_namex2aTFTP__Errorx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, error)), false, false, true, ::hilti::rt::type_info::struct_::Field::accessor_optional<hlt_internal_TFTP_Packet::TFTP::Error>() }, ::hilti::rt::type_info::struct_::Field{ "_t_error", &type_info::_t_ti_optional_spicy__RecoverableFailure__optionalx2anamex2ahilti__RecoverableFailurex2bx2b, static_cast<std::ptrdiff_t>(offsetof(TFTP::Packet, _t_error)), true, false, true }})) }; |
271 | 0 | const ::hilti::rt::TypeInfo _t_ti_value_ref_TFTP__Packet__value_refx2anamex2aTFTP__Packetx2bx2b = { {}, "value_ref<TFTP::Packet>", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const ::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Packet>*>(self)); }, new ::hilti::rt::type_info::ValueReference(&type_info::_t_ti_TFTP__Packet_namex2aTFTP__Packetx2b, ::hilti::rt::type_info::ValueReference::accessor<hlt_internal_TFTP_Packet::TFTP::Packet>()) }; |
272 | 0 | const ::hilti::rt::TypeInfo _t_ti_strong_ref_const_TFTP__Packet__strong_refx2anamex2aTFTP__Packetx2bx2b = { {}, "strong_ref<const TFTP::Packet>", [](const void *self) { return hilti::rt::to_string(*reinterpret_cast<const ::hilti::rt::StrongReference<hlt_internal_TFTP_Packet::TFTP::Packet>*>(self)); }, new ::hilti::rt::type_info::StrongReference(&type_info::_t_ti_TFTP__Packet_namex2aTFTP__Packetx2b, ::hilti::rt::type_info::StrongReference::accessor<hlt_internal_TFTP_Packet::TFTP::Packet>()) }; |
273 | | } } |
274 | | |
275 | | HILTI_PRE_INIT(hlt_internal_TFTP_Packet::TFTP::_t_register_module) |
276 | | |
277 | 0 | inline auto ::hilti::rt::detail::adl::to_string(hlt_internal_TFTP_Packet::TFTP::Opcode x, adl::tag) -> std::string { |
278 | 0 | switch ( x.value() ) { |
279 | 0 | case hlt_internal_TFTP_Packet::TFTP::Opcode::ERROR: return "Opcode::ERROR"; |
280 | 0 | case hlt_internal_TFTP_Packet::TFTP::Opcode::ACK: return "Opcode::ACK"; |
281 | 0 | case hlt_internal_TFTP_Packet::TFTP::Opcode::DATA: return "Opcode::DATA"; |
282 | 0 | case hlt_internal_TFTP_Packet::TFTP::Opcode::WRQ: return "Opcode::WRQ"; |
283 | 0 | case hlt_internal_TFTP_Packet::TFTP::Opcode::RRQ: return "Opcode::RRQ"; |
284 | 0 | case hlt_internal_TFTP_Packet::TFTP::Opcode::Undef: return "Opcode::Undef"; |
285 | 0 | default: return ::hilti::rt::fmt("Opcode::<unknown-%" PRIu64 ">", x.value()); |
286 | 0 | } |
287 | 0 | } |
288 | | |
289 | 641 | auto hlt_TFTP_Packet::TFTP::Packet::parse1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::Resumable { |
290 | 641 | auto args = std::make_tuple(::hilti::rt::resumable::detail::copyArg(_t_data), ::hilti::rt::resumable::detail::copyArg(_t_cur), ::hilti::rt::resumable::detail::copyArg(_t_context)); |
291 | 641 | auto args_on_heap = std::make_shared<decltype(args)>(std::move(args)); |
292 | 641 | auto cb = [args_on_heap = std::move(args_on_heap)](::hilti::rt::resumable::Handle* r) -> ::hilti::rt::any { |
293 | 641 | return hlt_internal_TFTP_Packet::TFTP::Packet::parse1(std::get<0>(*args_on_heap), std::get<1>(*args_on_heap), std::get<2>(*args_on_heap)); |
294 | 641 | }; |
295 | | |
296 | 641 | auto r = std::make_unique<::hilti::rt::Resumable>(std::move(cb)); |
297 | 641 | r->run(); |
298 | 641 | return std::move(*r); |
299 | 641 | } |
300 | | |
301 | 0 | auto hlt_TFTP_Packet::TFTP::Packet::parse2(::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Packet>& _t_unit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::Resumable { |
302 | 0 | auto args = std::make_tuple(::hilti::rt::resumable::detail::copyArg(_t_unit), ::hilti::rt::resumable::detail::copyArg(_t_data), ::hilti::rt::resumable::detail::copyArg(_t_cur), ::hilti::rt::resumable::detail::copyArg(_t_context)); |
303 | 0 | auto args_on_heap = std::make_shared<decltype(args)>(std::move(args)); |
304 | 0 | auto cb = [args_on_heap = std::move(args_on_heap)](::hilti::rt::resumable::Handle* r) -> ::hilti::rt::any { |
305 | 0 | return hlt_internal_TFTP_Packet::TFTP::Packet::parse2(std::get<0>(*args_on_heap), std::get<1>(*args_on_heap), std::get<2>(*args_on_heap), std::get<3>(*args_on_heap)); |
306 | 0 | }; |
307 | |
|
308 | 0 | auto r = std::make_unique<::hilti::rt::Resumable>(std::move(cb)); |
309 | 0 | r->run(); |
310 | 0 | return std::move(*r); |
311 | 0 | } |
312 | | |
313 | 0 | auto hlt_TFTP_Packet::TFTP::Packet::parse3(::hilti::rt::ValueReference<::spicy::rt::ParsedUnit>& _t_gunit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::Resumable { |
314 | 0 | auto args = std::make_tuple(::hilti::rt::resumable::detail::copyArg(_t_gunit), ::hilti::rt::resumable::detail::copyArg(_t_data), ::hilti::rt::resumable::detail::copyArg(_t_cur), ::hilti::rt::resumable::detail::copyArg(_t_context)); |
315 | 0 | auto args_on_heap = std::make_shared<decltype(args)>(std::move(args)); |
316 | 0 | auto cb = [args_on_heap = std::move(args_on_heap)](::hilti::rt::resumable::Handle* r) -> ::hilti::rt::any { |
317 | 0 | return hlt_internal_TFTP_Packet::TFTP::Packet::parse3(std::get<0>(*args_on_heap), std::get<1>(*args_on_heap), std::get<2>(*args_on_heap), std::get<3>(*args_on_heap)); |
318 | 0 | }; |
319 | |
|
320 | 0 | auto r = std::make_unique<::hilti::rt::Resumable>(std::move(cb)); |
321 | 0 | r->run(); |
322 | 0 | return std::move(*r); |
323 | 0 | } |
324 | | |
325 | 58 | auto hlt_internal_TFTP_Packet::TFTP::Acknowledgement::_t_parse_TFTP__Acknowledgement_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View { |
326 | 58 | auto _t_self = Acknowledgement::_t_self(); |
327 | 58 | ::hilti::rt::detail::checkStack(); |
328 | 58 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:91:24-93:1"); |
329 | 58 | ::hilti::rt::integer::safe<uint16_t> _t_v_num; |
330 | 58 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:92:10-92:15"); |
331 | | |
332 | | // Begin parsing production: Variable: num_4 -> uint<16>; |
333 | 58 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, ::hilti::rt::integer::safe<std::uint64_t>{2U}, "expecting 2 bytes for unpacking value"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:92:10-92:15"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
334 | 58 | ::hilti::rt::tuple::assign(std::tie(_t_v_num, _t_cur), ::hilti::rt::integer::unpack<uint16_t>(_t_cur, ::hilti::rt::ByteOrder{::hilti::rt::ByteOrder::Network}).valueOrThrow()); |
335 | 58 | if ( _t_trim ) { |
336 | 55 | (*_t_data).trim(_t_cur.begin()); |
337 | 55 | } |
338 | | |
339 | | // End parsing production: Variable: num_4 -> uint<16>; |
340 | | |
341 | 58 | ::hilti::rt::debug::dedent("spicy"sv); |
342 | 58 | return _t_cur; |
343 | 58 | } |
344 | | |
345 | 58 | auto hlt_internal_TFTP_Packet::TFTP::Acknowledgement::_t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View { |
346 | 58 | auto _t_self = Acknowledgement::_t_self(); |
347 | 58 | ::hilti::rt::detail::checkStack(); |
348 | 58 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:91:24-93:1"); |
349 | 58 | ::hilti::rt::debug::indent("spicy"sv); |
350 | 58 | ::hilti::rt::stream::SafeConstIterator _t_begin_ = _t_cur.begin(); |
351 | 58 | return (*_t_self)._t_parse_TFTP__Acknowledgement_2_stage2(_t_data, _t_cur, _t_trim); |
352 | 58 | } |
353 | | |
354 | 93 | auto hlt_internal_TFTP_Packet::TFTP::Data::_t_parse_TFTP__Data_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View { |
355 | 93 | ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters> _t_lhs_1; |
356 | 93 | auto _t_self = Data::_t_self(); |
357 | 93 | ::hilti::rt::detail::checkStack(); |
358 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:79:13-82:1"); |
359 | 93 | ::hilti::rt::integer::safe<uint16_t> _t_v_num; |
360 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:80:10-80:15"); |
361 | | |
362 | | // Begin parsing production: Variable: num_3 -> uint<16>; |
363 | 93 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, ::hilti::rt::integer::safe<std::uint64_t>{2U}, "expecting 2 bytes for unpacking value"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:80:10-80:15"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
364 | 93 | ::hilti::rt::tuple::assign(std::tie(_t_v_num, _t_cur), ::hilti::rt::integer::unpack<uint16_t>(_t_cur, ::hilti::rt::ByteOrder{::hilti::rt::ByteOrder::Network}).valueOrThrow()); |
365 | 93 | if ( _t_trim ) { |
366 | 90 | (*_t_data).trim(_t_cur.begin()); |
367 | 90 | } |
368 | | |
369 | | // End parsing production: Variable: num_3 -> uint<16>; |
370 | | |
371 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:81:11-81:15"); |
372 | | |
373 | | // Begin parsing production: Variable: data_2 -> bytes; |
374 | 93 | ::spicy::rt::detail::waitForEod(_t_data, _t_cur, (_t_lhs_1=(::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}))); |
375 | 93 | _t_cur = _t_cur.advance(_t_cur.size()); |
376 | 93 | if ( _t_trim ) { |
377 | 0 | (*_t_data).trim(_t_cur.begin()); |
378 | 0 | } |
379 | | |
380 | 93 | if ( _t_trim ) { |
381 | 0 | (*_t_data).trim(_t_cur.begin()); |
382 | 0 | } |
383 | | |
384 | | // End parsing production: Variable: data_2 -> bytes; |
385 | | |
386 | 93 | ::hilti::rt::debug::dedent("spicy"sv); |
387 | 93 | return _t_cur; |
388 | 93 | } |
389 | | |
390 | 93 | auto hlt_internal_TFTP_Packet::TFTP::Data::_t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View { |
391 | 93 | auto _t_self = Data::_t_self(); |
392 | 93 | ::hilti::rt::detail::checkStack(); |
393 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:79:13-82:1"); |
394 | 93 | ::hilti::rt::debug::indent("spicy"sv); |
395 | 93 | ::hilti::rt::stream::SafeConstIterator _t_begin_ = _t_cur.begin(); |
396 | 93 | return (*_t_self)._t_parse_TFTP__Data_2_stage2(_t_data, _t_cur, _t_trim); |
397 | 93 | } |
398 | | |
399 | 158 | auto hlt_internal_TFTP_Packet::TFTP::Error::_t_parse_TFTP__Error_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View { |
400 | 158 | auto _t_self = Error::_t_self(); |
401 | 158 | ::hilti::rt::detail::checkStack(); |
402 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:102:14-105:1"); |
403 | 158 | ::hilti::rt::integer::safe<uint16_t> _t_v_code; |
404 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:103:11-103:16"); |
405 | | |
406 | | // Begin parsing production: Variable: code_2 -> uint<16>; |
407 | 158 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, ::hilti::rt::integer::safe<std::uint64_t>{2U}, "expecting 2 bytes for unpacking value"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:103:11-103:16"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
408 | 158 | ::hilti::rt::tuple::assign(std::tie(_t_v_code, _t_cur), ::hilti::rt::integer::unpack<uint16_t>(_t_cur, ::hilti::rt::ByteOrder{::hilti::rt::ByteOrder::Network}).valueOrThrow()); |
409 | 158 | if ( _t_trim ) { |
410 | 155 | (*_t_data).trim(_t_cur.begin()); |
411 | 155 | } |
412 | | |
413 | | // End parsing production: Variable: code_2 -> uint<16>; |
414 | | |
415 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:104:10-104:14"); |
416 | | |
417 | | // Begin parsing production: Variable: msg_2 -> bytes; |
418 | 158 | ::hilti::rt::Bytes _t_until_bytes = "\000"_b; |
419 | 158 | ::hilti::rt::integer::safe<uint64_t> _t_until_bytes_sz = "\000"_b.size(); |
420 | 158 | (*_t_self).msg.valueOrInit() = ""_b; |
421 | 210 | while ( ::hilti::rt::Bool{true} ) { |
422 | 180 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, _t_until_bytes_sz, "end-of-data reached before &until expression found"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:104:23-104:29"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
423 | 180 | ::hilti::rt::Bool found; |
424 | 180 | ::hilti::rt::stream::SafeConstIterator it; |
425 | 180 | ::hilti::rt::tuple::assign(std::tie(found, it), _t_cur.find(_t_until_bytes)); |
426 | 180 | if ( ::hilti::rt::Bool{static_cast<bool>(_t_cur.sub(it).size())} ) { |
427 | 123 | (*_t_self).msg.value().append(_t_cur.sub(it)); |
428 | 123 | } |
429 | | |
430 | 180 | if ( found ) { |
431 | 128 | _t_cur = _t_cur.advance(it + _t_until_bytes_sz); |
432 | 128 | if ( _t_trim ) { |
433 | 128 | (*_t_data).trim(_t_cur.begin()); |
434 | 128 | } |
435 | | |
436 | 128 | goto _t_done_37992; |
437 | 128 | } |
438 | 52 | else { |
439 | 52 | _t_cur = _t_cur.advance(it); |
440 | 52 | if ( _t_trim ) { |
441 | 25 | (*_t_data).trim(_t_cur.begin()); |
442 | 25 | } |
443 | 52 | } |
444 | 180 | } |
445 | | |
446 | 128 | _t_done_37992: {} |
447 | | |
448 | 128 | if ( _t_trim ) { |
449 | 128 | (*_t_data).trim(_t_cur.begin()); |
450 | 128 | } |
451 | | |
452 | | // End parsing production: Variable: msg_2 -> bytes; |
453 | | |
454 | 128 | ::hilti::rt::debug::dedent("spicy"sv); |
455 | 128 | return _t_cur; |
456 | 158 | } |
457 | | |
458 | 158 | auto hlt_internal_TFTP_Packet::TFTP::Error::_t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim) -> ::hilti::rt::stream::View { |
459 | 158 | auto _t_self = Error::_t_self(); |
460 | 158 | ::hilti::rt::detail::checkStack(); |
461 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:102:14-105:1"); |
462 | 158 | ::hilti::rt::debug::indent("spicy"sv); |
463 | 158 | ::hilti::rt::stream::SafeConstIterator _t_begin_ = _t_cur.begin(); |
464 | 158 | return (*_t_self)._t_parse_TFTP__Error_2_stage2(_t_data, _t_cur, _t_trim); |
465 | 158 | } |
466 | | |
467 | 641 | auto hlt_internal_TFTP_Packet::TFTP::Packet::_t_parse_TFTP__Packet_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, ::hilti::rt::Bool _t_trim, const ::hilti::rt::integer::safe<int64_t>& _t_lah, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::integer::safe<int64_t>, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>> { |
468 | 641 | auto _t_self = Packet::_t_self(); |
469 | 641 | ::hilti::rt::detail::checkStack(); |
470 | 641 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
471 | 641 | TFTP::Opcode _t_v_op = TFTP::Opcode::Undef; |
472 | 641 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:20:9-20:14"); |
473 | 641 | ::hilti::rt::integer::safe<uint16_t> _t_parsed_op; |
474 | | |
475 | | // Begin parsing production: Variable: op -> uint<16>; |
476 | 641 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, ::hilti::rt::integer::safe<std::uint64_t>{2U}, "expecting 2 bytes for unpacking value"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:20:9-20:14"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
477 | 641 | ::hilti::rt::tuple::assign(std::tie(_t_parsed_op, _t_cur), ::hilti::rt::integer::unpack<uint16_t>(_t_cur, ::hilti::rt::ByteOrder{::hilti::rt::ByteOrder::Network}).valueOrThrow()); |
478 | 641 | if ( _t_trim ) { |
479 | 634 | (*_t_data).trim(_t_cur.begin()); |
480 | 634 | } |
481 | | |
482 | | // End parsing production: Variable: op -> uint<16>; |
483 | | |
484 | 641 | _t_v_op = TFTP::Opcode{::hilti::rt::detail::move_non_trivial(_t_parsed_op)}; |
485 | 641 | (*_t_self).op.valueOrInit() = ::hilti::rt::detail::move_non_trivial(_t_v_op); |
486 | 641 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:21:5-30:6"); |
487 | | |
488 | | // Begin parsing production: Switch: switch -> [Opcode::RRQ] -> switch_case_1 | [Opcode::WRQ] -> switch_case_2 | [Opcode::DATA] -> switch_case_3 | [Opcode::ACK] -> switch_case_4 | [Opcode::ERROR] -> switch_case_5 | | * -> switch_default; |
489 | 641 | ::hilti::rt::tuple::assign(std::tie(_t_cur, _t_error), (*_t_self)._t_parse_switch_stage1(_t_data, _t_cur, _t_trim, _t_error)); |
490 | | // End parsing production: Switch: switch -> [Opcode::RRQ] -> switch_case_1 | [Opcode::WRQ] -> switch_case_2 | [Opcode::DATA] -> switch_case_3 | [Opcode::ACK] -> switch_case_4 | [Opcode::ERROR] -> switch_case_5 | | * -> switch_default; |
491 | | |
492 | 641 | ::hilti::rt::debug::dedent("spicy"sv); |
493 | 641 | return ::hilti::rt::tuple::make_from_optionals(::hilti::rt::optional::make(_t_cur), ::hilti::rt::optional::make(_t_lah), ::hilti::rt::optional::make(_t_error)); |
494 | 641 | } |
495 | | |
496 | 641 | auto hlt_internal_TFTP_Packet::TFTP::Packet::_t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim, const ::hilti::rt::integer::safe<int64_t>& _t_lah, const ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>& _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::integer::safe<int64_t>, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>> { |
497 | 641 | auto _t_self = Packet::_t_self(); |
498 | 641 | ::hilti::rt::detail::checkStack(); |
499 | 641 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
500 | 641 | ::hilti::rt::debug::indent("spicy"sv); |
501 | 641 | ::hilti::rt::stream::SafeConstIterator _t_begin_ = _t_cur.begin(); |
502 | 641 | return (*_t_self)._t_parse_TFTP__Packet_stage2(_t_data, _t_cur, _t_trim, _t_lah, _t_error); |
503 | 641 | } |
504 | | |
505 | 634 | auto hlt_internal_TFTP_Packet::TFTP::Packet::_t_parse_switch_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, ::hilti::rt::Bool _t_trim, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>> { |
506 | 634 | auto _t_self = Packet::_t_self(); |
507 | 634 | ::hilti::rt::detail::checkStack(); |
508 | 634 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:21:5-30:6"); |
509 | 634 | ::hilti::rt::debug::indent("spicy"sv); |
510 | 634 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:21:5-30:6"); |
511 | 634 | switch ( auto _t_x = (*_t_self).op.value(); (_t_x).value() ) { |
512 | 208 | case (TFTP::Opcode{TFTP::Opcode::RRQ}).value(): { |
513 | 208 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:22:9-22:42"); |
514 | 208 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:22:9-22:42"); |
515 | | |
516 | | // Begin parsing production: Block: switch_case_1 -> Resolved_2; |
517 | 208 | ::hilti::rt::debug::indent("spicy"sv); |
518 | 208 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:63:16-70:1"); |
519 | | |
520 | | // Begin parsing production: Unit: TFTP__Request -> filename mode (field 'rrq', id n/a, parser, args: (True)); |
521 | 208 | (*_t_self).rrq.valueOrInit() = (hlt_internal_TFTP_Packet::TFTP::Request{::hilti::rt::struct_::tag::Parameters(), ::hilti::rt::Bool{true}}); |
522 | 208 | ::hilti::rt::tuple::assign(std::tie(_t_cur, _t_error), (*_t_self).rrq.value()._t_parse_stage1(_t_data, _t_cur, _t_trim, _t_error)); |
523 | | // End parsing production: Unit: TFTP__Request -> filename mode (field 'rrq', id n/a, parser, args: (True)); |
524 | | |
525 | 208 | ::hilti::rt::debug::dedent("spicy"sv); |
526 | | // End parsing production: Block: switch_case_1 -> Resolved_2; |
527 | | |
528 | 208 | break; |
529 | 0 | } |
530 | 109 | case (TFTP::Opcode{TFTP::Opcode::WRQ}).value(): { |
531 | 109 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:23:9-23:43"); |
532 | 109 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:23:9-23:43"); |
533 | | |
534 | | // Begin parsing production: Block: switch_case_2 -> Resolved_2; |
535 | 109 | ::hilti::rt::debug::indent("spicy"sv); |
536 | 109 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:63:16-70:1"); |
537 | | |
538 | | // Begin parsing production: Unit: TFTP__Request -> filename mode (field 'rrq', id n/a, parser, args: (True)); |
539 | 109 | (*_t_self).wrq.valueOrInit() = (hlt_internal_TFTP_Packet::TFTP::Request{::hilti::rt::struct_::tag::Parameters(), ::hilti::rt::Bool{false}}); |
540 | 109 | ::hilti::rt::tuple::assign(std::tie(_t_cur, _t_error), (*_t_self).wrq.value()._t_parse_stage1(_t_data, _t_cur, _t_trim, _t_error)); |
541 | | // End parsing production: Unit: TFTP__Request -> filename mode (field 'rrq', id n/a, parser, args: (True)); |
542 | | |
543 | 109 | ::hilti::rt::debug::dedent("spicy"sv); |
544 | | // End parsing production: Block: switch_case_2 -> Resolved_2; |
545 | | |
546 | 109 | break; |
547 | 0 | } |
548 | 93 | case (TFTP::Opcode{TFTP::Opcode::DATA}).value(): { |
549 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:24:9-24:35"); |
550 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:24:9-24:35"); |
551 | | |
552 | | // Begin parsing production: Block: switch_case_3 -> Resolved_3; |
553 | 93 | ::hilti::rt::debug::indent("spicy"sv); |
554 | 93 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:79:13-82:1"); |
555 | | |
556 | | // Begin parsing production: Unit: TFTP__Data -> num data; |
557 | 93 | (*_t_self).data.valueOrInit() = (hlt_internal_TFTP_Packet::TFTP::Data{}); |
558 | 93 | _t_cur = (*_t_self).data.value()._t_parse_stage1(_t_data, _t_cur, _t_trim); |
559 | | // End parsing production: Unit: TFTP__Data -> num data; |
560 | | |
561 | 93 | ::hilti::rt::debug::dedent("spicy"sv); |
562 | | // End parsing production: Block: switch_case_3 -> Resolved_3; |
563 | | |
564 | 93 | break; |
565 | 0 | } |
566 | 58 | case (TFTP::Opcode{TFTP::Opcode::ACK}).value(): { |
567 | 58 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:25:9-25:44"); |
568 | 58 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:25:9-25:44"); |
569 | | |
570 | | // Begin parsing production: Block: switch_case_4 -> Resolved_4; |
571 | 58 | ::hilti::rt::debug::indent("spicy"sv); |
572 | 58 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:91:24-93:1"); |
573 | | |
574 | | // Begin parsing production: Unit: TFTP__Acknowledgement -> num_2; |
575 | 58 | (*_t_self).ack.valueOrInit() = (hlt_internal_TFTP_Packet::TFTP::Acknowledgement{}); |
576 | 58 | _t_cur = (*_t_self).ack.value()._t_parse_stage1(_t_data, _t_cur, _t_trim); |
577 | | // End parsing production: Unit: TFTP__Acknowledgement -> num_2; |
578 | | |
579 | 58 | ::hilti::rt::debug::dedent("spicy"sv); |
580 | | // End parsing production: Block: switch_case_4 -> Resolved_4; |
581 | | |
582 | 58 | break; |
583 | 0 | } |
584 | 158 | case (TFTP::Opcode{TFTP::Opcode::ERROR}).value(): { |
585 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:26:9-26:38"); |
586 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:26:9-26:38"); |
587 | | |
588 | | // Begin parsing production: Block: switch_case_5 -> Resolved_5; |
589 | 158 | ::hilti::rt::debug::indent("spicy"sv); |
590 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:102:14-105:1"); |
591 | | |
592 | | // Begin parsing production: Unit: TFTP__Error -> code msg; |
593 | 158 | (*_t_self).error.valueOrInit() = (hlt_internal_TFTP_Packet::TFTP::Error{}); |
594 | 158 | _t_cur = (*_t_self).error.value()._t_parse_stage1(_t_data, _t_cur, _t_trim); |
595 | | // End parsing production: Unit: TFTP__Error -> code msg; |
596 | | |
597 | 158 | ::hilti::rt::debug::dedent("spicy"sv); |
598 | | // End parsing production: Block: switch_case_5 -> Resolved_5; |
599 | | |
600 | 158 | break; |
601 | 0 | } |
602 | 8 | default: { |
603 | 8 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:29:9-29:20"); |
604 | 8 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:29:9-29:20"); |
605 | | |
606 | | // Begin parsing production: Block: switch_default -> <epsilon>; |
607 | 8 | ::hilti::rt::debug::indent("spicy"sv); |
608 | 8 | ::hilti::rt::location("<no location>"); |
609 | | |
610 | | // Begin parsing production: Epsilon: <epsilon> -> (); |
611 | | // End parsing production: Epsilon: <epsilon> -> (); |
612 | | |
613 | 8 | ::hilti::rt::debug::dedent("spicy"sv); |
614 | | // End parsing production: Block: switch_default -> <epsilon>; |
615 | 8 | } |
616 | 634 | } |
617 | 349 | ::hilti::rt::debug::dedent("spicy"sv); |
618 | 349 | return ::hilti::rt::tuple::make_from_optionals(::hilti::rt::optional::make(_t_cur), ::hilti::rt::optional::make(_t_error)); |
619 | 634 | } |
620 | | |
621 | 641 | auto hlt_internal_TFTP_Packet::TFTP::Packet::parse1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::stream::View { |
622 | 641 | ::hilti::rt::detail::checkStack(); |
623 | 641 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
624 | 641 | ::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Packet> _t_unit = ::hilti::rt::reference::make_value<hlt_internal_TFTP_Packet::TFTP::Packet>((hlt_internal_TFTP_Packet::TFTP::Packet{})); |
625 | 641 | ::hilti::rt::stream::View _t_ncur = (_t_cur ? _t_cur.value() : (*_t_data).view()); |
626 | 641 | ::hilti::rt::integer::safe<int64_t> _t_lahead = ::hilti::rt::integer::safe<std::int64_t>{0}; |
627 | 641 | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error = ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>{}; |
628 | 641 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
629 | | |
630 | | // Begin parsing production: Unit: TFTP__Packet -> op switch; |
631 | 641 | ::hilti::rt::tuple::assign(std::tie(_t_ncur, _t_lahead, _t_error), (*::hilti::rt::detail::move_non_trivial(_t_unit))._t_parse_stage1(_t_data, _t_ncur, ::hilti::rt::Bool{true}, ::hilti::rt::detail::move_non_trivial(_t_lahead), _t_error)); |
632 | | // End parsing production: Unit: TFTP__Packet -> op switch; |
633 | | |
634 | 641 | if ( _t_error.hasValue() ) { |
635 | 0 | throw ::spicy::rt::ParseError{::hilti::rt::fmt("successful synchronization never confirmed: %s"sv, ::hilti::rt::exception::what(_t_error.value())), ::hilti::rt::exception::where(_t_error.value())}; |
636 | 0 | } |
637 | | |
638 | 641 | return _t_ncur; |
639 | 641 | } |
640 | | |
641 | 0 | auto hlt_internal_TFTP_Packet::TFTP::Packet::parse2(::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Packet>& _t_unit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::stream::View { |
642 | 0 | ::hilti::rt::detail::checkStack(); |
643 | 0 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
644 | 0 | ::hilti::rt::stream::View _t_ncur = (_t_cur ? _t_cur.value() : (*_t_data).view()); |
645 | 0 | ::hilti::rt::integer::safe<int64_t> _t_lahead = ::hilti::rt::integer::safe<std::int64_t>{0}; |
646 | 0 | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error = ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>{}; |
647 | 0 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
648 | | |
649 | | // Begin parsing production: Unit: TFTP__Packet -> op switch; |
650 | 0 | ::hilti::rt::tuple::assign(std::tie(_t_ncur, _t_lahead, _t_error), (*_t_unit)._t_parse_stage1(_t_data, _t_ncur, ::hilti::rt::Bool{true}, ::hilti::rt::detail::move_non_trivial(_t_lahead), _t_error)); |
651 | | // End parsing production: Unit: TFTP__Packet -> op switch; |
652 | |
|
653 | 0 | if ( _t_error.hasValue() ) { |
654 | 0 | throw ::spicy::rt::ParseError{::hilti::rt::fmt("successful synchronization never confirmed: %s"sv, ::hilti::rt::exception::what(_t_error.value())), ::hilti::rt::exception::where(_t_error.value())}; |
655 | 0 | } |
656 | | |
657 | 0 | return _t_ncur; |
658 | 0 | } |
659 | | |
660 | 0 | auto hlt_internal_TFTP_Packet::TFTP::Packet::parse3(::hilti::rt::ValueReference<::spicy::rt::ParsedUnit>& _t_gunit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::Optional<::hilti::rt::stream::View>& _t_cur, const ::hilti::rt::Optional<::spicy::rt::UnitContext>& _t_context) -> ::hilti::rt::stream::View { |
661 | 0 | ::hilti::rt::detail::checkStack(); |
662 | 0 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
663 | 0 | ::hilti::rt::ValueReference<hlt_internal_TFTP_Packet::TFTP::Packet> _t_unit = ::hilti::rt::reference::make_value<hlt_internal_TFTP_Packet::TFTP::Packet>((hlt_internal_TFTP_Packet::TFTP::Packet{})); |
664 | 0 | ::spicy::rt::ParsedUnit::initialize((*_t_gunit), _t_unit, &type_info::_t_ti_value_ref_TFTP__Packet__value_refx2anamex2aTFTP__Packetx2bx2b); |
665 | 0 | ::hilti::rt::stream::View _t_ncur = (_t_cur ? _t_cur.value() : (*_t_data).view()); |
666 | 0 | ::hilti::rt::integer::safe<int64_t> _t_lahead = ::hilti::rt::integer::safe<std::int64_t>{0}; |
667 | 0 | ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error = ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>{}; |
668 | 0 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:18:22-31:1"); |
669 | | |
670 | | // Begin parsing production: Unit: TFTP__Packet -> op switch; |
671 | 0 | ::hilti::rt::tuple::assign(std::tie(_t_ncur, _t_lahead, _t_error), (*::hilti::rt::detail::move_non_trivial(_t_unit))._t_parse_stage1(_t_data, _t_ncur, ::hilti::rt::Bool{true}, ::hilti::rt::detail::move_non_trivial(_t_lahead), _t_error)); |
672 | | // End parsing production: Unit: TFTP__Packet -> op switch; |
673 | |
|
674 | 0 | if ( _t_error.hasValue() ) { |
675 | 0 | throw ::spicy::rt::ParseError{::hilti::rt::fmt("successful synchronization never confirmed: %s"sv, ::hilti::rt::exception::what(_t_error.value())), ::hilti::rt::exception::where(_t_error.value())}; |
676 | 0 | } |
677 | | |
678 | 0 | return _t_ncur; |
679 | 0 | } |
680 | | |
681 | 158 | inline void hlt_internal_TFTP_Packet::TFTP::Request::_t_on_0x25_done() { |
682 | 158 | auto _t_self = TFTP::Request::_t_self(); |
683 | 158 | return hlt_internal_TFTP_Packet::TFTP::_t_hook_Request__t_on_0x25_done(_t_self); |
684 | 158 | } |
685 | | |
686 | 317 | auto hlt_internal_TFTP_Packet::TFTP::Request::_t_parse_TFTP__Request_2_stage2(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, ::hilti::rt::stream::View _t_cur, const ::hilti::rt::Bool& _t_trim, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure> _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>> { |
687 | 317 | auto _t_self = Request::_t_self(); |
688 | 317 | ::hilti::rt::detail::checkStack(); |
689 | 317 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:63:16-70:1"); |
690 | 317 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:64:15-64:19"); |
691 | | |
692 | | // Begin parsing production: Variable: filename_2 -> bytes; |
693 | 317 | ::hilti::rt::Bytes _t_until_bytes = "\000"_b; |
694 | 317 | ::hilti::rt::integer::safe<uint64_t> _t_until_bytes_sz = "\000"_b.size(); |
695 | 317 | (*_t_self).filename.valueOrInit() = ""_b; |
696 | 429 | while ( ::hilti::rt::Bool{true} ) { |
697 | 372 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, _t_until_bytes_sz, "end-of-data reached before &until expression found"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:64:28-64:34"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
698 | 372 | ::hilti::rt::Bool found; |
699 | 372 | ::hilti::rt::stream::SafeConstIterator it; |
700 | 372 | ::hilti::rt::tuple::assign(std::tie(found, it), _t_cur.find(_t_until_bytes)); |
701 | 372 | if ( ::hilti::rt::Bool{static_cast<bool>(_t_cur.sub(it).size())} ) { |
702 | 209 | (*_t_self).filename.value().append(_t_cur.sub(it)); |
703 | 209 | } |
704 | | |
705 | 372 | if ( found ) { |
706 | 260 | _t_cur = _t_cur.advance(it + _t_until_bytes_sz); |
707 | 260 | if ( _t_trim ) { |
708 | 260 | (*_t_data).trim(_t_cur.begin()); |
709 | 260 | } |
710 | | |
711 | 260 | goto _t_done_23974; |
712 | 260 | } |
713 | 112 | else { |
714 | 112 | _t_cur = _t_cur.advance(it); |
715 | 112 | if ( _t_trim ) { |
716 | 55 | (*_t_data).trim(_t_cur.begin()); |
717 | 55 | } |
718 | 112 | } |
719 | 372 | } |
720 | | |
721 | 260 | _t_done_23974: {} |
722 | | |
723 | 260 | if ( _t_trim ) { |
724 | 260 | (*_t_data).trim(_t_cur.begin()); |
725 | 260 | } |
726 | | |
727 | | // End parsing production: Variable: filename_2 -> bytes; |
728 | | |
729 | 260 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:65:11-65:15"); |
730 | | |
731 | | // Begin parsing production: Variable: mode_2 -> bytes; |
732 | 260 | ::hilti::rt::Bytes _t_until_bytes_ = "\000"_b; |
733 | 260 | ::hilti::rt::integer::safe<uint64_t> _t_until_bytes_sz_ = "\000"_b.size(); |
734 | 260 | (*_t_self).mode.valueOrInit() = ""_b; |
735 | 422 | while ( ::hilti::rt::Bool{true} ) { |
736 | 320 | ::spicy::rt::detail::waitForInput(_t_data, _t_cur, _t_until_bytes_sz_, "end-of-data reached before &until expression found"sv, "/src/spicy/spicy-tftp/analyzer/tftp.spicy:65:24-65:30"sv, ::hilti::rt::StrongReference<::spicy::rt::filter::detail::Filters>{}); |
737 | 320 | ::hilti::rt::Bool found_; |
738 | 320 | ::hilti::rt::stream::SafeConstIterator it_; |
739 | 320 | ::hilti::rt::tuple::assign(std::tie(found_, it_), _t_cur.find(_t_until_bytes_)); |
740 | 320 | if ( ::hilti::rt::Bool{static_cast<bool>(_t_cur.sub(it_).size())} ) { |
741 | 175 | (*_t_self).mode.value().append(_t_cur.sub(it_)); |
742 | 175 | } |
743 | | |
744 | 320 | if ( found_ ) { |
745 | 158 | _t_cur = _t_cur.advance(it_ + _t_until_bytes_sz_); |
746 | 158 | if ( _t_trim ) { |
747 | 158 | (*_t_data).trim(_t_cur.begin()); |
748 | 158 | } |
749 | | |
750 | 158 | goto _t_done_24584; |
751 | 158 | } |
752 | 162 | else { |
753 | 162 | _t_cur = _t_cur.advance(it_); |
754 | 162 | if ( _t_trim ) { |
755 | 60 | (*_t_data).trim(_t_cur.begin()); |
756 | 60 | } |
757 | 162 | } |
758 | 320 | } |
759 | | |
760 | 158 | _t_done_24584: {} |
761 | | |
762 | 158 | if ( _t_trim ) { |
763 | 158 | (*_t_data).trim(_t_cur.begin()); |
764 | 158 | } |
765 | | |
766 | | // End parsing production: Variable: mode_2 -> bytes; |
767 | | |
768 | 158 | (*_t_self)._t_error = _t_error; |
769 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:63:16-70:1"); |
770 | 158 | (*_t_self)._t_on_0x25_done(); |
771 | 158 | _t_error = (*_t_self)._t_error; |
772 | 158 | ::hilti::rt::debug::dedent("spicy"sv); |
773 | 158 | return ::hilti::rt::tuple::make_from_optionals(::hilti::rt::optional::make(_t_cur), ::hilti::rt::optional::make(_t_error)); |
774 | 260 | } |
775 | | |
776 | 317 | auto hlt_internal_TFTP_Packet::TFTP::Request::_t_parse_stage1(::hilti::rt::ValueReference<::hilti::rt::Stream>& _t_data, const ::hilti::rt::stream::View& _t_cur, const ::hilti::rt::Bool& _t_trim, const ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>& _t_error) -> ::hilti::rt::Tuple<::hilti::rt::stream::View, ::hilti::rt::Optional<::hilti::rt::RecoverableFailure>> { |
777 | 317 | auto _t_self = Request::_t_self(); |
778 | 317 | ::hilti::rt::detail::checkStack(); |
779 | 317 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:63:16-70:1"); |
780 | 317 | ::hilti::rt::debug::indent("spicy"sv); |
781 | 317 | ::hilti::rt::stream::SafeConstIterator _t_begin_ = _t_cur.begin(); |
782 | 317 | return (*_t_self)._t_parse_TFTP__Request_2_stage2(_t_data, _t_cur, _t_trim, _t_error); |
783 | 317 | } |
784 | | |
785 | 158 | extern void hlt_internal_TFTP_Packet::TFTP::_t_hook_Request__t_on_0x25_done_5389954716048438864(::hilti::rt::ValueReference<Request>& _t_self) { |
786 | 158 | ::hilti::rt::detail::checkStack(); |
787 | 158 | ::hilti::rt::location("/src/spicy/spicy-tftp/analyzer/tftp.spicy:68:9-68:29"); |
788 | 158 | ::spicy::rt::accept_input(); |
789 | 158 | } |
790 | | |
791 | 1 | extern void hlt_internal_TFTP_Packet::TFTP::_t_init_module() { |
792 | 1 | hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Acknowledgement(); |
793 | 1 | hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Data(); |
794 | 1 | hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Error(); |
795 | 1 | hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Packet(); |
796 | 1 | hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Request(); |
797 | 1 | } |
798 | | |
799 | 1 | extern void hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Acknowledgement() { ::hilti::rt::detail::checkStack(); } |
800 | | |
801 | 1 | extern void hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Data() { ::hilti::rt::detail::checkStack(); } |
802 | | |
803 | 1 | extern void hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Error() { ::hilti::rt::detail::checkStack(); } |
804 | | |
805 | 1 | extern void hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Packet() { |
806 | 1 | ::hilti::rt::detail::checkStack(); |
807 | 1 | TFTP::Packet::_t_parser = ::spicy::rt::Parser{::hilti::rt::struct_::tag::Inits(), "TFTP::Packet"sv, ::hilti::rt::Bool{true}, hlt_TFTP_Packet::TFTP::Packet::parse1, hlt_TFTP_Packet::TFTP::Packet::parse2, hlt_TFTP_Packet::TFTP::Packet::parse3, ::hilti::rt::Null{}, &type_info::_t_ti_TFTP__Packet_namex2aTFTP__Packetx2b, ""_hs, ::hilti::rt::Vector<::spicy::rt::MIMEType>({}), ::hilti::rt::Vector<::spicy::rt::ParserPort>({})}; |
808 | 1 | ::spicy::rt::detail::registerParser(TFTP::Packet::_t_parser, hlt_internal_TFTP_Packet_hlto_scope, ::hilti::rt::StrongReference<hlt_internal_TFTP_Packet::TFTP::Packet>{}, &type_info::_t_ti_strong_ref_const_TFTP__Packet__strong_refx2anamex2aTFTP__Packetx2bx2b); |
809 | 1 | } |
810 | | |
811 | 1 | extern void hlt_internal_TFTP_Packet::TFTP::_t_register_TFTP_Request() { ::hilti::rt::detail::checkStack(); } |
812 | | |
813 | 2 | extern void hlt_internal_TFTP_Packet::TFTP::_t_register_module() { |
814 | 2 | ::hilti::rt::Library::setScope(&hlt_internal_TFTP_Packet_hlto_scope); |
815 | 2 | ::hilti::rt::detail::registerModule({ "TFTP", hlt_internal_TFTP_Packet_hlto_scope, &_t_init_module, nullptr, nullptr, nullptr}); |
816 | 2 | } |
817 | | |
818 | 0 | extern auto hlt_internal_TFTP_Packet::TFTP::operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Acknowledgement& x) -> std::ostream& { return o << ::hilti::rt::to_string(x);; } |
819 | | |
820 | 0 | extern auto hlt_internal_TFTP_Packet::TFTP::operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Data& x) -> std::ostream& { return o << ::hilti::rt::to_string(x);; } |
821 | | |
822 | 0 | extern auto hlt_internal_TFTP_Packet::TFTP::operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Error& x) -> std::ostream& { return o << ::hilti::rt::to_string(x);; } |
823 | | |
824 | 0 | inline auto hlt_internal_TFTP_Packet::TFTP::operator<<(std::ostream& o, Opcode x) -> std::ostream& { o << ::hilti::rt::to_string(x); return o; } |
825 | | |
826 | 0 | extern auto hlt_internal_TFTP_Packet::TFTP::operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Request& x) -> std::ostream& { return o << ::hilti::rt::to_string(x);; } |
827 | | |
828 | 0 | extern auto hlt_internal_TFTP_Packet::TFTP::operator<<(std::ostream& o, const hlt_internal_TFTP_Packet::TFTP::Packet& x) -> std::ostream& { return o << ::hilti::rt::to_string(x);; } |