Lines Matching refs:hdr

111 static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
157 struct pcap_file_header hdr;
189 hdr.magic = magic_int;
190 amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1,
191 sizeof(hdr) - sizeof(hdr.magic), fp);
192 if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) {
199 sizeof(hdr), amt_read);
209 hdr.version_major = SWAPSHORT(hdr.version_major);
210 hdr.version_minor = SWAPSHORT(hdr.version_minor);
211 hdr.thiszone = SWAPLONG(hdr.thiszone);
212 hdr.sigfigs = SWAPLONG(hdr.sigfigs);
213 hdr.snaplen = SWAPLONG(hdr.snaplen);
214 hdr.linktype = SWAPLONG(hdr.linktype);
217 if (hdr.version_major < PCAP_VERSION_MAJOR) {
228 if (! ((hdr.version_major == PCAP_VERSION_MAJOR &&
229 hdr.version_minor <= PCAP_VERSION_MINOR) ||
230 (hdr.version_major == 543 &&
231 hdr.version_minor == 0))) {
234 hdr.version_major, hdr.version_minor);
250 p->version_major = hdr.version_major;
251 p->version_minor = hdr.version_minor;
252 p->tzoff = hdr.thiszone;
253 p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype));
254 p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype);
255 p->snapshot = pcap_adjust_snapshot(p->linktype, hdr.snaplen);
321 switch (hdr.version_major) {
324 if (hdr.version_minor < 3)
326 else if (hdr.version_minor == 3)
438 * in hdr and a pointer to the contents in data. Return 0 on success, 1
442 pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
477 hdr->caplen = SWAPLONG(sf_hdr.caplen);
478 hdr->len = SWAPLONG(sf_hdr.len);
479 hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec);
480 hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec);
482 hdr->caplen = sf_hdr.caplen;
483 hdr->len = sf_hdr.len;
484 hdr->ts.tv_sec = sf_hdr.ts.tv_sec;
485 hdr->ts.tv_usec = sf_hdr.ts.tv_usec;
501 hdr->ts.tv_usec = hdr->ts.tv_usec * 1000;
509 hdr->ts.tv_usec = hdr->ts.tv_usec / 1000;
520 if (hdr->caplen <= hdr->len) {
530 t = hdr->caplen;
531 hdr->caplen = hdr->len;
532 hdr->len = t;
539 if (hdr->caplen > max_snaplen_for_dlt(p->linktype)) {
548 if (hdr->caplen > (bpf_u_int32)p->snapshot) {
551 "snaplen of %d", hdr->caplen, p->snapshot);
555 "maximum of %u", hdr->caplen,
561 if (hdr->caplen > (bpf_u_int32)p->snapshot) {
600 if (hdr->caplen > p->bufsize) {
619 * Yes, this uses hdr->caplen; technically,
635 bytes_to_discard = hdr->caplen - p->snapshot;
651 hdr->caplen, bytes_read);
662 hdr->caplen = p->snapshot;
667 if (hdr->caplen > p->bufsize) {
674 new_bufsize = hdr->caplen;
694 amt_read = fread(p->buffer, 1, hdr->caplen, fp);
695 if (amt_read != hdr->caplen) {
703 hdr->caplen, amt_read);
711 swap_pseudo_headers(p->linktype, hdr, *data);
719 struct pcap_file_header hdr;
721 hdr.magic = p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? NSEC_TCPDUMP_MAGIC : TCPDUMP_MAGIC;
722 hdr.version_major = PCAP_VERSION_MAJOR;
723 hdr.version_minor = PCAP_VERSION_MINOR;
725 hdr.thiszone = thiszone;
726 hdr.snaplen = snaplen;
727 hdr.sigfigs = 0;
728 hdr.linktype = linktype;
730 if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1)