Beginning migration.

This commit is contained in:
Nicolás Ortega Froysa
2017-08-12 13:59:18 -05:00
parent e4de99086a
commit 48e9006220
11 changed files with 664 additions and 737 deletions

View File

@ -1,117 +0,0 @@
/*
* Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
*
* 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
* <http://www.gnu.org/licenses/>.
*/
#pragma once
/**
* @file connectivity.h
* @brief Interfaces relating to node connections.
*/
/**
* @brief Simple address structure providing IP/DNS and port information.
*/
struct NeoComm_address {
const char *address; ///< IP/DNS string.
unsigned short port; ///< Port of address.
};
/**
* @brief Structure used for NeoComm nodes.
*/
struct NeoComm_node {
/// The address of the node.
struct NeoComm_address address;
/// Whether or not it is a directory node/server.
int directory;
/// Number of connections a directory has.
unsigned int connections;
/// Maximum number of connections the directory can have.
unsigned int max_connections;
};
/**
* @brief Initialize the directory aspect of the node.
*
* @param max_num_nodes Maximum number of nodes in the directory.
* @param portnum Public facing port which other nodes can connect to.
*
* @return If the operation failed then a 0 will be returned and the error can
* be read from the NeoComm_get_last_error function, else 1 is returned.
*/
int NeoComm_init_directory(const unsigned int max_num_nodes,
const unsigned short portnum);
/**
* @brief Disconnect from all nodes and free memory.
*/
void NeoComm_shutdown_directory();
/**
* @brief Resize the directory.
* @note This function only increments the size, it currently does not have
* the ability to decrease size.
*
* @param new_max_num_nodes The new maximum number of nodes in the directory.
*
* @return If the operation failed then a 0 will be returned and the error can
* be read from the NeoComm_get_last_error function, else 1 is returned.
*/
int NeoComm_resize_directory(const unsigned int new_max_num_nodes);
/**
* @brief Get the current maximum number of nodes for the directory.
*
* @return The current maximum number of nodes for the directory.
*/
unsigned int NeoComm_get_directory_size();
/**
* @brief Get the current number of nodes registered in the directory.
*
* @return The current number of nodes in the directory.
*/
unsigned int NeoComm_get_num_nodes();
/**
* @brief Add and connect to a new node to the directory.
*
* @param addr The address of the new node to connect to.
*
* @return If the operation failed then a 0 will be returned and the error can
* be read from the NeoComm_get_last_error function, else 1 is returned.
*/
int NeoComm_add_node(const struct NeoComm_address addr);
/**
* @brief Disconnect and remove a node from the directory.
*
* @param addr The address of the node to remove.
*/
void NeoComm_remove_node(const struct NeoComm_address addr);
/**
* @brief Retrieve information on a specific node.
*
* @param addr The address of the node to retrieve.
*
* @return A NeoComm_node structure of the node.
*/
struct NeoComm_node NeoComm_get_node(const struct NeoComm_address addr);

View File

@ -1,27 +0,0 @@
/*
* Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
*
* 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
* <http://www.gnu.org/licenses/>.
*/
#pragma once
/**
* @brief Return the error caused by the last function call.
*
* @return A string with the error.
*/
const char* NeoComm_get_last_error();

View File

@ -1,23 +0,0 @@
/*
* Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
*
* 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
* <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "neocomm/error.h"
#include "neocomm/connectivity.h"