File: ospf2_1002.c

package info (click to toggle)
libtrace3 3.0.14-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 11,492 kB
  • sloc: ansic: 21,584; sh: 10,236; cpp: 1,765; makefile: 454; yacc: 96; lex: 50
file content (28 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (4)
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
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <arpa/inet.h>
#include "libpacketdump.h"

DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len) {
	libtrace_ospf_network_lsa_v2_t *net;
	struct in_addr *router = NULL;

	net = (libtrace_ospf_network_lsa_v2_t *)packet;

	if (len < 4)
		return;
	printf(" OSPF Network LSA: Netmask %s\n", inet_ntoa(net->netmask));

	router = (struct in_addr *)(packet + sizeof(libtrace_ospf_network_lsa_v2_t));
	len -= sizeof(libtrace_ospf_network_lsa_v2_t);

	while (len >= sizeof(struct in_addr)) {

		printf("OSPF Network LSA: Attached Router %s\n", 
				inet_ntoa(*router));
		router ++;
		len -= sizeof(struct in_addr);
	}
}