atalk.c (16178) | atalk.c (16285) |
---|---|
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 --- 56 unchanged lines hidden (view full) --- 65 66/* 67 * Print a summary of connections related to a Network Systems 68 * protocol. For XXX, also give state of connection. 69 * Listening processes (aflag) are suppressed unless the 70 * -a (all) flag is specified. 71 */ 72 | 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 --- 56 unchanged lines hidden (view full) --- 65 66/* 67 * Print a summary of connections related to a Network Systems 68 * protocol. For XXX, also give state of connection. 69 * Listening processes (aflag) are suppressed unless the 70 * -a (all) flag is specified. 71 */ 72 |
73char * 74at_pr_net(struct sockaddr_at *sat) 75{ 76static char mybuf[50]; 77 78 switch(sat->sat_addr.s_net) { 79 case ATADDR_ANYNODE: 80 return("any"); 81 case ATADDR_BCAST: 82 return "bcast"; 83 default: 84 sprintf(mybuf,"%hd",ntohs(sat->sat_addr.s_net)); 85 } 86 return mybuf; 87} 88 89char * 90at_pr_host(struct sockaddr_at *sat) 91{ 92static char mybuf[50]; 93 94 switch(sat->sat_addr.s_node) { 95 case 0: 96 return("local"); 97 case /*ATADDR_ANYNET*/0xffff: 98 return "????"; 99 default: 100 sprintf(mybuf,"%d",(unsigned int)sat->sat_addr.s_node); 101 } 102 return mybuf; 103} 104 105char * 106at_pr_port(struct sockaddr_at *sat) 107{ 108static char mybuf[50]; 109 110 switch(sat->sat_port) { 111 case ATADDR_ANYPORT: 112 return("any"); 113 case 0xff: 114 return "????"; 115 default: 116 sprintf(mybuf,"%d",(unsigned int)sat->sat_port); 117 } 118 return mybuf; 119} 120 121/* what == 0 for addr only == 3 */ 122/* 1 for net */ 123/* 2 for host */ 124/* 4 for port */ 125char * 126atalk_print(sa,what) 127 register struct sockaddr *sa; 128{ 129 struct sockaddr_at *sat = (struct sockaddr_at *)sa; 130static char mybuf[50]; 131 132 mybuf[0] = 0; 133 switch (what & 3 ) { 134 case 0: 135 mybuf[0] = 0; 136 break; 137 case 1: 138 sprintf(mybuf,"%s",at_pr_net(sat)); 139 break; 140 case 2: 141 sprintf(mybuf,"%s",at_pr_host(sat)); 142 break; 143 case 3: 144 sprintf(mybuf,"[%s.%s]", 145 at_pr_net(sat), 146 at_pr_host(sat)); 147 } 148 if (what & 4) { 149 sprintf(mybuf+strlen(mybuf),"%s",at_pr_port(sat)); 150 } 151#if 0 152 switch(sat->sat_hints.type) { 153 case SATHINT_NONE: 154 sprintf(mybuf,"[no type]"); 155 break; 156 case SATHINT_CONFIG: 157 case SATHINT_IFACE: 158 sprintf(mybuf,"[too hard for now]"); 159 break; 160 default: 161 sprintf(mybuf,"[unknown type]"); 162 } 163#endif 164 return mybuf; 165} |
|
73void 74atalkprotopr(off, name) 75 u_long off; 76 char *name; 77{ 78 struct ddpcb cb; 79 register struct ddpcb *prev, *next; 80 struct ddpcb *initial; --- 29 unchanged lines hidden (view full) --- 110 "Local Address", "Foreign Address", "(state)"); 111 first = 0; 112 } 113 if (Aflag) 114 printf("%8x ", ppcb); 115 printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc, 116 sockb.so_snd.sb_cc); 117 printf(Aflag?" %-18.18s":" %-22.22s", atalk_print( | 166void 167atalkprotopr(off, name) 168 u_long off; 169 char *name; 170{ 171 struct ddpcb cb; 172 register struct ddpcb *prev, *next; 173 struct ddpcb *initial; --- 29 unchanged lines hidden (view full) --- 203 "Local Address", "Foreign Address", "(state)"); 204 first = 0; 205 } 206 if (Aflag) 207 printf("%8x ", ppcb); 208 printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc, 209 sockb.so_snd.sb_cc); 210 printf(Aflag?" %-18.18s":" %-22.22s", atalk_print( |
118 (struct sockaddr *)&ddpcb.ddp_lsat)); | 211 (struct sockaddr *)&ddpcb.ddp_lsat,7)); |
119 printf(Aflag?" %-18.18s":" %-22.22s", atalk_print( | 212 printf(Aflag?" %-18.18s":" %-22.22s", atalk_print( |
120 (struct sockaddr *)&ddpcb.ddp_fsat)); | 213 (struct sockaddr *)&ddpcb.ddp_fsat,7)); |
121 putchar('\n'); 122 } 123} 124#define ANY(x,y,z) \ 125 ((x) ? printf("\t%d %s%s%s\n",x,y,plural(x),z) : 0) 126 127/* 128 * Dump DDP statistics structure. --- 26 unchanged lines hidden --- | 214 putchar('\n'); 215 } 216} 217#define ANY(x,y,z) \ 218 ((x) ? printf("\t%d %s%s%s\n",x,y,plural(x),z) : 0) 219 220/* 221 * Dump DDP statistics structure. --- 26 unchanged lines hidden --- |