aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGanesh Nawsupe <ganesh991@gmail.com>2014-12-12 11:50:21 +0530
committerAnders Broman <a.broman58@gmail.com>2014-12-17 13:01:25 +0000
commit6b7a395f9b22ac8e7cca1faf204e7e350508b6a3 (patch)
tree67558a228627bb95f399c905b6a2ff32d3aa8f79
parenta3510cc15f8e3225bd8e37ed127b0f2ddfa0aed6 (diff)
Adding fix to convert latitude/longitude degrees to floating point format from fixed point format
Change-Id: Ibcfeae69e4f60423c87a0fdb8666192a1ca5dc0c Reviewed-on: https://code.wireshark.org/review/5726 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/dissectors/packet-mip6.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/epan/dissectors/packet-mip6.c b/epan/dissectors/packet-mip6.c
index ff2d48d408..731913836f 100644
--- a/epan/dissectors/packet-mip6.c
+++ b/epan/dissectors/packet-mip6.c
@@ -3105,21 +3105,47 @@ static const value_string mip6_opt_acc_net_id_sub_opt_op_id_type[] = {
{ 2, "Realm of the operator"},
{ 0, NULL}
};
+static float degrees_covert_fixed_to_float(guint value)
+{
+ guint mantissa=0,exponent=0, sign=0, position=0, mask = 1,*ptrNumber = NULL, i ;
+ float floatNumber =0;
+ ptrNumber = (guint *) &floatNumber;
+ if(!value)
+ return 0;
-static void
-degrees_base_custom(gchar *result, guint32 degrees)
-{
+ /* If negative number save sign bit and take 2' complement*/
+ if(value & 0x800000) /* Input value is 24 bit number*/
+ {
+ value -= 1;
+ value ^= -1;
+ sign = 1;
+ }
- if (degrees & 0x800000) {
- /* Negative Number. */
- g_snprintf(result, ITEM_LABEL_LENGTH, "-%u.%u", (degrees & 0x7F8000)>>15, degrees & 0x007FFF);
- }
- else {
- g_snprintf(result, ITEM_LABEL_LENGTH, "%u.%u", (degrees & 0x7F8000)>>15, degrees & 0x007FFF);
- }
+ /* Find position of left most 1*/
+ for(i=0;i<24;i++)
+ {
+ if(value & mask )
+ position = i;
+ mask = (mask << 1);
+ }
+
+ mantissa = (value << (32 - position - 8 -1));
+ mantissa &= 0x007FFFFF;
+
+ if(sign)
+ mantissa = (mantissa | 0x80000000);
+
+ exponent = (position - 15 +127) << 23;
+
+ *ptrNumber = (mantissa | exponent);/* club mantissa, exponent and sign*/
+ return floatNumber;
}
+static void degrees_base_custom(gchar *str, guint degrees)
+{
+ g_snprintf(str, ITEM_LABEL_LENGTH, "%f", degrees_covert_fixed_to_float(degrees) );
+}
static void
dissect_pmip6_opt_acc_net_id(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset,