diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-24 17:04:44 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-25 00:05:07 +0000 |
commit | 318cf8a6782d8911c7c2891c395062f98eb0a316 (patch) | |
tree | c078f54d1ac8b39bb0b8bbe99226394bbcb98055 /epan/packet.c | |
parent | 6dffc3b7e364b7446c30db54d2193476a5f0fa93 (diff) |
Add support for dissecting non-packet records.
Add a dissector table indexed by the file type, and, for the
file-type-specific records, have the frame dissector skip the usual
pseudo-header processing, as the pseudo-header has a file-type-specific
record subtype in it, and call the dissector for that file type's
records.
Change-Id: Ibe97cf6340ffb0dabc08f355891bc346391b91f9
Reviewed-on: https://code.wireshark.org/review/1782
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/packet.c')
-rw-r--r-- | epan/packet.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/epan/packet.c b/epan/packet.c index b8026933ea..d06525cb1e 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -420,9 +420,36 @@ final_registration_all_protocols(void) /* Creates the top-most tvbuff and calls dissect_frame() */ void -dissect_record(epan_dissect_t *edt, struct wtap_pkthdr *phdr, - tvbuff_t *tvb, frame_data *fd, column_info *cinfo) +dissect_record(epan_dissect_t *edt, int file_type_subtype, + struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd, column_info *cinfo) { + const char *record_type; + + switch (phdr->rec_type) { + + case REC_TYPE_PACKET: + record_type = "Frame"; + break; + + case REC_TYPE_FT_SPECIFIC_EVENT: + record_type = "Event"; + break; + + case REC_TYPE_FT_SPECIFIC_REPORT: + record_type = "Report"; + break; + + default: + /* + * XXX - if we add record types that shouldn't be + * dissected and displayed, but that need to at + * least be processed somewhere, we need to somehow + * indicate that to our caller. + */ + g_assert_not_reached(); + break; + } + if (cinfo != NULL) col_init(cinfo, edt->session); edt->pi.epan = edt->session; @@ -430,6 +457,7 @@ dissect_record(epan_dissect_t *edt, struct wtap_pkthdr *phdr, edt->pi.current_proto = "<Missing Protocol Name>"; edt->pi.cinfo = cinfo; edt->pi.fd = fd; + edt->pi.file_type_subtype = file_type_subtype; edt->pi.phdr = phdr; edt->pi.pseudo_header = &phdr->pseudo_header; edt->pi.dl_src.type = AT_NONE; @@ -456,15 +484,11 @@ dissect_record(epan_dissect_t *edt, struct wtap_pkthdr *phdr, else if (fd->flags.has_phdr_comment) edt->pi.pkt_comment = phdr->opt_comment; - if (phdr->rec_type != REC_TYPE_PACKET) { - /* XXX = process these */ - } - - EP_CHECK_CANARY(("before dissecting frame %d",fd->num)); + EP_CHECK_CANARY(("before dissecting record %d",fd->num)); TRY { /* Add this tvbuffer into the data_src list */ - add_new_data_source(&edt->pi, edt->tvb, "Frame"); + add_new_data_source(&edt->pi, edt->tvb, record_type); /* Even though dissect_frame() catches all the exceptions a * sub-dissector can throw, dissect_frame() itself may throw @@ -478,11 +502,12 @@ dissect_record(epan_dissect_t *edt, struct wtap_pkthdr *phdr, } CATCH2(FragmentBoundsError, ReportedBoundsError) { proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0, - "[Malformed Frame: Packet Length]" ); + "[Malformed %s: Packet Length]", + record_type); } ENDTRY; - EP_CHECK_CANARY(("after dissecting frame %d",fd->num)); + EP_CHECK_CANARY(("after dissecting record %d",fd->num)); fd->flags.visited = 1; } @@ -499,6 +524,7 @@ dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr, edt->pi.current_proto = "<Missing Filetype Name>"; edt->pi.cinfo = cinfo; edt->pi.fd = fd; + edt->pi.file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_UNKNOWN; /* not a capture file, so not relevant */ edt->pi.phdr = phdr; edt->pi.pseudo_header = &phdr->pseudo_header; edt->pi.dl_src.type = AT_NONE; |