/* * Copyright (C) 2017 Ortega Froysa, Nicolás * Author: Ortega Froysa, Nicolás * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation, either * version 3 of the License, or (at your option) any later version. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * . */ #pragma once /** * @brief Initialize the node list. * * @param max_nodes Maximum number of nodes available. * * @return If the operation failed then it will return 0, else it will * return 1. */ int init_nodes(unsigned int max_nodes); /** * @brief Enlarge the list. * * @param new_max_nodes New number of maximum nodes. * * @return If the new size is less than or equal to the current size, or * the list failed to be reallocated, then it returns 0, else it returns 1. */ int resize_node_list(unsigned int new_max_nodes); /** * @brief Get the maximum number of nodes that can be used. * * @return The maximum number of nodes that can be used.. */ unsigned int get_node_max(); /** * @brief Get the number of nodes there currently are. * * @return The number of nodes remembered. */ unsigned int get_node_count(); /** * @brief Add a new node to the list with an address (normally IP) and port. * * @param addr Address of the new node (normally an IP, but also DNS). * @param port Port number for new node. * * @return If the node list is full it will return 0, else 1. */ int add_node(char *addr, unsigned short port); int remove_node(char *addr, unsigned short port);