/*
* Copyright (C) 1993-2001 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id: ipft_pc.c,v 1.10 2004/02/07 18:17:40 darrenr Exp $
*/
#include "ipf.h"
#include "pcap-ipf.h"
#include "bpf-ipf.h"
#include "ipt.h"
#if !defined(lint)
#endif
struct llc {
int lc_type;
};
/*
* While many of these maybe the same, some do have different header formats
* which make this useful.
*/
{ DLT_NULL, 0, 0, 0 },
{ DLT_EN3MB, 0, 0, 0 },
{ DLT_AX25, 0, 0, 0 },
{ DLT_PRONET, 0, 0, 0 },
{ DLT_CHAOS, 0, 0, 0 },
{ DLT_IEEE802, 0, 0, 0 },
{ DLT_ARCNET, 0, 0, 0 },
{ DLT_SLIP, 0, 0, 0 },
{ DLT_PPP, 0, 0, 0 },
{ DLT_FDDI, 0, 0, 0 },
#ifdef DLT_ATMRFC1483
{ DLT_ATMRFC1483, 0, 0, 0 },
#endif
{ DLT_RAW, 0, 0, 0 },
#ifdef DLT_ENC
{ DLT_ENC, 0, 0, 0 },
#endif
#ifdef DLT_SLIP_BSDOS
{ DLT_SLIP_BSDOS, 0, 0, 0 },
#endif
#ifdef DLT_PPP_BSDOS
{ DLT_PPP_BSDOS, 0, 0, 0 },
#endif
#ifdef DLT_HIPPI
{ DLT_HIPPI, 0, 0, 0 },
#endif
#ifdef DLT_HDLC
{ DLT_HDLC, 0, 0, 0 },
#endif
#ifdef DLT_PPP_SERIAL
#endif
#ifdef DLT_PPP_ETHER
#endif
#ifdef DLT_ECONET
{ DLT_ECONET, 0, 0, 0 },
#endif
{ -1, -1, -1, -1 }
};
static int pcap_close __P((void));
static int pcap_readip __P((char *, int, char **, int *));
#define SWAPLONG(y) \
((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
#define SWAPSHORT(y) \
( (((y)&0xff)<<8) | (((y)&0xff00)>>8) )
static void swap_hdr(p)
pcaphdr_t *p;
{
}
char *fname;
{
int fd, i;
if (pfd != -1)
return pfd;
fd = 0;
return -1;
return -2;
return -2;
}
swapped = 1;
}
return -2;
}
break;
}
return -2;
}
printf("\tid: %08x version: %d.%d type: %d snap %d\n",
return fd;
}
static int pcap_close()
{
}
/*
* read in the header (and validate) which should be the first record
* in a pcap file.
*/
struct pcap_pkthdr *rec;
{
int n, p;
return -2;
if (swapped) {
}
if (!n || n < 0)
return -3;
return p;
}
#ifdef notyet
/*
* read an entire pcap packet record. only the data part is copied into
* the available buffer, with the number of bytes copied returned.
*/
char *buf;
int cnt;
{
int i, n;
if ((i = pcap_read_rec(&rec)) <= 0)
return i;
if (!bufp)
else
return -2;
return n;
}
#endif
/*
* return only an IP packet read into buf
*/
{
struct llc *l;
int i, n;
l = llcp;
/* do { */
if ((i = pcap_read_rec(&rec)) <= 0)
return i;
if (!bufp)
else
s = bufp;
return -2;
i -= l->lc_sz;
s += l->lc_to;
s += l->lc_tl;
/* } while (ty[0] != 0x8 && ty[1] != 0); */
return n;
}