Lines Matching refs:hdr
177 static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
223 struct pcap_file_header hdr; in pcap_check_header() local
255 hdr.magic = magic_int; in pcap_check_header()
256 amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1, in pcap_check_header()
257 sizeof(hdr) - sizeof(hdr.magic), fp); in pcap_check_header()
258 if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) { in pcap_check_header()
265 sizeof(hdr), amt_read); in pcap_check_header()
275 hdr.version_major = SWAPSHORT(hdr.version_major); in pcap_check_header()
276 hdr.version_minor = SWAPSHORT(hdr.version_minor); in pcap_check_header()
277 hdr.thiszone = SWAPLONG(hdr.thiszone); in pcap_check_header()
278 hdr.sigfigs = SWAPLONG(hdr.sigfigs); in pcap_check_header()
279 hdr.snaplen = SWAPLONG(hdr.snaplen); in pcap_check_header()
280 hdr.linktype = SWAPLONG(hdr.linktype); in pcap_check_header()
283 if (hdr.version_major < PCAP_VERSION_MAJOR) { in pcap_check_header()
294 if (! ((hdr.version_major == PCAP_VERSION_MAJOR && in pcap_check_header()
295 hdr.version_minor <= PCAP_VERSION_MINOR) || in pcap_check_header()
296 (hdr.version_major == 543 && in pcap_check_header()
297 hdr.version_minor == 0))) { in pcap_check_header()
300 hdr.version_major, hdr.version_minor); in pcap_check_header()
308 if (LT_RESERVED1(hdr.linktype) != 0) { in pcap_check_header()
311 LT_RESERVED1(hdr.linktype)); in pcap_check_header()
327 p->version_major = hdr.version_major; in pcap_check_header()
328 p->version_minor = hdr.version_minor; in pcap_check_header()
329 p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype)); in pcap_check_header()
330 p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype); in pcap_check_header()
331 p->snapshot = pcapint_adjust_snapshot(p->linktype, hdr.snaplen); in pcap_check_header()
397 switch (hdr.version_major) { in pcap_check_header()
400 if (hdr.version_minor < 3) in pcap_check_header()
402 else if (hdr.version_minor == 3) in pcap_check_header()
518 pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) in pcap_next_packet() argument
553 hdr->caplen = SWAPLONG(sf_hdr.caplen); in pcap_next_packet()
554 hdr->len = SWAPLONG(sf_hdr.len); in pcap_next_packet()
555 hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec); in pcap_next_packet()
556 hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec); in pcap_next_packet()
558 hdr->caplen = sf_hdr.caplen; in pcap_next_packet()
559 hdr->len = sf_hdr.len; in pcap_next_packet()
560 hdr->ts.tv_sec = sf_hdr.ts.tv_sec; in pcap_next_packet()
561 hdr->ts.tv_usec = sf_hdr.ts.tv_usec; in pcap_next_packet()
577 hdr->ts.tv_usec = hdr->ts.tv_usec * 1000; in pcap_next_packet()
585 hdr->ts.tv_usec = hdr->ts.tv_usec / 1000; in pcap_next_packet()
596 if (hdr->caplen <= hdr->len) { in pcap_next_packet()
606 t = hdr->caplen; in pcap_next_packet()
607 hdr->caplen = hdr->len; in pcap_next_packet()
608 hdr->len = t; in pcap_next_packet()
615 if (hdr->caplen > max_snaplen_for_dlt(p->linktype)) { in pcap_next_packet()
624 if (hdr->caplen > (bpf_u_int32)p->snapshot) { in pcap_next_packet()
627 "snaplen of %d", hdr->caplen, p->snapshot); in pcap_next_packet()
631 "maximum of %u", hdr->caplen, in pcap_next_packet()
637 if (hdr->caplen > (bpf_u_int32)p->snapshot) { in pcap_next_packet()
676 if (hdr->caplen > p->bufsize) { in pcap_next_packet()
711 bytes_to_discard = hdr->caplen - p->snapshot; in pcap_next_packet()
727 hdr->caplen, bytes_read); in pcap_next_packet()
738 hdr->caplen = p->snapshot; in pcap_next_packet()
743 if (hdr->caplen > p->bufsize) { in pcap_next_packet()
750 new_bufsize = hdr->caplen; in pcap_next_packet()
770 amt_read = fread(p->buffer, 1, hdr->caplen, fp); in pcap_next_packet()
771 if (amt_read != hdr->caplen) { in pcap_next_packet()
779 hdr->caplen, amt_read); in pcap_next_packet()
786 pcapint_post_process(p->linktype, p->swapped, hdr, *data); in pcap_next_packet()
794 struct pcap_file_header hdr; in sf_write_header() local
796 …hdr.magic = p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? NSEC_TCPDUMP_MAGIC : TCPDUMP_M… in sf_write_header()
797 hdr.version_major = PCAP_VERSION_MAJOR; in sf_write_header()
798 hdr.version_minor = PCAP_VERSION_MINOR; in sf_write_header()
805 hdr.thiszone = 0; in sf_write_header()
806 hdr.sigfigs = 0; in sf_write_header()
807 hdr.snaplen = snaplen; in sf_write_header()
808 hdr.linktype = linktype; in sf_write_header()
810 if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1) in sf_write_header()