diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-02-09 02:54:12 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-02-09 02:54:12 +0000 |
commit | 5d3a4a06bc1aa95ae3407dfd93532d51cbbe3126 (patch) | |
tree | 67ed422c07cc4019d44528daa5e9ffaf5766c305 /epan/dissectors/packet-netflow.c | |
parent | 69b78fc118387a483ba94c4f6331f8867deb558c (diff) |
Rewrite this dissector's NTP-to-nstime routine to take a TVB and an offset
instead of a pointer into the TVB. Then use the standard accessor functions
to get data out of the TVB.
svn path=/trunk/; revision=35885
Diffstat (limited to 'epan/dissectors/packet-netflow.c')
-rw-r--r-- | epan/dissectors/packet-netflow.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index 4e45f7db64..28902de926 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -1494,9 +1494,11 @@ ntptime_to_nstime(ntptime_t *ntpt, nstime_t *nst) { #endif static void -ntptime_buf_to_nstime(const guint8 *ntptime_buf, nstime_t *nstime) { - nstime->secs = pntohl(&ntptime_buf[0]) - NTP_BASETIME; - nstime->nsecs = (int)((pntohl(&ntptime_buf[4])*1000000000.0)/FLOAT_DENOM); +ntptime_to_nstime(tvbuff_t *tvb, gint offset, nstime_t *nstime) { + nstime->secs = tvb_get_ntohl(tvb, offset); + if (nstime->secs) + nstime->secs -= NTP_BASETIME; + nstime->nsecs = (int)(1000000000*tvb_get_ntohl(tvb, offset+4)/FLOAT_DENOM); } /* ------------------------------------ */ @@ -2639,28 +2641,28 @@ dissect_v9_v10_pdu_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdutree, case 154: /* flowStartMicroseconds: 64-bit NTP format */ offset_s[rev] = offset; - ntptime_buf_to_nstime(tvb_get_ptr(tvb, offset, 8), &ts_start[rev]); + ntptime_to_nstime(tvb, offset, &ts_start[rev]); goto timestamp_common; break; case 155: /* flowEndMicroseconds: 64-bit NTP format */ /* XXX: Not tested ... */ offset_e[rev] = offset; - ntptime_buf_to_nstime(tvb_get_ptr(tvb, offset, 8), &ts_end[rev]); + ntptime_to_nstime(tvb, offset, &ts_end[rev]); goto timestamp_common; break; case 156: /* flowStartNanoseconds: 64-bit NTP format */ /* XXX: Not tested ... */ offset_s[rev] = offset; - ntptime_buf_to_nstime(tvb_get_ptr(tvb, offset, 8), &ts_start[rev]); + ntptime_to_nstime(tvb, offset, &ts_start[rev]); goto timestamp_common; break; case 157: /* flowEndNanoseconds: 64-bit NTP format */ /* XXX: Not tested ... */ offset_e[rev] = offset; - ntptime_buf_to_nstime(tvb_get_ptr(tvb, offset, 8), &ts_end[rev]); + ntptime_to_nstime(tvb, offset, &ts_end[rev]); goto timestamp_common; break; |