aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-01-07 05:13:29 +0000
committerGuy Harris <guy@alum.mit.edu>2004-01-07 05:13:29 +0000
commit349feca55d8cae74833cb15c8991f4dfa3ca26fe (patch)
treebccda3a723b82923495b6647baa74b021f1608b4 /plugins
parentf497416d2499a315bdae8dc0699c10165aa5f923 (diff)
Don't do anything exotic to get signed integral values - Ethereal's
dissectors assume a two's-complement machine (we offer our apologies to those trying to run it on sign-magnitude IBM 7090/7094's and one's complement Univac/Unisys 11xx machines :-)). svn path=/trunk/; revision=9584
Diffstat (limited to 'plugins')
-rw-r--r--plugins/docsis/packet-rngrsp.c62
1 files changed, 3 insertions, 59 deletions
diff --git a/plugins/docsis/packet-rngrsp.c b/plugins/docsis/packet-rngrsp.c
index d066d45ff4..29601714a0 100644
--- a/plugins/docsis/packet-rngrsp.c
+++ b/plugins/docsis/packet-rngrsp.c
@@ -2,7 +2,7 @@
* Routines for Ranging Response Message dissection
* Copyright 2002, Anand V. Narwani <anand[AT]narwani.org>
*
- * $Id: packet-rngrsp.c,v 1.7 2004/01/05 19:28:34 ulfl Exp $
+ * $Id: packet-rngrsp.c,v 1.8 2004/01/07 05:13:29 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -70,62 +70,6 @@ static const value_string rng_stat_vals[] = {
/* Initialize the subtree pointers */
static gint ett_docsis_rngrsp = -1;
-/* These Routines convert the specified type to a signed integer
- * using a Two's Compliment Format */
-
-gint8
-byte_to_signed (guint8 i)
-{
- gint16 val;
- if (i & 0x80)
- {
- val = ((~i) + 1);
- val = -val;
- }
- else
- {
- val = i;
- }
- return (gint8) (val);
-}
-
-gint16
-short_to_signed (guint16 i)
-{
- gint16 val;
-
- if (i & 0x8000)
- {
- val = (gint16) ((~i) + 1);
- val = -val;
- }
- else
- {
- val = (gint16) i;
- }
-
- return (val);
-}
-
-gint32
-long_to_signed (guint32 i)
-{
- gint32 val;
-
- if (i & 0x80000000)
- {
- val = (gint32) ((~i) + 1);
- val = -val;
- }
- else
- {
- val = (gint16) i;
- }
-
- return (val);
-
-}
-
/* Code to actually dissect the packets */
static void
dissect_rngrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
@@ -178,7 +122,7 @@ dissect_rngrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
case RNGRSP_TIMING:
if (tlvlen == 4)
{
- tim = long_to_signed (tvb_get_ntohl (tvb, pos));
+ tim = tvb_get_ntohl (tvb, pos);
proto_tree_add_int (rngrsp_tree,
hf_docsis_rngrsp_timing_adj, tvb, pos,
tlvlen, tim);
@@ -191,7 +135,7 @@ dissect_rngrsp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
case RNGRSP_PWR_LEVEL_ADJ:
if (tlvlen == 1)
{
- pwr = byte_to_signed (tvb_get_guint8 (tvb, pos));
+ pwr = tvb_get_guint8 (tvb, pos);
proto_tree_add_int (rngrsp_tree, hf_docsis_rngrsp_power_adj,
tvb, pos, tlvlen, pwr);
}