4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI" /* SunOS */
31 #include <sys/socket.h>
32 #include <sys/types.h>
34 #include <netinet/in_systm.h>
35 #include <netinet/in.h>
36 #include <netinet/ip.h>
39 #include <arpa/inet.h>
40 #include <protocols/routed.h>
41 #include <protocols/ripngd.h>
44 extern char *dlc_header
;
45 static char *show_cmd6();
47 static struct in6_addr all_zeroes_addr
= { { { 0x0, 0x0, 0x0, 0x0,
50 0x0, 0x0, 0x0, 0x0 } } };
53 interpret_rip6(int flags
, struct rip6
*rip6
, int fraglen
)
60 char dststr
[INET6_ADDRSTRLEN
];
63 switch (rip6
->rip6_cmd
) {
64 case RIPCMD6_REQUEST
: p
= "C"; break;
65 case RIPCMD6_RESPONSE
: p
= "R"; break;
66 default: p
= "?"; break;
69 switch (rip6
->rip6_cmd
) {
71 case RIPCMD6_RESPONSE
:
74 for (n
= rip6
->rip6_nets
;
75 len
>= sizeof (struct netinfo6
); n
++) {
77 len
-= sizeof (struct netinfo6
);
79 (void) sprintf(get_sum_line(),
80 "RIPng %s (%d destinations)", p
, count
);
83 (void) sprintf(get_sum_line(), "RIPng %s", p
);
88 if (flags
& F_DTAIL
) {
90 show_header("RIPng: ", "Routing Information Protocol for IPv6",
93 (void) sprintf(get_line((char *)(uintptr_t)rip6
->rip6_cmd
-
94 dlc_header
, 1), "Opcode = %d (%s)", rip6
->rip6_cmd
,
95 show_cmd6(rip6
->rip6_cmd
));
96 (void) sprintf(get_line((char *)(uintptr_t)rip6
->rip6_vers
-
97 dlc_header
, 1), "Version = %d", rip6
->rip6_vers
);
99 switch (rip6
->rip6_cmd
) {
100 case RIPCMD6_REQUEST
:
101 case RIPCMD6_RESPONSE
:
103 (void) sprintf(get_line(0, 0), "Address"
106 for (n
= rip6
->rip6_nets
;
107 len
>= sizeof (struct netinfo6
); n
++) {
108 if (rip6
->rip6_vers
> 0) {
109 n
->rip6_metric
= n
->rip6_metric
;
111 dst
= &n
->rip6_prefix
;
112 notdefault
= bcmp((caddr_t
*)dst
,
113 (caddr_t
*)&all_zeroes_addr
, sizeof (*dst
));
114 (void) inet_ntop(AF_INET6
, (char *)dst
, dststr
,
116 (void) sprintf(get_line((char *)n
- dlc_header
,
117 sizeof (struct netinfo6
)),
118 "%-30s %-10d %-5d %s",
119 notdefault
? dststr
:
120 " (default)", n
->rip6_prefix_length
,
121 n
->rip6_metric
, n
->rip6_metric
== 16 ?
122 " (not reachable)":"");
123 len
-= sizeof (struct netinfo
);
136 case RIPCMD6_REQUEST
: return ("route request");
137 case RIPCMD6_RESPONSE
: return ("route response");