Skip to content

Commit

Permalink
Fixed conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
basilkohler committed Sep 3, 2014
2 parents f0a385e + 24b69dc commit 323794c
Show file tree
Hide file tree
Showing 41 changed files with 2,272 additions and 1,386 deletions.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ EXTRA_CFLAGS := -Wall -g $(OPTCFLAGS)
obj-m += ccn-lite-lnxkernel.o
#ccn-lite-lnxkernel-objs += ccnl-ext-crypto.o

CCNB_LIB = pkt-ccnb.h pkt-ccnb-dec.c pkt-ccnb-enc.c fwd-ccnb.c
NDNTLV_LIB = pkt-ndntlv.h pkt-ndntlv-dec.c pkt-ndntlv-enc.c fwd-ndntlv.c
CCNB_LIB = pkt-ccnb.h pkt-ccnb-dec.c pkt-ccnb-enc.c fwd-ccnb.c
LOCRPC_LIB = pkt-localrpc.h fwd-localrpc.c
NDNTLV_LIB = pkt-ndntlv.h pkt-ndntlv-dec.c pkt-ndntlv-enc.c fwd-ndntlv.c

# ----------------------------------------------------------------------

all: ${PROGS}
make -C util

ccn-lite-minimalrelay: ccn-lite-minimalrelay.c \
${CCNB_LIB} ${NDNTLV_LIB} Makefile\
${CCNB_LIB} ${LOCRPC_LIB} ${NDNTLV_LIB} Makefile\
ccnl-core.c ccnl.h ccnl-core.h
${CC} -o $@ ${MYCFLAGS} $<

Expand All @@ -53,23 +54,22 @@ ccn-nfn-relay: ccn-lite-relay.c ${CCNB_LIB} ${NDNTLV_LIB} Makefile\
ccnl-ext-crypto.c ccnl-ext-nfn.c krivine.c krivine-common.c Makefile
${CC} -o $@ ${MYCFLAGS} ${NFNFLAGS} $< ${EXTLIBS}

ccn-lite-relay: ccn-lite-relay.c ${CCNB_LIB} ${NDNTLV_LIB} Makefile\
ccn-lite-relay: ccn-lite-relay.c ${CCNB_LIB} ${LOCRPC_LIB} ${NDNTLV_LIB} \
Makefile ccnl-includes.h ccnl.h ccnl-core.h \
ccnl-ext-debug.c ccnl-ext.h ccnl-platform.c ccnl-core.c \
ccnl-ext-http.c \
ccnl-ext-sched.c ccnl-ext-frag.c ccnl-ext-mgmt.c \
ccnl-ext-crypto.c Makefile
${CC} -o $@ ${MYCFLAGS} $< ${EXTLIBS} -DCCNL_NACK -DCCNL_NFN_MONITOR


ccn-lite-simu: ccn-lite-simu.c ${CCNB_LIB} ${NDNTLV_LIB} Makefile\
ccnl-includes.h ccnl.h ccnl-core.h \
ccn-lite-simu: ccn-lite-simu.c ${CCNB_LIB} ${LOCRPC_LIB} ${NDNTLV_LIB} \
Makefile ccnl-includes.h ccnl.h ccnl-core.h \
ccnl-ext-debug.c ccnl-ext.h ccnl-platform.c ccnl-core.c \
ccnl-ext-frag.c ccnl-ext-sched.c ccnl-simu-client.c
ccnl-ext-frag.c ccnl-ext-sched.c ccnl-simu-client.c ccnl-util.c
${EXTMAKE}
${CC} -o $@ ${MYCFLAGS} $< ${EXTLIBS}

ccn-lite-omnet: ${CCNB_LIB} ${NDNTLV_LIB} Makefile \
ccn-lite-omnet: ${CCNB_LIB} ${LOCRPC_LIB} ${NDNTLV_LIB} Makefile \
ccnl-core.c ccnl-core.h ccnl-ext-debug.c \
ccnl-ext-frag.c ccnl-ext.h ccnl-ext-sched.c ccnl.h \
ccnl-includes.h ccn-lite-omnet.c ccnl-platform.c \
Expand All @@ -85,8 +85,8 @@ ccn-lite-lnxkernel:
make modules
# rm -rf $@.o $@.mod.* .$@* .tmp_versions modules.order Module.symvers

