6 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include "file_wrappers.h"
35 static guchar nettl_magic_hpux9[12] = {
36 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xD0, 0x00
38 static guchar nettl_magic_hpux10[12] = {
39 0x54, 0x52, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80
42 /* HP nettl file header */
43 struct nettl_file_hdr {
55 /* HP nettl record header for the SX25L2 subsystem - The FCS is not included in the file. */
56 struct nettlrec_sx25l2_hdr {
68 /* HP nettl record header for the NS_LS_IP subsystem */
69 /* This also works for BASE100 and GSC100BT */
70 /* see /usr/include/sys/netdiag1.h for hints */
71 struct nettlrec_ns_ls_ip_hdr {
83 /* Full record header for writing out a nettl file */
84 struct nettlrec_dump_hdr {
87 struct nettlrec_ns_ls_ip_hdr hdr;
91 /* header is followed by data and once again the total length (2 bytes) ! */
95 The following shows what the header looks like for NS_LS_DRIVER
96 The capture was taken on HPUX11 and for a 100baseT interface.
98 000080 00 44 00 0b 00 00 00 02 00 00 00 00 20 00 00 00
99 000090 00 00 00 00 00 00 04 06 00 00 00 00 00 00 00 00
100 0000a0 00 00 00 74 00 00 00 74 3c e3 76 19 00 06 34 63
101 0000b0 ff ff ff ff 00 00 00 00 00 00 00 00 ff ff ff ff
102 0000c0 00 00 00 00 00 00 01 02 00 5c 00 5c ff ff ff ff
103 0000d0 3c e3 76 19 00 06 34 5a 00 0b 00 14 <here starts the MAC heder>
105 Each entry starts with 0x0044000b
107 The values 0x005c at position 0x0000c8 and 0x0000ca matches the number of bytes in
108 the packet up to the next entry, which starts with 0x00440b again. These probably
109 indicate the real and captured length of the packet (order unknown)
111 The values 0x00000074 at positions 0x0000a0 and 0x0000a4 seems to indicate
112 the same number as positions 0x0000c8 and 0x0000ca but added with 24.
113 Perhaps we have here two layers of headers.
114 The first layer is fixed and consists of all the bytes from 0x000084 up to and
115 including 0x0000c3 which is a generic header for all packets captured from any
116 device. This header might be of fixed size 64 bytes and there might be something in
117 it which indicates the type of the next header which is link type specific.
118 Following this header there is another header for the 100baseT interface which
119 in this case is 24 bytes long spanning positions 0x0000c4 to 0x0000db.
121 When someone reports that the loading of the captures breaks, we can compare
122 this header above with what he/she got to learn how to distinguish between different
123 types of link specific headers.
127 The first header seems to be
128 a normal nettlrec_ns_ls_ip_hdr
130 The header for 100baseT seems to be
139 struct nettlrec_ns_ls_drv_eth_hdr {
150 static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
152 static gboolean nettl_seek_read(wtap *wth, long seek_off,
153 union wtap_pseudo_header *pseudo_header, guchar *pd,
154 int length, int *err, gchar **err_info);
155 static int nettl_read_rec_header(wtap *wth, FILE_T fh,
156 struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header,
157 int *err, gchar **err_info, gboolean *fddihack);
158 static gboolean nettl_read_rec_data(FILE_T fh, guchar *pd, int length,
159 int *err, gboolean fddihack);
160 static void nettl_close(wtap *wth);
161 static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
162 const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
164 int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
166 char magic[12], os_vers[2];
170 /* Read in the string that should be at the start of a HP file */
171 errno = WTAP_ERR_CANT_READ;
172 bytes_read = file_read(magic, 1, 12, wth->fh);
173 if (bytes_read != 12) {
174 *err = file_error(wth->fh);
180 if (memcmp(magic, nettl_magic_hpux9, 12) &&
181 memcmp(magic, nettl_magic_hpux10, 12)) {
185 if (file_seek(wth->fh, 0x63, SEEK_SET, err) == -1)
187 wth->data_offset = 0x63;
188 bytes_read = file_read(os_vers, 1, 2, wth->fh);
189 if (bytes_read != 2) {
190 *err = file_error(wth->fh);
196 if (file_seek(wth->fh, 0x80, SEEK_SET, err) == -1)
198 wth->data_offset = 0x80;
200 /* This is an nettl file */
201 wth->file_type = WTAP_FILE_NETTL;
202 wth->capture.nettl = g_malloc(sizeof(nettl_t));
203 if (os_vers[0] == '1' && os_vers[1] == '1')
204 wth->capture.nettl->is_hpux_11 = TRUE;
206 wth->capture.nettl->is_hpux_11 = FALSE;
207 wth->subtype_read = nettl_read;
208 wth->subtype_seek_read = nettl_seek_read;
209 wth->subtype_close = nettl_close;
210 wth->snapshot_length = 0; /* not available in header, only in frame */
212 /* read the first header to take a guess at the file encap */
213 bytes_read = file_read(dummy, 1, 4, wth->fh);
214 if (bytes_read != 4) {
217 if (bytes_read != 0) {
218 *err = WTAP_ERR_SHORT_READ;
225 case NETTL_SUBSYS_HPPB_FDDI :
226 case NETTL_SUBSYS_EISA_FDDI :
227 case NETTL_SUBSYS_PCI_FDDI :
228 case NETTL_SUBSYS_HSC_FDDI :
229 wth->file_encap = WTAP_ENCAP_FDDI_BITSWAPPED;
231 case NETTL_SUBSYS_TOKEN :
232 case NETTL_SUBSYS_PCI_TR :
233 wth->file_encap = WTAP_ENCAP_TOKEN_RING;
235 case NETTL_SUBSYS_NS_LS_IP :
236 case NETTL_SUBSYS_NS_LS_LOOPBACK :
237 case NETTL_SUBSYS_NS_LS_TCP :
238 case NETTL_SUBSYS_NS_LS_UDP :
239 case NETTL_SUBSYS_NS_LS_IPV6 :
240 wth->file_encap = WTAP_ENCAP_RAW_IP;
243 /* if assumption is bad, the read will catch it */
244 wth->file_encap = WTAP_ENCAP_ETHERNET;
247 if (file_seek(wth->fh, 0x80, SEEK_SET, err) == -1)
249 wth->data_offset = 0x80;
254 /* Read the next packet */
255 static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
259 gboolean fddihack=FALSE;
261 /* Read record header. */
262 *data_offset = wth->data_offset;
263 ret = nettl_read_rec_header(wth, wth->fh, &wth->phdr, &wth->pseudo_header,
264 err, err_info, &fddihack);
266 /* Read error or EOF */
269 wth->data_offset += ret;
272 * If the per-file encapsulation isn't known, set it to this
273 * packet's encapsulation.
275 * If it *is* known, and it isn't this packet's encapsulation,
276 * set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
277 * have a single encapsulation for all packets in the file.
279 if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
280 wth->file_encap = wth->phdr.pkt_encap;
282 if (wth->file_encap != wth->phdr.pkt_encap)
283 wth->file_encap = WTAP_ENCAP_PER_PACKET;
287 * Read the packet data.
289 buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
290 if (!nettl_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer),
291 wth->phdr.caplen, err, fddihack))
292 return FALSE; /* Read error */
293 wth->data_offset += wth->phdr.caplen;
298 nettl_seek_read(wtap *wth, long seek_off,
299 union wtap_pseudo_header *pseudo_header, guchar *pd,
300 int length, int *err, gchar **err_info)
303 struct wtap_pkthdr phdr;
304 gboolean fddihack=FALSE;
306 if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
309 /* Read record header. */
310 ret = nettl_read_rec_header(wth, wth->random_fh, &phdr, pseudo_header,
311 err, err_info, &fddihack);
313 /* Read error or EOF */
315 /* EOF means "short read" in random-access mode */
316 *err = WTAP_ERR_SHORT_READ;
322 * Read the packet data.
324 return nettl_read_rec_data(wth->random_fh, pd, length, err, fddihack);
328 nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
329 union wtap_pseudo_header *pseudo_header, int *err,
330 gchar **err_info, gboolean *fddihack)
333 struct nettlrec_sx25l2_hdr lapb_hdr;
334 struct nettlrec_ns_ls_ip_hdr ip_hdr;
335 struct nettlrec_ns_ls_drv_eth_hdr drv_eth_hdr;
343 errno = WTAP_ERR_CANT_READ;
344 bytes_read = file_read(dummy, 1, 4, fh);
345 if (bytes_read != 4) {
346 *err = file_error(fh);
349 if (bytes_read != 0) {
350 *err = WTAP_ERR_SHORT_READ;
359 case NETTL_SUBSYS_LAN100 :
360 case NETTL_SUBSYS_EISA100BT :
361 case NETTL_SUBSYS_BASE100 :
362 case NETTL_SUBSYS_GSC100BT :
363 case NETTL_SUBSYS_PCI100BT :
364 case NETTL_SUBSYS_SPP100BT :
365 case NETTL_SUBSYS_100VG :
366 case NETTL_SUBSYS_GELAN :
367 case NETTL_SUBSYS_BTLAN :
368 case NETTL_SUBSYS_INTL100 :
369 case NETTL_SUBSYS_IGELAN :
370 case NETTL_SUBSYS_IETHER :
371 case NETTL_SUBSYS_HPPB_FDDI :
372 case NETTL_SUBSYS_EISA_FDDI :
373 case NETTL_SUBSYS_PCI_FDDI :
374 case NETTL_SUBSYS_HSC_FDDI :
375 case NETTL_SUBSYS_TOKEN :
376 case NETTL_SUBSYS_PCI_TR :
377 case NETTL_SUBSYS_NS_LS_IP :
378 case NETTL_SUBSYS_NS_LS_LOOPBACK :
379 case NETTL_SUBSYS_NS_LS_TCP :
380 case NETTL_SUBSYS_NS_LS_UDP :
381 case NETTL_SUBSYS_HP_APAPORT :
382 case NETTL_SUBSYS_HP_APALACP :
383 case NETTL_SUBSYS_NS_LS_IPV6 :
384 case NETTL_SUBSYS_NS_LS_ICMPV6 :
385 case NETTL_SUBSYS_NS_LS_ICMP :
386 if( (encap == NETTL_SUBSYS_NS_LS_IP)
387 || (encap == NETTL_SUBSYS_NS_LS_LOOPBACK)
388 || (encap == NETTL_SUBSYS_NS_LS_UDP)
389 || (encap == NETTL_SUBSYS_NS_LS_TCP)
390 || (encap == NETTL_SUBSYS_NS_LS_IPV6)) {
391 phdr->pkt_encap = WTAP_ENCAP_RAW_IP;
392 } else if (encap == NETTL_SUBSYS_NS_LS_ICMP) {
393 phdr->pkt_encap = WTAP_ENCAP_RAW_ICMP;
394 } else if (encap == NETTL_SUBSYS_NS_LS_ICMPV6) {
395 phdr->pkt_encap = WTAP_ENCAP_RAW_ICMPV6;
396 } else if( (encap == NETTL_SUBSYS_HPPB_FDDI)
397 || (encap == NETTL_SUBSYS_EISA_FDDI)
398 || (encap == NETTL_SUBSYS_PCI_FDDI)
399 || (encap == NETTL_SUBSYS_HSC_FDDI) ) {
400 phdr->pkt_encap = WTAP_ENCAP_FDDI_BITSWAPPED;
401 } else if( (encap == NETTL_SUBSYS_PCI_TR)
402 || (encap == NETTL_SUBSYS_TOKEN) ) {
403 phdr->pkt_encap = WTAP_ENCAP_TOKEN_RING;
405 phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
406 /* We assume there's no FCS in this frame. */
407 pseudo_header->eth.fcs_len = 0;
410 bytes_read = file_read(&ip_hdr, 1, sizeof ip_hdr, fh);
411 if (bytes_read != sizeof ip_hdr) {
412 *err = file_error(fh);
415 if (bytes_read != 0) {
416 *err = WTAP_ERR_SHORT_READ;
421 offset += sizeof ip_hdr;
423 /* The packet header in HP-UX 11 nettl traces is 4 octets longer than
425 if (wth->capture.nettl->is_hpux_11) {
426 bytes_read = file_read(dummy, 1, 4, fh);
427 if (bytes_read != 4) {
428 *err = file_error(fh);
431 if (bytes_read != 0) {
432 *err = WTAP_ERR_SHORT_READ;
440 /* HPPB FDDI has different inbound vs outbound trace records */
441 if (encap == NETTL_SUBSYS_HPPB_FDDI) {
442 if (ip_hdr.rectype == NETTL_HDR_PDUIN) {
443 /* inbound is very strange...
444 there are an extra 3 bytes after the DSAP and SSAP
448 length = pntohl(&ip_hdr.length);
452 length = pntohl(&ip_hdr.caplen);
453 phdr->caplen = length;
455 /* outbound appears to have variable padding */
456 bytes_read = file_read(dummyc, 1, 9, fh);
457 if (bytes_read != 9) {
458 *err = file_error(fh);
461 if (bytes_read != 0) {
462 *err = WTAP_ERR_SHORT_READ;
467 /* padding is usually either a total 11 or 16 bytes??? */
468 padlen = (int)dummyc[8];
469 bytes_read = file_read(dummy, 1, padlen, fh);
470 if (bytes_read != padlen) {
471 *err = file_error(fh);
474 if (bytes_read != 0) {
475 *err = WTAP_ERR_SHORT_READ;
482 length = pntohl(&ip_hdr.length);
485 phdr->len = length - padlen;
486 length = pntohl(&ip_hdr.caplen);
487 phdr->caplen = length - padlen;
489 } else if ( (encap == NETTL_SUBSYS_PCI_FDDI)
490 || (encap == NETTL_SUBSYS_EISA_FDDI)
491 || (encap == NETTL_SUBSYS_HSC_FDDI) ) {
492 /* other flavor FDDI cards have an extra 3 bytes of padding */
493 bytes_read = file_read(dummy, 1, 3, fh);
494 if (bytes_read != 3) {
495 *err = file_error(fh);
498 if (bytes_read != 0) {
499 *err = WTAP_ERR_SHORT_READ;
505 length = pntohl(&ip_hdr.length);
508 phdr->len = length - 3;
509 length = pntohl(&ip_hdr.caplen);
510 phdr->caplen = length - 3;
511 } else if (encap == NETTL_SUBSYS_NS_LS_LOOPBACK) {
512 /* LOOPBACK has an extra 26 bytes of padding */
513 bytes_read = file_read(dummy, 1, 26, fh);
514 if (bytes_read != 26) {
515 *err = file_error(fh);
518 if (bytes_read != 0) {
519 *err = WTAP_ERR_SHORT_READ;
525 length = pntohl(&ip_hdr.length);
528 phdr->len = length - 26;
529 length = pntohl(&ip_hdr.caplen);
530 phdr->caplen = length - 26;
532 length = pntohl(&ip_hdr.length);
536 length = pntohl(&ip_hdr.caplen);
537 phdr->caplen = length;
540 phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
541 phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
543 case NETTL_SUBSYS_NS_LS_DRIVER :
544 bytes_read = file_read(&ip_hdr, 1, sizeof ip_hdr, fh);
545 if (bytes_read != sizeof ip_hdr) {
546 *err = file_error(fh);
549 if (bytes_read != 0) {
550 *err = WTAP_ERR_SHORT_READ;
555 offset += sizeof ip_hdr;
557 /* The packet header in HP-UX 11 nettl traces is 4 octets longer than
559 if (wth->capture.nettl->is_hpux_11) {
560 bytes_read = file_read(dummy, 1, 4, fh);
561 if (bytes_read != 4) {
562 *err = file_error(fh);
565 if (bytes_read != 0) {
566 *err = WTAP_ERR_SHORT_READ;
574 /* XXX we dont know how to identify this as ethernet frames, so
575 we assumes everything is. We will crash and burn for anything else */
576 /* for encapsulated 100baseT we do this */
577 phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
578 /* We assume there's no FCS in this frame. */
579 pseudo_header->eth.fcs_len = 0;
580 bytes_read = file_read(&drv_eth_hdr, 1, sizeof drv_eth_hdr, fh);
581 if (bytes_read != sizeof drv_eth_hdr) {
582 *err = file_error(fh);
585 if (bytes_read != 0) {
586 *err = WTAP_ERR_SHORT_READ;
591 offset += sizeof drv_eth_hdr;
593 length = pntohs(&drv_eth_hdr.length);
594 if (length <= 0) return 0;
596 length = pntohs(&drv_eth_hdr.caplen);
597 phdr->caplen = length;
599 phdr->ts.tv_sec = pntohl(&ip_hdr.sec);
600 phdr->ts.tv_usec = pntohl(&ip_hdr.usec);
602 case NETTL_SUBSYS_SX25L2 :
603 phdr->pkt_encap = WTAP_ENCAP_LAPB;
604 bytes_read = file_read(&lapb_hdr, 1, sizeof lapb_hdr, fh);
605 if (bytes_read != sizeof lapb_hdr) {
606 *err = file_error(fh);
609 if (bytes_read != 0) {
610 *err = WTAP_ERR_SHORT_READ;
615 offset += sizeof lapb_hdr;
617 if (wth->capture.nettl->is_hpux_11) {
618 bytes_read = file_read(dummy, 1, 4, fh);
619 if (bytes_read != 4) {
620 *err = file_error(fh);
623 if (bytes_read != 0) {
624 *err = WTAP_ERR_SHORT_READ;
632 length = pntohs(&lapb_hdr.length);
633 if (length <= 0) return 0;
635 phdr->caplen = length;
637 phdr->ts.tv_sec = pntohl(&lapb_hdr.sec);
638 phdr->ts.tv_usec = pntohl(&lapb_hdr.usec);
639 pseudo_header->x25.flags =
640 (lapb_hdr.from_dce & 0x20 ? FROM_DCE : 0x00);
643 *err = WTAP_ERR_UNSUPPORTED_ENCAP;
644 *err_info = g_strdup_printf("nettl: subsystem %u unknown or unsupported",
652 nettl_read_rec_data(FILE_T fh, guchar *pd, int length, int *err, gboolean fddihack)
658 if (fddihack == TRUE) {
659 /* read in FC, dest, src, DSAP and SSAP */
660 if (file_read(pd, 1, 15, fh) == 15) {
661 if (pd[13] == 0xAA) {
662 /* it's SNAP, have to eat 3 bytes??? */
663 if (file_read(dummy, 1, 3, fh) == 3) {
665 bytes_read = file_read(p, 1, length-18, fh);
673 bytes_read = file_read(p, 1, length-15, fh);
679 bytes_read = file_read(pd, 1, length, fh);
681 if (bytes_read != length) {
682 *err = file_error(fh);
684 *err = WTAP_ERR_SHORT_READ;
690 static void nettl_close(wtap *wth)
692 g_free(wth->capture.nettl);
696 /* Returns 0 if we could write the specified encapsulation type,
697 an error indication otherwise. nettl files are WTAP_ENCAP_UNKNOWN
698 when they are first opened, so we allow that for tethereal read/write.
701 int nettl_dump_can_write_encap(int encap)
705 case WTAP_ENCAP_ETHERNET:
706 case WTAP_ENCAP_FDDI_BITSWAPPED:
707 case WTAP_ENCAP_TOKEN_RING:
708 case WTAP_ENCAP_RAW_IP:
709 case WTAP_ENCAP_RAW_ICMP:
710 case WTAP_ENCAP_RAW_ICMPV6:
711 case WTAP_ENCAP_PER_PACKET:
712 case WTAP_ENCAP_UNKNOWN:
715 return WTAP_ERR_UNSUPPORTED_ENCAP;
720 /* Returns TRUE on success, FALSE on failure;
721 sets "*err" to an error code on failure */
722 gboolean nettl_dump_open(wtap_dumper *wdh, gboolean cant_seek _U_, int *err)
724 struct nettl_file_hdr file_hdr;
727 /* This is a nettl file */
728 wdh->subtype_write = nettl_dump;
729 wdh->subtype_close = NULL;
731 /* Write the file header. */
732 memset(&file_hdr,0,sizeof(file_hdr));
733 memcpy(file_hdr.magic,nettl_magic_hpux10,sizeof(file_hdr.magic));
734 strcpy(file_hdr.file_name,"/tmp/ethereal.TRC000");
735 strcpy(file_hdr.tz,"UTC");
736 strcpy(file_hdr.host_name,"ethereal");
737 strcpy(file_hdr.os_vers,"B.11.11");
739 strcpy(file_hdr.model,"9000/800");
740 file_hdr.unknown=g_htons(0x406);
741 nwritten = fwrite(&file_hdr, 1, sizeof file_hdr, wdh->fh);
742 if (nwritten != sizeof(file_hdr)) {
743 if (nwritten == 0 && ferror(wdh->fh))
746 *err = WTAP_ERR_SHORT_WRITE;
749 wdh->bytes_dumped += sizeof(file_hdr);
754 /* Write a record for a packet to a dump file.
755 Returns TRUE on success, FALSE on failure. */
756 static gboolean nettl_dump(wtap_dumper *wdh,
757 const struct wtap_pkthdr *phdr,
758 const union wtap_pseudo_header *pseudo_header _U_,
759 const guchar *pd, int *err)
761 struct nettlrec_dump_hdr rec_hdr;
765 memset(&rec_hdr,0,sizeof(rec_hdr));
766 rec_hdr.hdr_len = g_htons(sizeof(rec_hdr));
767 rec_hdr.hdr.rectype = NETTL_HDR_PDUIN;
768 rec_hdr.hdr.sec = g_htonl(phdr->ts.tv_sec);
769 rec_hdr.hdr.usec = g_htonl(phdr->ts.tv_usec);
770 rec_hdr.hdr.caplen = g_htonl(phdr->caplen);
771 rec_hdr.hdr.length = g_htonl(phdr->len);
773 switch (phdr->pkt_encap) {
775 case WTAP_ENCAP_RAW_IP:
776 rec_hdr.subsys = g_htons(NETTL_SUBSYS_NS_LS_IP);
779 case WTAP_ENCAP_ETHERNET:
780 rec_hdr.subsys = g_htons(NETTL_SUBSYS_BTLAN);
783 case WTAP_ENCAP_FDDI_BITSWAPPED:
784 rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_FDDI);
785 /* account for pad bytes */
786 rec_hdr.hdr.caplen = g_htonl(phdr->caplen + 3);
787 rec_hdr.hdr.length = g_htonl(phdr->len + 3);
790 case WTAP_ENCAP_TOKEN_RING:
791 rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_TR);
794 case WTAP_ENCAP_RAW_ICMP:
795 rec_hdr.subsys = g_htons(NETTL_SUBSYS_NS_LS_ICMP);
798 case WTAP_ENCAP_RAW_ICMPV6:
799 rec_hdr.subsys = g_htons(NETTL_SUBSYS_NS_LS_ICMPV6);
803 /* found one we don't support */
804 *err = WTAP_ERR_UNSUPPORTED_ENCAP;
808 nwritten = fwrite(&rec_hdr, 1, sizeof(rec_hdr), wdh->fh);
809 if (nwritten != sizeof(rec_hdr)) {
810 if (nwritten == 0 && ferror(wdh->fh))
813 *err = WTAP_ERR_SHORT_WRITE;
816 wdh->bytes_dumped += sizeof(rec_hdr);
818 if (phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) {
819 /* add those weird 3 bytes of padding */
820 nwritten = fwrite(&dummy, 1, 3, wdh->fh);
822 if (nwritten == 0 && ferror(wdh->fh))
825 *err = WTAP_ERR_SHORT_WRITE;
828 wdh->bytes_dumped += 3;
831 /* write actual PDU data */
833 nwritten = fwrite(pd, 1, phdr->caplen, wdh->fh);
834 if (nwritten != phdr->caplen) {
835 if (nwritten == 0 && ferror(wdh->fh))
838 *err = WTAP_ERR_SHORT_WRITE;
841 wdh->bytes_dumped += phdr->caplen;