Main Page   Modules   Data Structures   File List   Data Fields   Globals  

savefile.c File Reference

#include <errno.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pcap-int.h"

Go to the source code of this file.

Data Structures

struct  linktype_map

Defines

#define TCPDUMP_MAGIC   0xa1b2c3d4
#define PATCHED_TCPDUMP_MAGIC   0xa1b2cd34
#define SWAPLONG(y)   ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
#define SWAPSHORT(y)   ( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) )
#define SFERR_TRUNC   1
#define SFERR_BADVERSION   2
#define SFERR_BADF   3
#define SFERR_EOF   4
#define LINKTYPE_NULL   DLT_NULL
#define LINKTYPE_ETHERNET   DLT_EN10MB
#define LINKTYPE_EXP_ETHERNET   DLT_EN3MB
#define LINKTYPE_AX25   DLT_AX25
#define LINKTYPE_PRONET   DLT_PRONET
#define LINKTYPE_CHAOS   DLT_CHAOS
#define LINKTYPE_TOKEN_RING   DLT_IEEE802
#define LINKTYPE_ARCNET   DLT_ARCNET
#define LINKTYPE_SLIP   DLT_SLIP
#define LINKTYPE_PPP   DLT_PPP
#define LINKTYPE_FDDI   DLT_FDDI
#define LINKTYPE_PPP_HDLC   50
#define LINKTYPE_PPP_ETHER   51
#define LINKTYPE_ATM_RFC1483   100
#define LINKTYPE_RAW   101
#define LINKTYPE_SLIP_BSDOS   102
#define LINKTYPE_PPP_BSDOS   103
#define LINKTYPE_C_HDLC   104
#define LINKTYPE_IEEE802_11   105
#define LINKTYPE_ATM_CLIP   106
#define LINKTYPE_FRELAY   107
#define LINKTYPE_LOOP   108
#define LINKTYPE_LINUX_SLL   113
#define LINKTYPE_LTALK   114
#define LINKTYPE_ECONET   115
#define LINKTYPE_CISCO_IOS   118
#define LINKTYPE_PRISM_HEADER   119
#define LINKTYPE_AIRONET_HEADER   120
#define LINKTYPE_SUNATM   123
#define LINKTYPE_ENC   109
#define LINKTYPE_LANE8023   110
#define LINKTYPE_HIPPI   111
#define LINKTYPE_HDLC   112
#define LINKTYPE_IPFILTER   116
#define LINKTYPE_PFLOG   117
#define LINKTYPE_HHDLC   121
#define LINKTYPE_IP_OVER_FC   122

Functions

int dlt_to_linktype (int dlt)
int linktype_to_dlt (int linktype)
int sf_write_header (FILE *fp, int linktype, int thiszone, int snaplen)
void swap_hdr (struct pcap_file_header *hp)
pcap_tpcap_open_offline (const char *fname, char *errbuf)
 Opens a savefile in the tcpdump/libpcap format to read the packets. More...

