forked from osmocom/wireshark
Get rid of warnings about shadowed variables (code was ok)
svn path=/trunk/; revision=12171
This commit is contained in:
parent
88b9b09373
commit
54e0e363a9
|
@ -342,6 +342,6 @@ guint
|
|||
fvalue_length(fvalue_t *fv);
|
||||
|
||||
fvalue_t*
|
||||
fvalue_slice(fvalue_t *fv, drange *drange);
|
||||
fvalue_slice(fvalue_t *fv, drange *dr);
|
||||
|
||||
#endif /* ftypes.h */
|
||||
|
|
106
tethereal.c
106
tethereal.c
|
@ -1510,16 +1510,16 @@ main(int argc, char *argv[])
|
|||
epan_cleanup();
|
||||
#ifdef HAVE_PCAP_OPEN_DEAD
|
||||
{
|
||||
pcap_t *p;
|
||||
pcap_t *pc;
|
||||
|
||||
p = pcap_open_dead(DLT_EN10MB, MIN_PACKET_SIZE);
|
||||
if (p != NULL) {
|
||||
if (pcap_compile(p, &fcode, rfilter, 0, 0) != -1) {
|
||||
pc = pcap_open_dead(DLT_EN10MB, MIN_PACKET_SIZE);
|
||||
if (pc != NULL) {
|
||||
if (pcap_compile(pc, &fcode, rfilter, 0, 0) != -1) {
|
||||
fprintf(stderr,
|
||||
" Note: That display filter code looks like a valid capture filter;\n"
|
||||
" maybe you mixed them up?\n");
|
||||
}
|
||||
pcap_close(p);
|
||||
pcap_close(pc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2161,14 +2161,14 @@ capture_pcap_cb(guchar *user, const struct pcap_pkthdr *phdr,
|
|||
{
|
||||
struct wtap_pkthdr whdr;
|
||||
union wtap_pseudo_header pseudo_header;
|
||||
loop_data *ld = (loop_data *) user;
|
||||
loop_data *ldat = (loop_data *) user;
|
||||
int loop_err;
|
||||
int err;
|
||||
|
||||
/* Convert from libpcap to Wiretap format.
|
||||
If that fails, ignore the packet (wtap_process_pcap_packet has
|
||||
written an error message). */
|
||||
pd = wtap_process_pcap_packet(ld->linktype, phdr, pd, &pseudo_header,
|
||||
pd = wtap_process_pcap_packet(ldat->linktype, phdr, pd, &pseudo_header,
|
||||
&whdr, &err);
|
||||
if (pd == NULL)
|
||||
return;
|
||||
|
@ -2189,17 +2189,17 @@ capture_pcap_cb(guchar *user, const struct pcap_pkthdr *phdr,
|
|||
*/
|
||||
if (cnd_ring_timeout != NULL && cnd_eval(cnd_ring_timeout)) {
|
||||
/* time elapsed for this ring file, switch to the next */
|
||||
if (ringbuf_switch_file(&cfile, &ld->pdh, &loop_err)) {
|
||||
if (ringbuf_switch_file(&cfile, &ldat->pdh, &loop_err)) {
|
||||
/* File switch succeeded: reset the condition */
|
||||
cnd_reset(cnd_ring_timeout);
|
||||
} else {
|
||||
/* File switch failed: stop here */
|
||||
/* XXX - we should do something with "loop_err" */
|
||||
ld->go = FALSE;
|
||||
ldat->go = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!process_packet(&cfile, ld->pdh, 0, &whdr, &pseudo_header, pd, &err)) {
|
||||
if (!process_packet(&cfile, ldat->pdh, 0, &whdr, &pseudo_header, pd, &err)) {
|
||||
/* Error writing to a capture file */
|
||||
if (!quiet) {
|
||||
/* We're capturing packets, so (if -q not specified) we're printing
|
||||
|
@ -2207,8 +2207,8 @@ capture_pcap_cb(guchar *user, const struct pcap_pkthdr *phdr,
|
|||
fprintf(stderr, "\n");
|
||||
}
|
||||
show_capture_file_io_error(cfile.save_file, err, FALSE);
|
||||
pcap_close(ld->pch);
|
||||
wtap_dump_close(ld->pdh, &err);
|
||||
pcap_close(ldat->pch);
|
||||
wtap_dump_close(ldat->pdh, &err);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
@ -3242,9 +3242,9 @@ fail:
|
|||
/* Take care of byte order in the libpcap headers read from pipes.
|
||||
* (function taken from wiretap/libpcap.c) */
|
||||
static void
|
||||
adjust_header(loop_data *ld, struct pcap_hdr *hdr, struct pcaprec_hdr *rechdr)
|
||||
adjust_header(loop_data *ldat, struct pcap_hdr *hdr, struct pcaprec_hdr *rechdr)
|
||||
{
|
||||
if (ld->byte_swapped) {
|
||||
if (ldat->byte_swapped) {
|
||||
/* Byte-swap the record header fields. */
|
||||
rechdr->ts_sec = BSWAP32(rechdr->ts_sec);
|
||||
rechdr->ts_usec = BSWAP32(rechdr->ts_usec);
|
||||
|
@ -3276,7 +3276,7 @@ adjust_header(loop_data *ld, struct pcap_hdr *hdr, struct pcaprec_hdr *rechdr)
|
|||
* N.B. : we can't read the libpcap formats used in RedHat 6.1 or SuSE 6.3
|
||||
* because we can't seek on pipes (see wiretap/libpcap.c for details) */
|
||||
static int
|
||||
pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
||||
pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ldat,
|
||||
char *errmsg, int errmsgl)
|
||||
{
|
||||
struct stat pipe_stat;
|
||||
|
@ -3293,12 +3293,12 @@ pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
else {
|
||||
if (stat(pipename, &pipe_stat) < 0) {
|
||||
if (errno == ENOENT || errno == ENOTDIR)
|
||||
ld->pipe_err = PIPNEXIST;
|
||||
ldat->pipe_err = PIPNEXIST;
|
||||
else {
|
||||
snprintf(errmsg, errmsgl,
|
||||
"The capture session could not be initiated "
|
||||
"due to error on pipe: %s", strerror(errno));
|
||||
ld->pipe_err = PIPERR;
|
||||
ldat->pipe_err = PIPERR;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -3308,12 +3308,12 @@ pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
* Assume the user specified an interface on a system where
|
||||
* interfaces are in /dev. Pretend we haven't seen it.
|
||||
*/
|
||||
ld->pipe_err = PIPNEXIST;
|
||||
ldat->pipe_err = PIPNEXIST;
|
||||
} else {
|
||||
snprintf(errmsg, errmsgl,
|
||||
"The capture session could not be initiated because\n"
|
||||
"\"%s\" is neither an interface nor a pipe", pipename);
|
||||
ld->pipe_err = PIPERR;
|
||||
ldat->pipe_err = PIPERR;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -3322,12 +3322,12 @@ pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
snprintf(errmsg, errmsgl,
|
||||
"The capture session could not be initiated "
|
||||
"due to error on pipe open: %s", strerror(errno));
|
||||
ld->pipe_err = PIPERR;
|
||||
ldat->pipe_err = PIPERR;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ld->from_pipe = TRUE;
|
||||
ldat->from_pipe = TRUE;
|
||||
|
||||
/* read the pcap header */
|
||||
bytes_read = 0;
|
||||
|
@ -3348,28 +3348,28 @@ pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
case PCAP_MAGIC:
|
||||
/* Host that wrote it has our byte order, and was running
|
||||
a program using either standard or ss990417 libpcap. */
|
||||
ld->byte_swapped = FALSE;
|
||||
ld->modified = FALSE;
|
||||
ldat->byte_swapped = FALSE;
|
||||
ldat->modified = FALSE;
|
||||
break;
|
||||
case PCAP_MODIFIED_MAGIC:
|
||||
/* Host that wrote it has our byte order, but was running
|
||||
a program using either ss990915 or ss991029 libpcap. */
|
||||
ld->byte_swapped = FALSE;
|
||||
ld->modified = TRUE;
|
||||
ldat->byte_swapped = FALSE;
|
||||
ldat->modified = TRUE;
|
||||
break;
|
||||
case PCAP_SWAPPED_MAGIC:
|
||||
/* Host that wrote it has a byte order opposite to ours,
|
||||
and was running a program using either standard or
|
||||
ss990417 libpcap. */
|
||||
ld->byte_swapped = TRUE;
|
||||
ld->modified = FALSE;
|
||||
ldat->byte_swapped = TRUE;
|
||||
ldat->modified = FALSE;
|
||||
break;
|
||||
case PCAP_SWAPPED_MODIFIED_MAGIC:
|
||||
/* Host that wrote it out has a byte order opposite to
|
||||
ours, and was running a program using either ss990915
|
||||
or ss991029 libpcap. */
|
||||
ld->byte_swapped = TRUE;
|
||||
ld->modified = TRUE;
|
||||
ldat->byte_swapped = TRUE;
|
||||
ldat->modified = TRUE;
|
||||
break;
|
||||
default:
|
||||
/* Not a "libpcap" type we know about. */
|
||||
|
@ -3393,7 +3393,7 @@ pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
bytes_read += b;
|
||||
}
|
||||
|
||||
if (ld->byte_swapped) {
|
||||
if (ldat->byte_swapped) {
|
||||
/* Byte-swap the header fields about which we care. */
|
||||
hdr->version_major = BSWAP16(hdr->version_major);
|
||||
hdr->version_minor = BSWAP16(hdr->version_minor);
|
||||
|
@ -3406,12 +3406,12 @@ pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
|
|||
goto error;
|
||||
}
|
||||
|
||||
ld->pipe_state = STATE_EXPECT_REC_HDR;
|
||||
ld->pipe_err = PIPOK;
|
||||
ldat->pipe_state = STATE_EXPECT_REC_HDR;
|
||||
ldat->pipe_err = PIPOK;
|
||||
return fd;
|
||||
|
||||
error:
|
||||
ld->pipe_err = PIPERR;
|
||||
ldat->pipe_err = PIPERR;
|
||||
close(fd);
|
||||
return -1;
|
||||
|
||||
|
@ -3420,7 +3420,7 @@ error:
|
|||
* header, write the record in the capture file, and update capture statistics. */
|
||||
|
||||
static int
|
||||
pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
||||
pipe_dispatch(int fd, loop_data *ldat, struct pcap_hdr *hdr,
|
||||
struct pcaprec_modified_hdr *rechdr, guchar *data,
|
||||
char *errmsg, int errmsgl)
|
||||
{
|
||||
|
@ -3429,18 +3429,18 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
|||
enum { PD_REC_HDR_READ, PD_DATA_READ, PD_PIPE_EOF, PD_PIPE_ERR,
|
||||
PD_ERR } result;
|
||||
|
||||
switch (ld->pipe_state) {
|
||||
switch (ldat->pipe_state) {
|
||||
|
||||
case STATE_EXPECT_REC_HDR:
|
||||
ld->bytes_to_read = ld->modified ?
|
||||
ldat->bytes_to_read = ldat->modified ?
|
||||
sizeof(struct pcaprec_modified_hdr) : sizeof(struct pcaprec_hdr);
|
||||
ld->bytes_read = 0;
|
||||
ld->pipe_state = STATE_READ_REC_HDR;
|
||||
ldat->bytes_read = 0;
|
||||
ldat->pipe_state = STATE_READ_REC_HDR;
|
||||
/* Fall through */
|
||||
|
||||
case STATE_READ_REC_HDR:
|
||||
b = read(fd, ((char *)rechdr)+ld->bytes_read,
|
||||
ld->bytes_to_read - ld->bytes_read);
|
||||
b = read(fd, ((char *)rechdr)+ldat->bytes_read,
|
||||
ldat->bytes_to_read - ldat->bytes_read);
|
||||
if (b <= 0) {
|
||||
if (b == 0)
|
||||
result = PD_PIPE_EOF;
|
||||
|
@ -3448,18 +3448,18 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
|||
result = PD_PIPE_ERR;
|
||||
break;
|
||||
}
|
||||
if ((ld->bytes_read += b) < ld->bytes_to_read)
|
||||
if ((ldat->bytes_read += b) < ldat->bytes_to_read)
|
||||
return 0;
|
||||
result = PD_REC_HDR_READ;
|
||||
break;
|
||||
|
||||
case STATE_EXPECT_DATA:
|
||||
ld->bytes_read = 0;
|
||||
ld->pipe_state = STATE_READ_DATA;
|
||||
ldat->bytes_read = 0;
|
||||
ldat->pipe_state = STATE_READ_DATA;
|
||||
/* Fall through */
|
||||
|
||||
case STATE_READ_DATA:
|
||||
b = read(fd, data+ld->bytes_read, rechdr->hdr.incl_len - ld->bytes_read);
|
||||
b = read(fd, data+ldat->bytes_read, rechdr->hdr.incl_len - ldat->bytes_read);
|
||||
if (b <= 0) {
|
||||
if (b == 0)
|
||||
result = PD_PIPE_EOF;
|
||||
|
@ -3467,7 +3467,7 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
|||
result = PD_PIPE_ERR;
|
||||
break;
|
||||
}
|
||||
if ((ld->bytes_read += b) < rechdr->hdr.incl_len)
|
||||
if ((ldat->bytes_read += b) < rechdr->hdr.incl_len)
|
||||
return 0;
|
||||
result = PD_DATA_READ;
|
||||
break;
|
||||
|
@ -3476,7 +3476,7 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
|||
snprintf(errmsg, errmsgl, "pipe_dispatch: invalid state");
|
||||
result = PD_ERR;
|
||||
|
||||
} /* switch (ld->pipe_state) */
|
||||
} /* switch (ldat->pipe_state) */
|
||||
|
||||
/*
|
||||
* We've now read as much data as we were expecting, so process it.
|
||||
|
@ -3485,13 +3485,13 @@ 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. */
|
||||
adjust_header(ld, hdr, &rechdr->hdr);
|
||||
adjust_header(ldat, hdr, &rechdr->hdr);
|
||||
if (rechdr->hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
|
||||
snprintf(errmsg, errmsgl, "Frame %u too long (%d bytes)",
|
||||
ld->packet_count+1, rechdr->hdr.incl_len);
|
||||
ldat->packet_count+1, rechdr->hdr.incl_len);
|
||||
break;
|
||||
}
|
||||
ld->pipe_state = STATE_EXPECT_DATA;
|
||||
ldat->pipe_state = STATE_EXPECT_DATA;
|
||||
return 0;
|
||||
|
||||
case PD_DATA_READ:
|
||||
|
@ -3501,13 +3501,13 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
|||
phdr.caplen = rechdr->hdr.incl_len;
|
||||
phdr.len = rechdr->hdr.orig_len;
|
||||
|
||||
capture_pcap_cb((guchar *)ld, &phdr, data);
|
||||
capture_pcap_cb((guchar *)ldat, &phdr, data);
|
||||
|
||||
ld->pipe_state = STATE_EXPECT_REC_HDR;
|
||||
ldat->pipe_state = STATE_EXPECT_REC_HDR;
|
||||
return 1;
|
||||
|
||||
case PD_PIPE_EOF:
|
||||
ld->pipe_err = PIPEOF;
|
||||
ldat->pipe_err = PIPEOF;
|
||||
return -1;
|
||||
|
||||
case PD_PIPE_ERR:
|
||||
|
@ -3518,7 +3518,7 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr,
|
|||
break;
|
||||
}
|
||||
|
||||
ld->pipe_err = PIPERR;
|
||||
ldat->pipe_err = PIPERR;
|
||||
/* Return here rather than inside the switch to prevent GCC warning */
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ static const char ascend_w2magic[] = { 'W', 'D', '_', 'D', 'I', 'A', 'L', 'O', '
|
|||
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
||||
long *data_offset);
|
||||
static gboolean ascend_seek_read(wtap *wth, long seek_off,
|
||||
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
|
||||
union wtap_pseudo_header *pseudo_head, guint8 *pd, int len,
|
||||
int *err, gchar **err_info);
|
||||
static void ascend_close(wtap *wth);
|
||||
|
||||
|
@ -340,12 +340,12 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
|||
}
|
||||
|
||||
static gboolean ascend_seek_read(wtap *wth, long seek_off,
|
||||
union wtap_pseudo_header *pseudo_header, guint8 *pd, int len,
|
||||
union wtap_pseudo_header *pseudo_head, guint8 *pd, int len,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
if (! parse_ascend(wth->random_fh, pd, &pseudo_header->ascend, NULL, len)) {
|
||||
if (! parse_ascend(wth->random_fh, pd, &pseudo_head->ascend, NULL, len)) {
|
||||
*err = WTAP_ERR_BAD_RECORD;
|
||||
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
|
||||
return FALSE;
|
||||
|
|
|
@ -318,7 +318,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
|
|||
int num_items_scanned;
|
||||
int eth_hdr_len, pkt_len, csec;
|
||||
int length_pos, length_from, length;
|
||||
struct tm time;
|
||||
struct tm tm;
|
||||
char mon[4];
|
||||
gchar *p;
|
||||
static gchar months[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
|
||||
|
@ -390,9 +390,9 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
|
|||
num_items_scanned = sscanf(line + LENGTH_POS,
|
||||
"%d byte buffer at %d-%3s-%d %d:%d:%d.%d",
|
||||
&pkt_len,
|
||||
&time.tm_mday, mon,
|
||||
&time.tm_year, &time.tm_hour, &time.tm_min,
|
||||
&time.tm_sec, &csec);
|
||||
&tm.tm_mday, mon,
|
||||
&tm.tm_year, &tm.tm_hour, &tm.tm_min,
|
||||
&tm.tm_sec, &csec);
|
||||
|
||||
if (num_items_scanned != 8) {
|
||||
*err = WTAP_ERR_BAD_RECORD;
|
||||
|
@ -470,11 +470,11 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
|
|||
if (wth) {
|
||||
p = strstr(months, mon);
|
||||
if (p)
|
||||
time.tm_mon = (p - months) / 3;
|
||||
time.tm_year -= 1900;
|
||||
tm.tm_mon = (p - months) / 3;
|
||||
tm.tm_year -= 1900;
|
||||
|
||||
time.tm_isdst = -1;
|
||||
wth->phdr.ts.tv_sec = mktime(&time);
|
||||
tm.tm_isdst = -1;
|
||||
wth->phdr.ts.tv_sec = mktime(&tm);
|
||||
|
||||
wth->phdr.ts.tv_usec = csec * 10000;
|
||||
wth->phdr.caplen = eth_hdr_len + pkt_len;
|
||||
|
|
|
@ -369,15 +369,15 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
|
|||
int pkt_len = 0;
|
||||
int pktnum;
|
||||
int csec = 101;
|
||||
struct tm time;
|
||||
struct tm tm;
|
||||
char mon[4] = {'J', 'A', 'N', 0};
|
||||
gchar *p;
|
||||
static gchar months[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
|
||||
|
||||
time.tm_year = 1970;
|
||||
time.tm_hour = 1;
|
||||
time.tm_min = 1;
|
||||
time.tm_sec = 1;
|
||||
tm.tm_year = 1970;
|
||||
tm.tm_hour = 1;
|
||||
tm.tm_min = 1;
|
||||
tm.tm_sec = 1;
|
||||
|
||||
/* Skip lines until one starts with a hex number */
|
||||
do {
|
||||
|
@ -397,16 +397,16 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
|
|||
/* First look for the Format 1 type sequencing */
|
||||
num_items_scanned = sscanf(p,
|
||||
"packet %d at %d-%3s-%d %d:%d:%d.%d",
|
||||
&pktnum, &time.tm_mday, mon,
|
||||
&time.tm_year, &time.tm_hour,
|
||||
&time.tm_min, &time.tm_sec, &csec);
|
||||
&pktnum, &tm.tm_mday, mon,
|
||||
&tm.tm_year, &tm.tm_hour,
|
||||
&tm.tm_min, &tm.tm_sec, &csec);
|
||||
/* Next look for the Format 2 type sequencing */
|
||||
if (num_items_scanned != 8) {
|
||||
num_items_scanned = sscanf(p,
|
||||
"packet seq # = %d at %d-%3s-%d %d:%d:%d.%d",
|
||||
&pktnum, &time.tm_mday, mon,
|
||||
&time.tm_year, &time.tm_hour,
|
||||
&time.tm_min, &time.tm_sec, &csec);
|
||||
&pktnum, &tm.tm_mday, mon,
|
||||
&tm.tm_year, &tm.tm_hour,
|
||||
&tm.tm_min, &tm.tm_sec, &csec);
|
||||
}
|
||||
/* if unknown format then exit with error */
|
||||
/* We will need to add code to handle new format */
|
||||
|
@ -435,11 +435,11 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
|
|||
if (wth) {
|
||||
p = strstr(months, mon);
|
||||
if (p)
|
||||
time.tm_mon = (p - months) / 3;
|
||||
time.tm_year -= 1900;
|
||||
tm.tm_mon = (p - months) / 3;
|
||||
tm.tm_year -= 1900;
|
||||
|
||||
time.tm_isdst = -1;
|
||||
wth->phdr.ts.tv_sec = mktime(&time);
|
||||
tm.tm_isdst = -1;
|
||||
wth->phdr.ts.tv_sec = mktime(&tm);
|
||||
|
||||
wth->phdr.ts.tv_usec = csec * 10000;
|
||||
wth->phdr.caplen = pkt_len;
|
||||
|
|
Loading…
Reference in New Issue