aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2006-03-21 09:36:07 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2006-03-21 09:36:07 +0000
commitad649acf4627922604cd2ccbd98fe7685fc6ba71 (patch)
treeff86ce3cb995f0233949c7b4d94e0cedc3124a97
parent21e83296b4e99b840246cafac333e88db38168aa (diff)
Simplify the argument list to cap_pipe_dispatch().
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@17690 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--capture_loop.c31
-rw-r--r--capture_loop.h3
-rw-r--r--tethereal.c5
3 files changed, 18 insertions, 21 deletions
diff --git a/capture_loop.c b/capture_loop.c
index f3c8564167..9c19f6023d 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -322,9 +322,7 @@ error:
/* We read one record from the pipe, take care of byte order in the record
* header, write the record to the capture file, and update capture statistics. */
int
-cap_pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
- struct pcaprec_modified_hdr *rechdr, guchar *data,
- char *errmsg, int errmsgl)
+cap_pipe_dispatch(loop_data *ld, guchar *data, char *errmsg, int errmsgl)
{
struct pcap_pkthdr phdr;
int b;
@@ -346,8 +344,8 @@ cap_pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
/* Fall through */
case STATE_READ_REC_HDR:
- b = read(fd, ((char *)rechdr)+ld->cap_pipe_bytes_read,
- ld->cap_pipe_bytes_to_read - ld->cap_pipe_bytes_read);
+ b = read(ld->cap_pipe_fd, ((char *)&ld->cap_pipe_rechdr)+ld->cap_pipe_bytes_read,
+ ld->cap_pipe_bytes_to_read - ld->cap_pipe_bytes_read);
if (b <= 0) {
if (b == 0)
result = PD_PIPE_EOF;
@@ -366,7 +364,8 @@ cap_pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
/* Fall through */
case STATE_READ_DATA:
- b = read(fd, data+ld->cap_pipe_bytes_read, rechdr->hdr.incl_len - ld->cap_pipe_bytes_read);
+ b = read(ld->cap_pipe_fd, data+ld->cap_pipe_bytes_read,
+ ld->cap_pipe_rechdr.hdr.incl_len - ld->cap_pipe_bytes_read);
if (b <= 0) {
if (b == 0)
result = PD_PIPE_EOF;
@@ -374,7 +373,7 @@ cap_pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
result = PD_PIPE_ERR;
break;
}
- if ((ld->cap_pipe_bytes_read += b) < rechdr->hdr.incl_len)
+ if ((ld->cap_pipe_bytes_read += b) < ld->cap_pipe_rechdr.hdr.incl_len)
return 0;
result = PD_DATA_READ;
break;
@@ -392,10 +391,11 @@ cap_pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
case PD_REC_HDR_READ:
/* We've read the header. Take care of byte order. */
- cap_pipe_adjust_header(ld->cap_pipe_byte_swapped, hdr, &rechdr->hdr);
- if (rechdr->hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
+ cap_pipe_adjust_header(ld->cap_pipe_byte_swapped, &ld->cap_pipe_hdr,
+ &ld->cap_pipe_rechdr.hdr);
+ if (ld->cap_pipe_rechdr.hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
g_snprintf(errmsg, errmsgl, "Frame %u too long (%d bytes)",
- ld->packet_count+1, rechdr->hdr.incl_len);
+ ld->packet_count+1, ld->cap_pipe_rechdr.hdr.incl_len);
break;
}
ld->cap_pipe_state = STATE_EXPECT_DATA;
@@ -403,10 +403,10 @@ cap_pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
case PD_DATA_READ:
/* Fill in a "struct pcap_pkthdr", and process the packet. */
- phdr.ts.tv_sec = rechdr->hdr.ts_sec;
- phdr.ts.tv_usec = rechdr->hdr.ts_usec;
- phdr.caplen = rechdr->hdr.incl_len;
- phdr.len = rechdr->hdr.orig_len;
+ phdr.ts.tv_sec = ld->cap_pipe_rechdr.hdr.ts_sec;
+ phdr.ts.tv_usec = ld->cap_pipe_rechdr.hdr.ts_usec;
+ phdr.caplen = ld->cap_pipe_rechdr.hdr.incl_len;
+ phdr.len = ld->cap_pipe_rechdr.hdr.orig_len;
ld->packet_cb((u_char *)ld, &phdr, data);
@@ -835,8 +835,7 @@ capture_loop_dispatch(capture_options *capture_opts _U_, loop_data *ld,
/*
* "select()" says we can read from the pipe without blocking
*/
- inpkts = cap_pipe_dispatch(ld->cap_pipe_fd, ld, &ld->cap_pipe_hdr, &ld->cap_pipe_rechdr, pcap_data,
- errmsg, errmsg_len);
+ inpkts = cap_pipe_dispatch(ld, pcap_data, errmsg, errmsg_len);
if (inpkts < 0) {
ld->go = FALSE;
}
diff --git a/capture_loop.h b/capture_loop.h
index aa17909f1b..1e4c0a58a5 100644
--- a/capture_loop.h
+++ b/capture_loop.h
@@ -141,8 +141,7 @@ capture_loop_init_filter(pcap_t *pcap_h, gboolean from_cap_pipe, const gchar * i
#ifdef HAVE_LIBPCAP
#ifndef _WIN32
extern int
-cap_pipe_dispatch(int, loop_data *, struct pcap_hdr *, \
- struct pcaprec_modified_hdr *, guchar *, char *, int);
+cap_pipe_dispatch(loop_data *, guchar *, char *, int);
#endif /* _WIN32 */
#endif
diff --git a/tethereal.c b/tethereal.c
index 30176210d9..982b994fca 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1689,11 +1689,10 @@ capture(void)
}
#ifndef _WIN32
if (ld.from_cap_pipe) {
- inpkts = cap_pipe_dispatch(ld.cap_pipe_fd, &ld, &ld.cap_pipe_hdr, &ld.cap_pipe_rechdr, pcap_data,
- errmsg, sizeof errmsg);
+ inpkts = cap_pipe_dispatch(&ld, pcap_data, errmsg, sizeof errmsg);
} else
#endif
- inpkts = pcap_dispatch(ld.pcap_h, pcap_cnt, capture_pcap_cb, (u_char *) &ld);
+ inpkts = pcap_dispatch(ld.pcap_h, pcap_cnt, ld.packet_cb, (u_char *) &ld);
if (inpkts < 0) {
/* Error from "pcap_dispatch()", or error or "no more packets" from
"cap_pipe_dispatch(). */