Adding faces from Configuration Done
diff --git a/nlsr-sync-0.0/Makefile b/nlsr-sync-0.0/Makefile
index d92ec7c..30e4fad 100755
--- a/nlsr-sync-0.0/Makefile
+++ b/nlsr-sync-0.0/Makefile
@@ -5,7 +5,7 @@
 PROGRAMS = nlsrc nlsr
 INSTALL_PATH=/usr/local/bin/
 
-NLSR_SRCS=nlsr.c nlsr_ndn.c nlsr_npl.c  nlsr_adl.c nlsr_lsdb.c nlsr_route.c nlsr_npt.c nlsr_fib.c nlsr_sync.c utility.c
+NLSR_SRCS=nlsr.c nlsr_ndn.c nlsr_npl.c  nlsr_adl.c nlsr_lsdb.c nlsr_route.c nlsr_npt.c nlsr_fib.c nlsr_sync.c  nlsr_face.c utility.c
 NLSRC_SRCS=nlsrc.c
 
 all: $(PROGRAMS)
diff --git a/nlsr-sync-0.0/macbook.conf b/nlsr-sync-0.0/macbook.conf
index 910b939..4150a56 100755
--- a/nlsr-sync-0.0/macbook.conf
+++ b/nlsr-sync-0.0/macbook.conf
@@ -1,9 +1,9 @@
 #----configuration file for macbook----------
 #
 router-name /ndn/memphis.edu/netlab/macbook
-ccnneighbor /ndn/memphis.edu/cs/maia face11
-ccnneighbor /ndn/memphis.edu/cs/mira face38
-ccnneighbor /ndn/memphis.edu/cs/castor face38
+ccnneighbor /ndn/memphis.edu/cs/maia
+ccnneighbor /ndn/memphis.edu/cs/mira
+ccnneighbor /ndn/memphis.edu/cs/castor
 ccnname /ndn/memphis.edu/macbook/patterson
 ccnname /ndn/memphis.edu/macbook/houston/
 #------lsdb-synch-interval-----
diff --git a/nlsr-sync-0.0/nlsr.c b/nlsr-sync-0.0/nlsr.c
index 578a0a6..c7c468f 100755
--- a/nlsr-sync-0.0/nlsr.c
+++ b/nlsr-sync-0.0/nlsr.c
@@ -38,6 +38,8 @@
 #include "nlsr_npt.h"
 #include "nlsr_route.h"
 #include "nlsr_sync.h"
+#include "nlsr_face.h"
+#include "nlsr_fib.h"
 
 
 #define ON_ERROR_DESTROY(resval) \
@@ -156,7 +158,8 @@
 	}
 	char *rem;
 	const char *sep=" \t\n";
-	char *rtr_name,*face;
+	char *rtr_name;
+	//char *face;
 
 	rtr_name=strtok_r(command,sep,&rem);
 	if(rtr_name==NULL)
@@ -165,7 +168,7 @@
 		return;
 	}
 
-	face=strtok_r(NULL,sep,&rem);
+	/*face=strtok_r(NULL,sep,&rem);
 	if(face==NULL)
 	{
 		printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
@@ -181,7 +184,7 @@
 	{
 		printf(" Wrong Command Format ( ccnneighbor router_name faceX) where X is integer\n");
 		return;
-	}
+	}*/
 
 	if ( rtr_name[strlen(rtr_name)-1] == '/' )
 	{
@@ -199,10 +202,13 @@
 	get_host_name_from_command_string(nbr_name,nbr->name,0);
 	printf("Hostname of neighbor: %s ",nbr_name->name);
 
-	struct sockaddr_in *ip=get_ip_from_hostname(nbr_name->name);
-	printf("IP Address: %s \n",inet_ntoa( ip->sin_addr ));
 
-	add_nbr_to_adl(nbr,face_id,inet_ntoa( ip->sin_addr ));
+	char *ip_addr=(char *)malloc(13);
+	memset(ip_addr,13,0);
+	get_ip_from_hostname_02(nbr_name->name,ip_addr);
+	printf("IP Address: %s \n",ip_addr);
+
+	add_nbr_to_adl(nbr,0,ip_addr);
 	
 
 	free(nbr->name);
@@ -711,6 +717,33 @@
 	return 0;
 }
 
+
+void
+add_faces_for_nbrs(void)
+{	
+	int i, adl_element;
+	struct ndn_neighbor *nbr;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = ⅇ
+    	
+    	hashtb_start(nlsr->adl, e);
+	adl_element=hashtb_n(nlsr->adl);
+
+	for(i=0;i<adl_element;i++)
+	{
+		nbr=e->data;
+		int face_id=add_ccn_face(nlsr->ccn, (const char *)nbr->neighbor->name, (const char *)nbr->ip_address, 9695);
+		update_face_to_adl_for_nbr(nbr->neighbor->name, face_id);		
+		add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id);
+		//add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_REG, face_id);
+		hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+
+}
+
 char *
 process_api_client_command(char *command)
 {
@@ -813,11 +846,18 @@
 				get_host_name_from_command_string(nbr_name,np->name,0);
 				printf("Hostname of neighbor: %s ",nbr_name->name);
 
-				struct sockaddr_in *ip=get_ip_from_hostname(nbr_name->name);
-				printf("IP Address: %s \n",inet_ntoa( ip->sin_addr ));
-				
-				add_nbr_to_adl(np,face_id,inet_ntoa( ip->sin_addr ));
+				char *ip_addr=(char *)malloc(13);
+				memset(ip_addr,13,0);
+				get_ip_from_hostname_02(nbr_name->name,ip_addr);
+				printf("IP Address: %s \n",ip_addr);
+				int face_id=add_ccn_face(nlsr->ccn, (const char *)nbr_name->name, (const char *)ip_addr, 9695);
+				update_face_to_adl_for_nbr(nbr_name->name, face_id);		
+				add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id);				
+
+				add_nbr_to_adl(np,face_id,ip_addr);
+
 				sprintf(msg,"Neighbor %s has been added to adjacency list.",name);
