~ Standard "peer sent a message, handle it" demuxer. Though it really only * handles one message, we use the standard form as principle of least * surprise. */
| 1325 | * handles one message, we use the standard form as principle of least |
| 1326 | * surprise. */ |
| 1327 | static u8 *handle_peer_in(struct state *state) |
| 1328 | { |
| 1329 | u8 *msg = peer_read(tmpctx, state->pps); |
| 1330 | enum peer_wire t = fromwire_peektype(msg); |
| 1331 | struct channel_id channel_id; |
| 1332 | bool extracted; |
| 1333 | |
| 1334 | if (t == WIRE_OPEN_CHANNEL) |
| 1335 | return fundee_channel(state, msg); |
| 1336 | |
| 1337 | /* Handles error cases. */ |
| 1338 | if (handle_peer_error(state->pps, &state->channel_id, msg)) |
| 1339 | return NULL; |
| 1340 | |
| 1341 | extracted = extract_channel_id(msg, &channel_id); |
| 1342 | |
| 1343 | peer_write(state->pps, |
| 1344 | take(towire_warningfmt(NULL, |
| 1345 | extracted ? &channel_id : NULL, |
| 1346 | "Unexpected message %s: %s", |
| 1347 | peer_wire_name(t), |
| 1348 | tal_hex(tmpctx, msg)))); |
| 1349 | |
| 1350 | /* FIXME: We don't actually want master to try to send an |
| 1351 | * error, since peer is transient. This is a hack. |
| 1352 | */ |
| 1353 | status_broken("Unexpected message %s", peer_wire_name(t)); |
| 1354 | peer_failed_connection_lost(); |
| 1355 | } |
| 1356 | |
| 1357 | /* Memory leak detection is DEVELOPER-only because we go to great lengths to |
| 1358 | * record the backtrace when allocations occur: without that, the leak |
no test coverage detected