csp_rtable.h
Go to the documentation of this file.
1 /*
2 Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
3 Copyright (C) 2012 GomSpace ApS (http://www.gomspace.com)
4 Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
5 
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10 
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15 
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
27 #ifndef CSP_RTABLE_H_
28 #define CSP_RTABLE_H_
29 
30 #include <csp/csp_types.h>
31 
32 #define CSP_NODE_MAC 0xFF
33 #define CSP_ROUTE_COUNT (CSP_ID_HOST_MAX + 2)
34 #define CSP_ROUTE_TABLE_SIZE 5 * CSP_ROUTE_COUNT
35 
42 
48 uint8_t csp_rtable_find_mac(uint8_t id);
49 
58 int csp_rtable_set(uint8_t node, uint8_t mask, csp_iface_t *ifc, uint8_t mac);
59 
63 void csp_rtable_print(void);
64 
65 
76 void csp_route_table_load(uint8_t route_table_in[CSP_ROUTE_TABLE_SIZE]);
77 
88 void csp_route_table_save(uint8_t route_table_out[CSP_ROUTE_TABLE_SIZE]);
89 
97 int csp_rtable_save(char * buffer, int maxlen);
98 
111 void csp_rtable_load(char * buffer);
112 
118 int csp_rtable_check(char * buffer);
119 
124 void csp_rtable_clear(void);
125 
135 #define csp_route_set(node, ifc, mac) csp_rtable_set(node, CSP_ID_HOST_SIZE, ifc, mac)
136 
141 #define csp_route_print_table() csp_rtable_print();
142 
147 #define csp_route_print_interfaces() csp_iflist_print();
148 
149 #endif /* CSP_RTABLE_H_ */
150 
151 /* @} */
void csp_rtable_load(char *buffer)
Load routing table from a string in the format u/u s u.
Interface struct.
Definition: csp_types.h:190
#define CSP_ROUTE_TABLE_SIZE
Definition: csp_rtable.h:34
int csp_rtable_check(char *buffer)
Check string for valid routing table.
void csp_rtable_clear(void)
Clear routing table: This could be done before load to ensure an entire clean table is loaded...
int csp_rtable_save(char *buffer, int maxlen)
Save routing table as a string to a buffer, which can be parsed again by csp_rtable_load.
void csp_rtable_print(void)
Print routing table to stdout.
void csp_route_table_load(uint8_t route_table_in[CSP_ROUTE_TABLE_SIZE])
Load the routing table from a buffer (deprecated, please use new csp_rtable_load) ...
uint8_t csp_rtable_find_mac(uint8_t id)
Find MAC address associated with node.
void csp_route_table_save(uint8_t route_table_out[CSP_ROUTE_TABLE_SIZE])
Save the routing table to a buffer (deprecated, please use new csp_rtable_save)
int csp_rtable_set(uint8_t node, uint8_t mask, csp_iface_t *ifc, uint8_t mac)
Setup routing entry.
csp_iface_t * csp_rtable_find_iface(uint8_t id)
Find outgoing interface in routing table.