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