Commit fe4ba115 authored by ikumar's avatar ikumar

Now we have the option to specify whether lan is present in the topology or not.

So while running client we specify in the command line whether Lans Exist in the
network or not. Making this a part of the query generated by the client node we
have some more flexibility!
parent 405e70cd
......@@ -18,7 +18,7 @@
*
* ---------------------------
*
* $Id: cli.c,v 1.7 2001-08-02 21:21:05 ikumar Exp $
* $Id: cli.c,v 1.8 2001-08-04 22:58:30 ikumar Exp $
*/
#include "discvr.h"
......@@ -86,9 +86,9 @@ find_nodeID(void)
}
void
make_inquiry(topd_inqid_t *tip, u_int16_t ttl, u_int16_t factor)
make_inquiry(topd_inqid_t *tip, u_int16_t ttl, u_int16_t factor, int lans_exist)
{
struct timeval tv;
struct timeval tv;
u_char *nid;
/* First goes the the time of day... */
......@@ -108,17 +108,18 @@ make_inquiry(topd_inqid_t *tip, u_int16_t ttl, u_int16_t factor)
nid = find_nodeID();
memcpy((void *)tip->tdi_nodeID, nid, ETHADDRSIZ);
bzero(tip->tdi_p_nodeIF,ETHADDRSIZ);
tip->lans_exist = htons(lans_exist);
}
void
cli(int sockfd, const struct sockaddr *pservaddr, socklen_t servlen,
u_int16_t ttl, u_int16_t factor)
u_int16_t ttl, u_int16_t factor, int lans_exist)
{
u_int32_t n;
char recvline[MAXLINE + 1];
topd_inqid_t ti;
make_inquiry(&ti, ttl, factor);
make_inquiry(&ti, ttl, factor, lans_exist);
printf("sending query to server:\n");
sendto(sockfd, &ti, TOPD_INQ_SIZ, 0, pservaddr, servlen);
......@@ -142,8 +143,9 @@ main(int argc, char **argv)
int sockfd;
struct sockaddr_in servaddr;
if (argc != 4) {
fprintf(stderr, "usage: cli <Server IPaddress> <TTL> <factor>\n");
if (argc != 5) {
fprintf(stderr, "usage: cli <Server IPaddress> <TTL> <factor> <lan
present?1/0>\n");
exit(1);
}
......@@ -155,7 +157,8 @@ main(int argc, char **argv)
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
//printf("calling client\n");
cli(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr), atoi(argv[2]), atoi(argv[3]));
cli(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr), atoi(argv[2]),
atoi(argv[3]), atoi(argv[4]));
exit(0);
}
/*$Id: discvr.h,v 1.8 2001-08-02 21:21:05 ikumar Exp $*/
/*$Id: discvr.h,v 1.9 2001-08-04 22:58:30 ikumar Exp $*/
#ifndef _TOPD_DISCVR_H_
#define _TOPD_DISCVR_H_
......@@ -125,4 +125,6 @@ tod(void);
void
gen_nam_file(const char *mesg, size_t nbytes, char *);
void remove_socket(int sock_index,int* sock_list,int* sock_num);
#endif /* _TOPD_DISCVR_H_ */
......@@ -18,7 +18,7 @@
*
* ---------------------------
*
* $Id: forw_requests.c,v 1.10 2001-08-02 21:21:05 ikumar Exp $
* $Id: forw_requests.c,v 1.11 2001-08-04 22:58:30 ikumar Exp $
*/
#include <math.h>
......@@ -110,8 +110,8 @@ forward_request(struct ifi_info *ifihead, const struct in_pktinfo *pktinfo,
continue;
}
memcpy(&(temp_mesg->tdi_p_nodeIF),&(ifi->ifi_haddr),IFHADDRSIZ);
//memcpy(&(temp_mesg->tdi_p_nodeIF),&myNodeID,IFHADDRSIZ);
memcpy(temp_mesg->tdi_p_nodeIF,ifi->ifi_haddr,ETHADDRSIZ);
//memcpy(&(temp_mesg->tdi_p_nodeIF),&myNodeID,ETHADDRSIZ);
printf("Forwarding the query to interface: \"%s\"\n",ifi->ifi_name);
temp_sock_list = sock_list;
......
......@@ -18,7 +18,7 @@
*
* ---------------------------
*
* $Id: packet.h,v 1.6 2001-08-02 21:21:05 ikumar Exp $
* $Id: packet.h,v 1.7 2001-08-04 22:58:30 ikumar Exp $
*/
#ifndef _TOPD_PACKET_H_
......@@ -47,6 +47,7 @@ typedef struct topd_inqid {
u_int16_t tdi_factor;
u_char tdi_nodeID[ETHADDRSIZ];
u_char tdi_p_nodeIF[ETHADDRSIZ];
int lans_exist;
} topd_inqid_t;
#define TOPD_INQ_SIZ ALIGN(sizeof(struct topd_inqid))
......
......@@ -18,7 +18,7 @@
*
* ---------------------------
*
* $Id: serv_listen.c,v 1.10 2001-08-02 21:21:05 ikumar Exp $
* $Id: serv_listen.c,v 1.11 2001-08-04 22:58:30 ikumar Exp $
*/
#include <math.h>
......@@ -44,6 +44,7 @@ extern topd_inqid_t inqid_current;
u_char myNodeID[ETHADDRSIZ];
u_char sendingIF[ETHADDRSIZ];
u_char receivingIF[ETHADDRSIZ];
int lans_exist=1;
/*
* Return 0 if the inquiry is not from us, 1 if it is.
......@@ -269,6 +270,7 @@ serv_listen(int servSockFd, struct sockaddr *pcliaddr, socklen_t clilen)
}
sock_num=0;
free(sock_list);
lans_exist = 1;
state = Q_LISTEN;
free(inqhead);
......@@ -333,6 +335,7 @@ serv_listen(int servSockFd, struct sockaddr *pcliaddr, socklen_t clilen)
memcpy(&senderIF, &(temp_inqid->tdi_p_nodeIF), ETHADDRSIZ);
ttl = ntohs(temp_inqid->tdi_ttl);
factor = ntohs(temp_inqid->tdi_factor);
lans_exist = ntohs(temp_inqid->lans_exist);
if(ttl==0)
printf("The TTL is zero so i will not forward!!\n");
......@@ -401,7 +404,6 @@ serv_listen(int servSockFd, struct sockaddr *pcliaddr, socklen_t clilen)
default:
break;
}
}
for(i=0;i<sock_num;i++)
......@@ -445,6 +447,13 @@ serv_listen(int servSockFd, struct sockaddr *pcliaddr, socklen_t clilen)
// interface, has
ifi->ifi_nbors->tdnbl_n = (n-sizeof(topd_inqid_t)) / sizeof(struct topd_nbor);
ifi->ifi_nbors->tdnbl_next = saveNbr;
if(lans_exist==0)
{
FD_CLR(sock_list[i],&readFd);
close(sock_list[i]);
remove_socket(i,sock_list,&sock_num);
}
}
}
......@@ -478,6 +487,16 @@ serv_listen(int servSockFd, struct sockaddr *pcliaddr, socklen_t clilen)
printf("Deadline still not met. Set timer to %ld\n", timeLimit.tv_sec);
}
}
}
}
void
remove_socket(int sock_index, int* sock_list, int *psock_num)
{
int i=0;
for(i=sock_index;i<(*psock_num-1);i++)
{
sock_list[i]=sock_list[i+1];
}
(*psock_num)--;
}
......@@ -18,7 +18,7 @@
*
* ---------------------------
*
* $Id: util.c,v 1.7 2001-08-02 21:21:05 ikumar Exp $
* $Id: util.c,v 1.8 2001-08-04 22:58:30 ikumar Exp $
*/
#include "discvr.h"
......@@ -191,11 +191,12 @@ print_tdinq(const char *mesg)
{
topd_inqid_t *tip = (topd_inqid_t *)mesg;
printf("\nINQ:%u.%u TTL:%d FACTOR:%d NODE:",
printf("\nINQ:%u.%u TTL:%d FACTOR:%d HAS_LAN:%d NODE:",
ntohl(tip->tdi_tv.tv_sec),
ntohl(tip->tdi_tv.tv_usec),
ntohs(tip->tdi_ttl),
ntohs(tip->tdi_factor));
ntohs(tip->tdi_factor),
ntohs(tip->lans_exist));
print_nodeID(tip->tdi_nodeID);
printf(" PARENT i/f:");
print_nodeID(tip->tdi_p_nodeIF);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment