* Copyright (c) 1983, 1988 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
"@(#) Copyright (c) 1983, 1988 Regents of the University of California.\n\
static char sccsid
[] = "@(#)implog.c 5.14 (Berkeley) 4/1/91";
#include <netimp/if_imp.h>
* Socket address, internet style, with
* unused space taken by timestamp and packet
extern int errno
, optind
;
char *logfile
, *strerror();
while ((ch
= getopt(argc
, argv
, "DFLcfh:i:l:rt:")) != EOF
)
packettype
= atoi(optarg
);
"usage: implog [-DFLcfr] [-h host] [-i imp] [-l link] [-t type] [logfile]\n");
logfile
= argc
? *argv
: _PATH_IMPLOG
;
log
= open(logfile
, O_RDONLY
, 0);
if (log
< 0 || fstat(log
, &b
)) {
fprintf(stderr
, "implog: %s: %s\n", logfile
, strerror(errno
));
(void)lseek(log
, size
, L_SET
);
while (read(log
, (char *)&from
, sizeof(from
)) == sizeof(from
)) {
if (from
.sin_family
== 0) {
printf("restarted: %.24s\n", ctime(&from
.sin_time
));
if (host
>= 0 || imp
>= 0) {
long addr
= ntohl(from
.sin_addr
.s_addr
);
hostfrom
= ((addr
>>16) & 0xFF);
} else if (IN_CLASSB(addr
)) {
hostfrom
= ((addr
>>8) & 0xFF);
hostfrom
= ((addr
>>4) & 0xF);
if (host
>= 0 && hostfrom
!= host
) {
(void)lseek(log
, (long)from
.sin_cc
, L_INCR
);
if (imp
>= 0 && impfrom
!= imp
) {
(void)lseek(log
, (long)from
.sin_cc
, L_INCR
);
int impdata(), impbadleader(), impdown(), impnoop();
int imprfnm(), impincomplete(), imphostdead(), imphostunreach();
int impbaddata(), impreset(), impretry(), impnotify(), imptrying();
int impready(), impundef();
u_char m_type
; /* type of message */
int (*m_func
)(); /* routine to process message */
{ IMPTYPE_DATA
, impdata
},
{ IMPTYPE_BADLEADER
, impbadleader
},
{ IMPTYPE_DOWN
, impdown
},
{ IMPTYPE_NOOP
, impnoop
},
{ IMPTYPE_RFNM
, imprfnm
},
{ IMPTYPE_INCOMPLETE
, impincomplete
},
{ IMPTYPE_HOSTDEAD
, imphostdead
},
{ IMPTYPE_HOSTUNREACH
, imphostunreach
},
{ IMPTYPE_BADDATA
, impbaddata
},
{ IMPTYPE_RESET
, impreset
},
{ IMPTYPE_RETRY
, impretry
},
{ IMPTYPE_NOTIFY
, impnotify
},
{ IMPTYPE_TRYING
, imptrying
},
{ IMPTYPE_READY
, impready
},
register struct messages
*mp
;
if (read(l
, (char *)buf
, f
->sin_cc
) != f
->sin_cc
) {
ip
= (struct imp_leader
*)buf
;
ip
->il_imp
= ntohs(ip
->il_imp
);
if (ip
->il_format
!= IMP_NFF
)
for (mp
= mtypes
; mp
->m_type
!= (u_char
)-1; mp
++)
if (mp
->m_type
== ip
->il_mtype
)
if (ip
->il_mtype
== IMPTYPE_DATA
) {
if (linkn
>= 0 && ip
->il_link
!= linkn
)
if (packettype
>= 0 && ip
->il_mtype
!= packettype
)
printf("%.24s: ", ctime(&f
->sin_time
));
if (f
->sin_cc
< sizeof(struct control_leader
))
printf("(truncated header, %d bytes): ", f
->sin_cc
);
if (rawheader
&& fn
!= impundef
) {
register struct imp_leader
*ip
;
printf("<DATA, source=%d/%u, link=", ip
->il_host
, (u_short
)ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%d,", ip
->il_link
);
printf(" len=%u bytes>\n", ntohs((u_short
)ip
->il_length
) >> 3);
register u_char
*cp
= ((u_char
*)ip
) + sizeof(*ip
);
i
= (ntohs(ip
->il_length
) >> 3) - sizeof(struct imp_leader
);
printf("data: (%d bytes)", cc
);
for (i
= 0; i
< cc
; i
++, cp
++) {
register struct imp_leader
*ip
;
if (ip
->il_subtype
> IMPLEADER_OPPOSITE
)
printf("%x\n", ip
->il_subtype
);
printf("%s\n", badleader
[ip
->il_subtype
]);
register struct imp_leader
*ip
;
printf("imp going down %s", impmessage
[ip
->il_link
& IMP_DMASK
]);
tdown
= ((ip
->il_link
>> IMPDOWN_WHENSHIFT
) & IMPDOWN_WHENMASK
) *
if ((ip
->il_link
& IMP_DMASK
) != IMPDOWN_GOING
)
printf(" in %d minutes", tdown
);
tbackup
= ip
->il_subtype
* IMPDOWN_WHENUNIT
;
printf("%d minutes\n", tbackup
);
register struct imp_leader
*ip
;
printf("noop: host %d, imp %u\n", ip
->il_host
, ip
->il_imp
);
register struct imp_leader
*ip
;
printf("rfnm: htype=%x, source=%d/%u, link=",
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%d,", ip
->il_link
);
printf(" subtype=%x\n", ip
->il_subtype
);
"tardy receiving messages",
"imp software won't allow messages",
"host down for scheduled pm",
"host down for hardware work",
"host down for software work",
"host down for emergency restart",
"host down because of power outage",
"host stopped at a breakpoint",
"host down due to hardware failure",
"host not scheduled to be up",
"host in the process of coming up"
register struct imp_leader
*ip
;
printf("host %u/%u dead: ", ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
& IMP_DMASK
)
printf("down %s, ", impmessage
[ip
->il_link
& IMP_DMASK
]);
if (ip
->il_subtype
<= IMPHOST_COMINGUP
)
printf("%s\n", hostdead
[ip
->il_subtype
]);
printf("subtype=%x\n", ip
->il_subtype
);
"destination imp can't be reached",
"destination host isn't up",
"host doesn't support long leader",
"communication is prohibited"
register struct imp_leader
*ip
;
printf("host %u/%u unreachable: ", ip
->il_host
, ip
->il_imp
);
if (ip
->il_subtype
<= IMPREACH_PROHIBITED
)
printf("%s\n", hostunreach
[ip
->il_subtype
]);
printf("subtype=%x\n", ip
->il_subtype
);
register struct imp_leader
*ip
;
printf("error in data: htype=%x, source=%u/%u, link=",
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%d, ", ip
->il_link
);
printf("subtype=%x\n", ip
->il_subtype
);
"host didn't take data fast enough",
"message transmission time > 15 seconds",
"no resources within 15 seconds",
"source imp i/o failure during receipt"
register struct imp_leader
*ip
;
printf("incomplete: htype=%x, source=%u/%u, link=",
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%d,", ip
->il_link
);
if (ip
->il_subtype
<= IMPCOMPLETE_IMPIO
)
printf(" %s\n", incomplete
[ip
->il_subtype
]);
printf(" subtype=%x\n", ip
->il_subtype
);
printf("reset complete\n");
"imp buffer wasn't available",
"connection block unavailable"
register struct imp_leader
*ip
;
printf("refused, try again: ");
if (ip
->il_subtype
<= IMPRETRY_BLOCK
)
printf("%s\n", retry
[ip
->il_subtype
]);
printf("subtype=%x\n", ip
->il_subtype
);
"connection not available",
"reassembly space not available at destination",
"message number not available",
"transaction block for message not available"
register struct imp_leader
*ip
;
printf("refused, will notify: ");
printf("%s\n", notify
[ip
->il_subtype
]);
printf("subtype=%x\n", ip
->il_subtype
);
printf("refused, still trying\n");
register struct imp_leader
*ip
;
printf("<fmt=%x, net=%x, flags=%x, mtype=", ip
->il_format
,
ip
->il_network
, ip
->il_flags
);
printf("%x, htype=%x,\n\t host=%d(x%x), imp=%u(x%x), link=",
ip
->il_mtype
, ip
->il_htype
, ip
->il_host
, ip
->il_host
,
if (ip
->il_link
== IMPLINK_IP
)
printf("%d (x%x),", ip
->il_link
, ip
->il_link
);
printf(" subtype=%x", ip
->il_subtype
);
if (cc
>= sizeof(struct imp_leader
) && ip
->il_length
)
printf(" len=%u bytes", ntohs((u_short
)ip
->il_length
) >> 3);