Skip to content

Commit

Permalink
Add Prefix name to debug dump output
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksheeep committed Jul 15, 2013
1 parent d06b2d8 commit cbe6091
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
11 changes: 6 additions & 5 deletions ccnl-ext-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,14 @@ get_buf_dump(int lev, void *p, int *outbuf, int *len, int *next)
}

int
get_prefix_dump(int lev, void *p, int *prefix, int *len, char* val)
get_prefix_dump(int lev, void *p, int *len, char** val)
{
struct ccnl_prefix_s *pre = (struct ccnl_prefix_s *) p;
int i;
INDENT(lev);
*prefix = (void *) pre;
//*prefix = (void *) pre;
*len = pre->compcnt;
val = ccnl_prefix_to_path(pre);

*val = ccnl_prefix_to_path(pre);
return 1;
}

Expand Down Expand Up @@ -415,7 +414,8 @@ get_num_fwds(void *p)
}

int
get_fwd_dump(int lev, void *p, int *outfwd, int *next, int *face, int *faceid)
get_fwd_dump(int lev, void *p, int *outfwd, int *next, int *face, int *faceid,
int *prefixlen, char **prefix)
{
struct ccnl_relay_s *top = (struct ccnl_relay_s *) p;
struct ccnl_forward_s *fwd = (struct ccnl_forward_s *) top->fib;
Expand All @@ -430,6 +430,7 @@ get_fwd_dump(int lev, void *p, int *outfwd, int *next, int *face, int *faceid)
face[line] = (void *) fwd->face;
faceid[line] = (void *) fwd->face->faceid;

get_prefix_dump(lev, fwd->prefix, prefixlen, &prefix[line]);
fwd = fwd->next;
++line;
}
Expand Down
24 changes: 19 additions & 5 deletions ccnl-ext-mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int create_faces_stmt(int num_faces, int *faceid, int *facenext, int *faceprev,

int
create_fwds_stmt(int num_fwds, int *fwd, int *fwdnext, int *fwdface, int *fwdfaceid,
char *stmt, int len3)
int *fwdprefixlen, char **fwdprefix, char *stmt, int len3)
{
int it;
unsigned char str[100];
Expand All @@ -214,6 +214,8 @@ create_fwds_stmt(int num_fwds, int *fwd, int *fwdnext, int *fwdface, int *fwdfac
memset(str, 0, 100);
sprintf(str, "%d", fwdfaceid[it]);
len3 += mkStrBlob(stmt+len3, CCN_DTAG_FACEID, CCN_TT_DTAG, str);

len3 += mkStrBlob(stmt+len3, CCNL_DTAG_PREFIX, CCN_TT_DTAG, fwdprefix[it]);

stmt[len3++] = 0; //end of fwd;

Expand Down Expand Up @@ -314,7 +316,8 @@ ccnl_mgmt_debug(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
int *faceid, *facenext, *faceprev, *faceifndx, *faceflags, *facetype; //store face-info
unsigned char **facepeer;

int *fwd, *fwdnext, *fwdface, *fwdfaceid;
int *fwd, *fwdnext, *fwdface, *fwdfaceid ,*fwdprefixlen;
char **fwdprefix;

int *interfaceifndx, *interfacedev, *interfacedevtype, *interfacereflect;
char **interfaceaddr;
Expand Down Expand Up @@ -356,6 +359,13 @@ ccnl_mgmt_debug(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
fwdnext = (int*)ccnl_malloc(num_fwds*sizeof(int));
fwdface = (int*)ccnl_malloc(num_fwds*sizeof(int));
fwdfaceid = (int*)ccnl_malloc(num_fwds*sizeof(int));
fwdprefixlen = (int*)ccnl_malloc(num_fwds*sizeof(int));
fwdprefix = (char**)ccnl_malloc(num_faces*sizeof(char*));
for(it = 0; it <num_fwds; ++it)
{
fwdprefix[it] = (char*)ccnl_malloc(256*sizeof(char));
memset(fwdprefix[it], 0, 256);
}

//Alloc memory storage for interface answer
num_interfaces = get_num_interface(ccnl);
Expand Down Expand Up @@ -428,7 +438,7 @@ ccnl_mgmt_debug(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
ccnl_dump(0, CCNL_RELAY, ccnl);

get_faces_dump(0,ccnl, faceid, facenext, faceprev, faceifndx, faceflags, facepeer, facetype);
get_fwd_dump(0,ccnl, fwd, fwdnext, fwdface, fwdfaceid);
get_fwd_dump(0,ccnl, fwd, fwdnext, fwdface, fwdfaceid, fwdprefixlen, fwdprefix);
get_interface_dump(0, ccnl, interfaceifndx, interfaceaddr, interfacedev, interfacedevtype, interfacereflect);
get_interest_dump(0,ccnl, interest, interestnext,
interestprev, interestlast, interestmin,
Expand All @@ -444,7 +454,7 @@ ccnl_mgmt_debug(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
ccnl_dump(0, CCNL_RELAY, ccnl);

get_faces_dump(0,ccnl, faceid, facenext, faceprev, faceifndx, faceflags, facepeer, facetype);
get_fwd_dump(0,ccnl, fwd, fwdnext, fwdface, fwdfaceid);
get_fwd_dump(0,ccnl, fwd, fwdnext, fwdface, fwdfaceid, fwdprefixlen, fwdprefix);
get_interface_dump(0, ccnl, interfaceifndx, interfaceaddr, interfacedev, interfacedevtype, interfacereflect);
get_interest_dump(0,ccnl, interest, interestnext,
interestprev, interestlast, interestmin,
Expand Down Expand Up @@ -498,7 +508,8 @@ ccnl_mgmt_debug(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
len3 = create_faces_stmt(num_faces, faceid, facenext, faceprev, faceifndx,
faceflags, facetype, facepeer, stmt, len3);

len3 = create_fwds_stmt(num_fwds, fwd, fwdnext, fwdface, fwdfaceid, stmt, len3);
len3 = create_fwds_stmt(num_fwds, fwd, fwdnext, fwdface, fwdfaceid,
fwdprefixlen, fwdprefix, stmt, len3);

len3 = create_interest_stmt(num_interests, interest, interestnext, interestprev,
interestlast, interestmin, interestmax, interestretries,
Expand Down Expand Up @@ -559,6 +570,9 @@ ccnl_mgmt_debug(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
}
ccnl_free(ccontents);
ccnl_free(cprefix);
for(it = 0; it <num_fwds; ++it)
ccnl_free(fwdprefix[it]);
ccnl_free(fwdprefix);

//ccnl_mgmt_return_msg(ccnl, orig, from, cp);
return rc;
Expand Down
4 changes: 4 additions & 0 deletions util/ccn-lite-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,10 @@ handle_ccn_debugreply_content(unsigned char **buf, int *len, int offset, char* t
print_offset(offset+4);
print_tag_content_with_tag(buf, len, "NAME", stream);
break;
case CCNL_DTAG_PREFIX:
print_offset(offset+4);
print_tag_content_with_tag(buf, len, "PREFIX", stream);
break;
default:
goto Bail;
}
Expand Down

0 comments on commit cbe6091

Please sign in to comment.