Lines Matching refs:hdr
110 static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
141 struct pcap_file_header hdr; in pcap_check_header() local
170 hdr.magic = magic; in pcap_check_header()
171 amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1, in pcap_check_header()
172 sizeof(hdr) - sizeof(hdr.magic), fp); in pcap_check_header()
173 if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) { in pcap_check_header()
180 (unsigned long)sizeof(hdr), in pcap_check_header()
191 hdr.version_major = SWAPSHORT(hdr.version_major); in pcap_check_header()
192 hdr.version_minor = SWAPSHORT(hdr.version_minor); in pcap_check_header()
193 hdr.thiszone = SWAPLONG(hdr.thiszone); in pcap_check_header()
194 hdr.sigfigs = SWAPLONG(hdr.sigfigs); in pcap_check_header()
195 hdr.snaplen = SWAPLONG(hdr.snaplen); in pcap_check_header()
196 hdr.linktype = SWAPLONG(hdr.linktype); in pcap_check_header()
199 if (hdr.version_major < PCAP_VERSION_MAJOR) { in pcap_check_header()
210 if (! ((hdr.version_major == PCAP_VERSION_MAJOR && in pcap_check_header()
211 hdr.version_minor <= PCAP_VERSION_MINOR) || in pcap_check_header()
212 (hdr.version_major == 543 && in pcap_check_header()
213 hdr.version_minor == 0))) { in pcap_check_header()
216 hdr.version_major, hdr.version_minor); in pcap_check_header()
232 p->version_major = hdr.version_major; in pcap_check_header()
233 p->version_minor = hdr.version_minor; in pcap_check_header()
234 p->tzoff = hdr.thiszone; in pcap_check_header()
235 p->snapshot = hdr.snaplen; in pcap_check_header()
245 p->snapshot = max_snaplen_for_dlt(hdr.linktype); in pcap_check_header()
247 p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype)); in pcap_check_header()
248 p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype); in pcap_check_header()
314 switch (hdr.version_major) { in pcap_check_header()
317 if (hdr.version_minor < 3) in pcap_check_header()
319 else if (hdr.version_minor == 3) in pcap_check_header()
429 pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) in pcap_next_packet() argument
465 hdr->caplen = SWAPLONG(sf_hdr.caplen); in pcap_next_packet()
466 hdr->len = SWAPLONG(sf_hdr.len); in pcap_next_packet()
467 hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec); in pcap_next_packet()
468 hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec); in pcap_next_packet()
470 hdr->caplen = sf_hdr.caplen; in pcap_next_packet()
471 hdr->len = sf_hdr.len; in pcap_next_packet()
472 hdr->ts.tv_sec = sf_hdr.ts.tv_sec; in pcap_next_packet()
473 hdr->ts.tv_usec = sf_hdr.ts.tv_usec; in pcap_next_packet()
489 hdr->ts.tv_usec = hdr->ts.tv_usec * 1000; in pcap_next_packet()
497 hdr->ts.tv_usec = hdr->ts.tv_usec / 1000; in pcap_next_packet()
508 if (hdr->caplen <= hdr->len) { in pcap_next_packet()
518 t = hdr->caplen; in pcap_next_packet()
519 hdr->caplen = hdr->len; in pcap_next_packet()
520 hdr->len = t; in pcap_next_packet()
527 if (hdr->caplen > max_snaplen_for_dlt(p->linktype)) { in pcap_next_packet()
536 if (hdr->caplen > (bpf_u_int32)p->snapshot) { in pcap_next_packet()
539 "snaplen of %d", hdr->caplen, p->snapshot); in pcap_next_packet()
543 "maximum of %u", hdr->caplen, in pcap_next_packet()
549 if (hdr->caplen > (bpf_u_int32)p->snapshot) { in pcap_next_packet()
588 if (hdr->caplen > p->bufsize) { in pcap_next_packet()
623 bytes_to_discard = hdr->caplen - p->snapshot; in pcap_next_packet()
639 hdr->caplen, (unsigned long)bytes_read); in pcap_next_packet()
650 hdr->caplen = p->snapshot; in pcap_next_packet()
652 if (hdr->caplen > p->bufsize) { in pcap_next_packet()
659 new_bufsize = hdr->caplen; in pcap_next_packet()
679 amt_read = fread(p->buffer, 1, hdr->caplen, fp); in pcap_next_packet()
680 if (amt_read != hdr->caplen) { in pcap_next_packet()
688 hdr->caplen, (unsigned long)amt_read); in pcap_next_packet()
696 swap_pseudo_headers(p->linktype, hdr, *data); in pcap_next_packet()
704 struct pcap_file_header hdr; in sf_write_header() local
706 …hdr.magic = p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? NSEC_TCPDUMP_MAGIC : TCPDUMP_M… in sf_write_header()
707 hdr.version_major = PCAP_VERSION_MAJOR; in sf_write_header()
708 hdr.version_minor = PCAP_VERSION_MINOR; in sf_write_header()
710 hdr.thiszone = thiszone; in sf_write_header()
711 hdr.snaplen = snaplen; in sf_write_header()
712 hdr.sigfigs = 0; in sf_write_header()
713 hdr.linktype = linktype; in sf_write_header()
715 if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1) in sf_write_header()