4133f94220d155ecd66a44cfa5804b20c7ee93de
[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.5 2006/10/16 00:15:35 pavalos 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 static const struct state       sigpvc_states[] = {
121         { "ACTIVE",     SIGPVC_ACTIVE },
122         { "DETACH",     SIGPVC_DETACH },
123         { 0,            0 }
124 };
125
126 /*
127  * SPANS state definitions
128  */
129 static const 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 static const 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 static const 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 static const 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 static const 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 static const 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 static const 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 static const 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 static const 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(struct air_arp_rsp *ai)
263 {
264         int     i;
265         const char      *atm_addr, *ip_addr, *origin;
266         char    age[8], flags[32];
267         struct sockaddr_in      *sin;
268
269         /*
270          * Print a header if it hasn't been done yet.
271          */
272         if (!arp_hdr) {
273                 printf(ARP_HDR);
274                 arp_hdr = 1;
275         }
276
277         /*
278          * Format the addresses
279          */
280         atm_addr = format_atm_addr(&ai->aap_addr);
281         sin = (struct sockaddr_in *)&ai->aap_arp_addr;
282         ip_addr = format_ip_addr(&sin->sin_addr);
283
284         /*
285          * Decode the flags
286          */
287         UM_ZERO(flags, sizeof(flags));
288         if (ai->aap_flags & ARPF_VALID) {
289                 strcat(flags, "V");
290         }
291         if (ai->aap_flags & ARPF_REFRESH) {
292                 strcat(flags, "R");
293         }
294
295         /*
296          * Format the origin
297          */
298         for (i=0; arp_origins[i].s_name != NULL && 
299                         ai->aap_origin != arp_origins[i].s_id;
300                         i++);
301         if (arp_origins[i].s_name) {
302                 origin = arp_origins[i].s_name;
303         } else {
304                 origin = "-";
305         }
306
307         /*
308          * Format the age
309          */
310         UM_ZERO(age, sizeof(age));
311         if (!(ai->aap_flags & ARPF_VALID)) {
312                 strcpy(age, "-");
313         } else {
314                 sprintf(age, "%d", ai->aap_age);
315         }
316
317         /*
318          * Print the ARP information
319          */
320         printf("%-8s  %-5s  %3s  %s\n    ATM address = %s\n    IP address = %s\n",
321                         ai->aap_intf,
322                         flags,
323                         age,
324                         origin,
325                         atm_addr,
326                         ip_addr);
327 }
328
329
330 /*
331  * Print ARP server information
332  * 
333  * Arguments:
334  *      si      pointer to a struct air_asrv_rsp
335  *
336  * Returns:
337  *      none
338  *
339  */
340 void
341 print_asrv_info(struct air_asrv_rsp *si)
342 {
343         int             i;
344         const char      *atm_addr, *state;
345         struct in_addr  *addr;
346
347         /*
348          * Print a header if it hasn't been done yet.
349          */
350         if (!asrv_hdr) {
351                 printf(ASRV_HDR);
352                 asrv_hdr = 1;
353         }
354
355         /*
356          * Format the ATM address of the ARP server
357          */
358         atm_addr = format_atm_addr(&si->asp_addr);
359
360         /*
361          * Format the server state
362          */
363         for (i=0; arpserver_states[i].s_name != NULL && 
364                         si->asp_state != arpserver_states[i].s_id;
365                         i++);
366         if (arpserver_states[i].s_name) {
367                 state = arpserver_states[i].s_name;
368         } else {
369                 state = "-";
370         }
371
372         /*
373          * Print the ARP server information
374          */
375         printf("%-8s  %-8s  %s\n",
376                         si->asp_intf,
377                         state,
378                         atm_addr);
379
380         /*
381          * Format and print the LIS prefixes
382          */
383         if (si->asp_nprefix) {
384                 addr = (struct in_addr *)((u_long)si +
385                                 sizeof(struct air_asrv_rsp));
386                 printf("    LIS = ");
387                 for (i = 0; i < si->asp_nprefix; i++) {
388                         printf("%s", inet_ntoa(*addr));
389                         addr++;
390                         printf("/0x%0lx", (unsigned long)ntohl(addr->s_addr));
391                         addr++;
392                         if (i < si->asp_nprefix -1)
393                                 printf(", ");
394                 }
395                 printf("\n");
396         }
397 }
398
399
400 /*
401  * Print adapter configuration information
402  * 
403  * Arguments:
404  *      si      pointer to a struct air_cfg_rsp
405  *
406  * Returns:
407  *      none
408  *
409  */
410 void
411 print_cfg_info(struct air_cfg_rsp *si)
412 {
413         const char      *adapter, *bus, *media, *vendor;
414
415         /*
416          * Print a header if it hasn't been done yet.
417          */
418         if (!cfg_hdr) {
419                 printf(CFG_HDR);
420                 cfg_hdr = 1;
421         }
422
423         /*
424          * Format the vendor name and adapter type
425          */
426         vendor = get_vendor(si->acp_vendor);
427         adapter = get_adapter(si->acp_device);
428
429         /*
430          * Format the communications medium
431          */
432         media = get_media_type(si->acp_media);
433         bus = get_bus_type(si->acp_bustype);
434
435         /*
436          * Print the ARP server information
437          */
438         printf("%-8s  %-8s  %-8s  %-14s  %-4s  %ld\n",
439                         si->acp_intf,
440                         vendor,
441                         adapter,
442                         media,
443                         bus,
444                         si->acp_serial);
445         printf("    MAC address = %s\n",
446                         format_mac_addr(&si->acp_macaddr));
447         printf("    Hardware version = %s\n", si->acp_hard_vers);
448         printf("    Firmware version = %s\n", si->acp_firm_vers);
449 }
450
451
452 /*
453  * Print interface information
454  * 
455  * Arguments:
456  *      ni      pointer to a struct air_int_rsp
457  *
458  * Returns:
459  *      none
460  *
461  */
462 void
463 print_intf_info(struct air_int_rsp *ni)
464 {
465         int     i;
466         char    nif_names[(IFNAMSIZ *2)+4];
467         char    *atm_addr;
468         const char      *sigmgr = "-", *state_name = "-";
469         const struct state      *s_t;
470
471         /*
472          * Print a header
473          */
474         printf(INTF_HDR);
475
476         /*
477          * Translate signalling manager name
478          */
479         for (i=0; proto_states[i].p_state != NULL; i++)
480                 if (ni->anp_sig_proto == proto_states[i].p_id)
481                         break;
482         if (proto_states[i].p_state != NULL)
483                 sigmgr = proto_states[i].p_name;
484
485         /*
486          * Get the signalling manager state
487          */
488         if (proto_states[i].p_state != NULL) {
489                 s_t = proto_states[i].p_state;
490                 for (i=0; s_t[i].s_name != NULL; i++)
491                         if (ni->anp_sig_state == s_t[i].s_id)
492                                 break;
493                 if (s_t[i].s_name != NULL)
494                         state_name = s_t[i].s_name;
495         }
496
497         /*
498          * Format the ATM address
499          */
500         atm_addr = format_atm_addr(&ni->anp_addr);
501
502         /*
503          * Get the range of NIFs on the physical interface
504          */
505         UM_ZERO(nif_names, sizeof(nif_names));
506         if (strlen(ni->anp_nif_pref) == 0) {
507                 strcpy(nif_names, "-");
508         } else {
509                 strcpy(nif_names, ni->anp_nif_pref);
510                 strcat(nif_names, "0");
511                 if (ni->anp_nif_cnt > 1) {
512                         strcat(nif_names, " - ");
513                         strcat(nif_names, ni->anp_nif_pref);
514                         sprintf(&nif_names[strlen(nif_names)], "%d",
515                                         ni->anp_nif_cnt-1);
516                 }
517         }
518         
519
520         /*
521          * Print the interface information
522          */
523         printf("%-9s  %-7s  %s\n",
524                         ni->anp_intf,
525                         sigmgr,
526                         state_name);
527         printf("    ATM address = %s\n", atm_addr);
528         printf("    Network interfaces: %s\n", nif_names);
529 }
530
531
532 /*
533  * Print IP address map information
534  * 
535  * Arguments:
536  *      ai      pointer to a struct air_arp_rsp
537  *
538  * Returns:
539  *      none
540  *
541  */
542 void
543 print_ip_vcc_info(struct air_ip_vcc_rsp *ai)
544 {
545         int     i;
546         const char      *ip_addr, *state;
547         char    flags[32], vpi_vci[16];
548         struct sockaddr_in      *sin;
549
550         /*
551          * Print a header if it hasn't been done yet.
552          */
553         if (!ip_vcc_hdr) {
554                 printf(IP_VCC_HDR);
555                 ip_vcc_hdr = 1;
556         }
557
558         /*
559          * Format the IP address
560          */
561         sin = (struct sockaddr_in *)&ai->aip_dst_addr;
562         ip_addr = format_ip_addr(&sin->sin_addr);
563
564         /*
565          * Format the VPI/VCI
566          */
567         if (ai->aip_vpi == 0 && ai->aip_vci == 0) {
568                 strcpy(vpi_vci, "  -     -");
569         } else {
570                 sprintf(vpi_vci, "%3d %5d", ai->aip_vpi, ai->aip_vci);
571         }
572
573         /*
574          * Decode VCC flags
575          */
576         UM_ZERO(flags, sizeof(flags));
577         if (ai->aip_flags & IVF_PVC) {
578                 strcat(flags, "P");
579         }
580         if (ai->aip_flags & IVF_SVC) {
581                 strcat(flags, "S");
582         }
583         if (ai->aip_flags & IVF_LLC) {
584                 strcat(flags, "L");
585         }
586         if (ai->aip_flags & IVF_MAPOK) {
587                 strcat(flags, "M");
588         }
589         if (ai->aip_flags & IVF_NOIDLE) {
590                 strcat(flags, "N");
591         }
592
593         /*
594          * Get the state of the VCC
595          */
596         for (i=0; ip_vcc_states[i].s_name != NULL && 
597                         ai->aip_state != ip_vcc_states[i].s_id;
598                         i++);
599         if (ip_vcc_states[i].s_name) {
600                 state = ip_vcc_states[i].s_name;
601         } else {
602                 state = "-";
603         }
604
605         /*
606          * Print the IP VCC information
607          */
608         printf("%-8s  %9s  %-7s %-5s %s\n",
609                         ai->aip_intf,
610                         vpi_vci,
611                         state,
612                         flags,
613                         ip_addr);
614 }
615
616
617 /*
618  * Print network interface information
619  * 
620  * Arguments:
621  *      ni      pointer to a struct air_int_rsp
622  *
623  * Returns:
624  *      none
625  *
626  */
627 void
628 print_netif_info(struct air_netif_rsp *ni)
629 {
630         const char              *ip_addr;
631         struct sockaddr_in      *sin;
632
633         /*
634          * Print a header
635          */
636         if (!netif_hdr) {
637                 netif_hdr++;
638                 printf(NETIF_HDR);
639         }
640
641         /*
642          * Format the protocol address
643          */
644         sin = (struct sockaddr_in *)&ni->anp_proto_addr;
645         ip_addr = format_ip_addr(&sin->sin_addr);
646
647         /*
648          * Print the network interface information
649          */
650         printf("%-8s  %-8s  %s\n",
651                         ni->anp_intf,
652                         ni->anp_phy_intf,
653                         ip_addr);
654 }
655
656
657 /*
658  * Print physical interface statistics
659  * 
660  * Arguments:
661  *      pi      pointer to a struct air_phy_stat_rsp
662  *
663  * Returns:
664  *      none
665  *
666  */
667 void
668 print_intf_stats(struct air_phy_stat_rsp *pi)
669 {
670         /*
671          * Print a header if it hasn't already been done
672          */
673         if (!phy_stats_hdr) {
674                 printf(PHY_STATS_HDR);
675                 phy_stats_hdr = 1;
676         }
677
678         /*
679          * Print the interface statistics
680          */
681         printf("%-9s  %7ld %8ld  %5ld %7ld %8ld  %5ld  %5ld\n",
682                         pi->app_intf,
683                         pi->app_ipdus,
684                         pi->app_ibytes,
685                         pi->app_ierrors,
686                         pi->app_opdus,
687                         pi->app_obytes,
688                         pi->app_oerrors,
689                         pi->app_cmderrors);
690 }
691
692
693 /*
694  * Print VCC statistics
695  * 
696  * Arguments:
697  *      vi      pointer to VCC statistics to print
698  *
699  * Returns:
700  *      none
701  *
702  */
703 void
704 print_vcc_stats(struct air_vcc_rsp *vi)
705 {
706
707         /*
708          * Print a header if it hasn't already been done
709          */
710         if (!vcc_stats_hdr) {
711                 printf(VCC_STATS_HDR);
712                 vcc_stats_hdr = 1;
713         }
714
715         /*
716          * Print the VCC statistics
717          */
718         printf("%-9s  %3d  %4d",
719                         vi->avp_intf,
720                         vi->avp_vpi,
721                         vi->avp_vci);
722         if ( vi->avp_type & VCC_IN )
723                 printf ( "  %7ld %8ld  %5ld",
724                         vi->avp_ipdus,
725                         vi->avp_ibytes,
726                         vi->avp_ierrors);
727         else
728                 printf ( "        -        -      -" );
729
730         if ( vi->avp_type & VCC_OUT )
731                 printf ( " %7ld %8ld  %5ld\n",
732                         vi->avp_opdus,
733                         vi->avp_obytes,
734                         vi->avp_oerrors);
735         else
736                 printf ( "       -        -      -\n" );
737 }
738
739
740 /*
741  * Print VCC information
742  * 
743  * Arguments:
744  *      vi      pointer to a struct air_vcc_rsp
745  *
746  * Returns:
747  *      none
748  *
749  */
750 void
751 print_vcc_info(struct air_vcc_rsp *vi)
752 {
753         int     i;
754         const char      *aal_name = "-" , *encaps_name = "-", *owner_name = "-";
755         const char      *state_name = "-", *type_name = "-";
756         char    dir_name[10];
757         const struct state      *s_t;
758
759         /*
760          * Print a header if it hasn't already been done
761          */
762         if (!vcc_hdr) {
763                 printf(VCC_HDR);
764                 vcc_hdr = 1;
765         }
766
767         /*
768          * Translate AAL
769          */
770         for (i=0; aals[i].a_name != NULL; i++)
771                 if (vi->avp_aal == aals[i].a_id)
772                         break;
773         if (aals[i].a_name)
774                 aal_name = aals[i].a_name;
775
776         /*
777          * Translate VCC type
778          */
779         if (vi->avp_type & VCC_PVC)
780                 type_name = "PVC";
781         else if (vi->avp_type & VCC_SVC)
782                 type_name = "SVC";
783         /*
784          * Translate VCC direction
785          */
786         UM_ZERO(dir_name, sizeof(dir_name));
787         if (vi->avp_type & VCC_IN)
788                 strcat(dir_name, "In");
789         if (vi->avp_type & VCC_OUT)
790                 strcat(dir_name, "Out");
791         if (strlen(dir_name) == 0)
792                 strcpy(dir_name, "-");
793
794         /*
795          * Translate state
796          */
797         for (i=0; proto_states[i].p_state != NULL; i++)
798                 if (vi->avp_sig_proto == proto_states[i].p_id)
799                         break;
800         if (proto_states[i].p_state) {
801                 s_t = proto_states[i].v_state;
802                 for (i=0; s_t[i].s_name != NULL; i++)
803                         if (vi->avp_state == s_t[i].s_id)
804                                 break;
805                 if (s_t[i].s_name)
806                         state_name = s_t[i].s_name;
807         }
808
809         /*
810          * Translate encapsulation
811          */
812         for (i=0; encaps[i].e_name != NULL; i++)
813                 if (vi->avp_encaps == encaps[i].e_id)
814                         break;
815         if (encaps[i].e_name)
816                 encaps_name = encaps[i].e_name;
817
818         /*
819          * Print the VCC information
820          */
821         printf("%-9s  %3d %5d  %-4s  %-4s %-5s  %-8s %-8s ",
822                         vi->avp_intf,
823                         vi->avp_vpi,
824                         vi->avp_vci,
825                         aal_name,
826                         type_name,
827                         dir_name,
828                         state_name,
829                         encaps_name);
830
831         /*
832          * Print VCC owners' names
833          */
834         for (i = 0, owner_name = vi->avp_owners;
835                         i < O_CNT - 1 && strlen(owner_name);
836                         i++, owner_name += (T_ATM_APP_NAME_LEN + 1)) {
837                 if (i > 0)
838                         printf(", ");
839                 printf("%s", owner_name);
840         }
841         if (i == 0)
842                 printf("-");
843         printf("\n");
844
845         /*
846          * Print destination address if it's an SVC
847          */
848         if (vi->avp_type & VCC_SVC) {
849                 printf("    Dest = %s\n",
850                                 format_atm_addr(&vi->avp_daddr));
851         }
852 }
853
854
855 /*
856  * Print network interface information
857  * 
858  * Arguments:
859  *      ni      pointer to a struct air_int_rsp
860  *
861  * Returns:
862  *      none
863  *
864  */
865 void
866 print_version_info(struct air_version_rsp *vi)
867 {
868         char                    version_str[80];
869
870         /*
871          * Print a header
872          */
873         if (!version_hdr) {
874                 version_hdr++;
875                 printf(VERSION_HDR);
876         }
877
878         /*
879          * Print the interface information
880          */
881         sprintf(version_str, "%d.%d",
882                         ATM_VERS_MAJ(vi->avp_version),
883                         ATM_VERS_MIN(vi->avp_version));
884         printf("%7s\n", version_str);
885 }