Deleted Added
full compact
route.c (9500) route.c (11819)
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "From: @(#)route.c 8.3 (Berkeley) 3/9/94";
37#endif
38static const char rcsid[] =
1/*
2 * Copyright (c) 1983, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "From: @(#)route.c 8.3 (Berkeley) 3/9/94";
37#endif
38static const char rcsid[] =
39 "$Id: route.c,v 1.5 1995/05/30 06:32:53 rgrimes Exp $";
39 "$Id: route.c,v 1.6 1995/07/12 19:21:36 bde Exp $";
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>
45#include <sys/mbuf.h>
46
47#include <net/if.h>
48#include <net/if_dl.h>
49#include <net/if_types.h>
50#define KERNEL
51#include <net/route.h>
52#undef KERNEL
53#include <netinet/in.h>
54
40#endif /* not lint */
41
42#include <sys/param.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>
45#include <sys/mbuf.h>
46
47#include <net/if.h>
48#include <net/if_dl.h>
49#include <net/if_types.h>
50#define KERNEL
51#include <net/route.h>
52#undef KERNEL
53#include <netinet/in.h>
54
55#include <netipx/ipx.h>
56
55#include <netns/ns.h>
56
57#include <sys/sysctl.h>
58
59#include <netdb.h>
60#include <stdio.h>
61#include <stdlib.h>
62#include <string.h>

--- 101 unchanged lines hidden (view full) ---

164 int af;
165{
166 char *afname;
167
168 switch (af) {
169 case AF_INET:
170 afname = "Internet";
171 break;
57#include <netns/ns.h>
58
59#include <sys/sysctl.h>
60
61#include <netdb.h>
62#include <stdio.h>
63#include <stdlib.h>
64#include <string.h>

--- 101 unchanged lines hidden (view full) ---

166 int af;
167{
168 char *afname;
169
170 switch (af) {
171 case AF_INET:
172 afname = "Internet";
173 break;
174 case AF_IPX:
175 afname = "IPX";
176 break;
172 case AF_NS:
173 afname = "XNS";
174 break;
175 case AF_ISO:
176 afname = "ISO";
177 break;
178 case AF_CCITT:
179 afname = "X.25";

--- 13 unchanged lines hidden (view full) ---

193#define WID_GW 18 /* width of gateway column */
194
195/*
196 * Print header for routing table columns.
197 */
198void
199pr_rthdr()
200{
177 case AF_NS:
178 afname = "XNS";
179 break;
180 case AF_ISO:
181 afname = "ISO";
182 break;
183 case AF_CCITT:
184 afname = "X.25";

--- 13 unchanged lines hidden (view full) ---

198#define WID_GW 18 /* width of gateway column */
199
200/*
201 * Print header for routing table columns.
202 */
203void
204pr_rthdr()
205{
201
202 if (Aflag)
203 printf("%-8.8s ","Address");
204 printf("%-*.*s %-*.*s %-6.6s %6.6s%8.8s %8.8s %6s\n",
205 WID_DST, WID_DST, "Destination",
206 WID_GW, WID_GW, "Gateway",
207 "Flags", "Refs", "Use", "Netif", "Expire");
208}
209

--- 164 unchanged lines hidden (view full) ---

374
375 cp = (sin->sin_addr.s_addr == 0) ? "default" :
376 ((flags & RTF_HOST) ?
377 routename(sin->sin_addr.s_addr) :
378 netname(sin->sin_addr.s_addr, 0L));
379 break;
380 }
381
206 if (Aflag)
207 printf("%-8.8s ","Address");
208 printf("%-*.*s %-*.*s %-6.6s %6.6s%8.8s %8.8s %6s\n",
209 WID_DST, WID_DST, "Destination",
210 WID_GW, WID_GW, "Gateway",
211 "Flags", "Refs", "Use", "Netif", "Expire");
212}
213

--- 164 unchanged lines hidden (view full) ---

378
379 cp = (sin->sin_addr.s_addr == 0) ? "default" :
380 ((flags & RTF_HOST) ?
381 routename(sin->sin_addr.s_addr) :
382 netname(sin->sin_addr.s_addr, 0L));
383 break;
384 }
385
386 case AF_IPX:
387 {
388struct ipx_addr work = ((struct sockaddr_ipx *)sa)->sipx_addr;
389 if (ipx_nullhost(satoipx_addr(work)))
390 cp = "default";
391 else
392 cp = ipx_print(sa);
393 break;
394 }
395
382 case AF_NS:
383 cp = ns_print(sa);
384 break;
385
386 case AF_LINK:
387 {
388 register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
389

--- 180 unchanged lines hidden (view full) ---

570 * width subnet fields.
571 */
572 while (i &~ mask)
573 mask = (long)mask >> subnetshift;
574 }
575 net = i & mask;
576 while ((mask & 1) == 0)
577 mask >>= 1, net >>= 1;
396 case AF_NS:
397 cp = ns_print(sa);
398 break;
399
400 case AF_LINK:
401 {
402 register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
403

--- 180 unchanged lines hidden (view full) ---

584 * width subnet fields.
585 */
586 while (i &~ mask)
587 mask = (long)mask >> subnetshift;
588 }
589 net = i & mask;
590 while ((mask & 1) == 0)
591 mask >>= 1, net >>= 1;
578 np = getnetbyaddr(net, AF_INET);
592 if (!(np = getnetbyaddr(net, AF_INET)))
593 np = getnetbyaddr(i, AF_INET);
579 if (np)
580 cp = np->n_name;
581 }
582 if (cp)
583 strncpy(line, cp, sizeof(line) - 1);
584 else if ((i & 0xffffff) == 0)
585 sprintf(line, "%u", C(i >> 24));
586 else if ((i & 0xffff) == 0)

--- 27 unchanged lines hidden (view full) ---

614 rtstat.rts_dynamic, plural(rtstat.rts_dynamic));
615 printf("\t%u new gateway%s due to redirects\n",
616 rtstat.rts_newgateway, plural(rtstat.rts_newgateway));
617 printf("\t%u destination%s found unreachable\n",
618 rtstat.rts_unreach, plural(rtstat.rts_unreach));
619 printf("\t%u use%s of a wildcard route\n",
620 rtstat.rts_wildcard, plural(rtstat.rts_wildcard));
621}
594 if (np)
595 cp = np->n_name;
596 }
597 if (cp)
598 strncpy(line, cp, sizeof(line) - 1);
599 else if ((i & 0xffffff) == 0)
600 sprintf(line, "%u", C(i >> 24));
601 else if ((i & 0xffff) == 0)

