blob: d77c12850d22a2785bb8e207ab5387dae863d30b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* packet-ppi-geolocation-common.c
* Routines for PPI-GEOLOCATION dissection
* Copyright 2010, Harris Corp, jellch@harris.com
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <glib.h>
#include "packet-ppi-geolocation-common.h"
/*
* input: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive)
* output: a signed floating point value between -180.0000000 and + 180.0000000, inclusive)
*/
double ppi_fixed3_7_to_double(uint32_t in) {
int32_t remapped_in = in - (180 * 10000000);
double ret = (double) ((double) remapped_in / 10000000);
return ret;
}
/*
* input: a native 32 bit unsigned value between 0 and 999999999
* output: a positive floating point value between 000.0000000 and 999.9999999
*/
double ppi_fixed3_6_to_double(uint32_t in) {
double ret = (double) in / 1000000.0;
return ret;
}
/*
* input: a native 32 bit unsigned value between 0 and 3600000000
* output: a signed floating point value between -180000.0000 and +180000.0000
*/
double ppi_fixed6_4_to_double(uint32_t in) {
int32_t remapped_in = in - (180000 * 10000);
double ret = (double) ((double) remapped_in / 10000);
return ret;
}
double ppi_ns_counter_to_double(uint32_t in) {
double ret;
ret = (double) in / 1000000000;
return ret;
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|