~ 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. */
| 1309 | * handles one message, we use the standard form as principle of least |
| 1310 | * surprise. */ |
| 1311 | static u8 *handle_peer_in(struct state *state) |
| 1312 | { |
| 1313 | u8 *msg = peer_read(tmpctx, state->pps); |
| 1314 | enum peer_wire t = fromwire_peektype(msg); |
| 1315 | struct channel_id channel_id; |
| 1316 | bool extracted; |
| 1317 | |
| 1318 | if (t == WIRE_OPEN_CHANNEL) |
| 1319 | return fundee_channel(state, msg); |
| 1320 | |
| 1321 | /* Handles error cases. */ |
| 1322 | if (handle_peer_error_or_warning(state->pps, msg)) |
| 1323 | return NULL; |
| 1324 | |
| 1325 | extracted = extract_channel_id(msg, &channel_id); |
| 1326 | |
| 1327 | peer_write(state->pps, |
| 1328 | take(towire_warningfmt(NULL, |
| 1329 | extracted ? &channel_id : NULL, |
| 1330 | "Unexpected message %s: %s", |
| 1331 | peer_wire_name(t), |
| 1332 | tal_hex(tmpctx, msg)))); |
| 1333 | |
| 1334 | /* FIXME: We don't actually want master to try to send an |
| 1335 | * error, since peer is transient. This is a hack. |
| 1336 | */ |
| 1337 | status_broken("Unexpected message %s", peer_wire_name(t)); |
| 1338 | peer_failed_connection_lost(); |
| 1339 | } |
| 1340 | |
| 1341 | static void handle_dev_memleak(struct state *state, const u8 *msg) |
| 1342 | { |
no test coverage detected