csp.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_H_
28 #define _CSP_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Includes */
35 #include <stdint.h>
36 
37 #include <csp/csp_autoconfig.h>
38 
39 /* CSP includes */
40 #include "csp_types.h"
41 #include "csp_platform.h"
42 #include "csp_error.h"
43 #include "csp_debug.h"
44 #include "csp_buffer.h"
45 #include "csp_rtable.h"
46 #include "csp_iflist.h"
47 
52 int csp_init(uint8_t my_node_address);
53 
58 void csp_set_address(uint8_t addr);
59 
64 uint8_t csp_get_address(void);
65 
71 void csp_set_hostname(char *hostname);
72 
77 char *csp_get_hostname(void);
78 
84 void csp_set_model(char *model);
85 
90 char *csp_get_model(void);
91 
97 void csp_set_revision(char *revision);
98 
103 char *csp_get_revision(void);
104 
110 csp_socket_t *csp_socket(uint32_t opts);
111 
118 csp_conn_t *csp_accept(csp_socket_t *socket, uint32_t timeout);
119 
130 csp_packet_t *csp_read(csp_conn_t *conn, uint32_t timeout);
131 
139 int csp_send(csp_conn_t *conn, csp_packet_t *packet, uint32_t timeout);
140 
153 int csp_send_prio(uint8_t prio, csp_conn_t *conn, csp_packet_t *packet, uint32_t timeout);
154 
169 int csp_transaction(uint8_t prio, uint8_t dest, uint8_t port, uint32_t timeout, void *outbuf, int outlen, void *inbuf, int inlen);
170 
182 int csp_transaction_persistent(csp_conn_t *conn, uint32_t timeout, void *outbuf, int outlen, void *inbuf, int inlen);
183 
191 csp_packet_t *csp_recvfrom(csp_socket_t *socket, uint32_t timeout);
192 
204 int csp_sendto(uint8_t prio, uint8_t dest, uint8_t dport, uint8_t src_port, uint32_t opts, csp_packet_t *packet, uint32_t timeout);
205 
215 int csp_sendto_reply(csp_packet_t * request_packet, csp_packet_t * reply_packet, uint32_t opts, uint32_t timeout);
216 
229 csp_conn_t *csp_connect(uint8_t prio, uint8_t dest, uint8_t dport, uint32_t timeout, uint32_t opts);
230 
236 int csp_close(csp_conn_t *conn);
237 
242 int csp_conn_dport(csp_conn_t *conn);
243 
248 int csp_conn_sport(csp_conn_t *conn);
249 
254 int csp_conn_dst(csp_conn_t *conn);
255 
260 int csp_conn_src(csp_conn_t *conn);
261 
266 int csp_conn_flags(csp_conn_t *conn);
267 
274 int csp_listen(csp_socket_t *socket, size_t conn_queue_length);
275 
282 int csp_bind(csp_socket_t *socket, uint8_t port);
283 
289 int csp_route_start_task(unsigned int task_stack_size, unsigned int priority);
290 
298 int csp_route_work(uint32_t timeout);
299 
308 int csp_bridge_start(unsigned int task_stack_size, unsigned int task_priority, csp_iface_t * _if_a, csp_iface_t * _if_b);
309 
319 int csp_promisc_enable(unsigned int buf_size);
320 
326 void csp_promisc_disable(void);
327 
336 csp_packet_t *csp_promisc_read(uint32_t timeout);
337 
349 int csp_sfp_send(csp_conn_t * conn, void * data, int totalsize, int mtu, uint32_t timeout);
350 
362 int csp_sfp_send_own_memcpy(csp_conn_t * conn, void * data, int totalsize, int mtu, uint32_t timeout, void * (*memcpyfcn)(void *, const void *, size_t));
363 
372 int csp_sfp_recv(csp_conn_t * conn, void ** dataout, int * datasize, uint32_t timeout);
373 
383 int csp_sfp_recv_fp(csp_conn_t * conn, void ** dataout, int * datasize, uint32_t timeout, csp_packet_t * first_packet);
384 
396 void csp_service_handler(csp_conn_t *conn, csp_packet_t *packet);
397 
406 int csp_ping(uint8_t node, uint32_t timeout, unsigned int size, uint8_t conn_options);
407 
412 void csp_ping_noreply(uint8_t node);
413 
420 void csp_ps(uint8_t node, uint32_t timeout);
421 
427 void csp_memfree(uint8_t node, uint32_t timeout);
428 
434 void csp_buf_free(uint8_t node, uint32_t timeout);
435 
440 void csp_reboot(uint8_t node);
441 
446 void csp_shutdown(uint8_t node);
447 
453 void csp_uptime(uint8_t node, uint32_t timeout);
454 
464 void csp_rdp_set_opt(unsigned int window_size, unsigned int conn_timeout_ms,
465  unsigned int packet_timeout_ms, unsigned int delayed_acks,
466  unsigned int ack_timeout, unsigned int ack_delay_count);
467 
477 void csp_rdp_get_opt(unsigned int *window_size, unsigned int *conn_timeout_ms,
478  unsigned int *packet_timeout_ms, unsigned int *delayed_acks,
479  unsigned int *ack_timeout, unsigned int *ack_delay_count);
480 
487 int csp_xtea_set_key(char *key, uint32_t keylen);
488 
495 int csp_hmac_set_key(char *key, uint32_t keylen);
496 
500 void csp_conn_print_table(void);
501 
505 void csp_buffer_print_table(void);
506 
507 #ifdef __AVR__
508 typedef uint32_t csp_memptr_t;
509 #else
510 typedef void * csp_memptr_t;
511 #endif
512 
515 
520 #include <stdarg.h>
521 typedef void (*csp_debug_hook_func_t)(csp_debug_level_t level, const char *format, va_list args);
523 
524 #ifdef __cplusplus
525 } /* extern "C" */
526 #endif
527 
528 #endif // _CSP_H_
529 
530 /* @} */
void * csp_memptr_t
Definition: csp.h:510
int csp_send(csp_conn_t *conn, csp_packet_t *packet, uint32_t timeout)
int csp_transaction(uint8_t prio, uint8_t dest, uint8_t port, uint32_t timeout, void *outbuf, int outlen, void *inbuf, int inlen)
csp_packet_t * csp_read(csp_conn_t *conn, uint32_t timeout)
Definition: csp_types.h:190
char * csp_get_hostname(void)
void(* csp_debug_hook_func_t)(csp_debug_level_t level, const char *format, va_list args)
Definition: csp.h:521
void csp_debug_hook_set(csp_debug_hook_func_t f)
int csp_conn_sport(csp_conn_t *conn)
int csp_bridge_start(unsigned int task_stack_size, unsigned int task_priority, csp_iface_t *_if_a, csp_iface_t *_if_b)
void csp_cmp_set_memcpy(csp_memcpy_fnc_t fnc)
int csp_sfp_send_own_memcpy(csp_conn_t *conn, void *data, int totalsize, int mtu, uint32_t timeout, void *(*memcpyfcn)(void *, const void *, size_t))
char * csp_get_model(void)
void csp_buffer_print_table(void)
int csp_conn_dport(csp_conn_t *conn)
int csp_conn_dst(csp_conn_t *conn)
void csp_shutdown(uint8_t node)
int csp_sfp_recv(csp_conn_t *conn, void **dataout, int *datasize, uint32_t timeout)
void csp_rdp_get_opt(unsigned int *window_size, unsigned int *conn_timeout_ms, unsigned int *packet_timeout_ms, unsigned int *delayed_acks, unsigned int *ack_timeout, unsigned int *ack_delay_count)
int csp_sfp_send(csp_conn_t *conn, void *data, int totalsize, int mtu, uint32_t timeout)
struct csp_conn_s csp_socket_t
Definition: csp_types.h:217
int csp_route_start_task(unsigned int task_stack_size, unsigned int priority)
void csp_reboot(uint8_t node)
int csp_sendto_reply(csp_packet_t *request_packet, csp_packet_t *reply_packet, uint32_t opts, uint32_t timeout)
struct csp_conn_s csp_conn_t
Definition: csp_types.h:218
csp_packet_t * csp_promisc_read(uint32_t timeout)
int csp_init(uint8_t my_node_address)
int csp_close(csp_conn_t *conn)
csp_memptr_t(* csp_memcpy_fnc_t)(csp_memptr_t, const csp_memptr_t, size_t)
Definition: csp.h:513
int csp_promisc_enable(unsigned int buf_size)
void csp_buf_free(uint8_t node, uint32_t timeout)
csp_debug_level_t
Definition: csp_debug.h:38
csp_socket_t * csp_socket(uint32_t opts)
void csp_ps(uint8_t node, uint32_t timeout)
uint8_t csp_get_address(void)
int csp_hmac_set_key(char *key, uint32_t keylen)
void csp_set_revision(char *revision)
void csp_memfree(uint8_t node, uint32_t timeout)
csp_conn_t * csp_connect(uint8_t prio, uint8_t dest, uint8_t dport, uint32_t timeout, uint32_t opts)
void csp_promisc_disable(void)
void csp_set_address(uint8_t addr)
int csp_listen(csp_socket_t *socket, size_t conn_queue_length)
void csp_conn_print_table(void)
csp_conn_t * csp_accept(csp_socket_t *socket, uint32_t timeout)
int csp_send_prio(uint8_t prio, csp_conn_t *conn, csp_packet_t *packet, uint32_t timeout)
int csp_sendto(uint8_t prio, uint8_t dest, uint8_t dport, uint8_t src_port, uint32_t opts, csp_packet_t *packet, uint32_t timeout)
int csp_conn_src(csp_conn_t *conn)
void csp_rdp_set_opt(unsigned int window_size, unsigned int conn_timeout_ms, unsigned int packet_timeout_ms, unsigned int delayed_acks, unsigned int ack_timeout, unsigned int ack_delay_count)
int csp_route_work(uint32_t timeout)
void csp_service_handler(csp_conn_t *conn, csp_packet_t *packet)
csp_packet_t * csp_recvfrom(csp_socket_t *socket, uint32_t timeout)
int csp_xtea_set_key(char *key, uint32_t keylen)
int csp_sfp_recv_fp(csp_conn_t *conn, void **dataout, int *datasize, uint32_t timeout, csp_packet_t *first_packet)
int csp_transaction_persistent(csp_conn_t *conn, uint32_t timeout, void *outbuf, int outlen, void *inbuf, int inlen)
char * csp_get_revision(void)
Definition: csp_types.h:174
void csp_uptime(uint8_t node, uint32_t timeout)
int csp_bind(csp_socket_t *socket, uint8_t port)
int csp_ping(uint8_t node, uint32_t timeout, unsigned int size, uint8_t conn_options)
void csp_set_model(char *model)
void csp_set_hostname(char *hostname)
void csp_ping_noreply(uint8_t node)
int csp_conn_flags(csp_conn_t *conn)