ccn-lite-riot.h
1 /*
2  * Copyright (C) 2015, 2016 INRIA
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #ifndef CCN_LITE_RIOT_H
10 #define CCN_LITE_RIOT_H
11 
23 #include <unistd.h>
24 #include "kernel_types.h"
25 #include "arpa/inet.h"
26 #include "net/packet.h"
27 #include "net/ethernet/hdr.h"
28 #include "sys/socket.h"
29 #include "ccnl-defs.h"
30 #include "ccnl-core.h"
31 #include "ccnl-headers.h"
32 #include "net/gnrc/netreg.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
41 #define LOG_LEVEL LOG_DEBUG
42 #include "log.h"
43 
49 #define ccnl_malloc(s) malloc(s)
50 #define ccnl_calloc(n,s) calloc(n,s)
51 #define ccnl_realloc(p,s) realloc(p,s)
52 #define ccnl_free(p) free(p)
53 
60 #define ccnl_close_socket(s) close(s)
61 
67 #define FATAL LOG_ERROR
68 #define ERROR LOG_ERROR
69 #define WARNING LOG_WARNING
70 #define INFO LOG_INFO
71 #define DEBUG LOG_DEBUG
72 #define TRACE LOG_DEBUG
73 #define VERBOSE LOG_ALL
74 
83 #define DEBUGMSG(LVL, ...) do { \
84  if ((LVL)>debug_level) break; \
85  LOG(LVL, __VA_ARGS__); \
86  } while (0)
87 
88 #define DEBUGMSG_CORE(...) DEBUGMSG(__VA_ARGS__)
89 #define DEBUGMSG_CFWD(...) DEBUGMSG(__VA_ARGS__)
90 #define DEBUGMSG_CUTL(...) DEBUGMSG(__VA_ARGS__)
91 #define DEBUGMSG_PIOT(...) DEBUGMSG(__VA_ARGS__)
92 
93 #define DEBUGSTMT(LVL, ...) do { \
94  if ((LVL)>debug_level) break; \
95  __VA_ARGS__; \
96  } while (0)
97 
98 #define TRACEIN(...) do {} while(0)
99 #define TRACEOUT(...) do {} while(0)
100 
108 #define free_2ptr_list(a,b) ccnl_free(a), ccnl_free(b)
109 #define free_3ptr_list(a,b,c) ccnl_free(a), ccnl_free(b), ccnl_free(c)
110 #define free_4ptr_list(a,b,c,d) ccnl_free(a), ccnl_free(b), ccnl_free(c), ccnl_free(d);
111 #define free_5ptr_list(a,b,c,d,e) ccnl_free(a), ccnl_free(b), ccnl_free(c), ccnl_free(d), ccnl_free(e);
112 
119 #define free_prefix(p) do{ if(p) \
120  free_5ptr_list(p->bytes,p->comp,p->complen,p->chunknum,p); } while(0)
121 
122 
126 #define CONSTSTR(s) s
127 
131 #define CCNL_STACK_SIZE (THREAD_STACKSIZE_MAIN)
132 
136 #define CCNL_QUEUE_SIZE (8)
137 
141 typedef struct {
142  struct ccnl_prefix_s *prefix;
143  unsigned char *buf;
144  size_t buflen;
146 
147 
151 #define CCNL_PREFIX_BUFSIZE (50)
152 
156 #define CCNL_MSG_TIMEOUT (0x1701)
157 
161 #define CCNL_MSG_AGEING (0x1702)
162 
166 #ifndef CCNL_CACHE_SIZE
167 #define CCNL_CACHE_SIZE (5)
168 #endif
169 #ifdef DOXYGEN
170 #define CCNL_CACHE_SIZE
171 #endif
172 
176 extern struct ccnl_relay_s ccnl_relay;
177 
181 typedef int (*ccnl_producer_func)(struct ccnl_relay_s *relay,
182  struct ccnl_face_s *from,
183  struct ccnl_pkt_s *pkt);
184 
188 typedef int (*ccnl_cache_strategy_func)(struct ccnl_relay_s *relay,
189  struct ccnl_content_s *c);
190 
197 
208 int ccnl_open_netif(kernel_pid_t if_pid, gnrc_nettype_t netreg_type);
209 
220 int ccnl_send_interest(struct ccnl_prefix_s *prefix,
221  unsigned char *buf, size_t buf_len);
222 
239 int ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout);
240 
251 int ccnl_fib_add_entry(struct ccnl_relay_s *relay, struct ccnl_prefix_s *pfx,
252  struct ccnl_face_s *face);
253 
264 int ccnl_fib_rem_entry(struct ccnl_relay_s *relay, struct ccnl_prefix_s *pfx, struct ccnl_face_s *face);
265 
271 void ccnl_fib_show(struct ccnl_relay_s *relay);
272 
282 
297 
298 #ifdef __cplusplus
299 }
300 #endif
301 #endif /* CCN_LITE_RIOT_H */
302 
Types used by the kernel.
Data structure for interest packet.
size_t buflen
size of the buffer
int(* ccnl_cache_strategy_func)(struct ccnl_relay_s *relay, struct ccnl_content_s *c)
Function pointer type for caching strategy function.
int ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout)
Wait for incoming content chunk.
void ccnl_set_cache_strategy_remove(ccnl_cache_strategy_func func)
Set a function to control the caching strategy.
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
int(* ccnl_producer_func)(struct ccnl_relay_s *relay, struct ccnl_face_s *from, struct ccnl_pkt_s *pkt)
Function pointer type for local producer function.
int ccnl_fib_add_entry(struct ccnl_relay_s *relay, struct ccnl_prefix_s *pfx, struct ccnl_face_s *face)
Add entry to the CCN-Lite FIB.
int ccnl_fib_rem_entry(struct ccnl_relay_s *relay, struct ccnl_prefix_s *pfx, struct ccnl_face_s *face)
Remove entry from the CCN-Lite FIB.
struct ccnl_prefix_s * prefix
requested prefix
int ccnl_open_netif(kernel_pid_t if_pid, gnrc_nettype_t netreg_type)
Opens a Network interfaces device for use with CCN-Lite.
unsigned char * buf
buffer to store the interest packet
void ccnl_set_local_producer(ccnl_producer_func func)
Set a local producer function.
Definitions to register network protocol PIDs to use with GNRC communication interface.
Ethernet header definitions.
Definitions for internet operations.
Defines the struct for AF_PACKET sockets.
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:42
void ccnl_fib_show(struct ccnl_relay_s *relay)
Prints the current CCN-Lite FIB.
System logging header.
Main socket header.
int ccnl_send_interest(struct ccnl_prefix_s *prefix, unsigned char *buf, size_t buf_len)
Sends out an Interest.
kernel_pid_t ccnl_start(void)
Start the main CCN-Lite event-loop.
struct ccnl_relay_s ccnl_relay
Struct holding CCN-Lite&#39;s central relay information.