Lines Matching refs:hdr
123 static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
154 struct pcap_file_header hdr; in pcap_check_header() local
183 hdr.magic = magic; in pcap_check_header()
184 amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1, in pcap_check_header()
185 sizeof(hdr) - sizeof(hdr.magic), fp); in pcap_check_header()
186 if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) { in pcap_check_header()
194 (unsigned long)sizeof(hdr), in pcap_check_header()
205 hdr.version_major = SWAPSHORT(hdr.version_major); in pcap_check_header()
206 hdr.version_minor = SWAPSHORT(hdr.version_minor); in pcap_check_header()
207 hdr.thiszone = SWAPLONG(hdr.thiszone); in pcap_check_header()
208 hdr.sigfigs = SWAPLONG(hdr.sigfigs); in pcap_check_header()
209 hdr.snaplen = SWAPLONG(hdr.snaplen); in pcap_check_header()
210 hdr.linktype = SWAPLONG(hdr.linktype); in pcap_check_header()
213 if (hdr.version_major < PCAP_VERSION_MAJOR) { in pcap_check_header()
224 if (! ((hdr.version_major == PCAP_VERSION_MAJOR && in pcap_check_header()
225 hdr.version_minor <= PCAP_VERSION_MINOR) || in pcap_check_header()
226 (hdr.version_major == 543 && in pcap_check_header()
227 hdr.version_minor == 0))) { in pcap_check_header()
230 hdr.version_major, hdr.version_minor); in pcap_check_header()
235 if (hdr.snaplen > MAXIMUM_SNAPLEN) { in pcap_check_header()
238 "maximum of %u", hdr.snaplen, MAXIMUM_SNAPLEN); in pcap_check_header()
254 p->version_major = hdr.version_major; in pcap_check_header()
255 p->version_minor = hdr.version_minor; in pcap_check_header()
256 p->tzoff = hdr.thiszone; in pcap_check_header()
257 p->snapshot = hdr.snaplen; in pcap_check_header()
258 p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype)); in pcap_check_header()
259 p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype); in pcap_check_header()
325 switch (hdr.version_major) { in pcap_check_header()
328 if (hdr.version_minor < 3) in pcap_check_header()
330 else if (hdr.version_minor == 3) in pcap_check_header()
420 pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) in pcap_next_packet() argument
457 hdr->caplen = SWAPLONG(sf_hdr.caplen); in pcap_next_packet()
458 hdr->len = SWAPLONG(sf_hdr.len); in pcap_next_packet()
459 hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec); in pcap_next_packet()
460 hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec); in pcap_next_packet()
462 hdr->caplen = sf_hdr.caplen; in pcap_next_packet()
463 hdr->len = sf_hdr.len; in pcap_next_packet()
464 hdr->ts.tv_sec = sf_hdr.ts.tv_sec; in pcap_next_packet()
465 hdr->ts.tv_usec = sf_hdr.ts.tv_usec; in pcap_next_packet()
481 hdr->ts.tv_usec = hdr->ts.tv_usec * 1000; in pcap_next_packet()
489 hdr->ts.tv_usec = hdr->ts.tv_usec / 1000; in pcap_next_packet()
500 if (hdr->caplen <= hdr->len) { in pcap_next_packet()
510 t = hdr->caplen; in pcap_next_packet()
511 hdr->caplen = hdr->len; in pcap_next_packet()
512 hdr->len = t; in pcap_next_packet()
516 if (hdr->caplen > p->bufsize) { in pcap_next_packet()
529 if (hdr->caplen > MAXIMUM_SNAPLEN) { in pcap_next_packet()
532 "maximum of %u", hdr->caplen, MAXIMUM_SNAPLEN); in pcap_next_packet()
561 hdr->caplen, (unsigned long)amt_read); in pcap_next_packet()
569 bytes_to_discard = hdr->caplen - p->bufsize; in pcap_next_packet()
585 hdr->caplen, (unsigned long)bytes_read); in pcap_next_packet()
596 hdr->caplen = p->bufsize; in pcap_next_packet()
599 amt_read = fread(p->buffer, 1, hdr->caplen, fp); in pcap_next_packet()
600 if (amt_read != hdr->caplen) { in pcap_next_packet()
608 hdr->caplen, (unsigned long)amt_read); in pcap_next_packet()
616 swap_pseudo_headers(p->linktype, hdr, *data); in pcap_next_packet()
624 struct pcap_file_header hdr; in sf_write_header() local
626 …hdr.magic = p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? NSEC_TCPDUMP_MAGIC : TCPDUMP_M… in sf_write_header()
627 hdr.version_major = PCAP_VERSION_MAJOR; in sf_write_header()
628 hdr.version_minor = PCAP_VERSION_MINOR; in sf_write_header()
630 hdr.thiszone = thiszone; in sf_write_header()
631 hdr.snaplen = snaplen; in sf_write_header()
632 hdr.sigfigs = 0; in sf_write_header()
633 hdr.linktype = linktype; in sf_write_header()
635 if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1) in sf_write_header()