modules: ccn-lite-lnxkernel.c ${CCNB_LIB} ${NDNTLV_LIB} Makefile\
ccnl-includes.h ccnl.h ccnl-core.h \
modules: ccn-lite-lnxkernel.c ${CCNB_LIB} ${LOCRPC_LIB} ${NDNTLV_LIB} \
Makefile ccnl-includes.h ccnl.h ccnl-core.h \
ccnl-ext-debug.c ccnl-ext.h ccnl-platform.c ccnl-core.c \
ccnl-ext-frag.c ccnl-ext-sched.c ccnl-ext-crypto.c Makefile
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(shell pwd) modules
Expand Down
1 change: 1 addition & 0 deletions ccn-lite-lnxkernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ ccnl_close_socket(struct socket *s)
#include "ccnl-platform.c"
#include "ccnl-ext.h"

#include "ccnl-util.c"
#include "ccnl-core.c"

#ifdef USE_FRAG
Expand Down
1 change: 1 addition & 0 deletions ccn-lite-minimalrelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ ccnl_path_to_prefix(const char *path)

// ----------------------------------------------------------------------

#include "ccnl-util.c"
#include "ccnl-core.c"

// ----------------------------------------------------------------------
Expand Down
149 changes: 97 additions & 52 deletions ccn-lite-relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define USE_SCHEDULER
#define USE_SUITE_CCNB
// #define USE_SUITE_CCNTLV
// #define USE_SUITE_LOCALRPC
#define USE_SUITE_NDNTLV
#define USE_UNIXSOCKET
// #define USE_SIGNATURES
Expand All @@ -56,6 +57,7 @@
#define ccnl_app_RX(x,y) do{}while(0)
#define ccnl_print_stats(x,y) do{}while(0)

#include "ccnl-util.c"
#include "ccnl-core.c"

#include "ccnl-ext-http.c"
Expand All @@ -72,7 +74,7 @@
// ----------------------------------------------------------------------

struct ccnl_relay_s theRelay;
char suite; // = CCNL_SUITE_CCNB, or = CCNL_SUITE_NDNTLV
char suite = CCNL_SUITE_NDNTLV; // = CCNL_SUITE_CCNB, or = CCNL_SUITE_NDNTLV

struct timeval*
ccnl_run_events()
Expand Down Expand Up @@ -312,119 +314,126 @@ void ccnl_ageing(void *relay, void *aux)
// ----------------------------------------------------------------------