--- 27 unchanged lines hidden (view full) ---

629 rtstat.rts_dynamic, plural(rtstat.rts_dynamic));
630 printf("\t%u new gateway%s due to redirects\n",
631 rtstat.rts_newgateway, plural(rtstat.rts_newgateway));
632 printf("\t%u destination%s found unreachable\n",
633 rtstat.rts_unreach, plural(rtstat.rts_unreach));
634 printf("\t%u use%s of a wildcard route\n",
635 rtstat.rts_wildcard, plural(rtstat.rts_wildcard));
636}
637
638char *
639ipx_print(sa)
640 register struct sockaddr *sa;
641{
642 u_short port;
643 struct netent *np = 0;
644 struct hostent *hp = 0;
645 struct servent *sp = 0;
646 char *net = "", *host = "";
647 register char *p; register u_char *q;
648 struct ipx_addr work = ((struct sockaddr_ipx *)sa)->sipx_addr;
649static char mybuf[50];
650 char cport[10], chost[15], cnet[15];
651
652 sp = getservbyport(work.x_port, "ipx");
653 port = ntohs(work.x_port);
654
655 if (ipx_nullnet(work) && ipx_nullhost(work)) {
656
657 if (port) {
658 if (sp) sprintf(mybuf, "*.%s", sp->s_name);
659 else sprintf(mybuf, "*.%x", port);
660 } else
661 sprintf(mybuf, "*.*");
662
663 return (mybuf);
664 }
665
666 if (np = getnetbyaddr(*(u_long *)&work.x_net, AF_IPX))
667 net = np->n_name;
668 else if (ipx_wildnet(work))
669 net = "any";
670 else if (ipx_nullnet(work))
671 net = "*";
672 else {
673 q = work.x_net.c_net;
674 sprintf(cnet, "%02x%02x%02x%02x",
675 q[0], q[1], q[2], q[3]);
676 for (p = cnet; *p == '0' && p < cnet + 8; p++)
677 continue;
678 net = p;
679 }
680
681 if (hp = gethostbyaddr((char *)&work.x_host, 6, AF_IPX))
682 host = hp->h_name;
683 else if (ipx_wildhost(work))
684 host = "any";
685 else if (ipx_nullhost(work))
686 host = "*";
687 else {
688 q = work.x_host.c_host;
689 sprintf(chost, "%02x%02x%02x%02x%02x%02x",
690 q[0], q[1], q[2], q[3], q[4], q[5]);
691 for (p = chost; *p == '0' && p < chost + 12; p++)
692 continue;
693 host = p;
694 }
695
696 if (port) {
697 if (strcmp(host, "*") == 0) host = "";
698 if (sp) sprintf(cport, "%s%s", *host ? "." : "", sp->s_name);
699 else sprintf(cport, "%s%x", *host ? "." : "", port);
700 } else
701 *cport = 0;
702
703 sprintf(mybuf,"%s.%s%s", net, host, cport);
704 return(mybuf);
705}
706
707char *
708ipx_phost(sa)
709 struct sockaddr *sa;
710{
711 register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)sa;
712 struct sockaddr_ipx work;
713static union ipx_net ipx_zeronet;
714 char *p;
715 struct ipx_addr in;
716 struct hostent *hp;
717
718 work = *sipx;
719 in = work.sipx_addr;
720
721 hp = gethostbyaddr((char *)&in, sizeof(struct ipx_addr), AF_IPX);
722 if (hp) return (hp->h_name);
723
724 work.sipx_addr.x_port = 0;
725 work.sipx_addr.x_net = ipx_zeronet;
726 p = ipx_print((struct sockaddr *)&work);
727 if (strncmp("*.", p, 2) == 0) p += 2;
728
729 return(p);
730}
731
622short ns_nullh[] = {0,0,0};
623short ns_bh[] = {-1,-1,-1};
624
625char *
626ns_print(sa)
627 register struct sockaddr *sa;
628{
629 register struct sockaddr_ns *sns = (struct sockaddr_ns*)sa;

--- 71 unchanged lines hidden ---
732short ns_nullh[] = {0,0,0};
733short ns_bh[] = {-1,-1,-1};
734
735char *
736ns_print(sa)
737 register struct sockaddr *sa;
738{
739 register struct sockaddr_ns *sns = (struct sockaddr_ns*)sa;

--- 71 unchanged lines hidden ---