~ Note the lack of static: this is called by peer_exchange_initmsg.c once the * INIT messages are exchanged, and also by the retry code above. */
| 291 | /*~ Note the lack of static: this is called by peer_exchange_initmsg.c once the |
| 292 | * INIT messages are exchanged, and also by the retry code above. */ |
| 293 | struct io_plan *peer_connected(struct io_conn *conn, |
| 294 | struct daemon *daemon, |
| 295 | const struct node_id *id, |
| 296 | const struct wireaddr_internal *addr, |
| 297 | const struct wireaddr *remote_addr, |
| 298 | struct crypto_state *cs, |
| 299 | const u8 *their_features TAKES, |
| 300 | enum is_websocket is_websocket, |
| 301 | struct timemono starttime, |
| 302 | bool incoming) |
| 303 | { |
| 304 | u8 *msg; |
| 305 | struct peer *peer, *oldpeer; |
| 306 | int unsup; |
| 307 | size_t depender, missing; |
| 308 | int subd_fd; |
| 309 | bool option_gossip_queries; |
| 310 | struct connecting *connect; |
| 311 | const char *connect_reason; |
| 312 | u64 connect_time_nsec; |
| 313 | u64 prev_connectd_counter; |
| 314 | struct timemono prev_connect_start; |
| 315 | |
| 316 | /* We remove any previous connection immediately, on the assumption it's dead */ |
| 317 | oldpeer = peer_htable_get(daemon->peers, id); |
| 318 | if (oldpeer) { |
| 319 | prev_connectd_counter = oldpeer->counter; |
| 320 | prev_connect_start = oldpeer->connect_starttime; |
| 321 | destroy_peer_immediately(oldpeer); |
| 322 | } |
| 323 | |
| 324 | /* BOLT #1: |
| 325 | * |
| 326 | * The receiving node: |
| 327 | * ... |
| 328 | * - upon receiving unknown _odd_ feature bits that are non-zero: |
| 329 | * - MUST ignore the bit. |
| 330 | * - upon receiving unknown _even_ feature bits that are non-zero: |
| 331 | * - MUST close the connection. |
| 332 | */ |
| 333 | unsup = features_unsupported(daemon->our_features, their_features, |
| 334 | INIT_FEATURE); |
| 335 | if (unsup != -1) { |
| 336 | if (taken(their_features)) |
| 337 | tal_free(their_features); |
| 338 | |
| 339 | /* We were going to send a reconnect message, but not now! */ |
| 340 | if (oldpeer) |
| 341 | send_disconnected(daemon, id, prev_connectd_counter, |
| 342 | prev_connect_start); |
| 343 | status_peer_unusual(id, "Unsupported feature %u", unsup); |
| 344 | msg = towire_warningfmt(NULL, NULL, "Unsupported feature %u", |
| 345 | unsup); |
| 346 | msg = cryptomsg_encrypt_msg(NULL, cs, take(msg)); |
| 347 | return io_write_wire(conn, take(msg), io_close_cb, NULL); |
| 348 | } |
| 349 | |
| 350 | if (!feature_check_depends(their_features, &depender, &missing)) { |
no test coverage detected