Revert "LATER... ei_kerberos_kdc_session_key ..."
[wireshark-sm.git] / wiretap / wtap_opttypes.h
blob665f18a099d6cb804293861149af697a50089275
1 /** @file
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 2001 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef WTAP_OPT_TYPES_H
11 #define WTAP_OPT_TYPES_H
13 #include "ws_symbol_export.h"
15 #include <wsutil/inet_addr.h>
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
22 * We use the pcapng option codes for option type values.
25 /* Options for all blocks */
26 #define OPT_EOFOPT 0 /**< Appears in pcapng files, but not in blocks. */
27 #define OPT_COMMENT 1 /**< A UTF-8 string containing a human-readable comment. */
28 #define OPT_CUSTOM_STR_COPY 2988 /**< A custom option containing a UTF-8 string, copying allowed. */
29 #define OPT_CUSTOM_BIN_COPY 2989 /**< A custom option containing binary data, copying allowed. */
30 #define OPT_CUSTOM_STR_NO_COPY 19372 /**< A custom option containing a UTF-8 string, copying not allowed. */
31 #define OPT_CUSTOM_BIN_NO_COPY 19373 /**< A custom option containing binary data, copying not allowed. */
33 /* Section Header block (SHB) */
34 #define OPT_SHB_HARDWARE 2 /**< A UTF-8 string containing the description of the
35 * hardware used to create this section.
37 #define OPT_SHB_OS 3 /**< A UTF-8 string containing the
38 * name of the operating system used to create this section.
40 #define OPT_SHB_USERAPPL 4 /**< A UTF-8 string containing the
41 * name of the application used to create this section.
44 /* Interface Description block (IDB) */
45 #define OPT_IDB_NAME 2 /**< A UTF-8 string containing the name
46 * of the device used to capture data.
47 * "eth0" / "\Device\NPF_{AD1CE675-96D0-47C5-ADD0-2504B9126B68}"
49 #define OPT_IDB_DESCRIPTION 3 /**< A UTF-8 string containing the description
50 * of the device used to capture data.
51 * "Wi-Fi" / "Local Area Connection" /
52 * "Wireless Network Connection" /
53 * "First Ethernet Interface"
55 #define OPT_IDB_IP4ADDR 4 /**< XXX: if_IPv4addr Interface network address and netmask.
56 * This option can be repeated multiple times within the same Interface Description Block
57 * when multiple IPv4 addresses are assigned to the interface.
58 * 192 168 1 1 255 255 255 0
60 #define OPT_IDB_IP6ADDR 5 /**< XXX: if_IPv6addr Interface network address and prefix length (stored in the last byte).
61 * This option can be repeated multiple times within the same Interface
62 * Description Block when multiple IPv6 addresses are assigned to the interface.
63 * 2001:0db8:85a3:08d3:1319:8a2e:0370:7344/64 is written (in hex) as
64 * "20 01 0d b8 85 a3 08 d3 13 19 8a 2e 03 70 73 44 40"
66 #define OPT_IDB_MACADDR 6 /**< XXX: if_MACaddr Interface Hardware MAC address (48 bits). */
67 #define OPT_IDB_EUIADDR 7 /**< XXX: if_EUIaddr Interface Hardware EUI address (64 bits) */
68 #define OPT_IDB_SPEED 8 /**< Interface speed (in bps). 100000000 for 100Mbps
70 #define OPT_IDB_TSRESOL 9 /**< Resolution of timestamps. If the Most Significant Bit is equal to zero,
71 * the remaining bits indicates the resolution of the timestamp as a
72 * negative power of 10 (e.g. 6 means microsecond resolution, timestamps
73 * are the number of microseconds since 1/1/1970). If the Most Significant Bit
74 * is equal to one, the remaining bits indicates the resolution has a
75 * negative power of 2 (e.g. 10 means 1/1024 of second).
76 * If this option is not present, a resolution of 10^-6 is assumed
77 * (i.e. timestamps have the same resolution of the standard 'libpcap' timestamps).
79 #define OPT_IDB_TZONE 10 /**< Time zone for GMT support. This option has neer been specified in
80 * greater detail and, unless it were to identify something such as
81 * an IANA time zone database timezone, would be insufficient for
82 * converting between UTC and local time. Therefore, it SHOULD NOT
83 * be used; instead, the if_iana_tzname option SHOULD be used if
84 * time zone information is to be specified. */
85 #define OPT_IDB_FILTER 11 /**< The filter (e.g. "capture only TCP traffic") used to capture traffic.
86 * The first byte of the Option Data keeps a code of the filter used
87 * (e.g. if this is a libpcap string, or BPF bytecode, and more).
88 * More details about this format will be presented in Appendix XXX (TODO).
89 * (TODO: better use different options for different fields?
90 * e.g. if_filter_pcap, if_filter_bpf, ...) 00 "tcp port 23 and host 10.0.0.5"
92 #define OPT_IDB_OS 12 /**< A UTF-8 string containing the name of the operating system of the
93 * machine in which this interface is installed.
94 * This can be different from the same information that can be
95 * contained by the Section Header Block
96 * (Section 3.1 (Section Header Block (mandatory))) because
97 * the capture can have been done on a remote machine.
98 * "Windows XP SP2" / "openSUSE 10.2"
100 #define OPT_IDB_FCSLEN 13 /**< An integer value that specified the length of the
101 * Frame Check Sequence (in bits) for this interface.
102 * For link layers whose FCS length can change during time,
103 * the Packet Block Flags Word can be used (see Appendix A (Packet Block Flags Word))
105 #define OPT_IDB_TSOFFSET 14 /**< A 64-bit signed integer value that specifies an offset (in seconds)
106 * that must be added to the timestamp of each packet to obtain
107 * the absolute timestamp of a packet. If the option is not present,
108 * an offst of 0 is assumed (i.e., timestamps in blocks are absolute
109 * timestamps).
111 * This offset is not intended to be used as an offset between local
112 * time and UTC; for this purpose, the if_iana_tzname option SHOULD be
113 * used to specify a timezone.
115 #define OPT_IDB_HARDWARE 15 /**< A UTF-8 string containing the description
116 * of the hardware of the device used
117 * to capture data.
118 * "Broadcom NetXtreme" /
119 * "Intel(R) PRO/1000 MT Network Connection" /
120 * "NETGEAR WNA1000Mv2 N150 Wireless USB Micro Adapter"
124 * These are the flags for an EPB, but we use them for all WTAP_BLOCK_PACKET
126 #define OPT_PKT_FLAGS 2
127 #define OPT_PKT_HASH 3
128 #define OPT_PKT_DROPCOUNT 4
129 #define OPT_PKT_PACKETID 5
130 #define OPT_PKT_QUEUE 6
131 #define OPT_PKT_VERDICT 7
133 /* Name Resolution Block (NRB) */
134 #define OPT_NS_DNSNAME 2
135 #define OPT_NS_DNSIP4ADDR 3
136 #define OPT_NS_DNSIP6ADDR 4
138 /* Interface Statistics Block (ISB) */
139 #define OPT_ISB_STARTTIME 2
140 #define OPT_ISB_ENDTIME 3
141 #define OPT_ISB_IFRECV 4
142 #define OPT_ISB_IFDROP 5
143 #define OPT_ISB_FILTERACCEPT 6
144 #define OPT_ISB_OSDROP 7
145 #define OPT_ISB_USRDELIV 8
147 struct wtap_block;
148 typedef struct wtap_block *wtap_block_t;
151 * Currently supported blocks; these are not the pcapng block type values
152 * for them, they're identifiers used internally, and more than one
153 * pcapng block type may use a given block type.
155 * Note that, in a given file format, this information won't necessarily
156 * appear in the form of blocks in the file, even though they're presented
157 * to the caller of libwiretap as blocks when reading and are presented
158 * by the caller of libwiretap as blocks when writing. See, for example,
159 * the iptrace file format, in which the interface name is given as part
160 * of the packet record header; we synthesize those blocks when reading
161 * (we don't currently support writing that format, but if we did, we'd
162 * get the interface name from the block and put it in the packet record
163 * header).
165 * WTAP_BLOCK_IF_ID_AND_INFO is a block that not only gives
166 * descriptive information about an interface but *also* assigns an
167 * ID to the interface, so that every packet has either an explicit
168 * or implicit interface ID indicating on which the packet arrived.
170 * It does *not* refer to information about interfaces that does not
171 * allow identification of the interface on which a packet arrives
172 * (I'm looking at *you*, Microsoft Network Monitor...). Do *not*
173 * indicate support for that block if your capture format merely
174 * gives a list of interface information without having every packet
175 * explicitly or implicitly (as in, for example, the pcapng Simple
176 * Packet Block) indicate on which of those interfaces the packet
177 * arrived.
179 * WTAP_BLOCK_PACKET (which corresponds to the Enhanced Packet Block,
180 * the Simple Packet Block, and the deprecated Packet Block) is not
181 * currently used; it's reserved for future use. The same applies
182 * to WTAP_BLOCK_SYSTEMD_JOURNAL_EXPORT.
184 typedef enum {
185 WTAP_BLOCK_SECTION = 0,
186 WTAP_BLOCK_IF_ID_AND_INFO,
187 WTAP_BLOCK_NAME_RESOLUTION,
188 WTAP_BLOCK_IF_STATISTICS,
189 WTAP_BLOCK_DECRYPTION_SECRETS,
190 WTAP_BLOCK_PACKET,
191 WTAP_BLOCK_FT_SPECIFIC_REPORT,
192 WTAP_BLOCK_FT_SPECIFIC_EVENT,
193 WTAP_BLOCK_SYSDIG_EVENT,
194 WTAP_BLOCK_META_EVENT,
195 WTAP_BLOCK_SYSTEMD_JOURNAL_EXPORT,
196 WTAP_BLOCK_CUSTOM,
197 MAX_WTAP_BLOCK_TYPE_VALUE
198 } wtap_block_type_t;
201 * Holds the required data from a WTAP_BLOCK_SECTION.
203 typedef struct wtapng_section_mandatory_s {
204 uint64_t section_length; /**< 64-bit value specifying the length in bytes of the
205 * following section.
206 * Section Length equal -1 (0xFFFFFFFFFFFFFFFF) means
207 * that the size of the section is not specified
208 * Note: if writing to a new file, this length will
209 * be invalid if anything changes, such as the other
210 * members of this struct, or the packets written.
212 } wtapng_section_mandatory_t;
214 /** struct holding the information to build a WTAP_BLOCK_IF_ID_AND_INFO.
215 * the interface_data array holds an array of wtap_block_t
216 * representing interfacs, one per interface.
218 typedef struct wtapng_iface_descriptions_s {
219 GArray *interface_data;
220 } wtapng_iface_descriptions_t;
223 * Holds the required data from a WTAP_BLOCK_IF_ID_AND_INFO.
225 typedef struct wtapng_if_descr_mandatory_s {
226 int wtap_encap; /**< link_type translated to wtap_encap */
227 uint64_t time_units_per_second;
228 int tsprecision; /**< WTAP_TSPREC_ value for this interface */
230 uint32_t snap_len;
232 uint8_t num_stat_entries;
233 GArray *interface_statistics; /**< An array holding the interface statistics from
234 * pcapng ISB:s or equivalent(?)*/
235 } wtapng_if_descr_mandatory_t;
238 * Holds the required data from a WTAP_BLOCK_NAME_RESOLUTION.
240 typedef struct wtapng_nrb_mandatory_s {
241 GList *ipv4_addr_list;
242 GList *ipv6_addr_list;
243 } wtapng_nrb_mandatory_t;
246 * Holds the required data from a WTAP_BLOCK_IF_STATISTICS.
248 typedef struct wtapng_if_stats_mandatory_s {
249 uint32_t interface_id;
250 uint32_t ts_high;
251 uint32_t ts_low;
252 } wtapng_if_stats_mandatory_t;
255 * Holds the required data from a WTAP_BLOCK_DECRYPTION_SECRETS.
257 typedef struct wtapng_dsb_mandatory_s {
258 uint32_t secrets_type; /** Type of secrets stored in data (see secrets-types.h) */
259 uint32_t secrets_len; /** Length of the secrets data in bytes */
260 uint8_t *secrets_data; /** Buffer of secrets (not NUL-terminated) */
261 } wtapng_dsb_mandatory_t;
264 * Holds the required data from a WTAP_BLOCK_META_EVENT.
266 typedef struct wtapng_meta_event_mandatory_s {
267 uint32_t mev_block_type; /** pcapng block type of the event, e.g. BLOCK_TYPE_SYSDIG_MI */
268 unsigned mev_data_len; /** Length of the mev data in bytes */
269 uint8_t *mev_data; /** Buffer of mev data (not NUL-terminated) */
270 } wtapng_meta_event_mandatory_t;
273 * Holds the required data from a WTAP_BLOCK_PACKET.
274 * This includes Enhanced Packet Block, Simple Packet Block, and the deprecated Packet Block.
275 * NB. I'm not including the packet data here since Wireshark handles it in other ways.
276 * If we were to add it we'd need to implement copy and free routines in wtap_opttypes.c
278 #if 0
279 /* Commented out for now, there's no mandatory data that isn't handled by
280 * Wireshark in other ways.
282 typedef struct wtapng_packet_mandatory_s {
283 uint32_t interface_id;
284 uint32_t ts_high;
285 uint32_t ts_low;
286 uint32_t captured_len;
287 uint32_t orig_len;
288 } wtapng_packet_mandatory_t;
289 #endif
292 * Holds the required data from a WTAP_BLOCK_FT_SPECIFIC_REPORT.
294 typedef struct wtapng_ft_specific_mandatory_s {
295 unsigned record_type; /* the type of record this is - file type-specific value */
296 } wtapng_ft_specific_mandatory_t;
299 * Currently supported option types. These are not option types
300 * in the sense that each one corresponds to a particular option,
301 * they are data types for the data of an option, so, for example,
302 * all options with a 32-bit unsigned integer value have the type
303 * WTAP_OPTTYPE_UINT32.
305 typedef enum {
306 WTAP_OPTTYPE_UINT8,
307 WTAP_OPTTYPE_UINT32,
308 WTAP_OPTTYPE_UINT64,
309 WTAP_OPTTYPE_STRING,
310 WTAP_OPTTYPE_BYTES,
311 WTAP_OPTTYPE_IPv4,
312 WTAP_OPTTYPE_IPv6,
313 WTAP_OPTTYPE_CUSTOM,
314 WTAP_OPTTYPE_IF_FILTER,
315 WTAP_OPTTYPE_PACKET_VERDICT,
316 WTAP_OPTTYPE_PACKET_HASH,
317 WTAP_OPTTYPE_INT8,
318 WTAP_OPTTYPE_INT32,
319 WTAP_OPTTYPE_INT64,
320 } wtap_opttype_e;
322 typedef enum {
323 WTAP_OPTTYPE_SUCCESS = 0,
324 WTAP_OPTTYPE_NO_SUCH_OPTION = -1,
325 WTAP_OPTTYPE_NOT_FOUND = -2,
326 WTAP_OPTTYPE_TYPE_MISMATCH = -3,
327 WTAP_OPTTYPE_NUMBER_MISMATCH = -4,
328 WTAP_OPTTYPE_ALREADY_EXISTS = -5,
329 WTAP_OPTTYPE_BAD_BLOCK = -6,
330 } wtap_opttype_return_val;
332 /* https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers */
333 #define PEN_NFLX 10949
334 #define PEN_VCTR 46254
337 * Structure describing a custom option.
340 typedef struct custom_opt_s {
341 uint32_t pen;
342 union {
343 struct generic_custom_opt_data {
344 size_t custom_data_len;
345 char *custom_data;
346 } generic_data;
347 struct nflx_custom_opt_data {
348 uint32_t type;
349 size_t custom_data_len;
350 char *custom_data;
351 bool use_little_endian;
352 } nflx_data;
353 } data;
354 } custom_opt_t;
357 * Structure describing a NFLX custom option.
359 typedef struct nflx_custom_opt_s {
360 bool nflx_use_little_endian;
361 uint32_t nflx_type;
362 size_t nflx_custom_data_len;
363 char *nflx_custom_data;
364 } nflx_custom_opt_t;
366 /* Interface description data - if_filter option structure */
368 /* BPF instruction */
369 typedef struct wtap_bpf_insn_s {
370 uint16_t code;
371 uint8_t jt;
372 uint8_t jf;
373 uint32_t k;
374 } wtap_bpf_insn_t;
377 * Type of filter.
379 typedef enum {
380 if_filter_pcap = 0, /* pcap filter string */
381 if_filter_bpf = 1 /* BPF program */
382 } if_filter_type_e;
384 typedef struct if_filter_opt_s {
385 if_filter_type_e type;
386 union {
387 char *filter_str; /**< pcap filter string */
388 struct wtap_bpf_insns {
389 unsigned bpf_prog_len; /**< number of BPF instructions */
390 wtap_bpf_insn_t *bpf_prog; /**< BPF instructions */
391 } bpf_prog; /**< BPF program */
392 } data;
393 } if_filter_opt_t;
395 /* Packet - packet_verdict option structure */
398 * Type of verdict.
400 typedef enum {
401 packet_verdict_hardware = 0, /* array of octets */
402 packet_verdict_linux_ebpf_tc = 1, /* 64-bit unsigned integer TC_ACT_ value */
403 packet_verdict_linux_ebpf_xdp = 2 /* 64-bit unsigned integer xdp_action value */
404 } packet_verdict_type_e;
406 typedef struct packet_verdict_opt_s {
407 packet_verdict_type_e type;
408 union {
409 GByteArray *verdict_bytes;
410 uint64_t verdict_linux_ebpf_tc;
411 uint64_t verdict_linux_ebpf_xdp;
412 } data;
413 } packet_verdict_opt_t;
415 typedef struct packet_hash_opt_s {
416 uint8_t type;
417 GByteArray *hash_bytes;
418 } packet_hash_opt_t;
421 * Structure describing a value of an option.
423 typedef union {
424 uint8_t uint8val;
425 uint32_t uint32val;
426 uint64_t uint64val;
427 int8_t int8val;
428 int32_t int32val;
429 int64_t int64val;
430 ws_in4_addr ipv4val; /* network byte order */
431 ws_in6_addr ipv6val;
432 char *stringval;
433 GBytes *byteval;
434 custom_opt_t custom_opt;
435 if_filter_opt_t if_filterval;
436 packet_verdict_opt_t packet_verdictval;
437 packet_hash_opt_t packet_hash;
438 } wtap_optval_t;
441 * Structure describing an option in a block.
443 typedef struct {
444 unsigned option_id; /**< option code for the option */
445 wtap_optval_t value; /**< value */
446 } wtap_option_t;
448 #define NFLX_OPT_TYPE_VERSION 1
449 #define NFLX_OPT_TYPE_TCPINFO 2
450 #define NFLX_OPT_TYPE_DUMPINFO 4
451 #define NFLX_OPT_TYPE_DUMPTIME 5
452 #define NFLX_OPT_TYPE_STACKNAME 6
454 struct nflx_dumpinfo {
455 uint32_t tlh_version;
456 uint32_t tlh_type;
457 uint64_t tlh_length;
458 uint16_t tlh_ie_fport;
459 uint16_t tlh_ie_lport;
460 uint32_t tlh_ie_faddr_addr32[4];
461 uint32_t tlh_ie_laddr_addr32[4];
462 uint32_t tlh_ie_zoneid;
463 uint64_t tlh_offset_tv_sec;
464 uint64_t tlh_offset_tv_usec;
465 char tlh_id[64];
466 char tlh_reason[32];
467 char tlh_tag[32];
468 uint8_t tlh_af;
469 uint8_t _pad[7];
472 /* Flags used in tlb_eventflags */
473 #define NFLX_TLB_FLAG_RXBUF 0x0001 /* Includes receive buffer info */
474 #define NFLX_TLB_FLAG_TXBUF 0x0002 /* Includes send buffer info */
475 #define NFLX_TLB_FLAG_HDR 0x0004 /* Includes a TCP header */
476 #define NFLX_TLB_FLAG_VERBOSE 0x0008 /* Includes function/line numbers */
477 #define NFLX_TLB_FLAG_STACKINFO 0x0010 /* Includes stack-specific info */
479 /* Flags used in tlb_flags */
480 #define NFLX_TLB_TF_REQ_SCALE 0x00000020 /* Sent WS option */
481 #define NFLX_TLB_TF_RCVD_SCALE 0x00000040 /* Received WS option */
483 /* Values of tlb_state */
484 #define NFLX_TLB_TCPS_ESTABLISHED 4
485 #define NFLX_TLB_IS_SYNCHRONIZED(state) (state >= NFLX_TLB_TCPS_ESTABLISHED)
487 struct nflx_tcpinfo {
488 uint64_t tlb_tv_sec;
489 uint64_t tlb_tv_usec;
490 uint32_t tlb_ticks;
491 uint32_t tlb_sn;
492 uint8_t tlb_stackid;
493 uint8_t tlb_eventid;
494 uint16_t tlb_eventflags;
495 int32_t tlb_errno;
496 uint32_t tlb_rxbuf_tls_sb_acc;
497 uint32_t tlb_rxbuf_tls_sb_ccc;
498 uint32_t tlb_rxbuf_tls_sb_spare;
499 uint32_t tlb_txbuf_tls_sb_acc;
500 uint32_t tlb_txbuf_tls_sb_ccc;
501 uint32_t tlb_txbuf_tls_sb_spare;
502 int32_t tlb_state;
503 uint32_t tlb_starttime;
504 uint32_t tlb_iss;
505 uint32_t tlb_flags;
506 uint32_t tlb_snd_una;
507 uint32_t tlb_snd_max;
508 uint32_t tlb_snd_cwnd;
509 uint32_t tlb_snd_nxt;
510 uint32_t tlb_snd_recover;
511 uint32_t tlb_snd_wnd;
512 uint32_t tlb_snd_ssthresh;
513 uint32_t tlb_srtt;
514 uint32_t tlb_rttvar;
515 uint32_t tlb_rcv_up;
516 uint32_t tlb_rcv_adv;
517 uint32_t tlb_flags2;
518 uint32_t tlb_rcv_nxt;
519 uint32_t tlb_rcv_wnd;
520 uint32_t tlb_dupacks;
521 int32_t tlb_segqlen;
522 int32_t tlb_snd_numholes;
523 uint32_t tlb_flex1;
524 uint32_t tlb_flex2;
525 uint32_t tlb_fbyte_in;
526 uint32_t tlb_fbyte_out;
527 uint8_t tlb_snd_scale:4,
528 tlb_rcv_scale:4;
529 uint8_t _pad[3];
531 /* The following fields might become part of a union */
532 uint64_t tlb_stackinfo_bbr_cur_del_rate;
533 uint64_t tlb_stackinfo_bbr_delRate;
534 uint64_t tlb_stackinfo_bbr_rttProp;
535 uint64_t tlb_stackinfo_bbr_bw_inuse;
536 uint32_t tlb_stackinfo_bbr_inflight;
537 uint32_t tlb_stackinfo_bbr_applimited;
538 uint32_t tlb_stackinfo_bbr_delivered;
539 uint32_t tlb_stackinfo_bbr_timeStamp;
540 uint32_t tlb_stackinfo_bbr_epoch;
541 uint32_t tlb_stackinfo_bbr_lt_epoch;
542 uint32_t tlb_stackinfo_bbr_pkts_out;
543 uint32_t tlb_stackinfo_bbr_flex1;
544 uint32_t tlb_stackinfo_bbr_flex2;
545 uint32_t tlb_stackinfo_bbr_flex3;
546 uint32_t tlb_stackinfo_bbr_flex4;
547 uint32_t tlb_stackinfo_bbr_flex5;
548 uint32_t tlb_stackinfo_bbr_flex6;
549 uint32_t tlb_stackinfo_bbr_lost;
550 uint16_t tlb_stackinfo_bbr_pacing_gain;
551 uint16_t tlb_stackinfo_bbr_cwnd_gain;
552 uint16_t tlb_stackinfo_bbr_flex7;
553 uint8_t tlb_stackinfo_bbr_bbr_state;
554 uint8_t tlb_stackinfo_bbr_bbr_substate;
555 uint8_t tlb_stackinfo_bbr_inhpts;
556 uint8_t tlb_stackinfo_bbr_ininput;
557 uint8_t tlb_stackinfo_bbr_use_lt_bw;
558 uint8_t tlb_stackinfo_bbr_flex8;
559 uint32_t tlb_stackinfo_bbr_pkt_epoch;
561 uint32_t tlb_len;
564 typedef void (*wtap_block_create_func)(wtap_block_t block);
565 typedef void (*wtap_mand_free_func)(wtap_block_t block);
566 typedef void (*wtap_mand_copy_func)(wtap_block_t dest_block, wtap_block_t src_block);
568 /** Initialize block types.
570 * This is currently just a placeholder as nothing needs to be
571 * initialized yet. Should handle "registration" when code is
572 * refactored to do so.
574 WS_DLL_PUBLIC void
575 wtap_opttypes_initialize(void);
577 /** Create a block by type
579 * Return a newly allocated block with default options provided
581 * @param[in] block_type Block type to be created
582 * @return Newly allocated block
584 WS_DLL_PUBLIC wtap_block_t
585 wtap_block_create(wtap_block_type_t block_type);
587 /** Increase reference count of a block
589 * Call when taking a copy of a block
591 * @param[in] block Block add ref to
592 * @return The block
594 WS_DLL_PUBLIC wtap_block_t
595 wtap_block_ref(wtap_block_t block);
597 /** Decrease reference count of a block
599 * Needs to be called on any block once you're done with it
601 * @param[in] block Block to be deref'd
603 WS_DLL_PUBLIC void
604 wtap_block_unref(wtap_block_t block);
606 /** Free an array of blocks
608 * Needs to be called to clean up blocks allocated
609 * through GArray (for multiple blocks of same type)
610 * Includes freeing the GArray
612 * @param[in] block_array Array of blocks to be freed
614 WS_DLL_PUBLIC void
615 wtap_block_array_free(GArray* block_array);
617 /** Decrement the reference count of an array of blocks
619 * Decrement the reference count of each block in the array
620 * and the GArray itself. Any element whose reference count
621 * drops to 0 will be freed. If the GArray and every block
622 * has a reference count of 1, this is the same as
623 * wtap_block_array_free().
625 * @param[in] block_array Array of blocks to be dereferenced
627 WS_DLL_PUBLIC void
628 wtap_block_array_unref(GArray* block_array);
630 /** Increment the reference count of an array of blocks
632 * Increment the reference count of each block in the array
633 * and the GArray itself.
635 * @param[in] block_array Array of blocks to be referenced
637 WS_DLL_PUBLIC void
638 wtap_block_array_ref(GArray* block_array);
640 /** Provide type of a block
642 * @param[in] block Block from which to retrieve mandatory data
643 * @return Block type.
645 WS_DLL_PUBLIC wtap_block_type_t
646 wtap_block_get_type(wtap_block_t block);
648 /** Provide mandatory data of a block
650 * @param[in] block Block from which to retrieve mandatory data
651 * @return Block mandatory data. Structure varies based on block type
653 WS_DLL_PUBLIC void*
654 wtap_block_get_mandatory_data(wtap_block_t block);
656 /** Count the number of times the given option appears in the block
658 * @param[in] block Block to which to add the option
659 * @param[in] option_id Identifier value for option
660 * @return unsigned - the number of times the option was found
662 WS_DLL_PUBLIC unsigned
663 wtap_block_count_option(wtap_block_t block, unsigned option_id);
665 /** Add UINT8 option value to a block
667 * @param[in] block Block to which to add the option
668 * @param[in] option_id Identifier value for option
669 * @param[in] value Value of option
670 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
671 * error code otherwise
673 WS_DLL_PUBLIC wtap_opttype_return_val
674 wtap_block_add_uint8_option(wtap_block_t block, unsigned option_id, uint8_t value);
676 /** Set UINT8 option value in a block
678 * @param[in] block Block in which to set the option value
679 * @param[in] option_id Identifier value for option
680 * @param[in] value New value of option
681 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
682 * error code otherwise
684 WS_DLL_PUBLIC wtap_opttype_return_val
685 wtap_block_set_uint8_option_value(wtap_block_t block, unsigned option_id, uint8_t value);
687 /** Get UINT8 option value from a block
689 * @param[in] block Block from which to get the option value
690 * @param[in] option_id Identifier value for option
691 * @param[out] value Returned value of option
692 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
693 * error code otherwise
695 WS_DLL_PUBLIC wtap_opttype_return_val
696 wtap_block_get_uint8_option_value(wtap_block_t block, unsigned option_id, uint8_t* value) G_GNUC_WARN_UNUSED_RESULT;
698 /** Add UINT32 option value to a block
700 * @param[in] block Block to which to add the option
701 * @param[in] option_id Identifier value for option
702 * @param[in] value Value of option
703 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
704 * error code otherwise
706 WS_DLL_PUBLIC wtap_opttype_return_val
707 wtap_block_add_uint32_option(wtap_block_t block, unsigned option_id, uint32_t value);
709 /** Set UINT32 option value in a block
711 * @param[in] block Block in which to set the option value
712 * @param[in] option_id Identifier value for option
713 * @param[in] value New value of option
714 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
715 * error code otherwise
717 WS_DLL_PUBLIC wtap_opttype_return_val
718 wtap_block_set_uint32_option_value(wtap_block_t block, unsigned option_id, uint32_t value);
720 /** Get UINT32 option value from a block
722 * @param[in] block Block from which to get the option value
723 * @param[in] option_id Identifier value for option
724 * @param[out] value Returned value of option
725 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
726 * error code otherwise
728 WS_DLL_PUBLIC wtap_opttype_return_val
729 wtap_block_get_uint32_option_value(wtap_block_t block, unsigned option_id, uint32_t* value) G_GNUC_WARN_UNUSED_RESULT;
731 /** Add UINT64 option value to a block
733 * @param[in] block Block to which to add the option
734 * @param[in] option_id Identifier value for option
735 * @param[in] value Value of option
736 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
737 * error code otherwise
739 WS_DLL_PUBLIC wtap_opttype_return_val
740 wtap_block_add_uint64_option(wtap_block_t block, unsigned option_id, uint64_t value);
742 /** Set UINT64 option value in a block
744 * @param[in] block Block in which to set the option value
745 * @param[in] option_id Identifier value for option
746 * @param[in] value New value of option
747 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
748 * error code otherwise
750 WS_DLL_PUBLIC wtap_opttype_return_val
751 wtap_block_set_uint64_option_value(wtap_block_t block, unsigned option_id, uint64_t value);
753 /** Get UINT64 option value from a block
755 * @param[in] block Block from which to get the option value
756 * @param[in] option_id Identifier value for option
757 * @param[out] value Returned value of option
758 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
759 * error code otherwise
761 WS_DLL_PUBLIC wtap_opttype_return_val
762 wtap_block_get_uint64_option_value(wtap_block_t block, unsigned option_id, uint64_t* value) G_GNUC_WARN_UNUSED_RESULT;
764 /** Add INT8 option value to a block
766 * @param[in] block Block to which to add the option
767 * @param[in] option_id Identifier value for option
768 * @param[in] value Value of option
769 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
770 * error code otherwise
772 WS_DLL_PUBLIC wtap_opttype_return_val
773 wtap_block_add_int8_option(wtap_block_t block, unsigned option_id, int8_t value);
775 /** Set INT8 option value in a block
777 * @param[in] block Block in which to set the option value
778 * @param[in] option_id Identifier value for option
779 * @param[in] value New value of option
780 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
781 * error code otherwise
783 WS_DLL_PUBLIC wtap_opttype_return_val
784 wtap_block_set_int8_option_value(wtap_block_t block, unsigned option_id, int8_t value);
786 /** Get INT8 option value from a block
788 * @param[in] block Block from which to get the option value
789 * @param[in] option_id Identifier value for option
790 * @param[out] value Returned value of option
791 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
792 * error code otherwise
794 WS_DLL_PUBLIC wtap_opttype_return_val
795 wtap_block_get_int8_option_value(wtap_block_t block, unsigned option_id, int8_t* value) G_GNUC_WARN_UNUSED_RESULT;
797 /** Add INT32 option value to a block
799 * @param[in] block Block to which to add the option
800 * @param[in] option_id Identifier value for option
801 * @param[in] value Value of option
802 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
803 * error code otherwise
805 WS_DLL_PUBLIC wtap_opttype_return_val
806 wtap_block_add_int32_option(wtap_block_t block, unsigned option_id, int32_t value);
808 /** Set INT32 option value in a block
810 * @param[in] block Block in which to set the option value
811 * @param[in] option_id Identifier value for option
812 * @param[in] value New value of option
813 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
814 * error code otherwise
816 WS_DLL_PUBLIC wtap_opttype_return_val
817 wtap_block_set_int32_option_value(wtap_block_t block, unsigned option_id, int32_t value);
819 /** Get INT32 option value from a block
821 * @param[in] block Block from which to get the option value
822 * @param[in] option_id Identifier value for option
823 * @param[out] value Returned value of option
824 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
825 * error code otherwise
827 WS_DLL_PUBLIC wtap_opttype_return_val
828 wtap_block_get_int32_option_value(wtap_block_t block, unsigned option_id, int32_t* value) G_GNUC_WARN_UNUSED_RESULT;
830 /** Add INT64 option value to a block
832 * @param[in] block Block to which to add the option
833 * @param[in] option_id Identifier value for option
834 * @param[in] value Value of option
835 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
836 * error code otherwise
838 WS_DLL_PUBLIC wtap_opttype_return_val
839 wtap_block_add_int64_option(wtap_block_t block, unsigned option_id, int64_t value);
841 /** Set INT64 option value in a block
843 * @param[in] block Block in which to set the option value
844 * @param[in] option_id Identifier value for option
845 * @param[in] value New value of option
846 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
847 * error code otherwise
849 WS_DLL_PUBLIC wtap_opttype_return_val
850 wtap_block_set_int64_option_value(wtap_block_t block, unsigned option_id, int64_t value);
852 /** Get INT64 option value from a block
854 * @param[in] block Block from which to get the option value
855 * @param[in] option_id Identifier value for option
856 * @param[out] value Returned value of option
857 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
858 * error code otherwise
860 WS_DLL_PUBLIC wtap_opttype_return_val
861 wtap_block_get_int64_option_value(wtap_block_t block, unsigned option_id, int64_t* value) G_GNUC_WARN_UNUSED_RESULT;
863 /** Add IPv4 address option value to a block
865 * @param[in] block Block to which to add the option
866 * @param[in] option_id Identifier value for option
867 * @param[in] value Value of option
868 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
869 * error code otherwise
871 WS_DLL_PUBLIC wtap_opttype_return_val
872 wtap_block_add_ipv4_option(wtap_block_t block, unsigned option_id, uint32_t value);
874 /** Set IPv4 option value in a block
876 * @param[in] block Block in which to set the option value
877 * @param[in] option_id Identifier value for option
878 * @param[in] value New value of option
879 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
880 * error code otherwise
882 WS_DLL_PUBLIC wtap_opttype_return_val
883 wtap_block_set_ipv4_option_value(wtap_block_t block, unsigned option_id, uint32_t value);
885 /** Get IPv4 option value from a block
887 * @param[in] block Block from which to get the option value
888 * @param[in] option_id Identifier value for option
889 * @param[out] value Returned value of option
890 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
891 * error code otherwise
893 WS_DLL_PUBLIC wtap_opttype_return_val
894 wtap_block_get_ipv4_option_value(wtap_block_t block, unsigned option_id, uint32_t* value) G_GNUC_WARN_UNUSED_RESULT;
896 /** Add IPv6 address option value to a block
898 * @param[in] block Block to which to add the option
899 * @param[in] option_id Identifier value for option
900 * @param[in] value Value of option
901 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
902 * error code otherwise
904 WS_DLL_PUBLIC wtap_opttype_return_val
905 wtap_block_add_ipv6_option(wtap_block_t block, unsigned option_id, ws_in6_addr *value);
907 /** Set IPv6 option value in a block
909 * @param[in] block Block in which to set the option value
910 * @param[in] option_id Identifier value for option
911 * @param[in] value New value of option
912 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
913 * error code otherwise
915 WS_DLL_PUBLIC wtap_opttype_return_val
916 wtap_block_set_ipv6_option_value(wtap_block_t block, unsigned option_id, ws_in6_addr *value);
918 /** Get IPv6 option value from a block
920 * @param[in] block Block from which to get the option value
921 * @param[in] option_id Identifier value for option
922 * @param[out] value Returned value of option
923 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
924 * error code otherwise
926 WS_DLL_PUBLIC wtap_opttype_return_val
927 wtap_block_get_ipv6_option_value(wtap_block_t block, unsigned option_id, ws_in6_addr* value) G_GNUC_WARN_UNUSED_RESULT;
929 /** Add a string option to a block
931 * @param[in] block Block to which to add the option
932 * @param[in] option_id Identifier value for option
933 * @param[in] value Value of option
934 * @param[in] value_length Maximum length of string to copy.
935 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
936 * error code otherwise
938 WS_DLL_PUBLIC wtap_opttype_return_val
939 wtap_block_add_string_option(wtap_block_t block, unsigned option_id, const char *value, size_t value_length);
941 /** Add a string option to a block taking ownership of the null-terminated string.
943 * @param[in] block Block to which to add the option
944 * @param[in] option_id Identifier value for option
945 * @param[in] value Value of option
946 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
947 * error code otherwise
949 WS_DLL_PUBLIC wtap_opttype_return_val
950 wtap_block_add_string_option_owned(wtap_block_t block, unsigned option_id, char *value);
952 /** Add a string option to a block with a printf-formatted string as its value
954 * @param[in] block Block to which to add the option
955 * @param[in] option_id Identifier value for option
956 * @param[in] format printf-like format string
957 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
958 * error code otherwise
960 WS_DLL_PUBLIC wtap_opttype_return_val
961 wtap_block_add_string_option_format(wtap_block_t block, unsigned option_id, const char *format, ...)
962 G_GNUC_PRINTF(3,4);
964 /** Set string option value in a block
966 * @param[in] block Block in which to set the option value
967 * @param[in] option_id Identifier value for option
968 * @param[in] value New value of option
969 * @param[in] value_length Maximum length of string to copy.
970 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
971 * error code otherwise
973 WS_DLL_PUBLIC wtap_opttype_return_val
974 wtap_block_set_string_option_value(wtap_block_t block, unsigned option_id, const char* value, size_t value_length);
976 /** Set string option value for the nth instance of a particular option
977 * in a block
979 * @param[in] block Block in which to set the option value
980 * @param[in] option_id Identifier value for option
981 * @param[in] idx Instance number of option with that ID
982 * @param[in] value New value of option
983 * @param[in] value_length Maximum length of string to copy.
984 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
985 * error code otherwise
987 WS_DLL_PUBLIC wtap_opttype_return_val
988 wtap_block_set_nth_string_option_value(wtap_block_t block, unsigned option_id, unsigned idx, const char* value, size_t value_length);
990 /** Set string option value in a block to a printf-formatted string
992 * @param[in] block Block in which to set the option value
993 * @param[in] option_id Identifier value for option
994 * @param[in] format printf-like format string
995 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
996 * error code otherwise
998 WS_DLL_PUBLIC wtap_opttype_return_val
999 wtap_block_set_string_option_value_format(wtap_block_t block, unsigned option_id, const char *format, ...)
1000 G_GNUC_PRINTF(3,4);
1002 /** Set string option value for the nth instance of a particular option
1003 * in a block to a printf-formatted string
1005 * @param[in] block Block in which to set the option value
1006 * @param[in] option_id Identifier value for option
1007 * @param[in] idx Instance number of option with that ID
1008 * @param[in] format printf-like format string
1009 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1010 * error code otherwise
1012 WS_DLL_PUBLIC wtap_opttype_return_val
1013 wtap_block_set_nth_string_option_value_format(wtap_block_t block, unsigned option_id, unsigned idx, const char *format, ...)
1014 G_GNUC_PRINTF(4,5);
1016 /** Get string option value from a block
1018 * @param[in] block Block from which to get the option value
1019 * @param[in] option_id Identifier value for option
1020 * @param[out] value Returned value of option
1021 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1022 * error code otherwise
1024 WS_DLL_PUBLIC wtap_opttype_return_val
1025 wtap_block_get_string_option_value(wtap_block_t block, unsigned option_id, char** value) G_GNUC_WARN_UNUSED_RESULT;
1027 /** Get string option value for the nth instance of a particular option
1028 * in a block
1030 * @param[in] block Block from which to get the option value
1031 * @param[in] option_id Identifier value for option
1032 * @param[in] idx Instance number of option with that ID
1033 * @param[out] value Returned value of option
1034 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1035 * error code otherwise
1037 WS_DLL_PUBLIC wtap_opttype_return_val
1038 wtap_block_get_nth_string_option_value(wtap_block_t block, unsigned option_id, unsigned idx, char** value) G_GNUC_WARN_UNUSED_RESULT;
1040 /** Add a bytes option to a block
1042 * @param[in] block Block to which to add the option
1043 * @param[in] option_id Identifier value for option
1044 * @param[in] value Value of option to copy
1045 * @param[in] value_length Number of bytes to copy
1046 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1047 * error code otherwise
1049 WS_DLL_PUBLIC wtap_opttype_return_val
1050 wtap_block_add_bytes_option(wtap_block_t block, unsigned option_id, const uint8_t *value, size_t value_length);
1052 /** Add a bytes option to a block, borrowing the value from a GBytes
1054 * @param[in] block Block to which to add the option
1055 * @param[in] option_id Identifier value for option
1056 * @param[in] value Value of option as a GBytes
1057 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1058 * error code otherwise
1060 WS_DLL_PUBLIC wtap_opttype_return_val
1061 wtap_block_add_bytes_option_borrow(wtap_block_t block, unsigned option_id, GBytes *value);
1063 /** Set bytes option value in a block
1065 * @param[in] block Block in which to set the option value
1066 * @param[in] option_id Identifier value for option
1067 * @param[in] value New value of option
1068 * @param[in] value_length Number of bytes to copy.
1069 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1070 * error code otherwise
1072 WS_DLL_PUBLIC wtap_opttype_return_val
1073 wtap_block_set_bytes_option_value(wtap_block_t block, unsigned option_id, const uint8_t* value, size_t value_length);
1075 /** Set bytes option value for nth instance of a particular option in a block
1077 * @param[in] block Block in which to set the option value
1078 * @param[in] option_id Identifier value for option
1079 * @param[in] idx Instance number of option with that ID
1080 * @param[in] value New value of option
1081 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1082 * error code otherwise
1084 WS_DLL_PUBLIC wtap_opttype_return_val
1085 wtap_block_set_nth_bytes_option_value(wtap_block_t block, unsigned option_id, unsigned idx, GBytes* value);
1087 /** Get bytes option value from a block
1089 * @param[in] block Block from which to get the option value
1090 * @param[in] option_id Identifier value for option
1091 * @param[out] value Returned value of option
1092 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1093 * error code otherwise
1094 * @note You should call g_bytes_ref() on value if you plan to keep it around
1095 * (and then g_bytes_unref() when you're done with it).
1097 WS_DLL_PUBLIC wtap_opttype_return_val
1098 wtap_block_get_bytes_option_value(wtap_block_t block, unsigned option_id, GBytes** value) G_GNUC_WARN_UNUSED_RESULT;
1100 /** Get bytes option value for nth instance of a particular option in a block
1102 * @param[in] block Block from which to get the option value
1103 * @param[in] option_id Identifier value for option
1104 * @param[in] idx Instance number of option with that ID
1105 * @param[out] value Returned value of option
1106 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1107 * error code otherwise
1108 * @note You should call g_bytes_ref() on value if you plan to keep it around
1109 * (and then g_bytes_unref() when you're done with it).
1111 WS_DLL_PUBLIC wtap_opttype_return_val
1112 wtap_block_get_nth_bytes_option_value(wtap_block_t block, unsigned option_id, unsigned idx, GBytes** value) G_GNUC_WARN_UNUSED_RESULT;
1114 /** Add an NFLX custom option to a block
1116 * @param[in] block Block to which to add the option
1117 * @param[in] nflx_type NFLX option type
1118 * @param[in] nflx_custom_data pointer to the data
1119 * @param[in] nflx_custom_data_len length of custom_data
1120 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1121 * error code otherwise
1123 WS_DLL_PUBLIC wtap_opttype_return_val
1124 wtap_block_add_nflx_custom_option(wtap_block_t block, uint32_t nflx_type, const char *nflx_custom_data, size_t nflx_custom_data_len);
1126 /** Get an NFLX custom option value from a block
1128 * @param[in] block Block from which to get the option value
1129 * @param[in] nflx_type type of the option
1130 * @param[out] nflx_custom_data Returned value of NFLX custom option value
1131 * @param[in] nflx_custom_data_len size of buffer provided in nflx_custom_data
1132 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1133 * error code otherwise
1135 WS_DLL_PUBLIC wtap_opttype_return_val
1136 wtap_block_get_nflx_custom_option(wtap_block_t block, uint32_t nflx_type, char *nflx_custom_data, size_t nflx_custom_data_len);
1138 /** Add a custom option to a block
1140 * @param[in] block Block to which to add the option
1141 * @param[in] option_id Identifier value for option
1142 * @param[in] pen PEN
1143 * @param[in] custom_data pointer to the data
1144 * @param[in] custom_data_len length of custom_data
1145 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1146 * error code otherwise
1148 WS_DLL_PUBLIC wtap_opttype_return_val
1149 wtap_block_add_custom_option(wtap_block_t block, unsigned option_id, uint32_t pen, const char *custom_data, size_t custom_data_len);
1151 /** Add an if_filter option value to a block
1153 * @param[in] block Block to which to add the option
1154 * @param[in] option_id Identifier value for option
1155 * @param[in] value Value of option
1156 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1157 * error code otherwise
1159 WS_DLL_PUBLIC wtap_opttype_return_val
1160 wtap_block_add_if_filter_option(wtap_block_t block, unsigned option_id, if_filter_opt_t* value);
1162 /** Set an if_filter option value in a block
1164 * @param[in] block Block in which to set the option value
1165 * @param[in] option_id Identifier value for option
1166 * @param[in] value New value of option
1167 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1168 * error code otherwise
1170 WS_DLL_PUBLIC wtap_opttype_return_val
1171 wtap_block_set_if_filter_option_value(wtap_block_t block, unsigned option_id, if_filter_opt_t* value);
1173 /** Get an if_filter option value from a block
1175 * @param[in] block Block from which to get the option value
1176 * @param[in] option_id Identifier value for option
1177 * @param[out] value Returned value of option value
1178 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1179 * error code otherwise
1181 WS_DLL_PUBLIC wtap_opttype_return_val
1182 wtap_block_get_if_filter_option_value(wtap_block_t block, unsigned option_id, if_filter_opt_t* value) G_GNUC_WARN_UNUSED_RESULT;
1184 /** Add a packet_verdict option value to a block
1186 * @param[in] block Block to which to add the option
1187 * @param[in] option_id Identifier value for option
1188 * @param[in] value Value of option
1189 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1190 * error code otherwise
1192 WS_DLL_PUBLIC wtap_opttype_return_val
1193 wtap_block_add_packet_verdict_option(wtap_block_t block, unsigned option_id, packet_verdict_opt_t* value);
1195 /** Set packet_verdict option value for the nth instsance of a particular
1196 * option in a block
1198 * @param[in] block Block in which to set the option value
1199 * @param[in] option_id Identifier value for option
1200 * @param[in] idx Instance number of option with that ID
1201 * @param[in] value New value of option
1202 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1203 * error code otherwise
1205 WS_DLL_PUBLIC wtap_opttype_return_val
1206 wtap_block_set_nth_packet_verdict_option_value(wtap_block_t block, unsigned option_id, unsigned idx, packet_verdict_opt_t* value);
1208 /** Get packet_verdict option value for the nth instance of a particular
1209 * option in a block
1211 * @param[in] block Block from which to get the option value
1212 * @param[in] option_id Identifier value for option
1213 * @param[in] idx Instance number of option with that ID
1214 * @param[out] value Returned value of option value
1215 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1216 * error code otherwise
1218 WS_DLL_PUBLIC wtap_opttype_return_val
1219 wtap_block_get_nth_packet_verdict_option_value(wtap_block_t block, unsigned option_id, unsigned idx, packet_verdict_opt_t* value) G_GNUC_WARN_UNUSED_RESULT;
1221 WS_DLL_PUBLIC void
1222 wtap_packet_verdict_free(packet_verdict_opt_t* verdict);
1224 /** Add a packet_hash option value to a block
1226 * @param[in] block Block to which to add the option
1227 * @param[in] option_id Identifier value for option
1228 * @param[in] value Value of option
1229 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1230 * error code otherwise
1232 WS_DLL_PUBLIC wtap_opttype_return_val
1233 wtap_block_add_packet_hash_option(wtap_block_t block, unsigned option_id, packet_hash_opt_t* value);
1235 WS_DLL_PUBLIC void
1236 wtap_packet_hash_free(packet_hash_opt_t* hash);
1238 /** Remove an option from a block
1240 * @param[in] block Block from which to remove the option
1241 * @param[in] option_id Identifier value for option
1242 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1243 * error code otherwise
1245 WS_DLL_PUBLIC wtap_opttype_return_val
1246 wtap_block_remove_option(wtap_block_t block, unsigned option_id);
1248 /** Remove the nth instance of an option from a block
1250 * @param[in] block Block from which to remove the option instance
1251 * @param[in] option_id Identifier value for option
1252 * @param[in] idx Instance number of option with that ID
1253 * @return wtap_opttype_return_val - WTAP_OPTTYPE_SUCCESS if successful,
1254 * error code otherwise
1256 WS_DLL_PUBLIC wtap_opttype_return_val
1257 wtap_block_remove_nth_option_instance(wtap_block_t block, unsigned option_id, unsigned idx);
1259 /** Copy a block to another.
1261 * Any options that are in the destination but not the source are not removed.
1262 * Options that are just in source will be added to destination
1264 * @param[in] dest_block Block to be copied to
1265 * @param[in] src_block Block to be copied from
1267 WS_DLL_PUBLIC void
1268 wtap_block_copy(wtap_block_t dest_block, wtap_block_t src_block);
1270 /** Make a copy of a block.
1272 * @param[in] block Block to be copied from
1273 * @return Newly allocated copy of that block
1275 WS_DLL_PUBLIC wtap_block_t
1276 wtap_block_make_copy(wtap_block_t block);
1278 typedef bool (*wtap_block_foreach_func)(wtap_block_t block, unsigned option_id, wtap_opttype_e option_type, wtap_optval_t *option, void *user_data);
1279 WS_DLL_PUBLIC bool
1280 wtap_block_foreach_option(wtap_block_t block, wtap_block_foreach_func func, void* user_data);
1282 /** Cleanup the internal structures
1284 WS_DLL_PUBLIC void
1285 wtap_opttypes_cleanup(void);
1287 #ifdef __cplusplus
1289 #endif /* __cplusplus */
1291 #endif /* WTAP_OPT_TYPES_H */