Formatting and CLeaning nlsr_sync.c/h
diff --git a/macbook.conf b/macbook.conf
index cba7a1d..f948796 100644
--- a/macbook.conf
+++ b/macbook.conf
@@ -1,7 +1,7 @@
#----configuration file for macbook----------
#
router-name /ndn/memphis.edu/netlab/macbook
-#ccnneighbor /ndn/memphis.edu/cs/maia
+ccnneighbor /ndn/memphis.edu/cs/maia
#ccnneighbor /ndn/memphis.edu/cs/mira
#ccnneighbor /ndn/memphis.edu/cs/castor
ccnneighbor /ndn/memphis.edu/cs/pollux 141.225.11.132
diff --git a/nlsr_adl.c b/nlsr_adl.c
index ad6254d..0c86785 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -977,3 +977,61 @@
return ret;
}
+
+void
+get_host_name_from_command_string(struct name_prefix *name_part,
+ char *nbr_name_uri, int offset)
+{
+
+
+
+ int res,i;
+ int len=0;
+ const unsigned char *comp_ptr1;
+ size_t comp_size;
+
+ struct ccn_charbuf *name=ccn_charbuf_create();
+ name = ccn_charbuf_create();
+ res = ccn_name_from_uri(name,nbr_name_uri);
+ if (res < 0) {
+ fprintf(stderr, "Bad ccn URI: %s\n", nbr_name_uri);
+ exit(1);
+ }
+
+ struct ccn_indexbuf cid={0};
+
+ struct ccn_indexbuf *components=&cid;
+ ccn_name_split (name, components);
+
+ for(i=components->n-2;i> (0+offset);i--)
+ {
+ res=ccn_name_comp_get(name->buf, components,i,&comp_ptr1, &comp_size);
+ len+=1;
+ len+=(int)comp_size;
+ }
+ len++;
+
+ char *neighbor=(char *)malloc(len);
+ memset(neighbor,0,len);
+
+ for(i=components->n-2;i> (0+offset);i--)
+ {
+ res=ccn_name_comp_get(name->buf, components,i,&comp_ptr1, &comp_size);
+ if ( i != components->n-2)
+ memcpy(neighbor+strlen(neighbor),".",1);
+ memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,
+ strlen((char *)comp_ptr1));
+
+ }
+
+ name_part->name=(char *)malloc(strlen(neighbor)+1);
+ memset(name_part->name,0,strlen(neighbor)+1);
+ memcpy(name_part->name,neighbor,strlen(neighbor)+1);
+ name_part->length=strlen(neighbor)+1;
+
+ // 01/31/2013
+ free(neighbor);
+ ccn_charbuf_destroy(&name);
+}
+
+
diff --git a/nlsr_adl.h b/nlsr_adl.h
index 1eb74d6..884ae22 100644
--- a/nlsr_adl.h
+++ b/nlsr_adl.h
@@ -51,4 +51,6 @@
int is_neighbor(char *nbr);
int is_active_neighbor(char *nbr);
void update_face_to_adl_for_nbr(char *nbr, int face);
+
+void get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset);
#endif
diff --git a/nlsr_sync.c b/nlsr_sync.c
index 789a0c5..86b26bf 100644
--- a/nlsr_sync.c
+++ b/nlsr_sync.c
@@ -93,7 +93,8 @@
ccn_name_init(content_name);
if (components->n < 2)
return 0;
- res = ccn_name_append_components(content_name, name->buf, components->buf[0], components->buf[components->n - 1]);
+ res = ccn_name_append_components(content_name, name->buf, components->buf[0]
+ , components->buf[components->n - 1]);
if ( res < 0)
return 0;
@@ -116,11 +117,13 @@
if ( nlsr->debugging )
{
printf("Number of components in name = %d \n",res);
- printf("Number of components in name as indexbuf->n = %d \n",(int)components1->n);
+ printf("Number of components in name as indexbuf->n = %d \n",
+ (int)components1->n);
}
ccn_name_chop(content_name,components1,-3);
if ( nlsr->debugging )
- printf("Number of components in name as indexbuf->n after chopping= %d \n",(int)components1->n);
+ printf("Number of components in name as indexbuf->n after chopping= %d \n"
+ ,(int)components1->n);
//debugging purpose
struct ccn_charbuf *temp1=ccn_charbuf_create();
@@ -138,8 +141,10 @@
}
+
void
-get_name_part(struct name_prefix *name_part,struct ccn_charbuf * interest_ccnb, struct ccn_indexbuf *interest_comps, int offset)
+get_name_part(struct name_prefix *name_part,struct ccn_charbuf * interest_ccnb,
+ struct ccn_indexbuf *interest_comps, int offset)
{
@@ -163,7 +168,8 @@
size_t comp_size;
for(i=lsa_position+1+offset;i<interest_comps->n-1;i++)
{
- ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size);
+ ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1,
+ &comp_size);
len+=1;
len+=(int)comp_size;
}
@@ -174,9 +180,11 @@
for(i=lsa_position+1+offset; i<interest_comps->n-1;i++)
{
- ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size);
+ ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1,
+ &comp_size);
memcpy(neighbor+strlen(neighbor),"/",1);
- memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1));
+ memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,
+ strlen((char *)comp_ptr1));
}
@@ -189,59 +197,7 @@
free(neighbor);
}
-void
-get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset)
-{
-
-
- int res,i;
- int len=0;
- const unsigned char *comp_ptr1;
- size_t comp_size;
-
- struct ccn_charbuf *name=ccn_charbuf_create();
- name = ccn_charbuf_create();
- res = ccn_name_from_uri(name,nbr_name_uri);
- if (res < 0) {
- fprintf(stderr, "Bad ccn URI: %s\n", nbr_name_uri);
- exit(1);
- }
-
- struct ccn_indexbuf cid={0};
-
- struct ccn_indexbuf *components=&cid;
- ccn_name_split (name, components);
-
- for(i=components->n-2;i> (0+offset);i--)
- {
- res=ccn_name_comp_get(name->buf, components,i,&comp_ptr1, &comp_size);
- len+=1;
- len+=(int)comp_size;
- }
- len++;
-
- char *neighbor=(char *)malloc(len);
- memset(neighbor,0,len);
-
- for(i=components->n-2;i> (0+offset);i--)
- {
- res=ccn_name_comp_get(name->buf, components,i,&comp_ptr1, &comp_size);
- if ( i != components->n-2)
- memcpy(neighbor+strlen(neighbor),".",1);
- memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1));
-
- }
-
- name_part->name=(char *)malloc(strlen(neighbor)+1);
- memset(name_part->name,0,strlen(neighbor)+1);
- memcpy(name_part->name,neighbor,strlen(neighbor)+1);
- name_part->length=strlen(neighbor)+1;
-
- // 01/31/2013
- free(neighbor);
- ccn_charbuf_destroy(&name);
-}
@@ -295,7 +251,8 @@
int i;
for (i = sizeof(buf) - 1; i >= 0; i--, lifetime_l12 >>= 8)
buf[i] = lifetime_l12 & 0xff;
- ccnb_append_tagged_blob(templ, CCN_DTAG_InterestLifetime, buf, sizeof(buf));
+ ccnb_append_tagged_blob(templ, CCN_DTAG_InterestLifetime, buf,
+ sizeof(buf));
}
ccn_charbuf_append_closer(templ); /* </Interest> */
}
@@ -307,7 +264,8 @@
resultbuf->length = 0;
}
}
- res = ccn_get(nlsr->ccn, name, templ, timeout_ms, resultbuf, &pcobuf, NULL, get_flags);
+ res = ccn_get(nlsr->ccn, name, templ, timeout_ms, resultbuf, &pcobuf, NULL,
+ get_flags);
if (res >= 0) {
ptr = resultbuf->buf;
length = resultbuf->length;
diff --git a/nlsr_sync.h b/nlsr_sync.h
index d2fe9e5..ad6cd8e 100644
--- a/nlsr_sync.h
+++ b/nlsr_sync.h
@@ -4,7 +4,6 @@
int sync_monitor(char *topo_prefix, char *slice_prefix);
int write_data_to_repo(char *data,char *name_prefix);
int create_sync_slice(char *topo_prefix, char *slice_prefix);
-void get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset);
void process_content_from_sync(struct ccn_charbuf *content_name, struct ccn_indexbuf *components);
#endif