Initial import from FreeBSD RELENG_4:
[games.git] / sbin / atm / atm / atm_print.c
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/sbin/atm/atm/atm_print.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $
27  *
28  */
29
30 /*
31  * User configuration and display program
32  * --------------------------------------
33  *
34  * Print routines for "show" subcommand
35  *
36  */
37
38 #include <sys/param.h>  
39 #include <sys/socket.h> 
40 #include <net/if.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 #include <netatm/port.h>
44 #include <netatm/atm.h>
45 #include <netatm/atm_if.h> 
46 #include <netatm/atm_sap.h>
47 #include <netatm/atm_sigmgr.h>
48 #include <netatm/atm_sys.h>
49 #include <netatm/atm_vc.h>
50 #include <netatm/atm_ioctl.h>
51 #include <netatm/ipatm/ipatm_var.h>
52 #include <netatm/sigpvc/sigpvc_var.h>
53 #include <netatm/spans/spans_var.h>
54 #include <netatm/uni/uniip_var.h>
55 #include <netatm/uni/unisig_var.h>
56
57 #include <errno.h>
58 #include <libatm.h>
59 #include <stdio.h>
60 #include <stdlib.h>
61 #include <string.h>
62
63 #include "atm.h"
64
65 #ifndef lint
66 __RCSID("@(#) $FreeBSD: src/sbin/atm/atm/atm_print.c,v 1.3.2.1 2000/07/01 06:02:14 ps Exp $");
67 #endif
68
69
70 #define ARP_HDR \
71 "Net Intf  Flags  Age  Origin\n"
72
73 #define ASRV_HDR \
74 "Net Intf  State     ATM Address\n"
75
76 #define CFG_HDR \
77 "Intf      Vendor    Model     Media           Bus   Serial No\n"
78
79 #define IP_VCC_HDR \
80 "Net Intf  VPI   VCI  State   Flags IP Address\n"
81
82 #define INTF_HDR \
83 "Interface  Sigmgr   State\n"
84
85 #define NETIF_HDR \
86 "Net Intf  Phy Intf  IP Address\n"
87
88 #define VCC_HDR \
89 "Interface  VPI   VCI  AAL   Type Dir    State    Encaps   Owner\n"
90
91 #define VCC_STATS_HDR \
92 "                        Input    Input  Input  Output   Output Output\n\
93 Interface  VPI   VCI     PDUs    Bytes   Errs    PDUs    Bytes   Errs\n"
94
95 #define VERSION_HDR \
96 "Version\n"
97
98 #define PHY_STATS_HDR \
99 "             Input    Input  Input  Output   Output Output    Cmd\n\
100 Interface     PDUs    Bytes   Errs    PDUs    Bytes   Errs   Errs\n"
101
102 /*
103  * External references
104  */
105 extern struct proto     protos[];
106 extern struct aal       aals[];
107 extern struct encaps    encaps[];
108
109 /*
110  * Local variables
111  */
112 static int      arp_hdr = 0;
113 static int      asrv_hdr = 0;
114 static int      cfg_hdr = 0;
115 static int      ip_vcc_hdr = 0;
116 static int      netif_hdr = 0;
117 static int      vcc_hdr = 0;
118 static int      vcc_stats_hdr = 0;
119 static int      phy_stats_hdr = 0;
120 static int      version_hdr = 0;
121
122 /*
123  * SIGPVC state definitions
124  */
125 struct state    sigpvc_states[] = {
126         { "ACTIVE",     SIGPVC_ACTIVE },
127         { "DETACH",     SIGPVC_DETACH },
128         { 0,            0 }
129 };
130
131 /*
132  * SPANS state definitions
133  */
134 struct state    spans_states[] = {
135         { "ACTIVE",     SPANS_ACTIVE },
136         { "DETACH",     SPANS_DETACH },
137         { "INIT",       SPANS_INIT },
138         { "PROBE",      SPANS_PROBE },
139         { 0,            0 }
140 };
141
142 /*
143  * UNISIG state definitions
144  */
145 struct state    unisig_states[] = {
146         { "NULL",       UNISIG_NULL },
147         { "ADR_WAIT",   UNISIG_ADDR_WAIT },
148         { "INIT",       UNISIG_INIT },
149         { "ACTIVE",     UNISIG_ACTIVE },
150         { "DETACH",     UNISIG_DETACH },
151         { 0,            0 }
152 };
153
154 /*
155  * SIGPVC VCC state definitions
156  */
157 struct state    sigpvc_vcc_states[] = {
158         { "NULL",       VCCS_NULL },
159         { "ACTIVE",     VCCS_ACTIVE },
160         { "FREE",       VCCS_FREE },
161         { 0,            0 }
162 };
163
164 /*
165  * SPANS VCC state definitions
166  */
167 struct state    spans_vcc_states[] = {
168         { "NULL",       SPANS_VC_NULL },
169         { "ACTIVE",     SPANS_VC_ACTIVE },
170         { "ACT_DOWN",   SPANS_VC_ACT_DOWN },
171         { "POPEN",      SPANS_VC_POPEN },
172         { "R_POPEN",    SPANS_VC_R_POPEN },
173         { "OPEN",       SPANS_VC_OPEN },
174         { "CLOSE",      SPANS_VC_CLOSE },
175         { "ABORT",      SPANS_VC_ABORT },
176         { "FREE",       SPANS_VC_FREE },
177         {0,             0 }
178 };
179
180 /*
181  * UNISIG VCC state definitions
182  */
183 struct state    unisig_vcc_states[] = {
184         { "NULL",       UNI_NULL },
185         { "C_INIT",     UNI_CALL_INITIATED },
186         { "C_OUT_PR",   UNI_CALL_OUT_PROC },
187         { "C_DELIV",    UNI_CALL_DELIVERED },
188         { "C_PRES",     UNI_CALL_PRESENT },
189         { "C_REC",      UNI_CALL_RECEIVED },
190         { "CONN_REQ",   UNI_CONNECT_REQUEST },
191         { "C_IN_PR",    UNI_CALL_IN_PROC },
192         { "ACTIVE",     UNI_ACTIVE },
193         { "REL_REQ",    UNI_RELEASE_REQUEST },
194         { "REL_IND",    UNI_RELEASE_IND },
195         { "SSCF_REC",   UNI_SSCF_RECOV },
196         { "FREE",       UNI_FREE },
197         { "ACTIVE",     UNI_PVC_ACTIVE },
198         { "ACT_DOWN",   UNI_PVC_ACT_DOWN },
199         {0,                     0 }
200 };
201
202 /*
203  * IP VCC state definitions
204  */
205 struct state    ip_vcc_states[] = {
206         { "FREE",       IPVCC_FREE },
207         { "PMAP",       IPVCC_PMAP },
208         { "POPEN",      IPVCC_POPEN },
209         { "PACCEPT",    IPVCC_PACCEPT },
210         { "ACTPENT",    IPVCC_ACTPENT },
211         { "ACTIVE",     IPVCC_ACTIVE },
212         { "CLOSED",     IPVCC_CLOSED },
213         { 0,            0 }
214 };
215
216 /*
217  * ARP server state definitions
218  */
219 struct state    arpserver_states[] = {
220         { "NOT_CONF",   UIAS_NOTCONF },
221         { "SERVER",     UIAS_SERVER_ACTIVE },
222         { "PEND_ADR",   UIAS_CLIENT_PADDR },
223         { "POPEN",      UIAS_CLIENT_POPEN },
224         { "REGISTER",   UIAS_CLIENT_REGISTER },
225         { "ACTIVE",     UIAS_CLIENT_ACTIVE },
226         { 0,            0 }
227 };
228
229 /*
230  * Supported signalling managers
231  */
232 struct proto_state      proto_states[] = {
233         { "SIGPVC",  sigpvc_states, sigpvc_vcc_states, ATM_SIG_PVC },
234         { "SPANS",   spans_states,  spans_vcc_states,  ATM_SIG_SPANS },
235         { "UNI 3.0", unisig_states, unisig_vcc_states, ATM_SIG_UNI30 },
236         { "UNI 3.1", unisig_states, unisig_vcc_states, ATM_SIG_UNI31 },
237         { "UNI 4.0", unisig_states, unisig_vcc_states, ATM_SIG_UNI40 },
238         { 0,         0,             0,                 0 }
239 };
240
241 /*
242  * ATMARP origin values
243  */
244 struct state    arp_origins[] = {
245         { "LOCAL",      UAO_LOCAL },
246         { "PERM",       UAO_PERM },
247         { "REG",        UAO_REGISTER },
248         { "SCSP",       UAO_SCSP },
249         { "LOOKUP",     UAO_LOOKUP },
250         { "PEER_RSP",   UAO_PEER_RSP },
251         { "PEER_REQ",   UAO_PEER_REQ },
252         { 0,            0 }
253 };
254
255
256 /*
257  * Print ARP table information
258  * 
259  * Arguments:
260  *      ai      pointer to a struct air_arp_rsp
261  *
262  * Returns:
263  *      none
264  *
265  */
266 void
267 print_arp_info(ai)
268         struct air_arp_rsp      *ai;
269 {
270         int     i;
271         char    *atm_addr, *ip_addr, *origin;
272         char    age[8], flags[32];
273         struct sockaddr_in      *sin;
274
275         /*
276          * Print a header if it hasn't been done yet.
277          */
278         if (!arp_hdr) {
279                 printf(ARP_HDR);
280                 arp_hdr = 1;
281         }
282
283         /*
284          * Format the addresses
285          */
286         atm_addr = format_atm_addr(&ai->aap_addr);
287         sin = (struct sockaddr_in *)&ai->aap_arp_addr;
288         ip_addr = format_ip_addr(&sin->sin_addr);
289
290         /*
291          * Decode the flags
292          */
293         UM_ZERO(flags, sizeof(flags));
294         if (ai->aap_flags & ARPF_VALID) {
295                 strcat(flags, "V");
296         }
297         if (ai->aap_flags & ARPF_REFRESH) {
298                 strcat(flags, "R");
299         }
300
301         /*
302          * Format the origin
303          */
304         for (i=0; arp_origins[i].s_name != NULL && 
305                         ai->aap_origin != arp_origins[i].s_id;
306                         i++);
307         if (arp_origins[i].s_name) {
308                 origin = arp_origins[i].s_name;
309         } else {
310                 origin = "-";
311         }
312
313         /*
314          * Format the age
315          */
316         UM_ZERO(age, sizeof(age));
317         if (!(ai->aap_flags & ARPF_VALID)) {
318                 strcpy(age, "-");
319         } else {
320                 sprintf(age, "%d", ai->aap_age);
321         }
322
323         /*
324          * Print the ARP information
325          */
326         printf("%-8s  %-5s  %3s  %s\n    ATM address = %s\n    IP address = %s\n",
327                         ai->aap_intf,
328                         flags,
329                         age,
330                         origin,
331                         atm_addr,
332                         ip_addr);
333 }
334
335
336 /*
337  * Print ARP server information
338  * 
339  * Arguments:
340  *      si      pointer to a struct air_asrv_rsp
341  *
342  * Returns:
343  *      none
344  *
345  */
346 void
347 print_asrv_info(si)
348         struct air_asrv_rsp     *si;
349 {
350         int             i;
351         char            *atm_addr, *state;
352         struct in_addr  *addr;
353
354         /*
355          * Print a header if it hasn't been done yet.
356          */
357         if (!asrv_hdr) {
358                 printf(ASRV_HDR);
359                 asrv_hdr = 1;
360         }
361
362         /*
363          * Format the ATM address of the ARP server
364          */
365         atm_addr = format_atm_addr(&si->asp_addr);
366
367         /*
368          * Format the server state
369          */
370         for (i=0; arpserver_states[i].s_name != NULL && 
371                         si->asp_state != arpserver_states[i].s_id;
372                         i++);
373         if (arpserver_states[i].s_name) {
374                 state = arpserver_states[i].s_name;
375         } else {
376                 state = "-";
377         }
378
379         /*
380          * Print the ARP server information
381          */
382         printf("%-8s  %-8s  %s\n",
383                         si->asp_intf,
384                         state,
385                         atm_addr);
386
387         /*
388          * Format and print the LIS prefixes
389          */
390         if (si->asp_nprefix) {
391                 addr = (struct in_addr *)((u_long)si +
392                                 sizeof(struct air_asrv_rsp));
393                 printf("    LIS = ");
394                 for (i = 0; i < si->asp_nprefix; i++) {
395                         printf("%s", inet_ntoa(*addr));
396                         addr++;
397                         printf("/0x%0lx", ntohl(addr->s_addr));
398                         addr++;
399                         if (i < si->asp_nprefix -1)
400                                 printf(", ");
401                 }
402                 printf("\n");
403         }
404 }
405
406
407 /*
408  * Print adapter configuration information
409  * 
410  * Arguments:
411  *      si      pointer to a struct air_cfg_rsp
412  *
413  * Returns:
414  *      none
415  *
416  */
417 void
418 print_cfg_info(si)
419         struct air_cfg_rsp      *si;
420 {
421         char    *adapter, *bus, *media, *vendor;
422
423         /*
424          * Print a header if it hasn't been done yet.
425          */
426         if (!cfg_hdr) {
427                 printf(CFG_HDR);
428                 cfg_hdr = 1;
429         }
430
431         /*
432          * Format the vendor name and adapter type
433          */
434         vendor = get_vendor(si->acp_vendor);
435         adapter = get_adapter(si->acp_device);
436
437         /*
438          * Format the communications medium
439          */
440         media = get_media_type(si->acp_media);
441         bus = get_bus_type(si->acp_bustype);
442
443         /*
444          * Print the ARP server information
445          */
446         printf("%-8s  %-8s  %-8s  %-14s  %-4s  %ld\n",
447                         si->acp_intf,
448                         vendor,
449                         adapter,
450                         media,
451                         bus,
452                         si->acp_serial);
453         printf("    MAC address = %s\n",
454                         format_mac_addr(&si->acp_macaddr));
455         printf("    Hardware version = %s\n", si->acp_hard_vers);
456         printf("    Firmware version = %s\n", si->acp_firm_vers);
457 }
458
459
460 /*
461  * Print interface information
462  * 
463  * Arguments:
464  *      ni      pointer to a struct air_int_rsp
465  *
466  * Returns:
467  *      none
468  *
469  */
470 void
471 print_intf_info(ni)
472         struct air_int_rsp      *ni;
473 {
474         int     i;
475         char    nif_names[(IFNAMSIZ *2)+4];
476         char    *atm_addr;
477         char    *sigmgr = "-", *state_name = "-";
478         struct state            *s_t;
479
480         /*
481          * Print a header
482          */
483         printf(INTF_HDR);
484
485         /*
486          * Translate signalling manager name
487          */
488         for (i=0; proto_states[i].p_state != NULL; i++)
489                 if (ni->anp_sig_proto == proto_states[i].p_id)
490                         break;
491         if (proto_states[i].p_state != NULL)
492                 sigmgr = proto_states[i].p_name;
493
494         /*
495          * Get the signalling manager state
496          */
497         if (proto_states[i].p_state != NULL) {
498                 s_t = proto_states[i].p_state;
499                 for (i=0; s_t[i].s_name != NULL; i++)
500                         if (ni->anp_sig_state == s_t[i].s_id)
501                                 break;
502                 if (s_t[i].s_name != NULL)
503                         state_name = s_t[i].s_name;
504         }
505
506         /*
507          * Format the ATM address
508          */
509         atm_addr = format_atm_addr(&ni->anp_addr);
510
511         /*
512          * Get the range of NIFs on the physical interface
513          */
514         UM_ZERO(nif_names, sizeof(nif_names));
515         if (strlen(ni->anp_nif_pref) == 0) {
516                 strcpy(nif_names, "-");
517         } else {
518                 strcpy(nif_names, ni->anp_nif_pref);
519                 strcat(nif_names, "0");
520                 if (ni->anp_nif_cnt > 1) {
521                         strcat(nif_names, " - ");
522                         strcat(nif_names, ni->anp_nif_pref);
523                         sprintf(&nif_names[strlen(nif_names)], "%d",
524                                         ni->anp_nif_cnt-1);
525                 }
526         }
527         
528
529         /*
530          * Print the interface information
531          */
532         printf("%-9s  %-7s  %s\n",
533                         ni->anp_intf,
534                         sigmgr,
535                         state_name);
536         printf("    ATM address = %s\n", atm_addr);
537         printf("    Network interfaces: %s\n", nif_names);
538 }
539
540
541 /*
542  * Print IP address map information
543  * 
544  * Arguments:
545  *      ai      pointer to a struct air_arp_rsp
546  *
547  * Returns:
548  *      none
549  *
550  */
551 void
552 print_ip_vcc_info(ai)
553         struct air_ip_vcc_rsp   *ai;
554 {
555         int     i;
556         char    *ip_addr, *state;
557         char    flags[32], vpi_vci[16];
558         struct sockaddr_in      *sin;
559
560         /*
561          * Print a header if it hasn't been done yet.
562          */
563         if (!ip_vcc_hdr) {
564                 printf(IP_VCC_HDR);
565                 ip_vcc_hdr = 1;
566         }
567
568         /*
569          * Format the IP address
570          */
571         sin = (struct sockaddr_in *)&ai->aip_dst_addr;
572         ip_addr = format_ip_addr(&sin->sin_addr);
573
574         /*
575          * Format the VPI/VCI
576          */
577         if (ai->aip_vpi == 0 && ai->aip_vci == 0) {
578                 strcpy(vpi_vci, "  -     -");
579         } else {
580                 sprintf(vpi_vci, "%3d %5d", ai->aip_vpi, ai->aip_vci);
581         }
582
583         /*
584          * Decode VCC flags
585          */
586         UM_ZERO(flags, sizeof(flags));
587         if (ai->aip_flags & IVF_PVC) {
588                 strcat(flags, "P");
589         }
590         if (ai->aip_flags & IVF_SVC) {
591                 strcat(flags, "S");
592         }
593         if (ai->aip_flags & IVF_LLC) {
594                 strcat(flags, "L");
595         }
596         if (ai->aip_flags & IVF_MAPOK) {
597                 strcat(flags, "M");
598         }
599         if (ai->aip_flags & IVF_NOIDLE) {
600                 strcat(flags, "N");
601         }
602
603         /*
604          * Get the state of the VCC
605          */
606         for (i=0; ip_vcc_states[i].s_name != NULL && 
607                         ai->aip_state != ip_vcc_states[i].s_id;
608                         i++);
609         if (ip_vcc_states[i].s_name) {
610                 state = ip_vcc_states[i].s_name;
611         } else {
612                 state = "-";
613         }
614
615         /*
616          * Print the IP VCC information
617          */
618         printf("%-8s  %9s  %-7s %-5s %s\n",
619                         ai->aip_intf,
620                         vpi_vci,
621                         state,
622                         flags,
623                         ip_addr);
624 }
625
626
627 /*
628  * Print network interface information
629  * 
630  * Arguments:
631  *      ni      pointer to a struct air_int_rsp
632  *
633  * Returns:
634  *      none
635  *
636  */
637 void
638 print_netif_info(ni)
639         struct air_netif_rsp    *ni;
640 {
641         char                    *ip_addr;
642         struct sockaddr_in      *sin;
643
644         /*
645          * Print a header
646          */
647         if (!netif_hdr) {
648                 netif_hdr++;
649                 printf(NETIF_HDR);
650         }
651
652         /*
653          * Format the protocol address
654          */
655         sin = (struct sockaddr_in *)&ni->anp_proto_addr;
656         ip_addr = format_ip_addr(&sin->sin_addr);
657
658         /*
659          * Print the network interface information
660          */
661         printf("%-8s  %-8s  %s\n",
662                         ni->anp_intf,
663                         ni->anp_phy_intf,
664                         ip_addr);
665 }
666
667
668 /*
669  * Print physical interface statistics
670  * 
671  * Arguments:
672  *      pi      pointer to a struct air_phy_stat_rsp
673  *
674  * Returns:
675  *      none
676  *
677  */
678 void
679 print_intf_stats(pi)
680         struct air_phy_stat_rsp *pi;
681 {
682         /*
683          * Print a header if it hasn't already been done
684          */
685         if (!phy_stats_hdr) {
686                 printf(PHY_STATS_HDR);
687                 phy_stats_hdr = 1;
688         }
689
690         /*
691          * Print the interface statistics
692          */
693         printf("%-9s  %7ld %8ld  %5ld %7ld %8ld  %5ld  %5ld\n",
694                         pi->app_intf,
695                         pi->app_ipdus,
696                         pi->app_ibytes,
697                         pi->app_ierrors,
698                         pi->app_opdus,
699                         pi->app_obytes,
700                         pi->app_oerrors,
701                         pi->app_cmderrors);
702 }
703
704
705 /*
706  * Print VCC statistics
707  * 
708  * Arguments:
709  *      vi      pointer to VCC statistics to print
710  *
711  * Returns:
712  *      none
713  *
714  */
715 void
716 print_vcc_stats(vi)
717         struct air_vcc_rsp      *vi;
718 {
719
720         /*
721          * Print a header if it hasn't already been done
722          */
723         if (!vcc_stats_hdr) {
724                 printf(VCC_STATS_HDR);
725                 vcc_stats_hdr = 1;
726         }
727
728         /*
729          * Print the VCC statistics
730          */
731         printf("%-9s  %3d  %4d",
732                         vi->avp_intf,
733                         vi->avp_vpi,
734                         vi->avp_vci);
735         if ( vi->avp_type & VCC_IN )
736                 printf ( "  %7ld %8ld  %5ld",
737                         vi->avp_ipdus,
738                         vi->avp_ibytes,
739                         vi->avp_ierrors);
740         else
741                 printf ( "        -        -      -" );
742
743         if ( vi->avp_type & VCC_OUT )
744                 printf ( " %7ld %8ld  %5ld\n",
745                         vi->avp_opdus,
746                         vi->avp_obytes,
747                         vi->avp_oerrors);
748         else
749                 printf ( "       -        -      -\n" );
750 }
751
752
753 /*
754  * Print VCC information
755  * 
756  * Arguments:
757  *      vi      pointer to a struct air_vcc_rsp
758  *
759  * Returns:
760  *      none
761  *
762  */
763 void
764 print_vcc_info(vi)
765         struct air_vcc_rsp      *vi;
766 {
767         int     i;
768         char    *aal_name = "-" , *encaps_name = "-", *owner_name = "-";
769         char    *state_name = "-", *type_name = "-";
770         char    dir_name[10];
771         struct state    *s_t;
772
773         /*
774          * Print a header if it hasn't already been done
775          */
776         if (!vcc_hdr) {
777                 printf(VCC_HDR);
778                 vcc_hdr = 1;
779         }
780
781         /*
782          * Translate AAL
783          */
784         for (i=0; aals[i].a_name != NULL; i++)
785                 if (vi->avp_aal == aals[i].a_id)
786                         break;
787         if (aals[i].a_name)
788                 aal_name = aals[i].a_name;
789
790         /*
791          * Translate VCC type
792          */
793         if (vi->avp_type & VCC_PVC)
794                 type_name = "PVC";
795         else if (vi->avp_type & VCC_SVC)
796                 type_name = "SVC";
797         /*
798          * Translate VCC direction
799          */
800         UM_ZERO(dir_name, sizeof(dir_name));
801         if (vi->avp_type & VCC_IN)
802                 strcat(dir_name, "In");
803         if (vi->avp_type & VCC_OUT)
804                 strcat(dir_name, "Out");
805         if (strlen(dir_name) == 0)
806                 strcpy(dir_name, "-");
807
808         /*
809          * Translate state
810          */
811         for (i=0; proto_states[i].p_state != NULL; i++)
812                 if (vi->avp_sig_proto == proto_states[i].p_id)
813                         break;
814         if (proto_states[i].p_state) {
815                 s_t = proto_states[i].v_state;
816                 for (i=0; s_t[i].s_name != NULL; i++)
817                         if (vi->avp_state == s_t[i].s_id)
818                                 break;
819                 if (s_t[i].s_name)
820                         state_name = s_t[i].s_name;
821         }
822
823         /*
824          * Translate encapsulation
825          */
826         for (i=0; encaps[i].e_name != NULL; i++)
827                 if (vi->avp_encaps == encaps[i].e_id)
828                         break;
829         if (encaps[i].e_name)
830                 encaps_name = encaps[i].e_name;
831
832         /*
833          * Print the VCC information
834          */
835         printf("%-9s  %3d %5d  %-4s  %-4s %-5s  %-8s %-8s ",
836                         vi->avp_intf,
837                         vi->avp_vpi,
838                         vi->avp_vci,
839                         aal_name,
840                         type_name,
841                         dir_name,
842                         state_name,
843                         encaps_name);
844
845         /*
846          * Print VCC owners' names
847          */
848         for (i = 0, owner_name = vi->avp_owners;
849                         i < O_CNT - 1 && strlen(owner_name);
850                         i++, owner_name += (T_ATM_APP_NAME_LEN + 1)) {
851                 if (i > 0)
852                         printf(", ");
853                 printf("%s", owner_name);
854         }
855         if (i == 0)
856                 printf("-");
857         printf("\n");
858
859         /*
860          * Print destination address if it's an SVC
861          */
862         if (vi->avp_type & VCC_SVC) {
863                 printf("    Dest = %s\n",
864                                 format_atm_addr(&vi->avp_daddr));
865         }
866 }
867
868
869 /*
870  * Print network interface information
871  * 
872  * Arguments:
873  *      ni      pointer to a struct air_int_rsp
874  *
875  * Returns:
876  *      none
877  *
878  */
879 void
880 print_version_info(vi)
881         struct air_version_rsp  *vi;
882 {
883         char                    version_str[80];
884
885         /*
886          * Print a header
887          */
888         if (!version_hdr) {
889                 version_hdr++;
890                 printf(VERSION_HDR);
891         }
892
893         /*
894          * Print the interface information
895          */
896         sprintf(version_str, "%d.%d",
897                         ATM_VERS_MAJ(vi->avp_version),
898                         ATM_VERS_MIN(vi->avp_version));
899         printf("%7s\n", version_str);
900 }