home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
internet
/
tcpipsrc
/
ARP
/
c
/
ARPDUMP
< prev
Wrap
Text File
|
1994-06-24
|
2KB
|
58 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "timer.h"
#include "netuser.h"
#include "arp.h"
#include "misc.h"
void arp_dump(struct mbuf **bpp)
{
struct arp arp;
struct arp_type *at;
int is_ip = 0;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
twprintf("ARP: len %d",len_mbuf(*bpp));
if(ntoharp(&arp,bpp) == -1){
twprintf(" bad packet\n");
return;
}
/* Print hardware type in Ascii if known, numerically if not */
if(arp.hardware < NHWTYPES){
at = &arp_type[arp.hardware];
twprintf(" hwtype %s",arptypes[arp.hardware]);
} else {
at = NULLATYPE;
twprintf(" hwtype %u",arp.hardware);
}
/* Print hardware length only if unknown type, or if it doesn't match
* the length in the known types table
*/
if(at == NULLATYPE || arp.hwalen != at->hwalen)
twprintf(" hwlen %u",arp.hwalen);
/* Check for most common case -- upper level protocol is IP */
if(at != NULLATYPE && arp.protocol == at->iptype){
twprintf(" prot IP");
is_ip = 1;
} else {
twprintf(" prot 0x%x prlen %u",arp.protocol,arp.pralen);
}
switch(arp.opcode){
case ARP_REQUEST:
twprintf(" op REQUEST");
break;
case ARP_REPLY:
twprintf(" op REPLY");
break;
default:
twprintf(" op %u",arp.opcode);
break;
}
if(is_ip)
twprintf(" target %s",inet_ntoa(arp.tprotaddr));
twprintf("\n");
}