diff options
author | Guy Harris <gharris@sonic.net> | 2021-07-11 03:06:10 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-07-11 03:06:10 -0700 |
commit | c4731738fc37c791f1aad806eaec6cc08fe39ec6 (patch) | |
tree | ca17443092bbcfedbb4719ce1cf4f030a326cbbf /sharkd.h | |
parent | 379352ef7f3e2be00ec2b16b84f0a2a424586af6 (diff) |
sharkd: various cleanups.
Extend sharkd_dissect_request() so that it can replace
sharkd_dissect_columns().
Have it return a status indicating success, invalid frame number, or
read error, so that the caller knows what the problem is.
Pass it pointers to the wtap_rec and Buffer to use when reading packets
from the file, so that if it's called in a loop iterating over all
frames, those structures can be initialized once, before the loop, and
cleaned up once, after the loop, rather than doing both once per loop
iteration.
Pass pointers to the read error code and additional read error
information string pointer, so that, on a file read error, that
information is available to the caller.
Get rid of sharkd_dissect_columns(); instead, use
sharkd_dissect_request(), with code from the loop body pulled into a
callback routine. Fix that code to correctly determine whether the
current frame has any comments, rather than just treating all frames
that have blocks as having comments.
Use _U_ to mark arguments as unused, rather than throwing in a
(void) variablename;
statement.
Move some variables used only within a loop into the for() statement or
the loop body.
Diffstat (limited to 'sharkd.h')
-rw-r--r-- | sharkd.h | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -34,8 +34,17 @@ int sharkd_load_cap_file(void); int sharkd_retap(void); int sharkd_filter(const char *dftext, guint8 **result); frame_data *sharkd_get_frame(guint32 framenum); -int sharkd_dissect_columns(frame_data *fdata, guint32 frame_ref_num, guint32 prev_dis_num, column_info *cinfo, gboolean dissect_color); -int sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis_num, sharkd_dissect_func_t cb, guint32 dissect_flags, void *data); +enum dissect_request_status { + DISSECT_REQUEST_SUCCESS, + DISSECT_REQUEST_NO_SUCH_FRAME, + DISSECT_REQUEST_READ_ERROR +}; +enum dissect_request_status +sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, + guint32 prev_dis_num, wtap_rec *rec, Buffer *buf, + column_info *cinfo, guint32 dissect_flags, + sharkd_dissect_func_t cb, void *data, + int *err, gchar **err_info); wtap_block_t sharkd_get_modified_block(const frame_data *fd); wtap_block_t sharkd_get_packet_block(const frame_data *fd); int sharkd_set_modified_block(frame_data *fd, wtap_block_t new_block); |