Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 68 lines (59 sloc) 2.451 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/* vim: set expandtab ts=4 sw=4: */
/*
* You may redistribute this program and/or modify it under the terms of
* the GNU 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef SwitchCore_H
#define SwitchCore_H

#include "interface/Interface.h"
#include "util/log/Log.h"
#include "wire/Message.h"
#include "util/Linker.h"
Linker_require("switch/SwitchCore.c")

#include <stdint.h>

/** The switch core which is opaque to users. */
struct SwitchCore;

/**
* Create a new router core.
*
* @param logger what to log output to.
* @param allocator the memory allocator to use for allocating the core context and interfaces.
*/
struct SwitchCore* SwitchCore_new(struct Log* logger, struct Allocator* allocator);

/**
* Register a new interface.
* All interfaces are point to point so messages sent down an interface.
*
* @param iface the interface to add.
* @param trust the amount that you trust the connected node.
* @param labelOut_be a buffer which will be filled with the label part for getting
* to the newly added node. It will be set to the big endian value.
* @param core the switchcore.
* @return 0 on success, SwitchCore_addInterface_OUT_OF_SPACE if there are no more interface slots.
*/
#define SwitchCore_addInterface_OUT_OF_SPACE -1
int SwitchCore_addInterface(struct Interface* iface,
                            const uint64_t trust,
                            uint64_t* labelOut_be,
                            struct SwitchCore* core);

/**
* Set the router interface.
* This interface is needed by all switches because a switch cannot function without a router.
* Do not send messages before registering this interface and at least one other.
*
* @param iface the router interface.
* @param core the switchcore.
* @return 0
*/
int SwitchCore_setRouterInterface(struct Interface* iface, struct SwitchCore* core);

void SwitchCore_swapInterfaces(struct Interface* if1, struct Interface* if2);

#endif
Something went wrong with that request. Please try again.