4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since e224862 was
e224862,
checked in by Shane Alcock <salcock@…>, 9 years ago
|
- Added libpacketdump decoders for a large portion of OSPF v2
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <inttypes.h> |
---|
3 | #include <dlfcn.h> |
---|
4 | #include <sys/socket.h> |
---|
5 | #include <netinet/in.h> |
---|
6 | #include <arpa/inet.h> |
---|
7 | |
---|
8 | #include "libpacketdump.h" |
---|
9 | |
---|
10 | static void dump_ospf_v2_header(libtrace_ospf_v2_t *hdr, unsigned len) { |
---|
11 | |
---|
12 | printf(" OSPF Header: Version %u Type %u ", |
---|
13 | hdr->ospf_v, hdr->type); |
---|
14 | switch(hdr->type) { |
---|
15 | case TRACE_OSPF_HELLO: |
---|
16 | printf("(Hello)"); |
---|
17 | break; |
---|
18 | case TRACE_OSPF_DATADESC: |
---|
19 | printf("(Database Desc)"); |
---|
20 | break; |
---|
21 | case TRACE_OSPF_LSREQ: |
---|
22 | printf("(Link State Request)"); |
---|
23 | break; |
---|
24 | case TRACE_OSPF_LSUPDATE: |
---|
25 | printf("(Link State Update)"); |
---|
26 | break; |
---|
27 | case TRACE_OSPF_LSACK: |
---|
28 | printf("(Link State Ack.)"); |
---|
29 | break; |
---|
30 | } |
---|
31 | |
---|
32 | printf("\n OSPF Header: Length %u \n", ntohs(hdr->len)); |
---|
33 | printf(" OSPF Header: Router Id %s ", inet_ntoa(hdr->router)); |
---|
34 | printf("Area Id %s\n", inet_ntoa(hdr->area)); |
---|
35 | printf(" OSPF Header: Checksum %u Auth Type %u\n", ntohs(hdr->sum), |
---|
36 | ntohs(hdr->au_type)); |
---|
37 | |
---|
38 | printf(" OSPF Header: Auth Key ID %u Auth Data Len %u\n", |
---|
39 | hdr->au_key_id, hdr->au_data_len); |
---|
40 | printf(" OSPF Header: Auth Crypto Seq %u\n", ntohl(hdr->au_seq_num)); |
---|
41 | |
---|
42 | |
---|
43 | } |
---|
44 | |
---|
45 | DLLEXPORT void decode(int link_type UNUSED, const char *packet, unsigned len) { |
---|
46 | |
---|
47 | libtrace_ospf_v2_t *hdr = (libtrace_ospf_v2_t *)packet; |
---|
48 | |
---|
49 | if (hdr->ospf_v == 2) { |
---|
50 | dump_ospf_v2_header(hdr, len); |
---|
51 | decode_next(packet + sizeof(libtrace_ospf_v2_t), |
---|
52 | len - sizeof(libtrace_ospf_v2_t), "ospf2", |
---|
53 | hdr->type); |
---|
54 | } |
---|
55 | |
---|
56 | return; |
---|
57 | |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.