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