Add "tvb_get_ntoh64()" and "tvb_get_letoh64()" routines to fetch 64-bit
[obnox/wireshark/wip.git] / epan / ftypes / ftype-integer.c
1 /*
2  * $Id$
3  *
4  * Ethereal - Network traffic analyzer
5  * By Gerald Combs <gerald@ethereal.com>
6  * Copyright 2001 Gerald Combs
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include <stdlib.h>
28 #include <errno.h>
29 #include "ftypes-int.h"
30 #include <epan/addr_resolv.h>
31
32 /*
33  * GLib 1.2[.x] doesn't define G_MAXUINT32; if it's not defined, we define
34  * it as the maximum 32-bit unsigned number.
35  */
36 #ifndef G_MAXUINT32
37 #define G_MAXUINT32     ((guint32)0xFFFFFFFF)
38 #endif
39
40 static void
41 int_fvalue_new(fvalue_t *fv)
42 {
43         fv->value.integer = 0;
44 }
45
46 static void
47 set_integer(fvalue_t *fv, guint32 value)
48 {
49         fv->value.integer = value;
50 }
51
52 static guint32
53 get_integer(fvalue_t *fv)
54 {
55         return fv->value.integer;
56 }
57
58 static gboolean
59 val_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
60 {
61         unsigned long value;
62         char    *endptr;
63
64         errno = 0;
65         value = strtoul(s, &endptr, 0);
66
67         if (errno == EINVAL || endptr == s || *endptr != '\0') {
68                 /* This isn't a valid number. */
69                 if (logfunc != NULL)
70                         logfunc("\"%s\" is not a valid number.", s);
71                 return FALSE;
72         }
73         if (errno == ERANGE) {
74                 if (logfunc != NULL) {
75                         if (value == ULONG_MAX) {
76                                 logfunc("\"%s\" causes an integer overflow.",
77                                     s);
78                         }
79                         else {
80                                 /*
81                                  * XXX - can "strtoul()" set errno to
82                                  * ERANGE without returning ULONG_MAX?
83                                  */
84                                 logfunc("\"%s\" is not an integer.", s);
85                         }
86                 }
87                 return FALSE;
88         }
89         if (value > G_MAXUINT32) {
90                 /*
91                  * Fits in an unsigned long, but not in a guint32
92                  * (an unsigned long might be 64 bits).
93                  */
94                 if (logfunc != NULL)
95                         logfunc("\"%s\" causes an integer overflow.", s);
96                 return FALSE;
97         }
98
99         fv->value.integer = value;
100         return TRUE;
101 }
102
103 static gboolean
104 ipxnet_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
105 {
106         guint32         val;
107         gboolean        known;
108
109         /*
110          * Don't log a message if this fails; we'll try looking it
111          * up as an IPX network name if it does, and if that fails,
112          * we'll log a message.
113          */
114         if (val_from_unparsed(fv, s, TRUE, NULL)) {
115                 return TRUE;
116         }
117
118         val = get_ipxnet_addr(s, &known);
119         if (known) {
120                 fv->value.integer = val;
121                 return TRUE;
122         }
123
124         logfunc("\"%s\" is not a valid IPX network name or address.", s);
125         return FALSE;
126 }
127
128 static gboolean
129 cmp_eq(fvalue_t *a, fvalue_t *b)
130 {
131         return a->value.integer == b->value.integer;
132 }
133
134 static gboolean
135 cmp_ne(fvalue_t *a, fvalue_t *b)
136 {
137         return a->value.integer != b->value.integer;
138 }
139
140 static gboolean
141 u_cmp_gt(fvalue_t *a, fvalue_t *b)
142 {
143         return (int)a->value.integer > (int)b->value.integer;
144 }
145
146 static gboolean
147 u_cmp_ge(fvalue_t *a, fvalue_t *b)
148 {
149         return (int)a->value.integer >= (int)b->value.integer;
150 }
151
152 static gboolean
153 u_cmp_lt(fvalue_t *a, fvalue_t *b)
154 {
155         return (int)a->value.integer < (int)b->value.integer;
156 }
157
158 static gboolean
159 u_cmp_le(fvalue_t *a, fvalue_t *b)
160 {
161         return (int)a->value.integer <= (int)b->value.integer;
162 }
163
164 static gboolean
165 s_cmp_gt(fvalue_t *a, fvalue_t *b)
166 {
167         return a->value.integer > b->value.integer;
168 }
169
170 static gboolean
171 s_cmp_ge(fvalue_t *a, fvalue_t *b)
172 {
173         return a->value.integer >= b->value.integer;
174 }
175
176 static gboolean
177 s_cmp_lt(fvalue_t *a, fvalue_t *b)
178 {
179         return a->value.integer < b->value.integer;
180 }
181
182 static gboolean
183 s_cmp_le(fvalue_t *a, fvalue_t *b)
184 {
185         return a->value.integer <= b->value.integer;
186 }
187
188 static gboolean
189 cmp_bitwise_and(fvalue_t *a, fvalue_t *b)
190 {
191         return (a->value.integer & b->value.integer);
192 }
193
194 static void
195 int64_fvalue_new(fvalue_t *fv)
196 {
197         fv->value.integer64 = 0;
198 }
199
200 static void
201 set_integer64(fvalue_t *fv, guint64 value)
202 {
203         fv->value.integer64 = value;
204 }
205
206 static guint64
207 get_integer64(fvalue_t *fv)
208 {
209         return fv->value.integer64;
210 }
211
212 static gboolean
213 val64_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
214 {
215         guint64 value;
216         char    *endptr;
217
218         errno = 0;
219         value = strtoull(s, &endptr, 0);
220
221         if (errno == EINVAL || endptr == s || *endptr != '\0') {
222                 /* This isn't a valid number. */
223                 if (logfunc != NULL)
224                         logfunc("\"%s\" is not a valid number.", s);
225                 return FALSE;
226         }
227         if (errno == ERANGE) {
228                 if (logfunc != NULL) {
229                         if (value == ULONG_MAX) {
230                                 logfunc("\"%s\" causes an integer overflow.",
231                                     s);
232                         }
233                         else {
234                                 /*
235                                  * XXX - can "strtoul()" set errno to
236                                  * ERANGE without returning ULONG_MAX?
237                                  */
238                                 logfunc("\"%s\" is not an integer.", s);
239                         }
240                 }
241                 return FALSE;
242         }
243         if (value > G_MAXUINT64) {
244                 /*
245                  * Fits in an unsigned long, but not in a guint64
246                  * (unlikely, but not impossible).
247                  */
248                 if (logfunc != NULL)
249                         logfunc("\"%s\" causes an integer overflow.", s);
250                 return FALSE;
251         }
252
253         fv->value.integer64 = value;
254         return TRUE;
255 }
256
257 static gboolean
258 cmp_eq64(fvalue_t *a, fvalue_t *b)
259 {
260         return a->value.integer64 == b->value.integer64;
261 }
262
263 static gboolean
264 cmp_ne64(fvalue_t *a, fvalue_t *b)
265 {
266         return a->value.integer64 != b->value.integer64;
267 }
268
269 static gboolean
270 u_cmp_gt64(fvalue_t *a, fvalue_t *b)
271 {
272         return (gint64)a->value.integer64 > (gint64)b->value.integer64;
273 }
274
275 static gboolean
276 u_cmp_ge64(fvalue_t *a, fvalue_t *b)
277 {
278         return (gint64)a->value.integer64 >= (gint64)b->value.integer64;
279 }
280
281 static gboolean
282 u_cmp_lt64(fvalue_t *a, fvalue_t *b)
283 {
284         return (gint64)a->value.integer64 < (gint64)b->value.integer64;
285 }
286
287 static gboolean
288 u_cmp_le64(fvalue_t *a, fvalue_t *b)
289 {
290         return (gint64)a->value.integer64 <= (gint64)b->value.integer64;
291 }
292
293 static gboolean
294 s_cmp_gt64(fvalue_t *a, fvalue_t *b)
295 {
296         return a->value.integer64 > b->value.integer64;
297 }
298
299 static gboolean
300 s_cmp_ge64(fvalue_t *a, fvalue_t *b)
301 {
302         return a->value.integer64 >= b->value.integer64;
303 }
304
305 static gboolean
306 s_cmp_lt64(fvalue_t *a, fvalue_t *b)
307 {
308         return a->value.integer64 < b->value.integer64;
309 }
310
311 static gboolean
312 s_cmp_le64(fvalue_t *a, fvalue_t *b)
313 {
314         return a->value.integer64 <= b->value.integer64;
315 }
316
317 static gboolean
318 cmp_bitwise_and64(fvalue_t *a, fvalue_t *b)
319 {
320         return (a->value.integer64 & b->value.integer64);
321 }
322
323 /* BOOLEAN-specific */
324
325 static void
326 boolean_fvalue_new(fvalue_t *fv)
327 {
328         fv->value.integer = TRUE;
329 }
330
331 static int
332 boolean_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_)
333 {
334         return 1;
335 }
336
337 static void
338 boolean_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf)
339 {
340         sprintf(buf, "%s", fv->value.integer ? "1" : "0");
341 }
342
343 /* Checks for equality with zero or non-zero */
344 static gboolean
345 bool_eq(fvalue_t *a, fvalue_t *b)
346 {
347         if (a->value.integer) {
348                 if (b->value.integer) {
349                         return TRUE;
350                 }
351                 else {
352                         return FALSE;
353                 }
354         }
355         else {
356                 if (b->value.integer) {
357                         return FALSE;
358                 }
359                 else {
360                         return TRUE;
361                 }
362         }
363 }
364
365 /* Checks for inequality with zero or non-zero */
366 static gboolean
367 bool_ne(fvalue_t *a, fvalue_t *b)
368 {
369         return (!bool_eq(a,b));
370 }
371
372
373
374 void
375 ftype_register_integers(void)
376 {
377
378         static ftype_t uint8_type = {
379                 "FT_UINT8",                     /* name */
380                 "unsigned, 1 byte",             /* pretty name */
381                 1,                              /* wire_size */
382                 int_fvalue_new,                 /* new_value */
383                 NULL,                           /* free_value */
384                 val_from_unparsed,              /* val_from_unparsed */
385                 NULL,                           /* val_from_string */
386                 NULL,                           /* val_to_string_repr */
387                 NULL,                           /* len_string_repr */
388
389                 NULL,                           /* set_value */
390                 set_integer,                    /* set_value_integer */
391                 NULL,                           /* set_value_integer64 */
392                 NULL,                           /* set_value_floating */
393
394                 NULL,                           /* get_value */
395                 get_integer,                    /* get_value_integer */
396                 NULL,                           /* get_value_integer64 */
397                 NULL,                           /* get_value_floating */
398
399                 cmp_eq,
400                 cmp_ne,
401                 u_cmp_gt,
402                 u_cmp_ge,
403                 u_cmp_lt,
404                 u_cmp_le,
405                 cmp_bitwise_and,
406                 NULL,                           /* cmp_contains */
407                 NULL,                           /* cmp_matches */
408
409                 NULL,                           /* len */
410                 NULL,                           /* slice */
411         };
412         static ftype_t uint16_type = {
413                 "FT_UINT16",                    /* name */
414                 "unsigned, 2 bytes",            /* pretty_name */
415                 2,                              /* wire_size */
416                 int_fvalue_new,                 /* new_value */
417                 NULL,                           /* free_value */
418                 val_from_unparsed,              /* val_from_unparsed */
419                 NULL,                           /* val_from_string */
420                 NULL,                           /* val_to_string_repr */
421                 NULL,                           /* len_string_repr */
422
423                 NULL,                           /* set_value */
424                 set_integer,                    /* set_value_integer */
425                 NULL,                           /* set_value_integer64 */
426                 NULL,                           /* set_value_floating */
427
428                 NULL,                           /* get_value */
429                 get_integer,                    /* get_value_integer */
430                 NULL,                           /* get_value_integer64 */
431                 NULL,                           /* get_value_floating */
432
433                 cmp_eq,
434                 cmp_ne,
435                 u_cmp_gt,
436                 u_cmp_ge,
437                 u_cmp_lt,
438                 u_cmp_le,
439                 cmp_bitwise_and,
440                 NULL,                           /* cmp_contains */
441                 NULL,                           /* cmp_matches */
442
443                 NULL,                           /* len */
444                 NULL,                           /* slice */
445         };
446         static ftype_t uint24_type = {
447                 "FT_UINT24",                    /* name */
448                 "unsigned, 3 bytes",            /* pretty_name */
449                 3,                              /* wire_size */
450                 int_fvalue_new,                 /* new_value */
451                 NULL,                           /* free_value */
452                 val_from_unparsed,              /* val_from_unparsed */
453                 NULL,                           /* val_from_string */
454                 NULL,                           /* val_to_string_repr */
455                 NULL,                           /* len_string_repr */
456
457                 NULL,                           /* set_value */
458                 set_integer,                    /* set_value_integer */
459                 NULL,                           /* set_value_integer64 */
460                 NULL,                           /* set_value_floating */
461
462                 NULL,                           /* get_value */
463                 get_integer,                    /* get_value_integer */
464                 NULL,                           /* get_value_integer64 */
465                 NULL,                           /* get_value_floating */
466
467                 cmp_eq,
468                 cmp_ne,
469                 u_cmp_gt,
470                 u_cmp_ge,
471                 u_cmp_lt,
472                 u_cmp_le,
473                 cmp_bitwise_and,
474                 NULL,                           /* cmp_contains */
475                 NULL,                           /* cmp_matches */
476
477                 NULL,                           /* len */
478                 NULL,                           /* slice */
479         };
480         static ftype_t uint32_type = {
481                 "FT_UINT32",                    /* name */
482                 "unsigned, 4 bytes",            /* pretty_name */
483                 4,                              /* wire_size */
484                 int_fvalue_new,                 /* new_value */
485                 NULL,                           /* free_value */
486                 val_from_unparsed,              /* val_from_unparsed */
487                 NULL,                           /* val_from_string */
488                 NULL,                           /* val_to_string_repr */
489                 NULL,                           /* len_string_repr */
490
491                 NULL,                           /* set_value */
492                 set_integer,                    /* set_value_integer */
493                 NULL,                           /* set_value_integer64 */
494                 NULL,                           /* set_value_floating */
495
496                 NULL,                           /* get_value */
497                 get_integer,                    /* get_value_integer */
498                 NULL,                           /* get_value_integer64 */
499                 NULL,                           /* get_value_floating */
500
501                 cmp_eq,
502                 cmp_ne,
503                 u_cmp_gt,
504                 u_cmp_ge,
505                 u_cmp_lt,
506                 u_cmp_le,
507                 cmp_bitwise_and,
508                 NULL,                           /* cmp_contains */
509                 NULL,                           /* cmp_matches */
510
511                 NULL,                           /* len */
512                 NULL,                           /* slice */
513         };
514         static ftype_t uint64_type = {
515                 "FT_UINT64",                    /* name */
516                 "unsigned, 8 bytes",            /* pretty_name */
517                 8,                              /* wire_size */
518                 int64_fvalue_new,               /* new_value */
519                 NULL,                           /* free_value */
520                 val64_from_unparsed,            /* val_from_unparsed */
521                 NULL,                           /* val_from_string */
522                 NULL,                           /* val_to_string_repr */
523                 NULL,                           /* len_string_repr */
524
525                 NULL,                           /* set_value */
526                 NULL,                           /* set_value_integer */
527                 set_integer64,                  /* set_value_integer64 */
528                 NULL,                           /* set_value_floating */
529
530                 NULL,                           /* get_value */
531                 NULL,                           /* get_value_integer */
532                 get_integer64,                  /* get_value_integer64 */
533                 NULL,                           /* get_value_floating */
534
535                 cmp_eq64,
536                 cmp_ne64,
537                 u_cmp_gt64,
538                 u_cmp_ge64,
539                 u_cmp_lt64,
540                 u_cmp_le64,
541                 cmp_bitwise_and64,
542                 NULL,                           /* cmp_contains */
543                 NULL,                           /* cmp_matches */
544
545                 NULL,
546                 NULL,
547         };
548         static ftype_t int8_type = {
549                 "FT_INT8",                      /* name */
550                 "signed, 1 byte",               /* pretty_name */
551                 1,                              /* wire_size */
552                 int_fvalue_new,                 /* new_value */
553                 NULL,                           /* free_value */
554                 val_from_unparsed,              /* val_from_unparsed */
555                 NULL,                           /* val_from_string */
556                 NULL,                           /* val_to_string_repr */
557                 NULL,                           /* len_string_repr */
558
559                 NULL,                           /* set_value */
560                 set_integer,                    /* set_value_integer */
561                 NULL,                           /* set_value_integer64 */
562                 NULL,                           /* set_value_floating */
563
564                 NULL,                           /* get_value */
565                 get_integer,                    /* get_value_integer */
566                 NULL,                           /* get_value_integer64 */
567                 NULL,                           /* get_value_floating */
568
569                 cmp_eq,
570                 cmp_ne,
571                 s_cmp_gt,
572                 s_cmp_ge,
573                 s_cmp_lt,
574                 s_cmp_le,
575                 cmp_bitwise_and,
576                 NULL,                           /* cmp_contains */
577                 NULL,                           /* cmp_matches */
578
579                 NULL,                           /* len */
580                 NULL,                           /* slice */
581         };
582         static ftype_t int16_type = {
583                 "FT_INT16",                     /* name */
584                 "signed, 2 bytes",              /* pretty_name */
585                 2,                              /* wire_size */
586                 int_fvalue_new,                 /* new_value */
587                 NULL,                           /* free_value */
588                 val_from_unparsed,              /* val_from_unparsed */
589                 NULL,                           /* val_from_string */
590                 NULL,                           /* val_to_string_repr */
591                 NULL,                           /* len_string_repr */
592
593                 NULL,                           /* set_value */
594                 set_integer,                    /* set_value_integer */
595                 NULL,                           /* set_value_integer64 */
596                 NULL,                           /* set_value_floating */
597
598                 NULL,                           /* get_value */
599                 get_integer,                    /* get_value_integer */
600                 NULL,                           /* get_value_integer64 */
601                 NULL,                           /* get_value_floating */
602
603                 cmp_eq,
604                 cmp_ne,
605                 s_cmp_gt,
606                 s_cmp_ge,
607                 s_cmp_lt,
608                 s_cmp_le,
609                 cmp_bitwise_and,
610                 NULL,                           /* cmp_contains */
611                 NULL,                           /* cmp_matches */
612
613                 NULL,                           /* len */
614                 NULL,                           /* slice */
615         };
616         static ftype_t int24_type = {
617                 "FT_INT24",                     /* name */
618                 "signed, 3 bytes",              /* pretty_name */
619                 3,                              /* wire_size */
620                 int_fvalue_new,                 /* new_value */
621                 NULL,                           /* free_value */
622                 val_from_unparsed,              /* val_from_unparsed */
623                 NULL,                           /* val_from_string */
624                 NULL,                           /* val_to_string_repr */
625                 NULL,                           /* len_string_repr */
626
627                 NULL,                           /* set_value */
628                 set_integer,                    /* set_value_integer */
629                 NULL,                           /* set_value_integer64 */
630                 NULL,                           /* set_value_floating */
631
632                 NULL,                           /* get_value */
633                 get_integer,                    /* get_value_integer */
634                 NULL,                           /* get_value_integer64 */
635                 NULL,                           /* get_value_floating */
636
637                 cmp_eq,
638                 cmp_ne,
639                 s_cmp_gt,
640                 s_cmp_ge,
641                 s_cmp_lt,
642                 s_cmp_le,
643                 cmp_bitwise_and,
644                 NULL,                           /* cmp_contains */
645                 NULL,                           /* cmp_matches */
646
647                 NULL,                           /* len */
648                 NULL,                           /* slice */
649         };
650         static ftype_t int32_type = {
651                 "FT_INT32",                     /* name */
652                 "signed, 4 bytes",              /* pretty_name */
653                 4,                              /* wire_size */
654                 int_fvalue_new,                 /* new_value */
655                 NULL,                           /* free_value */
656                 val_from_unparsed,              /* val_from_unparsed */
657                 NULL,                           /* val_from_string */
658                 NULL,                           /* val_to_string_repr */
659                 NULL,                           /* len_string_repr */
660
661                 NULL,                           /* set_value */
662                 set_integer,                    /* set_value_integer */
663                 NULL,                           /* set_value_integer64 */
664                 NULL,                           /* set_value_floating */
665
666                 NULL,                           /* get_value */
667                 get_integer,                    /* get_value_integer */
668                 NULL,                           /* get_value_integer64 */
669                 NULL,                           /* get_value_floating */
670
671                 cmp_eq,
672                 cmp_ne,
673                 s_cmp_gt,
674                 s_cmp_ge,
675                 s_cmp_lt,
676                 s_cmp_le,
677                 cmp_bitwise_and,
678                 NULL,                           /* cmp_contains */
679                 NULL,                           /* cmp_matches */
680
681                 NULL,                           /* len */
682                 NULL,                           /* slice */
683         };
684         static ftype_t int64_type = {
685                 "FT_INT64",                     /* name */
686                 "signed, 8 bytes",              /* pretty_name */
687                 8,                              /* wire_size */
688                 int64_fvalue_new,               /* new_value */
689                 NULL,                           /* free_value */
690                 val64_from_unparsed,            /* val_from_unparsed */
691                 NULL,                           /* val_from_string */
692                 NULL,                           /* val_to_string_repr */
693                 NULL,                           /* len_string_repr */
694
695                 NULL,                           /* set_value */
696                 NULL,                           /* set_value_integer */
697                 set_integer64,                  /* set_value_integer64 */
698                 NULL,                           /* set_value_floating */
699
700                 NULL,                           /* get_value */
701                 NULL,                           /* get_value_integer */
702                 get_integer64,                  /* get_value_integer64 */
703                 NULL,                           /* get_value_floating */
704
705                 cmp_eq64,
706                 cmp_ne64,
707                 s_cmp_gt64,
708                 s_cmp_ge64,
709                 s_cmp_lt64,
710                 s_cmp_le64,
711                 cmp_bitwise_and64,
712                 NULL,                           /* cmp_contains */
713                 NULL,                           /* cmp_matches */
714
715                 NULL,
716                 NULL,
717         };
718         static ftype_t boolean_type = {
719                 "FT_BOOLEAN",                   /* name */
720                 "Boolean",                      /* pretty_name */
721                 0,                              /* wire_size */
722                 boolean_fvalue_new,             /* new_value */
723                 NULL,                           /* free_value */
724                 val_from_unparsed,              /* val_from_unparsed */
725                 NULL,                           /* val_from_string */
726                 boolean_to_repr,                /* val_to_string_repr */
727                 boolean_repr_len,               /* len_string_repr */
728
729                 NULL,                           /* set_value */
730                 set_integer,                    /* set_value_integer */
731                 NULL,                           /* set_value_integer64 */
732                 NULL,                           /* set_value_floating */
733
734                 NULL,                           /* get_value */
735                 get_integer,                    /* get_value_integer */
736                 NULL,                           /* get_value_integer64 */
737                 NULL,                           /* get_value_floating */
738
739                 bool_eq,                        /* cmp_eq */
740                 bool_ne,                        /* cmp_ne */
741                 NULL,                           /* cmp_gt */
742                 NULL,                           /* cmp_ge */
743                 NULL,                           /* cmp_lt */
744                 NULL,                           /* cmp_le */
745                 NULL,                           /* cmp_bitwise_and */
746                 NULL,                           /* cmp_contains */
747                 NULL,                           /* cmp_matches */
748
749                 NULL,                           /* len */
750                 NULL,                           /* slice */
751         };
752
753         static ftype_t ipxnet_type = {
754                 "FT_IPXNET",                    /* name */
755                 "IPX network number",           /* pretty_name */
756                 4,                              /* wire_size */
757                 int_fvalue_new,                 /* new_value */
758                 NULL,                           /* free_value */
759                 ipxnet_from_unparsed,           /* val_from_unparsed */
760                 NULL,                           /* val_from_string */
761                 NULL,                           /* val_to_string_repr */
762                 NULL,                           /* len_string_repr */
763
764                 NULL,                           /* set_value */
765                 set_integer,                    /* set_value_integer */
766                 NULL,                           /* set_value_integer64 */
767                 NULL,                           /* set_value_floating */
768
769                 NULL,                           /* get_value */
770                 get_integer,                    /* get_value_integer */
771                 NULL,                           /* get_value_integer64 */
772                 NULL,                           /* get_value_floating */
773
774                 cmp_eq,
775                 cmp_ne,
776                 u_cmp_gt,
777                 u_cmp_ge,
778                 u_cmp_lt,
779                 u_cmp_le,
780                 cmp_bitwise_and,
781                 NULL,                           /* cmp_contains */
782                 NULL,                           /* cmp_matches */
783
784                 NULL,                           /* len */
785                 NULL,                           /* slice */
786         };
787
788         static ftype_t framenum_type = {
789                 "FT_FRAMENUM",                  /* name */
790                 "frame number",                 /* pretty_name */
791                 4,                              /* wire_size */
792                 int_fvalue_new,                 /* new_value */
793                 NULL,                           /* free_value */
794                 val_from_unparsed,              /* val_from_unparsed */
795                 NULL,                           /* val_from_string */
796                 NULL,                           /* val_to_string_repr */
797                 NULL,                           /* len_string_repr */
798
799                 NULL,                           /* set_value */
800                 set_integer,                    /* set_value_integer */
801                 NULL,                           /* set_value_integer64 */
802                 NULL,                           /* set_value_floating */
803
804                 NULL,                           /* get_value */
805                 get_integer,                    /* get_value_integer */
806                 NULL,                           /* get_value_integer64 */
807                 NULL,                           /* get_value_floating */
808
809                 cmp_eq,
810                 cmp_ne,
811                 u_cmp_gt,
812                 u_cmp_ge,
813                 u_cmp_lt,
814                 u_cmp_le,
815                 NULL,                           /* cmp_bitwise_and */
816                 NULL,                           /* cmp_contains */
817                 NULL,                           /* cmp_matches */
818
819                 NULL,                           /* len */
820                 NULL,                           /* slice */
821         };
822
823         ftype_register(FT_UINT8, &uint8_type);
824         ftype_register(FT_UINT16, &uint16_type);
825         ftype_register(FT_UINT24, &uint24_type);
826         ftype_register(FT_UINT32, &uint32_type);
827         ftype_register(FT_UINT64, &uint64_type);
828         ftype_register(FT_INT8, &int8_type);
829         ftype_register(FT_INT16, &int16_type);
830         ftype_register(FT_INT24, &int24_type);
831         ftype_register(FT_INT32, &int32_type);
832         ftype_register(FT_INT64, &int64_type);
833         ftype_register(FT_BOOLEAN, &boolean_type);
834         ftype_register(FT_IPXNET, &ipxnet_type);
835         ftype_register(FT_FRAMENUM, &framenum_type);
836 }