| 450 | } |
| 451 | |
| 452 | static int showaddrs_do(unsigned int nodeid) |
| 453 | { |
| 454 | cs_error_t result; |
| 455 | corosync_cfg_handle_t handle; |
| 456 | int numaddrs; |
| 457 | int i; |
| 458 | int rc = EXIT_SUCCESS; |
| 459 | corosync_cfg_node_address_t addrs[INTERFACE_MAX]; |
| 460 | |
| 461 | |
| 462 | result = corosync_cfg_initialize (&handle, NULL); |
| 463 | if (result != CS_OK) { |
| 464 | fprintf (stderr, "Could not initialize corosync configuration API error %d\n", result); |
| 465 | exit (EXIT_FAILURE); |
| 466 | } |
| 467 | |
| 468 | if (corosync_cfg_get_node_addrs(handle, nodeid, INTERFACE_MAX, &numaddrs, addrs) == CS_OK) { |
| 469 | for (i=0; i<numaddrs; i++) { |
| 470 | char buf[INET6_ADDRSTRLEN]; |
| 471 | struct sockaddr_storage *ss = (struct sockaddr_storage *)addrs[i].address; |
| 472 | struct sockaddr_in *sin = (struct sockaddr_in *)addrs[i].address; |
| 473 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addrs[i].address; |
| 474 | void *saddr; |
| 475 | |
| 476 | if (!ss->ss_family) { |
| 477 | continue; |
| 478 | } |
| 479 | if (ss->ss_family == AF_INET6) { |
| 480 | saddr = &sin6->sin6_addr; |
| 481 | } else { |
| 482 | saddr = &sin->sin_addr; |
| 483 | } |
| 484 | |
| 485 | inet_ntop(ss->ss_family, saddr, buf, sizeof(buf)); |
| 486 | if (i != 0) { |
| 487 | printf(" "); |
| 488 | } |
| 489 | printf("%s", buf); |
| 490 | } |
| 491 | printf("\n"); |
| 492 | } else { |
| 493 | fprintf (stderr, "Could not get node address for nodeid %d\n", nodeid); |
| 494 | rc = EXIT_FAILURE; |
| 495 | } |
| 496 | |
| 497 | |
| 498 | (void)corosync_cfg_finalize (handle); |
| 499 | return rc; |
| 500 | } |
| 501 | |
| 502 | |
| 503 | static void killnode_do(unsigned int nodeid) |
no test coverage detected