void
ccnl_relay_config(struct ccnl_relay_s *ccnl, char *ethdev, int udpport,
int tcpport, char *uxpath, int max_cache_entries,
ccnl_relay_config(struct ccnl_relay_s *relay, char *ethdev, int udpport,
int tcpport, char *uxpath, int suite, int max_cache_entries,
char *crypto_face_path)
{
struct ccnl_if_s *i;

DEBUGMSG(99, "ccnl_relay_config\n");

ccnl->max_cache_entries = max_cache_entries;
relay->max_cache_entries = max_cache_entries;
#ifdef USE_SCHEDULER
ccnl->defaultFaceScheduler = ccnl_relay_defaultFaceScheduler;
ccnl->defaultInterfaceScheduler = ccnl_relay_defaultInterfaceScheduler;
relay->defaultFaceScheduler = ccnl_relay_defaultFaceScheduler;
relay->defaultInterfaceScheduler = ccnl_relay_defaultInterfaceScheduler;
#endif

#ifdef USE_ETHERNET
// add (real) eth0 interface with index 0:
if (ethdev) {
i = &ccnl->ifs[ccnl->ifcount];
i = &relay->ifs[relay->ifcount];
i->sock = ccnl_open_ethdev(ethdev, &i->addr.eth, CCNL_ETH_TYPE);
i->mtu = 1500;
i->reflect = 1;
i->fwdalli = 1;
if (i->sock >= 0) {
ccnl->ifcount++;
relay->ifcount++;
DEBUGMSG(99, "new ETH interface (%s %s) configured\n",
ethdev, ccnl_addr2ascii(&i->addr));
if (ccnl->defaultInterfaceScheduler)
i->sched = ccnl->defaultInterfaceScheduler(ccnl,
if (relay->defaultInterfaceScheduler)
i->sched = relay->defaultInterfaceScheduler(relay,
ccnl_interface_CTS);
} else
fprintf(stderr, "sorry, could not open eth device\n");
}
#endif // USE_ETHERNET

if (udpport > 0) {
i = &ccnl->ifs[ccnl->ifcount];
i = &relay->ifs[relay->ifcount];
i->sock = ccnl_open_udpdev(udpport, &i->addr.ip4);
// i->frag = CCNL_DGRAM_FRAG_NONE;
i->mtu = CCN_DEFAULT_MTU;

#ifdef USE_SUITE_CCNB
if (suite == CCNL_SUITE_CCNB)
i->mtu = CCN_DEFAULT_MTU;
#endif
#ifdef USE_SUITE_NDNTLV
if (suite == CCNL_SUITE_NDNTLV)
i->mtu = NDN_DEFAULT_MTU;
#endif
i->fwdalli = 1;
if (i->sock >= 0) {
ccnl->ifcount++;
relay->ifcount++;
DEBUGMSG(99, "new UDP interface (ip4 %s) configured\n",
ccnl_addr2ascii(&i->addr));
if (ccnl->defaultInterfaceScheduler)
i->sched = ccnl->defaultInterfaceScheduler(ccnl,
if (relay->defaultInterfaceScheduler)
i->sched = relay->defaultInterfaceScheduler(relay,
ccnl_interface_CTS);
} else
fprintf(stderr, "sorry, could not open udp device\n");
}

#ifdef USE_HTTP_STATUS
if (tcpport) {
ccnl->http = ccnl_http_new(ccnl, tcpport);
relay->http = ccnl_http_new(relay, tcpport);
}
#endif // USE_HTTP_STATUS

#ifdef USE_UNIXSOCKET
if (uxpath) {
i = &ccnl->ifs[ccnl->ifcount];
i = &relay->ifs[relay->ifcount];
i->sock = ccnl_open_unixpath(uxpath, &i->addr.ux);
i->mtu = 4096;
if (i->sock >= 0) {
ccnl->ifcount++;
relay->ifcount++;
DEBUGMSG(99, "new UNIX interface (%s) configured\n",
ccnl_addr2ascii(&i->addr));
if (ccnl->defaultInterfaceScheduler)
i->sched = ccnl->defaultInterfaceScheduler(ccnl,
if (relay->defaultInterfaceScheduler)
i->sched = relay->defaultInterfaceScheduler(relay,
ccnl_interface_CTS);
} else
fprintf(stderr, "sorry, could not open unix datagram device\n");
}
#ifdef USE_SIGNATURES
if(crypto_face_path)
{
char h[1024];
char h[1024];
//sending interface + face
i = &ccnl->ifs[ccnl->ifcount];
i->sock = ccnl_open_unixpath(crypto_face_path, &i->addr.ux);
i->mtu = 4096;
if (i->sock >= 0) {
ccnl->ifcount++;
DEBUGMSG(99, "new UNIX interface (%s) configured\n",
ccnl_addr2ascii(&i->addr));
if (ccnl->defaultInterfaceScheduler){
i->sched = ccnl->defaultInterfaceScheduler(ccnl,
i = &relay->ifs[relay->ifcount];
i->sock = ccnl_open_unixpath(crypto_face_path, &i->addr.ux);
i->mtu = 4096;
if (i->sock >= 0) {
relay->ifcount++;
DEBUGMSG(99, "new UNIX interface (%s) configured\n",
ccnl_addr2ascii(&i->addr));
if (relay->defaultInterfaceScheduler)
i->sched = relay->defaultInterfaceScheduler(relay,
ccnl_interface_CTS);
}
ccnl_crypto_create_ccnl_crypto_face(ccnl, crypto_face_path);
ccnl->crypto_path = crypto_face_path;
ccnl_crypto_create_ccnl_crypto_face(relay, crypto_face_path);
relay->crypto_path = crypto_face_path;
} else
fprintf(stderr, "sorry, could not open unix datagram device\n");

//receiving interface
memset(h,0,sizeof(h));
sprintf(h,"%s-2",crypto_face_path);
i = &ccnl->ifs[ccnl->ifcount];
i = &relay->ifs[relay->ifcount];
i->sock = ccnl_open_unixpath(h, &i->addr.ux);
i->mtu = 4096;
if (i->sock >= 0) {
ccnl->ifcount++;
relay->ifcount++;
DEBUGMSG(99, "new UNIX interface (%s) configured\n",
ccnl_addr2ascii(&i->addr));
if (ccnl->defaultInterfaceScheduler)
i->sched = ccnl->defaultInterfaceScheduler(ccnl,
if (relay->defaultInterfaceScheduler)
i->sched = relay->defaultInterfaceScheduler(relay,
ccnl_interface_CTS);
//create_ccnl_crypto_face(relay, crypto_face_path);
} else
fprintf(stderr, "sorry, could not open unix datagram device\n");
}
#endif //USE_SIGNATURES
#endif // USE_UNIXSOCKET
ccnl_set_timer(1000000, ccnl_ageing, ccnl, 0);
ccnl_set_timer(1000000, ccnl_ageing, relay, 0);
}

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -512,19 +521,34 @@ ccnl_io_loop(struct ccnl_relay_s *ccnl)


void
ccnl_populate_cache(struct ccnl_relay_s *ccnl, char *path)
ccnl_populate_cache(struct ccnl_relay_s *ccnl, char *path, int suite)
{
DIR *dir;
struct dirent *de;
int datalen;
char *suffix;

DEBUGMSG(99, "ccnl_populate_cache %s\n", path);

switch (suite) {
#ifdef USE_SUITE_CCNB
case CCNL_SUITE_CCNB:
suffix = "*.ccnb"; break;
#endif
#ifdef USE_SUITE_NDNTLV
case CCNL_SUITE_NDNTLV:
suffix = "*.ndntlv"; break;
#endif
default:
fprintf(stderr, "unknown suite and encoding, cannot populate cache.\n");
return;
}

dir = opendir(path);
if (!dir)
return;
while ((de = readdir(dir))) {
if (!fnmatch("*.ccnb", de->d_name, FNM_NOESCAPE)) {
if (!fnmatch(suffix, de->d_name, FNM_NOESCAPE)) {
char fname[1000];
struct stat s;
strcpy(fname, path);
Expand All @@ -548,25 +572,46 @@ ccnl_populate_cache(struct ccnl_relay_s *ccnl, char *path)
s.st_size);
datalen = read(fd, buf->data, s.st_size);
close(fd);
if (datalen == s.st_size && datalen >= 2 &&
buf->data[0] == 0x04 && buf->data[1] == 0x82) {
if (datalen == s.st_size && datalen >= 2) {
struct ccnl_prefix_s *prefix = 0;
struct ccnl_content_s *c = 0;
struct ccnl_buf_s *nonce=0, *ppkd=0, *pkt = 0;
unsigned char *content, *data = buf->data + 2;
int contlen;
unsigned char *content, *data;
int contlen, typ, len;

buf->datalen = datalen;
datalen -= 2;
pkt = ccnl_ccnb_extract(&data, &datalen, 0, 0, 0, 0,
switch (suite) {
#ifdef USE_SUITE_CCNB
case CCNL_SUITE_CCNB:
if (buf->data[0] != 0x04 || buf->data[1] != 0x82)
goto notacontent;
data = buf->data + 2;
datalen -= 2;
pkt = ccnl_ccnb_extract(&data, &datalen, 0, 0, 0, 0,
&prefix, &nonce, &ppkd, &content, &contlen);
break;
#endif
#ifdef USE_SUITE_NDNTLV
case CCNL_SUITE_NDNTLV:
data = buf->data;
if (ccnl_ndntlv_dehead(&data, &datalen, &typ, &len) ||
typ != NDN_TLV_Data)
goto notacontent;
pkt = ccnl_ndntlv_extract(data - buf->data,
&data, &datalen, 0, 0, 0, 0,
&prefix, &nonce, &ppkd, &content, &contlen);
break;
#endif
default:
goto Done;
}
if (!pkt) {
DEBUGMSG(6, " parsing error\n"); goto Done;
}
if (!prefix) {
DEBUGMSG(6, " no prefix error\n"); goto Done;
}
c = ccnl_content_new(ccnl, CCNL_SUITE_CCNB, &pkt, &prefix,
c = ccnl_content_new(ccnl, suite, &pkt, &prefix,
&ppkd, content, contlen);
if (!c)
goto Done;
Expand All @@ -579,6 +624,7 @@ ccnl_populate_cache(struct ccnl_relay_s *ccnl, char *path)
ccnl_free(nonce);
ccnl_free(ppkd);
} else {
notacontent:
DEBUGMSG(6, " not a content object\n");
ccnl_free(buf);
}
Expand All @@ -594,8 +640,7 @@ main(int argc, char **argv)
{
int opt;
int max_cache_entries = -1;
int udpport = CCN_UDP_PORT;
int tcpport = CCN_UDP_PORT;
int udpport, tcpport;
char *datadir = NULL;
char *ethdev = NULL;
char *crypto_sock_path = 0;
Expand Down Expand Up @@ -666,7 +711,7 @@ main(int argc, char **argv)
" [-g MIN_INTER_PACKET_INTERVAL]"
" [-i MIN_INTER_CCNMSG_INTERVAL]"
" [-s SUITE (0=ccnb, 2=ndntlv)"
" [-t tcpport]"
" [-t tcpport (for HTML status page)]"
" [-u udpport]"
" [-v DEBUG_LEVEL]"

Expand All @@ -685,9 +730,9 @@ main(int argc, char **argv)
DEBUGMSG(1, " compile options: %s\n", compile_string());

ccnl_relay_config(&theRelay, ethdev, udpport, tcpport,
uxpath, max_cache_entries, crypto_sock_path);
uxpath, suite, max_cache_entries, crypto_sock_path);
if (datadir)
ccnl_populate_cache(&theRelay, datadir);
ccnl_populate_cache(&theRelay, datadir, suite);

ccnl_io_loop(&theRelay);

Expand Down
Loading

0 comments on commit 323794c

Please sign in to comment.