if.c (10974) | if.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 --- 29 unchanged lines hidden (view full) --- 38#include <sys/types.h> 39#include <sys/protosw.h> 40#include <sys/socket.h> 41 42#include <net/if.h> 43#include <net/if_dl.h> 44#include <netinet/in.h> 45#include <netinet/in_var.h> | 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 --- 29 unchanged lines hidden (view full) --- 38#include <sys/types.h> 39#include <sys/protosw.h> 40#include <sys/socket.h> 41 42#include <net/if.h> 43#include <net/if_dl.h> 44#include <netinet/in.h> 45#include <netinet/in_var.h> |
46#include <netipx/ipx.h> 47#include <netipx/ipx_if.h> |
|
46#include <netns/ns.h> 47#include <netns/ns_if.h> 48#include <netiso/iso.h> 49#include <netiso/iso_var.h> 50#include <arpa/inet.h> 51 52#include <signal.h> 53#include <stdio.h> --- 15 unchanged lines hidden (view full) --- 69intpr(interval, ifnetaddr) 70 int interval; 71 u_long ifnetaddr; 72{ 73 struct ifnet ifnet; 74 union { 75 struct ifaddr ifa; 76 struct in_ifaddr in; | 48#include <netns/ns.h> 49#include <netns/ns_if.h> 50#include <netiso/iso.h> 51#include <netiso/iso_var.h> 52#include <arpa/inet.h> 53 54#include <signal.h> 55#include <stdio.h> --- 15 unchanged lines hidden (view full) --- 71intpr(interval, ifnetaddr) 72 int interval; 73 u_long ifnetaddr; 74{ 75 struct ifnet ifnet; 76 union { 77 struct ifaddr ifa; 78 struct in_ifaddr in; |
79 struct ipx_ifaddr ipx; |
|
77 struct ns_ifaddr ns; 78 struct iso_ifaddr iso; 79 } ifaddr; 80 u_long ifaddraddr; 81 struct sockaddr *sa; 82 char name[32], tname[16]; 83 84 if (ifnetaddr == 0) { 85 printf("ifnet: symbol not defined\n"); 86 return; 87 } 88 if (interval) { 89 sidewaysintpr((unsigned)interval, ifnetaddr); 90 return; 91 } 92 if (kread(ifnetaddr, (char *)&ifnetaddr, sizeof ifnetaddr)) 93 return; | 80 struct ns_ifaddr ns; 81 struct iso_ifaddr iso; 82 } ifaddr; 83 u_long ifaddraddr; 84 struct sockaddr *sa; 85 char name[32], tname[16]; 86 87 if (ifnetaddr == 0) { 88 printf("ifnet: symbol not defined\n"); 89 return; 90 } 91 if (interval) { 92 sidewaysintpr((unsigned)interval, ifnetaddr); 93 return; 94 } 95 if (kread(ifnetaddr, (char *)&ifnetaddr, sizeof ifnetaddr)) 96 return; |
94 printf("%-5.5s %-5.5s %-11.11s %-15.15s %8.8s %5.5s", | 97 printf("%-5.5s %-5.5s %-13.13s %-15.15s %8.8s %5.5s", |
95 "Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs"); 96 if (bflag) 97 printf(" %10.10s","Ibytes"); 98 printf(" %8.8s %5.5s", "Opkts", "Oerrs"); 99 if (bflag) 100 printf(" %10.10s","Obytes"); 101 printf(" %5s", "Coll"); 102 if (tflag) --- 19 unchanged lines hidden (view full) --- 122 cp = index(name, '\0'); 123 if ((ifnet.if_flags&IFF_UP) == 0) 124 *cp++ = '*'; 125 *cp = '\0'; 126 ifaddraddr = (u_long)ifnet.if_addrlist; 127 } 128 printf("%-5.5s %-5d ", name, ifnet.if_mtu); 129 if (ifaddraddr == 0) { | 98 "Name", "Mtu", "Network", "Address", "Ipkts", "Ierrs"); 99 if (bflag) 100 printf(" %10.10s","Ibytes"); 101 printf(" %8.8s %5.5s", "Opkts", "Oerrs"); 102 if (bflag) 103 printf(" %10.10s","Obytes"); 104 printf(" %5s", "Coll"); 105 if (tflag) --- 19 unchanged lines hidden (view full) --- 125 cp = index(name, '\0'); 126 if ((ifnet.if_flags&IFF_UP) == 0) 127 *cp++ = '*'; 128 *cp = '\0'; 129 ifaddraddr = (u_long)ifnet.if_addrlist; 130 } 131 printf("%-5.5s %-5d ", name, ifnet.if_mtu); 132 if (ifaddraddr == 0) { |
130 printf("%-11.11s ", "none"); | 133 printf("%-13.13s ", "none"); |
131 printf("%-15.15s ", "none"); 132 } else { 133 if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) { 134 ifaddraddr = 0; 135 continue; 136 } 137#define CP(x) ((char *)(x)) 138 cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + 139 CP(&ifaddr); sa = (struct sockaddr *)cp; 140 switch (sa->sa_family) { 141 case AF_UNSPEC: | 134 printf("%-15.15s ", "none"); 135 } else { 136 if (kread(ifaddraddr, (char *)&ifaddr, sizeof ifaddr)) { 137 ifaddraddr = 0; 138 continue; 139 } 140#define CP(x) ((char *)(x)) 141 cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) + 142 CP(&ifaddr); sa = (struct sockaddr *)cp; 143 switch (sa->sa_family) { 144 case AF_UNSPEC: |
142 printf("%-11.11s ", "none"); | 145 printf("%-13.13s ", "none"); |
143 printf("%-15.15s ", "none"); 144 break; 145 case AF_INET: 146 sin = (struct sockaddr_in *)sa; 147#ifdef notdef 148 /* can't use inet_makeaddr because kernel 149 * keeps nets unshifted. 150 */ --- 4 unchanged lines hidden (view full) --- 155#else 156 printf("%-11.11s ", 157 netname(htonl(ifaddr.in.ia_subnet), 158 ifaddr.in.ia_subnetmask)); 159#endif 160 printf("%-15.15s ", 161 routename(sin->sin_addr.s_addr)); 162 break; | 146 printf("%-15.15s ", "none"); 147 break; 148 case AF_INET: 149 sin = (struct sockaddr_in *)sa; 150#ifdef notdef 151 /* can't use inet_makeaddr because kernel 152 * keeps nets unshifted. 153 */ --- 4 unchanged lines hidden (view full) --- 158#else 159 printf("%-11.11s ", 160 netname(htonl(ifaddr.in.ia_subnet), 161 ifaddr.in.ia_subnetmask)); 162#endif 163 printf("%-15.15s ", 164 routename(sin->sin_addr.s_addr)); 165 break; |
166 case AF_IPX: 167 { 168 struct sockaddr_ipx *sipx = 169 (struct sockaddr_ipx *)sa; 170 u_long net; 171 char netnum[10]; 172 173 *(union ipx_net *) &net = sipx->sipx_addr.x_net; 174 sprintf(netnum, "%lx", ntohl(net)); 175 printf("ipx:%-8s ", netnum); 176/* printf("ipx:%-8s ", netname(net, 0L)); */ 177 printf("%-15s ", 178 ipx_phost((struct sockaddr *)sipx)); 179 } 180 break; |
|
163 case AF_NS: 164 { 165 struct sockaddr_ns *sns = 166 (struct sockaddr_ns *)sa; 167 u_long net; | 181 case AF_NS: 182 { 183 struct sockaddr_ns *sns = 184 (struct sockaddr_ns *)sa; 185 u_long net; |
168 char netnum[8]; | 186 char netnum[10]; |
169 170 *(union ns_net *) &net = sns->sns_addr.x_net; 171 sprintf(netnum, "%lxH", ntohl(net)); 172 upHex(netnum); 173 printf("ns:%-8s ", netnum); 174 printf("%-15s ", 175 ns_phost((struct sockaddr *)sns)); 176 } --- 12 unchanged lines hidden (view full) --- 189 for (cp = sa->sa_len + (char *)sa; 190 --cp > sa->sa_data && (*cp == 0);) {} 191 n = cp - sa->sa_data + 1; 192 cp = sa->sa_data; 193 hexprint: 194 while (--n >= 0) 195 m += printf("%02x%c", *cp++ & 0xff, 196 n > 0 ? '.' : ' '); | 187 188 *(union ns_net *) &net = sns->sns_addr.x_net; 189 sprintf(netnum, "%lxH", ntohl(net)); 190 upHex(netnum); 191 printf("ns:%-8s ", netnum); 192 printf("%-15s ", 193 ns_phost((struct sockaddr *)sns)); 194 } --- 12 unchanged lines hidden (view full) --- 207 for (cp = sa->sa_len + (char *)sa; 208 --cp > sa->sa_data && (*cp == 0);) {} 209 n = cp - sa->sa_data + 1; 210 cp = sa->sa_data; 211 hexprint: 212 while (--n >= 0) 213 m += printf("%02x%c", *cp++ & 0xff, 214 n > 0 ? '.' : ' '); |
197 m = 28 - m; | 215 m = 30 - m; |
198 while (m-- > 0) 199 putchar(' '); 200 break; 201 } 202 ifaddraddr = (u_long)ifaddr.ifa.ifa_next; 203 } 204 printf("%8d %5d ", 205 ifnet.if_ipackets, ifnet.if_ierrors); --- 210 unchanged lines hidden --- | 216 while (m-- > 0) 217 putchar(' '); 218 break; 219 } 220 ifaddraddr = (u_long)ifaddr.ifa.ifa_next; 221 } 222 printf("%8d %5d ", 223 ifnet.if_ipackets, ifnet.if_ierrors); --- 210 unchanged lines hidden --- |