+
 			}
 			else
 			{
@@ -1121,6 +1161,8 @@
 
 	readConfigFile(config_file);
 
+	print_adjacent_from_adl();
+
 	if ( daemon_mode == 1 )
 	{
 		daemonize_nlsr();
@@ -1169,6 +1211,7 @@
 		printf("lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
 	writeLogg(__FILE__,__FUNCTION__,__LINE__,"lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
 
+	add_faces_for_nbrs();
 	print_name_prefix_from_npl();
 	print_adjacent_from_adl();
 	build_and_install_name_lsas();
@@ -1178,8 +1221,6 @@
 
 	write_name_lsdb_to_repo(nlsr->slice_prefix);
 
-	//write_data_to_repo();
-
 	nlsr->sched = ccn_schedule_create(nlsr, &ndn_rtr_ticker);
 	nlsr->event_send_info_interest = ccn_schedule_event(nlsr->sched, 1, &send_info_interest, NULL, 0);
 	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
diff --git a/nlsr-sync-0.0/nlsr.h b/nlsr-sync-0.0/nlsr.h
index 254f1ec..e9d83d0 100755
--- a/nlsr-sync-0.0/nlsr.h
+++ b/nlsr-sync-0.0/nlsr.h
@@ -16,7 +16,7 @@
 #define NAME_LSA_VALID 1
 #define NAME_LSA_INVALID 0
 
-#define API_PORT 9696
+#define API_PORT 9999
 
 
 struct name_prefix
diff --git a/nlsr-sync-0.0/nlsr_adl.c b/nlsr-sync-0.0/nlsr_adl.c
index 8a5fbb4..3b41345 100755
--- a/nlsr-sync-0.0/nlsr_adl.c
+++ b/nlsr-sync-0.0/nlsr_adl.c
@@ -899,6 +899,32 @@
 	return connecting_face;
 }
 
+void
+update_face_to_adl_for_nbr(char *nbr, int face)
+{
+	int res;
+	struct ndn_neighbor *nnbr;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+
+	hashtb_start(nlsr->adl, e);
+	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
+
+	if( res == HT_OLD_ENTRY )
+	{
+		nnbr=e->data;
+		nnbr->face=face;
+		
+	}
+	else if(res == HT_NEW_ENTRY)
+	{
+		hashtb_delete(e);
+	}
+
+	hashtb_end(e);
+}
+
 int 
 is_neighbor(char *nbr)
 {
diff --git a/nlsr-sync-0.0/nlsr_adl.h b/nlsr-sync-0.0/nlsr_adl.h
index 6fca523..af00a2f 100755
--- a/nlsr-sync-0.0/nlsr_adl.h
+++ b/nlsr-sync-0.0/nlsr_adl.h
@@ -49,4 +49,5 @@
 void adjust_adjacent_last_lsdb_requested_to_adl(char *nbr, long int sec);
 int get_next_hop_face_from_adl(char *nbr);
 int is_neighbor(char *nbr);
+void update_face_to_adl_for_nbr(char *nbr, int face);
 #endif
diff --git a/nlsr-sync-0.0/utility.c b/nlsr-sync-0.0/utility.c
index d18af41..cf7452a 100755
--- a/nlsr-sync-0.0/utility.c
+++ b/nlsr-sync-0.0/utility.c
@@ -232,16 +232,16 @@
     hints.ai_family = AF_UNSPEC;
     hints.ai_socktype = SOCK_STREAM;
 
-    if ( (res = getaddrinfo( hostname , "http", &hints , &servinfo)) != 0)
+    if ( (res = getaddrinfo( hostname , "9696", &hints , &servinfo)) != 0)
     {
         fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(res));
         return NULL;
     }
-    //int i=0;
+    int i=0;
     for(p = servinfo; p != NULL; p = p->ai_next)
     {
         ip = (struct sockaddr_in *) p->ai_addr;
-	//i++;
+	i++;
    
     }
     freeaddrinfo(servinfo);
@@ -251,3 +251,26 @@
 }
 
 
+
+int 
+get_ip_from_hostname_02(char * hostname , char* ip)
+{
+    struct hostent *he;
+    struct in_addr **addr_list;
+    int i;
+    if ( (he = gethostbyname( hostname ) ) == NULL)
+    {
+        herror("gethostbyname");
+        return 1;
+    }
+    addr_list = (struct in_addr **) he->h_addr_list;
+    for(i = 0; addr_list[i] != NULL; i++)
+    {
+        strcpy(ip , inet_ntoa(*addr_list[i]) );
+        return 0;
+    }
+    return 1;
+}
+
+
+
diff --git a/nlsr-sync-0.0/utility.h b/nlsr-sync-0.0/utility.h
index 9028600..f90c281 100755
--- a/nlsr-sync-0.0/utility.h
+++ b/nlsr-sync-0.0/utility.h
@@ -10,4 +10,5 @@
 void startLogging(char *loggingDir);
 void writeLogg(const char *source_file, const char *function, const int line, const char *format, ...);
 struct sockaddr_in * get_ip_from_hostname(char *hostname);
+int get_ip_from_hostname_02(char * hostname , char* ip);
 #endif