tracedump
single application IP packet sniffer

pcap.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011-2012 IITiS PAN Gliwice <http://www.iitis.pl/>
00003  * Author: Paweł Foremski <pjf@iitis.pl>
00004  * Licensed under GNU GPL v. 3
00005  */
00006 
00007 #ifndef _PCAP_H_
00008 #define _PCAP_H_
00009 
00010 #include "tracedump.h"
00011 
00013 struct pcap {
00014         int fd;                
00015         pthread_t reader;      
00016         FILE *fp;              
00017 };
00018 
00019 /* From http://wiki.wireshark.org/Development/LibpcapFileFormat */
00020 #ifndef PCAP_MAGIC_NUMBER
00021 #define PCAP_MAGIC_NUMBER 0xa1b2c3d4
00022 #endif
00023 #ifndef LINKTYPE_LINUX_SLL
00024 #define LINKTYPE_LINUX_SLL 113
00025 #endif
00026 struct pcap_file_hdr {
00027         uint32_t magic_number;   /* magic number */
00028         uint16_t version_major;  /* major version number */
00029         uint16_t version_minor;  /* minor version number */
00030         int32_t  thiszone;       /* GMT to local correction */
00031         uint32_t sigfigs;        /* accuracy of timestamps */
00032         uint32_t snaplen;        /* max length of captured packets, in octets */
00033         uint32_t network;        /* data link type */
00034 };
00035 struct pcap_pkt_hdr {
00036         uint32_t ts_sec;         /* timestamp seconds */
00037         uint32_t ts_usec;        /* timestamp microseconds */
00038         uint32_t incl_len;       /* number of octets of packet saved in file */
00039         uint32_t orig_len;       /* actual length of packet */
00040 };
00041 struct pcap_sll_hdr {
00042         uint16_t sll_pkttype;
00043         uint16_t sll_hatype;
00044         uint16_t sll_halen;
00045         uint8_t  sll_addr[8];
00046         uint16_t sll_protocol;
00047 };
00048 
00050 void pcap_init(struct tracedump *td);
00051 
00053 void pcap_deinit(struct tracedump *td);
00054 
00056 void pcap_update(struct tracedump *td);
00057 
00058 #endif
 All Data Structures Files Functions Variables Enumerations Enumerator Defines