/* * This file is part of the DiscImageChef Remote Server. * Copyright (c) 2019 Natalia Portillo. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "../dicmote.h" #include #include #include int PrintNetworkAddresses() { int ret; struct ifaddrs* ifa; struct ifaddrs* ifa_start; char ipv4_address[INET_ADDRSTRLEN]; ret = getifaddrs(&ifa); if(ret) return -1; ifa_start = ifa; printf("Available addresses:\n"); while(ifa != NULL) { if(ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { inet_ntop(AF_INET, &((struct sockaddr_in*)ifa->ifa_addr)->sin_addr, ipv4_address, INET_ADDRSTRLEN); printf("%s port %d\n", ipv4_address, DICMOTE_PORT); } ifa = ifa->ifa_next; } freeifaddrs(ifa_start); return 0; }