ccn-lite
ccn-lite copied to clipboard
[discussion] data structures for CS, FIB, PIT?
In the current situation there are instances, where the CS, FIB or PIT are accessed directly through a global struct (ccnl_relay_s). Adding support for proper data structures for CS, FIB, PIT can improve access control and allows for thread-safe read and write operations.
Further, it is far simpler to provide interchangeable data structure implementaitons (malloc vs. static memory), without using too many #ifdef
s or major code restructurings.
Should we put some effort into this topic? How should we organize these data structures?
Personally, I think this might change how you use CCN-lite, since you don't want to
- make the free'd data structures parameters of functions, e.g.
226 int
227 ccnl_fwd_handleInterest(struct ccnl_relay_s *relay, struct ccnl_face_s *from,
228 struct ccnl_pkt_s **pkt, cMatchFct cMatch)
229 {
becomes
226 int
227 ccnl_fwd_handleInterest(struct ccnl_relay_s *relay, struct ccnl_face_s *from,
228 struct ccnl_interest_s *pit, struct ccnl_pkt_s **pkt,
229 cMatchFct cMatch)
230 {
- introduce additional global variables which are passed around as functions.
Also, besides having thread-safe functions I'm wondering if we want to support some kind of a generic "interface" which allows you to easily swap implementations. So, you e.g. you would have something like
struct some_data_type get_interest(const char* prefix);
and the function could use a hash map or a double linked list in the background.