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