Fix for bug 5422:
[obnox/wireshark/wip.git] / epan / dissectors / packet-ppi-geolocation-common.c
1 /* packet-ppi-geolocation-common.c
2  * Routines for PPI-GEOLOCATION  dissection
3  * Copyright 2010, Harris Corp, jellch@harris.com
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "packet-ppi-geolocation-common.h"
27
28 /*
29  * input: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive)
30  * output: a signed floating point value betwen -180.0000000 and + 180.0000000, inclusive)
31  */
32 gdouble fixed3_7_to_gdouble(guint32 in) {
33     gint32 remapped_in = in - (180 * 10000000);
34     gdouble ret = (gdouble) ((gdouble) remapped_in / 10000000);
35     return ret;
36 }
37 /*
38  * input: a native 32 bit unsigned value between 0 and 999999999
39  * output: a positive floating point value between 000.0000000 and 999.9999999
40  */
41
42 gdouble fixed3_6_to_gdouble(guint32 in) {
43     gdouble ret = (gdouble) in  / 1000000.0;
44     return ret;
45
46 }
47 /*
48  * input: a native 32 bit unsigned value between 0 and 3600000000
49  * output: a signed floating point value between -180000.0000 and +180000.0000
50  */
51 gdouble fixed6_4_to_gdouble(guint32 in) {
52     gint32 remapped_in = in - (180000 * 10000);
53     gdouble ret = (gdouble) ((gdouble) remapped_in / 10000);
54     return ret;
55 }
56
57 gdouble ns_counter_to_gdouble(guint32 in) {
58     gdouble ret;
59     ret = (gdouble) in / 1000000000;
60     return ret;
61 }
62
63 /*
64  * Editor modelines
65  *
66  * Local Variables:
67  * c-basic-offset: 4
68  * tab-width: 8
69  * indent-tabs-mode: nil
70  * End:
71  *
72  * ex: set shiftwidth=4 tabstop=8 expandtab
73  * :indentSize=4:tabSize=8:noTabs=true:
74  */