diff options
author | Michael Mann <mmann78@netscape.net> | 2013-11-09 17:46:28 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2013-11-09 17:46:28 +0000 |
commit | 8081cf1d90397cbbb4404f9720595e1537ed5e14 (patch) | |
tree | 353220f46e08be1f0020603538f501b65bea8f3b /epan/dissectors/packet-synphasor.c | |
parent | c9b2ee3768abb730b49fc4fc779e77578a1c4971 (diff) |
Add data parameter to tcp_dissect_pdus() as well as convert it to using "new" style dissectors.
Now that "bytes consumed" can be determined, should tcp_dissect_pdus() take advantage of that?
Should tcp_dissect_pdus return length (bytes consumed)? There are many dissectors that just call tcp_dissect_pdus() then return tvb_length(tvb). Seems like that could all be rolled into one.
svn path=/trunk/; revision=53198
Diffstat (limited to 'epan/dissectors/packet-synphasor.c')
-rw-r--r-- | epan/dissectors/packet-synphasor.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index 6fcee1a495..a7b58c8592 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -448,30 +448,6 @@ static void synphasor_init(void) } -/* the main dissection routine */ -static void dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); - -/* called for synchrophasors over UDP */ -static int dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) -{ - dissect_common(tvb, pinfo, tree); - - return tvb_length(tvb); -} - -/* callback for 'tcp_dissect_pdus()' to give it the length of the frame */ -static guint get_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) -{ - return tvb_get_ntohs(tvb, offset + 2); -} - -static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) -{ - tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_pdu_length, dissect_common); - - return tvb_length(tvb); -} - /* Checks the CRC of a synchrophasor frame, 'tvb' has to include the whole * frame, including CRC, the calculated CRC is returned in '*computedcrc'. */ @@ -501,7 +477,7 @@ static gint dissect_header(tvbuff_t *, proto_tree *); /* Dissects the header (common to all types of frames) and then calls * one of the subdissectors (declared above) for the rest of the frame. */ -static void dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { guint8 frame_type; guint16 crc; @@ -511,7 +487,7 @@ static void dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tvbsize < 17 /* 17 bytes = header frame with only a NULL character, useless but valid */ || tvb_get_guint8(tvb, 0) != 0xAA) /* every synchrophasor frame starts with 0xAA */ - return; + return 0; /* write the protocol name to the info column */ col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTOCOL_SHORT_NAME); @@ -617,8 +593,30 @@ static void dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /*offset += 2;*/ /* CRC */ } /* if (tree) */ + + return tvb_length(tvb); } /* dissect_synphasor() */ +/* called for synchrophasors over UDP */ +static int dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +{ + return dissect_common(tvb, pinfo, tree, data); +} + +/* callback for 'tcp_dissect_pdus()' to give it the length of the frame */ +static guint get_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset) +{ + return tvb_get_ntohs(tvb, offset + 2); +} + +static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +{ + tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_pdu_length, dissect_common, data); + + return tvb_length(tvb); +} + + /* Dissects the common header of frames. * * Returns the framesize, in contrast to most |