10.4. Adding support for writing capture formats
To add the ability to write a new capture file format, you have to:
-
Add a "can_write_encap" routine that returns an indication of
whether a given packet encapsulation format is supported by the
new capture file format;
-
Add a "dump_open" routine that starts writing a file (writing
headers, allocating data structures, etc.);
-
Add a "dump" routine to write a packet to a file, and have the
"dump_open" routine set the "subtype_write" member of the
"wtap_dumper" structure passed to it to point to it;
-
Add a "dump_close" routine, if necessary (if, for example, the
"dump_open" routine allocates any memory, or if some of the file
header can be written only after all the packets have been
written), and have the "dump_open" routine set the
"subtype_close" member of the "wtap_dumper" structure to point
to it;
-
Put pointers to the "can_write_encap" and "dump_open" routines
in the "file_type_subtype_info" struct passed to
wtap_register_file_type_subtypes().