int sf_next_packet (pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, int buflen)
int pcap_offline_read (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
void pcap_dump (u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 Saves a packet to disk. More...

pcap_dumper_tpcap_dump_open (pcap_t *p, const char *fname)
 Opens a file to write the network traffic. More...

void pcap_dump_close (pcap_dumper_t *p)
 pcap_dump_close() closes the "savefile". More...


Variables

const char rcsid []
linktype_map map []


Define Documentation

#define LINKTYPE_AIRONET_HEADER   120
 

Definition at line 166 of file savefile.c.

#define LINKTYPE_ARCNET   DLT_ARCNET
 

Definition at line 126 of file savefile.c.

#define LINKTYPE_ATM_CLIP   106
 

Definition at line 156 of file savefile.c.

#define LINKTYPE_ATM_RFC1483   100
 

Definition at line 150 of file savefile.c.

#define LINKTYPE_AX25   DLT_AX25
 

Definition at line 122 of file savefile.c.

#define LINKTYPE_C_HDLC   104
 

Definition at line 154 of file savefile.c.

#define LINKTYPE_CHAOS   DLT_CHAOS
 

Definition at line 124 of file savefile.c.

#define LINKTYPE_CISCO_IOS   118
 

Definition at line 164 of file savefile.c.

#define LINKTYPE_ECONET   115
 

Definition at line 162 of file savefile.c.

#define LINKTYPE_ENC   109
 

Definition at line 172 of file savefile.c.

#define LINKTYPE_ETHERNET   DLT_EN10MB
 

Definition at line 120 of file savefile.c.

#define LINKTYPE_EXP_ETHERNET   DLT_EN3MB
 

Definition at line 121 of file savefile.c.

#define LINKTYPE_FDDI   DLT_FDDI
 

Definition at line 129 of file savefile.c.

#define LINKTYPE_FRELAY   107
 

Definition at line 157 of file savefile.c.

#define LINKTYPE_HDLC   112
 

Definition at line 175 of file savefile.c.

#define LINKTYPE_HHDLC   121
 

Definition at line 178 of file savefile.c.

#define LINKTYPE_HIPPI   111
 

Definition at line 174 of file savefile.c.

#define LINKTYPE_IEEE802_11   105
 

Definition at line 155 of file savefile.c.

#define LINKTYPE_IP_OVER_FC   122
 

Definition at line 179 of file savefile.c.

#define LINKTYPE_IPFILTER   116
 

Definition at line 176 of file savefile.c.

#define LINKTYPE_LANE8023   110
 

Definition at line 173 of file savefile.c.

#define LINKTYPE_LINUX_SLL   113
 

Definition at line 160 of file savefile.c.

#define LINKTYPE_LOOP   108
 

Definition at line 158 of file savefile.c.

#define LINKTYPE_LTALK   114
 

Definition at line 161 of file savefile.c.

#define LINKTYPE_NULL   DLT_NULL
 

Definition at line 119 of file savefile.c.

#define LINKTYPE_PFLOG   117
 

Definition at line 177 of file savefile.c.

#define LINKTYPE_PPP   DLT_PPP
 

Definition at line 128 of file savefile.c.

#define LINKTYPE_PPP_BSDOS   103
 

Definition at line 153 of file savefile.c.

#define LINKTYPE_PPP_ETHER   51
 

Definition at line 148 of file savefile.c.

#define LINKTYPE_PPP_HDLC   50
 

Definition at line 146 of file savefile.c.

#define LINKTYPE_PRISM_HEADER   119
 

Definition at line 165 of file savefile.c.

#define LINKTYPE_PRONET   DLT_PRONET
 

Definition at line 123 of file savefile.c.

#define LINKTYPE_RAW   101
 

Definition at line 151 of file savefile.c.

#define LINKTYPE_SLIP   DLT_SLIP
 

Definition at line 127 of file savefile.c.

#define LINKTYPE_SLIP_BSDOS   102
 

Definition at line 152 of file savefile.c.

#define LINKTYPE_SUNATM   123
 

Definition at line 167 of file savefile.c.

#define LINKTYPE_TOKEN_RING   DLT_IEEE802
 

Definition at line 125 of file savefile.c.

#define PATCHED_TCPDUMP_MAGIC   0xa1b2cd34
 

Definition at line 53 of file savefile.c.

Referenced by pcap_open_offline.

#define SFERR_BADF   3
 

Definition at line 72 of file savefile.c.

#define SFERR_BADVERSION   2
 

Definition at line 71 of file savefile.c.

#define SFERR_EOF   4
 

Definition at line 73 of file savefile.c.

#define SFERR_TRUNC   1
 

Definition at line 70 of file savefile.c.

#define SWAPLONG      ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
 

Definition at line 65 of file savefile.c.

Referenced by pcap_open_offline, sf_next_packet, and swap_hdr.

#define SWAPSHORT      ( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) )
 

Definition at line 67 of file savefile.c.

Referenced by swap_hdr.

#define TCPDUMP_MAGIC   0xa1b2c3d4
 

Definition at line 52 of file savefile.c.

Referenced by pcap_open_offline, and sf_write_header.


Function Documentation

int dlt_to_linktype int    dlt [static]
 

Definition at line 293 of file savefile.c.

References linktype_map::dlt, linktype_map::linktype, and map.

Referenced by pcap_dump_open.

int linktype_to_dlt int    linktype [static]
 

Definition at line 311 of file savefile.c.

References linktype_map::dlt, linktype_map::linktype, and map.

Referenced by pcap_open_offline.

int pcap_offline_read pcap_t   p,
int    cnt,
pcap_handler    callback,
u_char *    user
 

Definition at line 590 of file savefile.c.

References bpf_filter, pcap_pkthdr::caplen, pcap_pkthdr::len, pcap_handler, pcap_t, and sf_next_packet.

Referenced by pcap_dispatch, and pcap_loop.

int sf_next_packet pcap_t   p,
struct pcap_pkthdr   hdr,
u_char *    buf,
int    buflen
 

Definition at line 488 of file savefile.c.

References pcap_pkthdr::caplen, pcap_pkthdr::len, PCAP_ERRBUF_SIZE, pcap_t, SWAPLONG, and pcap_pkthdr::ts.

Referenced by pcap_offline_read, and pcap_read_ex.

int sf_write_header FILE *    fp,
int    linktype,
int    thiszone,
int    snaplen
[static]
 

Definition at line 329 of file savefile.c.

References pcap_file_header::linktype, pcap_file_header::magic, pcap_file_header::sigfigs, pcap_file_header::snaplen, TCPDUMP_MAGIC, pcap_file_header::thiszone, pcap_file_header::version_major, and pcap_file_header::version_minor.

Referenced by pcap_dump_open.

void swap_hdr struct pcap_file_header   hp [static]
 

Definition at line 349 of file savefile.c.

References pcap_file_header::linktype, pcap_file_header::sigfigs, pcap_file_header::snaplen, SWAPLONG, SWAPSHORT, pcap_file_header::thiszone, pcap_file_header::version_major, and pcap_file_header::version_minor.

Referenced by pcap_open_offline.


Variable Documentation

struct linktype_map map[] [static]
 

Referenced by dlt_to_linktype, and linktype_to_dlt.

const char rcsid[] [static]
 

Initial value:

    "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.66 2002/08/06 06:27:49 guy Exp $ (LBL)"

Definition at line 32 of file savefile.c.


documentation. Copyright (c) 2002 Politecnico di Torino. All rights reserved.