1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
#include <config.h>
#include "netdissect-stdinc.h"
#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
#define FIREWIRE_EUI64_LEN 8
struct firewire_header {
nd_byte firewire_dhost[FIREWIRE_EUI64_LEN];
nd_byte firewire_shost[FIREWIRE_EUI64_LEN];
nd_uint16_t firewire_type;
};
#define FIREWIRE_HDRLEN 18
static const char *
fwaddr_string(netdissect_options *ndo, const u_char *addr)
{
return GET_LINKADDR_STRING(addr, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN);
}
static void
ap1394_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const struct firewire_header *fp;
uint16_t firewire_type;
fp = (const struct firewire_header *)bp;
ND_PRINT("%s > %s",
fwaddr_string(ndo, fp->firewire_shost),
fwaddr_string(ndo, fp->firewire_dhost));
firewire_type = GET_BE_U_2(fp->firewire_type);
if (!ndo->ndo_qflag) {
ND_PRINT(", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", firewire_type),
firewire_type);
} else {
ND_PRINT(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
}
ND_PRINT(", length %u: ", length);
}
void
ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const struct firewire_header *fp;
u_short ether_type;
struct lladdr_info src, dst;
ndo->ndo_protocol = "ap1394";
ND_TCHECK_LEN(p, FIREWIRE_HDRLEN);
ndo->ndo_ll_hdr_len += FIREWIRE_HDRLEN;
if (ndo->ndo_eflag)
ap1394_hdr_print(ndo, p, length);
length -= FIREWIRE_HDRLEN;
caplen -= FIREWIRE_HDRLEN;
fp = (const struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
ether_type = GET_BE_U_2(fp->firewire_type);
src.addr = fp->firewire_shost;
src.addr_string = fwaddr_string;
dst.addr = fp->firewire_dhost;
dst.addr_string = fwaddr_string;
if (ethertype_print(ndo, ether_type, p, length, caplen, &src, &dst) == 0) {
if (!ndo->ndo_eflag)
ap1394_hdr_print(ndo, (const u_char *)fp, length + FIREWIRE_HDRLEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
}
|