2 * Wireshark - Network traffic analyzer
3 * By Gerald Combs <gerald@wireshark.org>
4 * Copyright 2001 Gerald Combs
6 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include <ftypes-int.h>
15 #include <epan/addr_resolv.h>
16 #include <epan/strutil.h>
17 #include <epan/oids.h>
18 #include <epan/osi-utils.h>
19 #include <epan/to_str.h>
20 #include <wsutil/array.h>
21 #include <wsutil/pint.h>
24 bytes_fvalue_new(fvalue_t
*fv
)
26 fv
->value
.bytes
= NULL
;
30 bytes_fvalue_copy(fvalue_t
*dst
, const fvalue_t
*src
)
32 dst
->value
.bytes
= g_bytes_ref(src
->value
.bytes
);
36 bytes_fvalue_free(fvalue_t
*fv
)
38 if (fv
->value
.bytes
) {
39 g_bytes_unref(fv
->value
.bytes
);
40 fv
->value
.bytes
= NULL
;
46 bytes_fvalue_set(fvalue_t
*fv
, GBytes
*value
)
48 /* Free up the old value, if we have one */
49 bytes_fvalue_free(fv
);
51 fv
->value
.bytes
= g_bytes_ref(value
);
55 bytes_fvalue_get(fvalue_t
*fv
)
57 return g_bytes_ref(fv
->value
.bytes
);
61 oid_to_repr(wmem_allocator_t
*scope
, const fvalue_t
*fv
, ftrepr_t rtype _U_
, int field_display _U_
)
63 return oid_encoded2string(scope
, g_bytes_get_data(fv
->value
.bytes
, NULL
), (unsigned)g_bytes_get_size(fv
->value
.bytes
));
67 rel_oid_to_repr(wmem_allocator_t
*scope
, const fvalue_t
*fv
, ftrepr_t rtype _U_
, int field_display _U_
)
69 return rel_oid_encoded2string(scope
, g_bytes_get_data(fv
->value
.bytes
, NULL
), (unsigned)g_bytes_get_size(fv
->value
.bytes
));
73 system_id_to_repr(wmem_allocator_t
*scope
, const fvalue_t
*fv
, ftrepr_t rtype _U_
, int field_display _U_
)
75 return print_system_id(scope
, g_bytes_get_data(fv
->value
.bytes
, NULL
), (unsigned)g_bytes_get_size(fv
->value
.bytes
));
79 bytes_to_dfilter_repr(wmem_allocator_t
*scope
,
80 const uint8_t *src
, size_t src_size
)
86 /* Include space for extra punct and '\0'. */
87 max_char_size
= src_size
* 3 + 1;
89 buf
= wmem_alloc(scope
, max_char_size
);
90 buf_ptr
= bytes_to_hexstr_punct(buf
, src
, src_size
, ':');
98 bytes_to_repr(wmem_allocator_t
*scope
, const fvalue_t
*fv
, ftrepr_t rtype
, int field_display
)
101 const uint8_t *bytes
;
104 bytes
= g_bytes_get_data(fv
->value
.bytes
, &bytes_size
);
106 if (rtype
== FTREPR_DFILTER
) {
107 if (bytes_size
== 0) {
108 /* An empty byte array in a display filter is represented as "" */
109 return wmem_strdup(scope
, "\"\"");
111 return bytes_to_dfilter_repr(scope
, bytes
, bytes_size
);
114 switch(FIELD_DISPLAY(field_display
))
131 return bytes_to_str_punct_maxlen(scope
, bytes
, bytes_size
, separator
, 0);
134 return wmem_strdup(scope
, "");
138 bytes_from_string(fvalue_t
*fv
, const char *s
, size_t len
, char **err_msg _U_
)
142 bytes
= g_byte_array_new();
147 g_byte_array_append(bytes
, (const uint8_t *)s
, (unsigned)len
);
149 /* Free up the old value, if we have one */
150 bytes_fvalue_free(fv
);
151 fv
->value
.bytes
= g_byte_array_free_to_bytes(bytes
);
157 byte_array_from_literal(const char *s
, char **err_msg
)
162 /* Skip leading colon if any. */
167 * Special case where the byte string is specified using a one byte
168 * hex literal. We can't allow this for byte strings that are longer
169 * than one byte, because then we'd have to know which endianness the
170 * byte string should be in.
172 if (strlen(s
) == 4 && s
[0] == '0' && (s
[1] == 'x' || s
[1] == 'X'))
175 bytes
= g_byte_array_new();
177 /* Hack: If we have a binary number 0bXXXXXXXX use that as a byte array
178 * of length one. This is ambiguous because it can also be
179 * parsed (without separators) as a byte array of length 5:
180 * 0bXXXXXXXX = 0b:XX:XX:XX:XX = { 0x0b, 0xXX, 0xXX, 0xXX, 0xXX } */
181 if (strlen(s
) == 10 && s
[0] == '0' && (s
[1] == 'b' || s
[1] == 'B') &&
182 (s
[2] == '0' || s
[2] == '1')) {
185 long number
= strtol(s
+ 2, &endptr
, 2);
186 if (errno
== 0 && *endptr
== '\0' && number
>= 0x0 && number
<= 0xff) {
187 uint8_t byte
= (uint8_t)number
;
188 g_byte_array_append(bytes
, &byte
, 1);
193 res
= hex_str_to_bytes(s
, bytes
, false);
197 *err_msg
= ws_strdup_printf("\"%s\" is not a valid byte string.", s
);
198 g_byte_array_free(bytes
, true);
206 bytes_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value _U_
, char **err_msg
)
210 bytes
= byte_array_from_literal(s
, err_msg
);
214 /* Free up the old value, if we have one */
215 bytes_fvalue_free(fv
);
217 fv
->value
.bytes
= g_byte_array_free_to_bytes(bytes
);
223 byte_array_from_charconst(unsigned long num
, char **err_msg
)
225 if (num
> UINT8_MAX
) {
227 *err_msg
= ws_strdup_printf("%lu is too large for a byte value", num
);
232 GByteArray
*bytes
= g_byte_array_new();
233 uint8_t one_byte
= (uint8_t)num
;
234 g_byte_array_append(bytes
, &one_byte
, 1);
239 bytes_from_charconst(fvalue_t
*fv
, unsigned long num
, char **err_msg
)
243 bytes
= byte_array_from_charconst(num
, err_msg
);
247 /* Free up the old value, if we have one */
248 bytes_fvalue_free(fv
);
250 fv
->value
.bytes
= g_byte_array_free_to_bytes(bytes
);
256 bytes_from_uinteger64(fvalue_t
*fv
, const char *s _U_
, uint64_t num
, char **err_msg
)
258 if (num
> UINT8_MAX
) {
260 *err_msg
= ws_strdup_printf("%s is too large for a byte value", s
);
265 return bytes_from_charconst(fv
, (unsigned long)num
, err_msg
);
269 bytes_from_sinteger64(fvalue_t
*fv
, const char *s
, int64_t num
, char **err_msg
)
273 *err_msg
= ws_strdup_printf("Byte values cannot be negative");
277 return bytes_from_uinteger64(fv
, s
, (uint64_t)num
, err_msg
);
281 vines_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value
, char **err_msg
)
284 * Don't request an error message if bytes_from_literal fails;
285 * if it does, we'll report an error specific to this address
288 if (bytes_from_literal(fv
, s
, true, NULL
)) {
289 if (g_bytes_get_size(fv
->value
.bytes
) > FT_VINES_ADDR_LEN
) {
290 if (err_msg
!= NULL
) {
291 *err_msg
= ws_strdup_printf("\"%s\" contains too many bytes to be a valid Vines address.",
296 else if (g_bytes_get_size(fv
->value
.bytes
) < FT_VINES_ADDR_LEN
&& !allow_partial_value
) {
297 if (err_msg
!= NULL
) {
298 *err_msg
= ws_strdup_printf("\"%s\" contains too few bytes to be a valid Vines address.",
307 /* XXX - need better validation of Vines address */
310 *err_msg
= ws_strdup_printf("\"%s\" is not a valid Vines address.", s
);
315 ether_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value
, char **err_msg
)
318 * Don't request an error message if bytes_from_literal fails;
319 * if it does, we'll report an error specific to this address
322 if (bytes_from_literal(fv
, s
, true, NULL
)) {
323 if (g_bytes_get_size(fv
->value
.bytes
) > FT_ETHER_LEN
) {
324 if (err_msg
!= NULL
) {
325 *err_msg
= ws_strdup_printf("\"%s\" contains too many bytes to be a valid Ethernet address.",
330 else if (g_bytes_get_size(fv
->value
.bytes
) < FT_ETHER_LEN
&& !allow_partial_value
) {
331 if (err_msg
!= NULL
) {
332 *err_msg
= ws_strdup_printf("\"%s\" contains too few bytes to be a valid Ethernet address.",
341 /* XXX - Try resolving as an Ethernet host name and parse that? */
344 *err_msg
= ws_strdup_printf("\"%s\" is not a valid Ethernet address.", s
);
349 oid_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value _U_
, char **err_msg
)
357 * Don't log a message if this fails; we'll try looking it
358 * up as an OID if it does, and if that fails,
359 * we'll log a message.
361 /* do not try it as '.' is handled as valid separator for hexbytes :( */
362 if (bytes_from_literal(fv
, s
, true, NULL
)) {
367 bytes
= g_byte_array_new();
368 res
= oid_str_to_bytes(s
, bytes
);
371 *err_msg
= ws_strdup_printf("\"%s\" is not a valid OBJECT IDENTIFIER.", s
);
372 g_byte_array_free(bytes
, true);
376 /* Free up the old value, if we have one */
377 bytes_fvalue_free(fv
);
378 fv
->value
.bytes
= g_byte_array_free_to_bytes(bytes
);
384 rel_oid_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value _U_
, char **err_msg
)
389 bytes
= g_byte_array_new();
390 res
= rel_oid_str_to_bytes(s
, bytes
, false);
393 *err_msg
= ws_strdup_printf("\"%s\" is not a valid RELATIVE-OID.", s
);
394 g_byte_array_free(bytes
, true);
398 /* Free up the old value, if we have one */
399 bytes_fvalue_free(fv
);
400 fv
->value
.bytes
= g_byte_array_free_to_bytes(bytes
);
406 system_id_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value _U_
, char **err_msg
)
409 * Don't request an error message if bytes_from_literal fails;
410 * if it does, we'll report an error specific to this address
413 if (bytes_from_literal(fv
, s
, true, NULL
)) {
414 if (g_bytes_get_size(fv
->value
.bytes
) > MAX_SYSTEMID_LEN
) {
415 if (err_msg
!= NULL
) {
416 *err_msg
= ws_strdup_printf("\"%s\" contains too many bytes to be a valid OSI System-ID.",
425 /* XXX - need better validation of OSI System-ID address */
428 *err_msg
= ws_strdup_printf("\"%s\" is not a valid OSI System-ID.", s
);
433 fcwwn_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value _U_
, char **err_msg
)
436 * Don't request an error message if bytes_from_literal fails;
437 * if it does, we'll report an error specific to this address
440 if (bytes_from_literal(fv
, s
, true, NULL
)) {
441 if (g_bytes_get_size(fv
->value
.bytes
) > FT_FCWWN_LEN
) {
442 if (err_msg
!= NULL
) {
443 *err_msg
= ws_strdup_printf("\"%s\" contains too many bytes to be a valid FCWWN.",
452 /* XXX - need better validation of FCWWN address */
455 *err_msg
= ws_strdup_printf("\"%s\" is not a valid FCWWN.", s
);
460 eui64_from_literal(fvalue_t
*fv
, const char *s
, bool allow_partial_value
, char **err_msg
)
463 * Don't request an error message if bytes_from_literal fails;
464 * if it does, we'll report an error specific to this address
467 if (bytes_from_literal(fv
, s
, true, NULL
)) {
468 if (g_bytes_get_size(fv
->value
.bytes
) > FT_EUI64_LEN
) {
469 if (err_msg
!= NULL
) {
470 *err_msg
= ws_strdup_printf("\"%s\" contains too many bytes to be a valid EUI-64 address.",
475 else if (g_bytes_get_size(fv
->value
.bytes
) < FT_EUI64_LEN
&& !allow_partial_value
) {
476 if (err_msg
!= NULL
) {
477 *err_msg
= ws_strdup_printf("\"%s\" contains too few bytes to be a valid EUI-64 address.",
486 /* XXX - Implement EUI-64 resolving (#15487) and lookup and parse that? */
489 *err_msg
= ws_strdup_printf("\"%s\" is not a valid EUI-64 address.", s
);
494 eui64_from_uinteger64(fvalue_t
*fv
, const char *s _U_
, uint64_t value
, char **err_msg _U_
)
496 /* Backwards compatibility for specifying as unsigned integer. */
497 uint8_t data
[FT_EUI64_LEN
];
498 phton64(data
, value
);
500 /* Free up the old value, if we have one */
501 bytes_fvalue_free(fv
);
502 fv
->value
.bytes
= g_bytes_new(data
, FT_EUI64_LEN
);
509 return (unsigned)g_bytes_get_size(fv
->value
.bytes
);
513 slice(fvalue_t
*fv
, GByteArray
*bytes
, unsigned offset
, unsigned length
)
515 const uint8_t *data
= (const uint8_t *)g_bytes_get_data(fv
->value
.bytes
, NULL
) + offset
;
516 g_byte_array_append(bytes
, data
, length
);
519 static enum ft_result
520 cmp_order(const fvalue_t
*fv_a
, const fvalue_t
*fv_b
, int *cmp
)
522 *cmp
= g_bytes_compare(fv_a
->value
.bytes
, fv_b
->value
.bytes
);
526 static enum ft_result
527 bytes_bitwise_and(fvalue_t
*fv_dst
, const fvalue_t
*fv_a
, const fvalue_t
*fv_b
, char **err_ptr _U_
)
530 const uint8_t *p_a
, *p_b
;
531 size_t size_a
, size_b
;
533 p_a
= g_bytes_get_data(fv_a
->value
.bytes
, &size_a
);
534 p_b
= g_bytes_get_data(fv_b
->value
.bytes
, &size_b
);
536 size_t len
= MIN(size_a
, size_b
);
538 fv_dst
->value
.bytes
= g_bytes_new(NULL
, 0);
542 dst
= g_byte_array_sized_new((unsigned)len
);
543 for (size_t i
= 0; i
< len
; i
++) {
544 uint8_t byte
= p_a
[i
] & p_b
[i
];
545 g_byte_array_append(dst
, &byte
, 1);
547 fv_dst
->value
.bytes
= g_byte_array_free_to_bytes(dst
);
551 static enum ft_result
552 cmp_contains(const fvalue_t
*fv_a
, const fvalue_t
*fv_b
, bool *contains
)
554 const void *data_a
, *data_b
;
555 size_t size_a
, size_b
;
557 data_a
= g_bytes_get_data(fv_a
->value
.bytes
, &size_a
);
558 data_b
= g_bytes_get_data(fv_b
->value
.bytes
, &size_b
);
560 if (ws_memmem(data_a
, size_a
, data_b
, size_b
)) {
570 static enum ft_result
571 cmp_matches(const fvalue_t
*fv
, const ws_regex_t
*regex
, bool *matches
)
576 data
= g_bytes_get_data(fv
->value
.bytes
, &data_size
);
578 *matches
= ws_regex_matches_length(regex
, data
, data_size
);
583 bytes_hash(const fvalue_t
*fv
)
585 return g_bytes_hash(fv
->value
.bytes
);
589 bytes_is_zero(const fvalue_t
*fv
)
594 data
= g_bytes_get_data(fv
->value
.bytes
, &data_size
);
599 for (size_t i
= 0; i
< data_size
; i
++) {
608 ftype_register_bytes(void)
611 static const ftype_t bytes_type
= {
612 FT_BYTES
, /* ftype */
614 bytes_fvalue_new
, /* new_value */
615 bytes_fvalue_copy
, /* copy_value */
616 bytes_fvalue_free
, /* free_value */
617 bytes_from_literal
, /* val_from_literal */
618 bytes_from_string
, /* val_from_string */
619 bytes_from_charconst
, /* val_from_charconst */
620 bytes_from_uinteger64
, /* val_from_uinteger64 */
621 bytes_from_sinteger64
, /* val_from_sinteger64 */
622 NULL
, /* val_from_double */
623 bytes_to_repr
, /* val_to_string_repr */
625 NULL
, /* val_to_uinteger64 */
626 NULL
, /* val_to_sinteger64 */
627 NULL
, /* val_to_double */
629 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
630 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
636 bytes_hash
, /* hash */
637 bytes_is_zero
, /* is_zero */
638 NULL
, /* is_negative */
641 bytes_bitwise_and
, /* bitwise_and */
642 NULL
, /* unary_minus */
650 static const ftype_t uint_bytes_type
= {
651 FT_UINT_BYTES
, /* ftype */
653 bytes_fvalue_new
, /* new_value */
654 bytes_fvalue_copy
, /* copy_value */
655 bytes_fvalue_free
, /* free_value */
656 bytes_from_literal
, /* val_from_literal */
657 NULL
, /* val_from_string */
658 NULL
, /* val_from_charconst */
659 NULL
, /* val_from_uinteger64 */
660 NULL
, /* val_from_sinteger64 */
661 NULL
, /* val_from_double */
662 bytes_to_repr
, /* val_to_string_repr */
664 NULL
, /* val_to_uinteger64 */
665 NULL
, /* val_to_sinteger64 */
666 NULL
, /* val_to_double */
668 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
669 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
673 NULL
, /* cmp_matches */
675 bytes_hash
, /* hash */
676 bytes_is_zero
, /* is_zero */
677 NULL
, /* is_negative */
680 bytes_bitwise_and
, /* bitwise_and */
681 NULL
, /* unary_minus */
689 static const ftype_t vines_type
= {
690 FT_VINES
, /* ftype */
691 FT_VINES_ADDR_LEN
, /* wire_size */
692 bytes_fvalue_new
, /* new_value */
693 bytes_fvalue_copy
, /* copy_value */
694 bytes_fvalue_free
, /* free_value */
695 vines_from_literal
, /* val_from_literal */
696 NULL
, /* val_from_string */
697 NULL
, /* val_from_charconst */
698 NULL
, /* val_from_uinteger64 */
699 NULL
, /* val_from_sinteger64 */
700 NULL
, /* val_from_double */
701 bytes_to_repr
, /* val_to_string_repr */
703 NULL
, /* val_to_uinteger64 */
704 NULL
, /* val_to_sinteger64 */
705 NULL
, /* val_to_double */
707 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
708 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
714 bytes_hash
, /* hash */
715 bytes_is_zero
, /* is_zero */
716 NULL
, /* is_negative */
719 bytes_bitwise_and
, /* bitwise_and */
720 NULL
, /* unary_minus */
728 static const ftype_t ether_type
= {
729 FT_ETHER
, /* ftype */
730 FT_ETHER_LEN
, /* wire_size */
731 bytes_fvalue_new
, /* new_value */
732 bytes_fvalue_copy
, /* copy_value */
733 bytes_fvalue_free
, /* free_value */
734 ether_from_literal
, /* val_from_literal */
735 NULL
, /* val_from_string */
736 NULL
, /* val_from_charconst */
737 NULL
, /* val_from_uinteger64 */
738 NULL
, /* val_from_sinteger64 */
739 NULL
, /* val_from_double */
740 bytes_to_repr
, /* val_to_string_repr */
742 NULL
, /* val_to_uinteger64 */
743 NULL
, /* val_to_sinteger64 */
744 NULL
, /* val_to_double */
746 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
747 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
753 bytes_hash
, /* hash */
754 bytes_is_zero
, /* is_zero */
755 NULL
, /* is_negative */
758 bytes_bitwise_and
, /* bitwise_and */
759 NULL
, /* unary_minus */
767 static const ftype_t oid_type
= {
770 bytes_fvalue_new
, /* new_value */
771 bytes_fvalue_copy
, /* copy_value */
772 bytes_fvalue_free
, /* free_value */
773 oid_from_literal
, /* val_from_literal */
774 NULL
, /* val_from_string */
775 NULL
, /* val_from_charconst */
776 NULL
, /* val_from_uinteger64 */
777 NULL
, /* val_from_sinteger64 */
778 NULL
, /* val_from_double */
779 oid_to_repr
, /* val_to_string_repr */
781 NULL
, /* val_to_uinteger64 */
782 NULL
, /* val_to_sinteger64 */
783 NULL
, /* val_to_double */
785 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
786 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
790 NULL
, /* cmp_matches */
792 bytes_hash
, /* hash */
793 bytes_is_zero
, /* is_zero */
794 NULL
, /* is_negative */
797 bytes_bitwise_and
, /* bitwise_and */
798 NULL
, /* unary_minus */
806 static const ftype_t rel_oid_type
= {
807 FT_REL_OID
, /* ftype */
809 bytes_fvalue_new
, /* new_value */
810 bytes_fvalue_copy
, /* copy_value */
811 bytes_fvalue_free
, /* free_value */
812 rel_oid_from_literal
, /* val_from_literal */
813 NULL
, /* val_from_string */
814 NULL
, /* val_from_charconst */
815 NULL
, /* val_from_uinteger64 */
816 NULL
, /* val_from_sinteger64 */
817 NULL
, /* val_from_double */
818 rel_oid_to_repr
, /* val_to_string_repr */
820 NULL
, /* val_to_uinteger64 */
821 NULL
, /* val_to_sinteger64 */
822 NULL
, /* val_to_double */
824 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
825 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
829 NULL
, /* cmp_matches */
831 bytes_hash
, /* hash */
832 bytes_is_zero
, /* is_zero */
833 NULL
, /* is_negative */
836 bytes_bitwise_and
, /* bitwise_and */
837 NULL
, /* unary_minus */
845 static const ftype_t system_id_type
= {
846 FT_SYSTEM_ID
, /* ftype */
848 bytes_fvalue_new
, /* new_value */
849 bytes_fvalue_copy
, /* copy_value */
850 bytes_fvalue_free
, /* free_value */
851 system_id_from_literal
, /* val_from_literal */
852 NULL
, /* val_from_string */
853 NULL
, /* val_from_charconst */
854 NULL
, /* val_from_uinteger64 */
855 NULL
, /* val_from_sinteger64 */
856 NULL
, /* val_from_double */
857 system_id_to_repr
, /* val_to_string_repr */
859 NULL
, /* val_to_uinteger64 */
860 NULL
, /* val_to_sinteger64 */
861 NULL
, /* val_to_double */
863 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
864 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
868 NULL
, /* cmp_matches */
870 bytes_hash
, /* hash */
871 bytes_is_zero
, /* is_zero */
872 NULL
, /* is_negative */
875 bytes_bitwise_and
, /* bitwise_and */
876 NULL
, /* unary_minus */
884 static const ftype_t fcwwn_type
= {
885 FT_FCWWN
, /* ftype */
886 FT_FCWWN_LEN
, /* wire_size */
887 bytes_fvalue_new
, /* new_value */
888 bytes_fvalue_copy
, /* copy_value */
889 bytes_fvalue_free
, /* free_value */
890 fcwwn_from_literal
, /* val_from_literal */
891 NULL
, /* val_from_string */
892 NULL
, /* val_from_charconst */
893 NULL
, /* val_from_uinteger64 */
894 NULL
, /* val_from_sinteger64 */
895 NULL
, /* val_from_double */
896 bytes_to_repr
, /* val_to_string_repr */
898 NULL
, /* val_to_uinteger64 */
899 NULL
, /* val_to_sinteger64 */
900 NULL
, /* val_to_double */
902 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
903 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
909 bytes_hash
, /* hash */
910 bytes_is_zero
, /* is_zero */
911 NULL
, /* is_negative */
914 bytes_bitwise_and
, /* bitwise_and */
915 NULL
, /* unary_minus */
923 static const ftype_t eui64_type
= {
924 FT_EUI64
, /* ftype */
925 FT_EUI64_LEN
, /* wire_size */
926 bytes_fvalue_new
, /* new_value */
927 bytes_fvalue_copy
, /* copy_value */
928 bytes_fvalue_free
, /* free_value */
929 eui64_from_literal
, /* val_from_literal */
930 NULL
, /* val_from_string */
931 NULL
, /* val_from_charconst */
932 eui64_from_uinteger64
, /* val_from_uinteger64 */
933 NULL
, /* val_from_sinteger64 */
934 NULL
, /* val_from_double */
935 bytes_to_repr
, /* val_to_string_repr */
937 NULL
, /* val_to_uinteger64 */
938 NULL
, /* val_to_sinteger64 */
939 NULL
, /* val_to_double */
941 { .set_value_bytes
= bytes_fvalue_set
}, /* union set_value */
942 { .get_value_bytes
= bytes_fvalue_get
}, /* union get_value */
948 bytes_hash
, /* hash */
949 bytes_is_zero
, /* is_zero */
950 NULL
, /* is_negative */
953 bytes_bitwise_and
, /* bitwise_and */
954 NULL
, /* unary_minus */
962 ftype_register(FT_BYTES
, &bytes_type
);
963 ftype_register(FT_UINT_BYTES
, &uint_bytes_type
);
964 ftype_register(FT_VINES
, &vines_type
);
965 ftype_register(FT_ETHER
, ðer_type
);
966 ftype_register(FT_OID
, &oid_type
);
967 ftype_register(FT_REL_OID
, &rel_oid_type
);
968 ftype_register(FT_SYSTEM_ID
, &system_id_type
);
969 ftype_register(FT_FCWWN
, &fcwwn_type
);
970 ftype_register(FT_EUI64
, &eui64_type
);
974 ftype_register_pseudofields_bytes(int proto
)
976 static int hf_ft_bytes
;
977 static int hf_ft_uint_bytes
;
978 static int hf_ft_vines
;
979 static int hf_ft_ether
;
980 static int hf_ft_oid
;
981 static int hf_ft_rel_oid
;
982 static int hf_ft_system_id
;
983 static int hf_ft_eui64
;
985 static hf_register_info hf_ftypes
[] = {
987 { "FT_BYTES", "_ws.ftypes.bytes",
988 FT_BYTES
, BASE_NONE
, NULL
, 0x00,
992 { "FT_UINT_BYTES", "_ws.ftypes.uint_bytes",
993 FT_UINT_BYTES
, BASE_NONE
, NULL
, 0x00,
997 { "FT_VINES", "_ws.ftypes.vines",
998 FT_VINES
, BASE_NONE
, NULL
, 0x00,
1002 { "FT_ETHER", "_ws.ftypes.ether",
1003 FT_ETHER
, BASE_NONE
, NULL
, 0x00,
1007 { "FT_OID", "_ws.ftypes.oid",
1008 FT_OID
, BASE_NONE
, NULL
, 0x00,
1012 { "FT_REL_OID", "_ws.ftypes.rel_oid",
1013 FT_REL_OID
, BASE_NONE
, NULL
, 0x00,
1017 { "FT_SYSTEM_ID", "_ws.ftypes.system_id",
1018 FT_SYSTEM_ID
, BASE_NONE
, NULL
, 0x00,
1022 { "FT_EUI64", "_ws.ftypes.eui64",
1023 FT_EUI64
, BASE_NONE
, NULL
, 0x00,
1028 proto_register_field_array(proto
, hf_ftypes
, array_length(hf_ftypes
));
1032 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1037 * indent-tabs-mode: t
1040 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1041 * :indentSize=8:tabSize=8:noTabs=false: