File: eth_34916.c

package info (click to toggle)
libtrace3 3.0.7-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,676 kB
  • ctags: 3,140
  • sloc: ansic: 20,551; sh: 10,125; cpp: 1,384; makefile: 415; yacc: 96; lex: 50
file content (37 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (5)
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

#include "libtrace_int.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include "libpacketdump.h"
#include "libtrace.h"

typedef struct pppoe_t {
	LT_BITFIELD8	ver:4;
	LT_BITFIELD8	type:4;
	uint8_t		code;
	uint16_t	session;
	uint16_t	length;
} pppoe_t;

DLLEXPORT void decode(int link_type UNUSED,const char *pkt,unsigned len) 
{
	pppoe_t *pppoe = (pppoe_t *) pkt;
	
	if (len < sizeof(*pppoe)) {
		printf(" PPPoE: Truncated (len = %u)\n", len);
		return;
	}

	printf(" PPPoE: Version: %d\n",pppoe->ver);
	printf(" PPPoE: Type: %d\n",pppoe->type);
	printf(" PPPoE: Code: %d\n",pppoe->code);
	printf(" PPPoE: Session: %d\n",ntohs(pppoe->session));
	printf(" PPPoE: Length: %d\n",ntohs(pppoe->length));

	/* Meh.. pass it off to eth decoder */
	decode_next(pkt + sizeof(*pppoe), len - sizeof(*pppoe), "link", 5);

}