File: ip_89.c

package info (click to toggle)
libtrace3 3.0.22-0.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,452 kB
  • sloc: ansic: 24,574; sh: 11,372; cpp: 1,811; makefile: 460; yacc: 96; lex: 50
file content (57 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (3)
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
#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) {

	DISPLAY(hdr, ospf_v, " OSPF Header: Version %u");
        DISPLAY(hdr, type, " Type %u ");
	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");

	DISPLAYS(hdr, ospf_len, "OSPF Header: Length %u \n");
        DISPLAYIP(hdr, router, " OSPF Header: Router Id %s ");
        DISPLAYIP(hdr, area, "Area Id %s\n");
	DISPLAYS(hdr, sum, " OSPF Header: Checksum %u ");
        DISPLAYS(hdr, au_type, "Auth Type %u\n");
        DISPLAY(hdr, au_key_id, " OSPF Header: Auth Key ID %u ");
        DISPLAY(hdr, au_data_len, "Auth Data Len %u\n");
        DISPLAYL(hdr, au_seq_num, " OSPF Header: Auth Crypto Seq %u\n");

}

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;

}