static char sccsid
[] = "@(#)implog.c 4.3 (Berkeley) 11/14/82";
#include <netimp/if_imp.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
char *logfile
= "/usr/adm/implog";
* Socket address, internet style, with
* unused space taken by timestamp and packet
while (argc
> 0 && argv
[0][0] == '-') {
if (strcmp(*argv
, "-D") == 0) {
if (strcmp(*argv
, "-f") == 0) {
if (strcmp(*argv
, "-c") == 0) {
if (strcmp(*argv
, "-l") == 0) {
if (strcmp(*argv
, "-h") == 0) {
printf("-h: missing host #\n");
if (strcmp(*argv
, "-i") == 0) {
printf("-i: missing imp #\n");
if (strcmp(*argv
, "-t") == 0) {
printf("-t: missing packet type\n");
packettype
= atoi(*argv
);
printf("usage: implog [ -D ] [ -c ] [ -f ] [-h #] [-i #] [ -t # ] [-l [#]] [logfile]\n");
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 && from
.sin_addr
.s_host
!= host
) {
lseek(log
, from
.sin_cc
, 1);
from
.sin_addr
.s_imp
= ntohs(from
.sin_addr
.s_imp
);
if (from
.sin_addr
.s_imp
!= imp
) {
lseek(log
, from
.sin_cc
, 1);
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((u_short
)ip
->il_imp
);
for (mp
= mtypes
; mp
->m_type
!= -1; mp
++)
if (mp
->m_type
== ip
->il_mtype
)
if (mp
->m_type
== IMPTYPE_DATA
) {
if (link
>= 0 && ip
->il_link
!= link
)
if (packettype
>= 0 && mp
->m_type
!= packettype
)
printf("%.24s: ", ctime(&f
->sin_time
));
(*mp
->m_func
)(ip
, f
->sin_cc
);
register struct imp_leader
*ip
;
printf("<%d/%d, DATA, link=", ip
->il_host
, ntohs((u_short
)ip
->il_imp
));
if (ip
->il_link
== IMPLINK_IP
)
printf("%d,", ip
->il_link
);
printf(" len=%d 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", down
[ip
->il_link
& IMP_DMASK
]);
tdown
= ((ip
->il_link
>> 2) & 0xf) * 5;
if (ip
->il_link
& IMP_DMASK
)
printf(" in %d minutes", tdown
);
tbackup
= ip
->il_subtype
* 5;
printf("%d minutes\n", tbackup
);
register struct imp_leader
*ip
;
printf("noop: host %d, imp %d\n", ip
->il_host
,
ntohs((u_short
)ip
->il_imp
));
register struct imp_leader
*ip
;
printf("rfnm: htype=%x, source=%d/%d, link=",
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%x,", 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
;
if (ip
->il_link
& IMP_DMASK
)
printf("down %s, ", down
[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 unreachable: ");
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=%d/%d, link=",
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%x, ", 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=%d/%d, link=",
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%x,", ip
->il_link
);
if (ip
->il_subtype
<= IMPCOMPLETE_IMPIO
)
printf(" %s\n", incomplete
[ip
->il_subtype
]);
printf(" subtype=%x\n", ip
->il_subtype
);
register struct imp_leader
*ip
;
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
);
register struct imp_leader
*ip
;
printf("refused, still trying\n");
register struct imp_leader
*ip
;
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, host=%x, imp=%x, link=", ip
->il_mtype
,
ip
->il_htype
, ip
->il_host
, ip
->il_imp
);
if (ip
->il_link
== IMPLINK_IP
)
printf("%x,", ip
->il_link
);
printf(" subtype=%x>\n", ip
->il_subtype
);