route.c

stanonik at nprdc stanonik at nprdc
Thu Feb 21 03:17:26 AEST 1985


At one time we were getting some route entries which
we could not remove because the distributed route.c,
using only the address and metric, could not specify
all combinations of rt_flags.  Also I could never
remember what the metric meant.  So, I've changed route.c
to also accept the rt_flags explicitly.

Ron Stanonik
stanonik at nprdc

RCS file: RCS/route.c,v
retrieving revision 1.1
diff -c -r1.1 route.c
*** /tmp/,RCSt1001882	Wed Feb 20 09:07:31 1985
--- route.c	Wed Sep 26 10:32:28 1984
***************
*** 168,174
  	char *cmd;
  
  	if (argc < 3 || argc > 4) {
! 		printf("usage: %s destination gateway [ metric ]\n", argv[0]);
  		return;
  	}
  	cmd = argv[0];

--- 168,174 -----
  	char *cmd;
  
  	if (argc < 3 || argc > 4) {
! 		printf("usage: %s destination gateway [ metric | HG ]\n", argv[0]);
  		return;
  	}
  	cmd = argv[0];
***************
*** 180,185
  		route.rt_flags |= RTF_HOST;
  	if (argc > 3 && atoi(argv[3]) > 0)
  		route.rt_flags |= RTF_GATEWAY;
  	printf("%s %s: gateway ", cmd, routename(sin->sin_addr));
  	sin = (struct sockaddr_in *)&route.rt_gateway;
  	printf("%s, flags %x\n", routename(sin->sin_addr), route.rt_flags);

--- 180,192 -----
  		route.rt_flags |= RTF_HOST;
  	if (argc > 3 && atoi(argv[3]) > 0)
  		route.rt_flags |= RTF_GATEWAY;
+ 	if (argc > 3 && !isdigit(argv[3][0])) {
+ 		route.rt_flags &= ~(RTF_HOST|RTF_GATEWAY); /* undo flags */
+ 		if (index(argv[3], 'H'))
+ 			route.rt_flags |= RTF_HOST;
+ 		if (index(argv[3], 'G'))
+ 			route.rt_flags |= RTF_GATEWAY;
+ 	}
  	printf("%s %s: gateway ", cmd, routename(sin->sin_addr));
  	sin = (struct sockaddr_in *)&route.rt_gateway;
  	printf("%s, flags %x\n", routename(sin->sin_addr), route.rt_flags);



More information about the Comp.unix.wizards mailing list