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