diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2019-08-26 12:18:27 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2019-08-26 17:26:15 +0000 |
commit | a7838d940339fddd85d15cacd888369c1288b337 (patch) | |
tree | 0806f7298c442935314840a9ddc77b8e03bbbd08 | |
parent | d966c0dd5e7e66fd06fac0c07d496f5090d7d220 (diff) |
coap: Distinguish observe option for request and response
The observe option has different values for request and response. For
request it identifies register or deregister, and for response it is a
sequence number for reordering detection. RFC 7641 chapter 2.
Change-Id: I09515864997a32f7259e344532ea770b74030b04
Reviewed-on: https://code.wireshark.org/review/34368
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | epan/dissectors/packet-coap.c | 19 | ||||
-rw-r--r-- | epan/dissectors/packet-coap.h | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-oscore.c | 2 |
3 files changed, 24 insertions, 11 deletions
diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c index 3acff1a913..3622be3094 100644 --- a/epan/dissectors/packet-coap.c +++ b/epan/dissectors/packet-coap.c @@ -662,7 +662,7 @@ dissect_coap_opt_uri_port(tvbuff_t *tvb, proto_item *head_item, proto_tree *subt * return the total length of the option including the header (e.g. delta and length). */ static int -dissect_coap_options_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, guint8 opt_count, guint *opt_num, gint offset_end, coap_info *coinfo, coap_common_dissect_t *dissect_hf) +dissect_coap_options_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, guint8 opt_count, guint *opt_num, gint offset_end, guint8 code_class, coap_info *coinfo, coap_common_dissect_t *dissect_hf) { guint8 opt_jump; gint opt_length, opt_length_ext, opt_delta, opt_delta_ext; @@ -850,8 +850,15 @@ dissect_coap_options_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tr opt_length, coinfo, dissect_hf->hf.opt_uri_path); break; case COAP_OPT_OBSERVE: - dissect_coap_opt_uint(tvb, item, subtree, offset, - opt_length, dissect_hf->hf.opt_observe); + if (code_class == 0) { + /* Request */ + dissect_coap_opt_uint(tvb, item, subtree, offset, + opt_length, dissect_hf->hf.opt_observe_req); + } else { + /* Response */ + dissect_coap_opt_uint(tvb, item, subtree, offset, + opt_length, dissect_hf->hf.opt_observe_rsp); + } break; case COAP_OPT_ACCEPT: dissect_coap_opt_ctype(tvb, item, subtree, offset, @@ -894,7 +901,7 @@ dissect_coap_options_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tr * or the end of the data. */ int -dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, gint offset_end, coap_info *coinfo, coap_common_dissect_t *dissect_hf) +dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, gint offset_end, guint8 code_class, coap_info *coinfo, coap_common_dissect_t *dissect_hf) { guint opt_num = 0; int i; @@ -903,7 +910,7 @@ dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, g /* loop for dissecting options */ for (i = 1; offset < offset_end; i++) { offset = dissect_coap_options_main(tvb, pinfo, coap_tree, - offset, i, &opt_num, offset_end, coinfo, dissect_hf); + offset, i, &opt_num, offset_end, code_class, coinfo, dissect_hf); if (offset == -1) return -1; if (offset >= offset_end) @@ -1147,7 +1154,7 @@ dissect_coap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, } /* process options */ - offset = dissect_coap_options(tvb, pinfo, coap_tree, offset, coap_length, coinfo, &dissect_coap_hf); + offset = dissect_coap_options(tvb, pinfo, coap_tree, offset, coap_length, code_class, coinfo, &dissect_coap_hf); if (offset == -1) return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-coap.h b/epan/dissectors/packet-coap.h index b8783c7ce2..f641921cdc 100644 --- a/epan/dissectors/packet-coap.h +++ b/epan/dissectors/packet-coap.h @@ -85,7 +85,8 @@ typedef struct coap_common_dissect { int opt_location_query; int opt_uri_path; int opt_uri_path_recon; - int opt_observe; + int opt_observe_req; + int opt_observe_rsp; int opt_accept; int opt_if_match; int opt_block_number; @@ -126,7 +127,7 @@ typedef struct coap_common_dissect { } coap_common_dissect_t; guint8 dissect_coap_code(tvbuff_t *tvb, proto_tree *coap_tree, gint *offset, coap_common_dissect_t *dissect_hf, guint8 *code_class); -int dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, gint offset_end, coap_info *coinfo, coap_common_dissect_t *dissect_hf); +int dissect_coap_options(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, gint offset, gint offset_end, guint8 code_class, coap_info *coinfo, coap_common_dissect_t *dissect_hf); void dissect_coap_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tree, proto_tree *parent_tree, gint offset, gint offset_end, guint8 code_class, coap_info *coinfo, coap_common_dissect_t *dissect_hf, gboolean oscore); extern const value_string coap_vals_observe_options[]; @@ -140,7 +141,7 @@ coap_common_dissect_t name = { \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ - -1, \ + -1, -1, \ }, \ /* ett */ { \ -1, -1, \ @@ -318,11 +319,16 @@ coap_common_dissect_t name = { \ FT_STRING, BASE_NONE, NULL, 0x0, \ NULL, HFILL } \ }, \ - { & name .hf.opt_observe, \ + { & name .hf.opt_observe_req, \ { "Observe", prefix ".opt.observe", \ FT_UINT32, BASE_DEC, VALS(coap_vals_observe_options), 0x0, \ NULL, HFILL } \ }, \ + { & name .hf.opt_observe_rsp, \ + { "Observe sequence number", prefix ".opt.observe", \ + FT_UINT32, BASE_DEC, NULL, 0x0, \ + NULL, HFILL } \ + }, \ { & name .hf.opt_accept, \ { "Accept", prefix ".opt.accept", \ FT_STRING, BASE_NONE, NULL, 0x0, \ diff --git a/epan/dissectors/packet-oscore.c b/epan/dissectors/packet-oscore.c index 1bdb776b07..2cc4bdde81 100644 --- a/epan/dissectors/packet-oscore.c +++ b/epan/dissectors/packet-oscore.c @@ -733,7 +733,7 @@ oscore_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (coinfo) { dissect_coap_code(tvb_decrypted, oscore_tree, &offset, &dissect_oscore_hf, &code_class); - offset = dissect_coap_options(tvb_decrypted, pinfo, oscore_tree, offset, oscore_length, coinfo, &dissect_oscore_hf); + offset = dissect_coap_options(tvb_decrypted, pinfo, oscore_tree, offset, oscore_length, code_class, coinfo, &dissect_oscore_hf); if (oscore_length > offset) { dissect_coap_payload(tvb_decrypted, pinfo, oscore_tree, tree, offset, oscore_length, code_class, coinfo, &dissect_oscore_hf, TRUE); } |