File: raw.c

package info (click to toggle)
ipgrab 0.5-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 268 kB
  • ctags: 169
  • sloc: sh: 1,507; ansic: 1,234; makefile: 56
file content (60 lines) | stat: -rw-r--r-- 1,441 bytes parent folder | download | duplicates (2)
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
59
60
/**************************************************************************** 
** File: raw.c
**
** Author: Mike Borella
**
** Comments: Dump raw data link packets
**
*****************************************************************************/

#include <stdio.h>
#include <unistd.h>
#include <pcap.h>
#include "config.h"

u_char *packet_ptr;
u_char *packet_end;

/*----------------------------------------------------------------------------
**
** dump_raw()
**
** Process packets from the DLT_RAW interface type
**
**----------------------------------------------------------------------------
*/

void dump_raw(u_char *user, const struct pcap_pkthdr *h, u_char *p)
{
  u_int length; 
  u_int caplen;
  void dump_ip(u_char *, u_int);

  /*
   * Get total packet length and length of the captured section
   */

  length = h->len;
  caplen = h->caplen;

  /*
   * Dump raw header
   */

  printf("==========================================================\n");
  printf("                        Raw Header(%u.%06u)\n",
	 (u_int32_t) h->ts.tv_sec, (u_int32_t) h->ts.tv_usec);
  printf("----------------------------------------------------------\n");

  /*
   * Some printers want to get back at the link level addresses,
   * and/or check that they're not walking off the end of the packet.
   * Rather than pass them all the way down, we set these globals.
   */
   
  packet_ptr = p;
  packet_end = p + caplen;

  dump_ip(p, length);

}