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
|
#include <stdio.h>
#include <inttypes.h>
#include <dlfcn.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "libpacketdump.h"
static void dump_ospf_v2_header(libtrace_ospf_v2_t *hdr, unsigned len) {
printf(" OSPF Header: Version %u Type %u ",
hdr->ospf_v, hdr->type);
switch(hdr->type) {
case TRACE_OSPF_HELLO:
printf("(Hello)");
break;
case TRACE_OSPF_DATADESC:
printf("(Database Desc)");
break;
case TRACE_OSPF_LSREQ:
printf("(Link State Request)");
break;
case TRACE_OSPF_LSUPDATE:
printf("(Link State Update)");
break;
case TRACE_OSPF_LSACK:
printf("(Link State Ack.)");
break;
}
printf("\n OSPF Header: Length %u \n", ntohs(hdr->len));
printf(" OSPF Header: Router Id %s ", inet_ntoa(hdr->router));
printf("Area Id %s\n", inet_ntoa(hdr->area));
printf(" OSPF Header: Checksum %u Auth Type %u\n", ntohs(hdr->sum),
ntohs(hdr->au_type));
printf(" OSPF Header: Auth Key ID %u Auth Data Len %u\n",
hdr->au_key_id, hdr->au_data_len);
printf(" OSPF Header: Auth Crypto Seq %u\n", ntohl(hdr->au_seq_num));
}
DLLEXPORT void decode(int link_type UNUSED, const char *packet, unsigned len) {
libtrace_ospf_v2_t *hdr = (libtrace_ospf_v2_t *)packet;
if (hdr->ospf_v == 2) {
dump_ospf_v2_header(hdr, len);
decode_next(packet + sizeof(libtrace_ospf_v2_t),
len - sizeof(libtrace_ospf_v2_t), "ospf2",
hdr->type);
}
return;
}
|