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;
183 hdr.magic = magic;
184 amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1,
185 sizeof(hdr) - sizeof(hdr.magic), fp);
186 if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) {
194 (unsigned long)sizeof(hdr),
205 hdr.version_major = SWAPSHORT(hdr.version_major);
206 hdr.version_minor = SWAPSHORT(hdr.version_minor);
207 hdr.thiszone = SWAPLONG(hdr.thiszone);
208 hdr.sigfigs = SWAPLONG(hdr.sigfigs);
209 hdr.snaplen = SWAPLONG(hdr.snaplen);
210 hdr.linktype = SWAPLONG(hdr.linktype);
213 if (hdr.version_major < PCAP_VERSION_MAJOR) {
231 p->version_major = hdr.version_major;
232 p->version_minor = hdr.version_minor;
233 p->tzoff = hdr.thiszone;
234 p->snapshot = hdr.snaplen;
235 p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype));
236 p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype);
302 switch (hdr.version_major) {
305 if (hdr.version_minor < 3)
307 else if (hdr.version_minor == 3)
393 * in hdr and a pointer to the contents in data. Return 0 on success, 1
397 pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
434 hdr->caplen = SWAPLONG(sf_hdr.caplen);
435 hdr->len = SWAPLONG(sf_hdr.len);
436 hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec);
437 hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec);
439 hdr->caplen = sf_hdr.caplen;
440 hdr->len = sf_hdr.len;
441 hdr->ts.tv_sec = sf_hdr.ts.tv_sec;
442 hdr->ts.tv_usec = sf_hdr.ts.tv_usec;
458 hdr->ts.tv_usec = hdr->ts.tv_usec * 1000;
466 hdr->ts.tv_usec = hdr->ts.tv_usec / 1000;
477 if (hdr->caplen <= hdr->len) {
487 t = hdr->caplen;
488 hdr->caplen = hdr->len;
489 hdr->len = t;
493 if (hdr->caplen > p->bufsize) {
503 if (hdr->caplen > 65535) {
509 if (tsize < hdr->caplen) {
510 tsize = ((hdr->caplen + 1023) / 1024) * 1024;
521 amt_read = fread((char *)tp, 1, hdr->caplen, fp);
522 if (amt_read != hdr->caplen) {
530 hdr->caplen, (unsigned long)amt_read);
542 hdr->caplen = p->bufsize;
546 amt_read = fread(p->buffer, 1, hdr->caplen, fp);
547 if (amt_read != hdr->caplen) {
555 hdr->caplen, (unsigned long)amt_read);
563 swap_pseudo_headers(p->linktype, hdr, *data);
571 struct pcap_file_header hdr;
573 hdr.magic = p->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? NSEC_TCPDUMP_MAGIC : TCPDUMP_MAGIC;
574 hdr.version_major = PCAP_VERSION_MAJOR;
575 hdr.version_minor = PCAP_VERSION_MINOR;
577 hdr.thiszone = thiszone;
578 hdr.snaplen = snaplen;
579 hdr.sigfigs = 0;
580 hdr.linktype = linktype;
582 if (fwrite((char *)&hdr, sizeof(hdr), 1, fp) != 1)