]>
git.saurik.com Git - apple/network_cmds.git/blob - tcpdump.tproj/print-igrp.c
a35e6ac4618fa596f828ff5f05d0b62c9c1f960f
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
26 * The Regents of the University of California. All rights reserved.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that: (1) source code distributions
30 * retain the above copyright notice and this paragraph in its entirety, (2)
31 * distributions including binary code include the above copyright notice and
32 * this paragraph in its entirety in the documentation or other materials
33 * provided with the distribution, and (3) all advertising materials mentioning
34 * features or use of this software display the following acknowledgement:
35 * ``This product includes software developed by the University of California,
36 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
37 * the University nor the names of its contributors may be used to endorse
38 * or promote products derived from this software without specific prior
40 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
41 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
44 * Initial contribution from Francis Dupont (francis.dupont@inria.fr)
48 static const char rcsid
[] =
49 "@(#) $Header: /cvs/Darwin/Commands/NeXT/network_cmds/tcpdump.tproj/print-igrp.c,v 1.1.1.1 1999/05/02 03:58:33 wsanchez Exp $ (LBL)";
52 #include <sys/param.h>
53 #include <sys/socket.h>
55 #include <netinet/in.h>
56 #include <netinet/in_systm.h>
57 #include <netinet/ip.h>
58 #include <netinet/ip_var.h>
59 #include <netinet/udp.h>
60 #include <netinet/udp_var.h>
65 #include "addrtoname.h"
66 #include "interface.h"
68 #include "extract.h" /* must come after interface.h */
71 igrp_entry_print(register struct igrprte
*igr
, register int is_interior
,
72 register int is_exterior
)
74 register u_int delay
, bandwidth
;
78 printf(" *.%d.%d.%d", igr
->igr_net
[0],
79 igr
->igr_net
[1], igr
->igr_net
[2]);
81 printf(" X%d.%d.%d.0", igr
->igr_net
[0],
82 igr
->igr_net
[1], igr
->igr_net
[2]);
84 printf(" %d.%d.%d.0", igr
->igr_net
[0],
85 igr
->igr_net
[1], igr
->igr_net
[2]);
87 delay
= EXTRACT_24BITS(igr
->igr_dly
);
88 bandwidth
= EXTRACT_24BITS(igr
->igr_bw
);
89 metric
= bandwidth
+ delay
;
90 if (metric
> 0xffffff)
92 mtu
= EXTRACT_16BITS(igr
->igr_mtu
);
94 printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
95 10 * delay
, bandwidth
== 0 ? 0 : 10000000 / bandwidth
,
96 igr
->igr_rel
, igr
->igr_ld
, metric
,
100 static struct tok op2str
[] = {
101 { IGRP_UPDATE
, "update" },
102 { IGRP_REQUEST
, "request" },
107 igrp_print(register const u_char
*bp
, u_int length
, register const u_char
*bp2
)
109 register struct igrphdr
*hdr
;
110 register struct ip
*ip
;
112 u_int nint
, nsys
, next
;
114 hdr
= (struct igrphdr
*)bp
;
115 ip
= (struct ip
*)bp2
;
116 cp
= (u_char
*)(hdr
+ 1);
117 (void)printf("%s > %s: igrp: ",
118 ipaddr_string(&ip
->ip_src
),
119 ipaddr_string(&ip
->ip_dst
));
123 nint
= EXTRACT_16BITS(&hdr
->ig_ni
);
124 nsys
= EXTRACT_16BITS(&hdr
->ig_ns
);
125 next
= EXTRACT_16BITS(&hdr
->ig_nx
);
127 (void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
128 tok2str(op2str
, "op-#%d", hdr
->ig_op
),
131 EXTRACT_16BITS(&hdr
->ig_as
),
136 length
-= sizeof(*hdr
);
137 while (length
>= IGRP_RTE_SIZE
) {
139 TCHECK2(*cp
, IGRP_RTE_SIZE
);
140 igrp_entry_print((struct igrprte
*)cp
, 1, 0);
142 } else if (nsys
> 0) {
143 TCHECK2(*cp
, IGRP_RTE_SIZE
);
144 igrp_entry_print((struct igrprte
*)cp
, 0, 0);
146 } else if (next
> 0) {
147 TCHECK2(*cp
, IGRP_RTE_SIZE
);
148 igrp_entry_print((struct igrprte
*)cp
, 0, 1);
151 (void)printf("[extra bytes %d]", length
);
155 length
-= IGRP_RTE_SIZE
;
157 if (nint
== 0 && nsys
== 0 && next
== 0)
160 fputs("[|igrp]", stdout
);