diff options
author | Bill Meier <wmeier@newsguy.com> | 2014-10-05 22:14:57 -0400 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2014-10-06 02:55:49 +0000 |
commit | 07698d536b72f5267ebe654b0b0cbc394b713ce1 (patch) | |
tree | 1ae72c69e7e2ac830cf3ac3752da6c9fe067ee15 /ui | |
parent | 0111e461938d47efd1eb8dc17f135b93b253ab52 (diff) |
Adjust some whitespace to match editor modelines.
Change-Id: Ia22cac3ebd7a454c156f98d967e6fd61f708a2b3
Reviewed-on: https://code.wireshark.org/review/4489
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/cli/tap-rtp.c | 58 | ||||
-rw-r--r-- | ui/decode_as_utils.c | 4 | ||||
-rw-r--r-- | ui/export_object_smb.c | 676 | ||||
-rw-r--r-- | ui/iface_lists.c | 32 | ||||
-rw-r--r-- | ui/time_shift.c | 194 | ||||
-rw-r--r-- | ui/win32/console_win32.c | 90 |
6 files changed, 527 insertions, 527 deletions
diff --git a/ui/cli/tap-rtp.c b/ui/cli/tap-rtp.c index 11322dab84..8ab5d3fe9a 100644 --- a/ui/cli/tap-rtp.c +++ b/ui/cli/tap-rtp.c @@ -85,19 +85,19 @@ rtp_streams_stat_draw(void *arg _U_) /* payload type */ if(strinfo->pt>95){ - if(strinfo->info_payload_type_str != NULL){ + if(strinfo->info_payload_type_str != NULL){ payload_type = g_strdup(strinfo->info_payload_type_str); - }else{ - payload_type = g_strdup_printf("Unknown(%u)",strinfo->pt); - } + }else{ + payload_type = g_strdup_printf("Unknown(%u)",strinfo->pt); + } }else{ - payload_type = g_strdup(val_to_str_ext(strinfo->pt, &rtp_payload_type_vals_ext, - "Unknown (%u)")); + payload_type = g_strdup(val_to_str_ext(strinfo->pt, &rtp_payload_type_vals_ext, + "Unknown (%u)")); } /* packet count, lost packets */ - expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.cycles*65536) + expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.cycles*65536) - strinfo->rtp_stats.start_seq_nr + 1; lost = expected - strinfo->rtp_stats.total_nr; if (expected){ @@ -108,21 +108,21 @@ rtp_streams_stat_draw(void *arg _U_) printf("%15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.2f %15.2f %15.2f %s\n", ep_address_to_display(&(strinfo->src_addr)), - strinfo->src_port, - ep_address_to_display(&(strinfo->dest_addr)), - strinfo->dest_port, - strinfo->ssrc, - payload_type, - strinfo->npackets, - lost, perc, - strinfo->rtp_stats.max_delta, - strinfo->rtp_stats.max_jitter, - strinfo->rtp_stats.mean_jitter, - (strinfo->problem)?"X":""); - - list = g_list_next(list); - - g_free(payload_type); + strinfo->src_port, + ep_address_to_display(&(strinfo->dest_addr)), + strinfo->dest_port, + strinfo->ssrc, + payload_type, + strinfo->npackets, + lost, perc, + strinfo->rtp_stats.max_delta, + strinfo->rtp_stats.max_jitter, + strinfo->rtp_stats.mean_jitter, + (strinfo->problem)?"X":""); + + list = g_list_next(list); + + g_free(payload_type); } @@ -136,19 +136,19 @@ rtp_streams_stat_draw(void *arg _U_) static void rtp_streams_stat_init(const char *opt_arg _U_, void* userdata _U_) { - GString *err_p; + GString *err_p; err_p = - register_tap_listener("rtp", &the_tapinfo_struct, NULL, 0, - rtpstream_reset_cb, - rtpstream_packet, - rtp_streams_stat_draw); + register_tap_listener("rtp", &the_tapinfo_struct, NULL, 0, + rtpstream_reset_cb, + rtpstream_packet, + rtp_streams_stat_draw); if (err_p != NULL) { - g_string_free(err_p, TRUE); + g_string_free(err_p, TRUE); - exit(1); + exit(1); } } diff --git a/ui/decode_as_utils.c b/ui/decode_as_utils.c index 5a29b3a4ee..8db4f2dff3 100644 --- a/ui/decode_as_utils.c +++ b/ui/decode_as_utils.c @@ -92,8 +92,8 @@ change_dissector_if_matched(gpointer item, gpointer user_data) */ static prefs_set_pref_e read_set_decode_as_entries(gchar *key, const gchar *value, - void *user_data _U_, - gboolean return_range_errors _U_) + void *user_data _U_, + gboolean return_range_errors _U_) { gchar *values[4] = {NULL, NULL, NULL, NULL}; gchar delimiter[4] = {',', ',', ',','\0'}; diff --git a/ui/export_object_smb.c b/ui/export_object_smb.c index 704b2cd155..de866916dc 100644 --- a/ui/export_object_smb.c +++ b/ui/export_object_smb.c @@ -47,29 +47,29 @@ #define LEGAL_FILENAME_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.- /\\{}[]=()&%$!,;.+&%$~#@" static const value_string smb_eo_contains_string[] = { - {SMB_EO_CONTAINS_NOTHING, "" }, - {SMB_EO_CONTAINS_READS, "R" }, - {SMB_EO_CONTAINS_WRITES, "W" }, - {SMB_EO_CONTAINS_READSANDWRITES, "R&W"}, - {0, NULL} + {SMB_EO_CONTAINS_NOTHING, "" }, + {SMB_EO_CONTAINS_READS, "R" }, + {SMB_EO_CONTAINS_WRITES, "W" }, + {SMB_EO_CONTAINS_READSANDWRITES, "R&W"}, + {0, NULL} }; /* Strings that describes the SMB object type */ static const value_string smb_fid_types[] = { - {SMB_FID_TYPE_UNKNOWN,"UNKNOWN"}, - {SMB_FID_TYPE_FILE,"FILE"}, - {SMB_FID_TYPE_DIR,"DIRECTORY (Not Implemented)"}, - {SMB_FID_TYPE_PIPE,"PIPE (Not Implemented)"}, - {0, NULL} + {SMB_FID_TYPE_UNKNOWN,"UNKNOWN"}, + {SMB_FID_TYPE_FILE,"FILE"}, + {SMB_FID_TYPE_DIR,"DIRECTORY (Not Implemented)"}, + {SMB_FID_TYPE_PIPE,"PIPE (Not Implemented)"}, + {0, NULL} }; static const value_string smb2_fid_types[] = { - {SMB2_FID_TYPE_UNKNOWN,"UNKNOWN"}, - {SMB2_FID_TYPE_FILE,"FILE"}, - {SMB2_FID_TYPE_DIR,"DIRECTORY (Not Implemented)"}, - {SMB2_FID_TYPE_PIPE,"PIPE (Not Implemented)"}, - {SMB2_FID_TYPE_OTHER,"OTHER (Not Implemented)"}, - {0, NULL} + {SMB2_FID_TYPE_UNKNOWN,"UNKNOWN"}, + {SMB2_FID_TYPE_FILE,"FILE"}, + {SMB2_FID_TYPE_DIR,"DIRECTORY (Not Implemented)"}, + {SMB2_FID_TYPE_PIPE,"PIPE (Not Implemented)"}, + {SMB2_FID_TYPE_OTHER,"OTHER (Not Implemented)"}, + {0, NULL} }; /* This struct contains the relationship between @@ -112,323 +112,323 @@ typedef struct _free_chunk { static void insert_chunk(active_file *file, export_object_entry_t *entry, const smb_eo_t *eo_info) { -gint nfreechunks = g_slist_length(file->free_chunk_list); -gint i; -free_chunk *current_free_chunk; -free_chunk *new_free_chunk; -guint64 chunk_offset = eo_info->smb_file_offset; -guint64 chunk_length = eo_info->payload_len; -guint64 chunk_end_offset = chunk_offset + chunk_length-1; + gint nfreechunks = g_slist_length(file->free_chunk_list); + gint i; + free_chunk *current_free_chunk; + free_chunk *new_free_chunk; + guint64 chunk_offset = eo_info->smb_file_offset; + guint64 chunk_length = eo_info->payload_len; + guint64 chunk_end_offset = chunk_offset + chunk_length-1; /* Size of file in memory */ -guint64 calculated_size = chunk_offset + chunk_length; -gpointer dest_memory_addr; - - /* Let's recalculate the file length and data gathered */ - if ((file->data_gathered == 0) && (nfreechunks == 0)) { - /* If this is the first entry for this file, we first - create an initial free chunk */ - new_free_chunk = (free_chunk *)g_malloc(sizeof(free_chunk)); - new_free_chunk->start_offset = 0; - new_free_chunk->end_offset = MAX(file->file_length, chunk_end_offset+1) - 1; - file->free_chunk_list = NULL; - file->free_chunk_list = g_slist_append(file->free_chunk_list, new_free_chunk); - nfreechunks += 1; - } else { - if (chunk_end_offset > file->file_length-1) { - new_free_chunk = (free_chunk *)g_malloc(sizeof(free_chunk)); - new_free_chunk->start_offset = file->file_length; - new_free_chunk->end_offset = chunk_end_offset; - file->free_chunk_list = g_slist_append(file->free_chunk_list, new_free_chunk); - nfreechunks += 1; - } - } - file->file_length = MAX(file->file_length, chunk_end_offset+1); - - /* Recalculate each free chunk according with the incoming data chunk */ - for (i=0; i<nfreechunks; i++) { - current_free_chunk = (free_chunk *)g_slist_nth_data(file->free_chunk_list, i); - /* 1. data chunk before the free chunk? */ - /* -> free chunk is not altered and no new data gathered */ - if (chunk_end_offset<current_free_chunk->start_offset) { - continue; - } - /* 2. data chunk overlaps the first part of free_chunk */ - /* -> free chunk shrinks from the beginning */ - if (chunk_offset<=current_free_chunk->start_offset && chunk_end_offset>=current_free_chunk->start_offset && chunk_end_offset<current_free_chunk->end_offset) { - file->data_gathered += chunk_end_offset-current_free_chunk->start_offset+1; - current_free_chunk->start_offset=chunk_end_offset+1; - continue; - } - /* 3. data chunk overlaps completely the free chunk */ - /* -> free chunk is removed */ - if (chunk_offset<=current_free_chunk->start_offset && chunk_end_offset>=current_free_chunk->end_offset) { - file->data_gathered += current_free_chunk->end_offset-current_free_chunk->start_offset+1; - file->free_chunk_list = g_slist_remove(file->free_chunk_list, current_free_chunk); - nfreechunks -= 1; - if (nfreechunks == 0) { /* The free chunk list is empty */ - g_slist_free(file->free_chunk_list); - file->free_chunk_list = NULL; - break; - } - i--; - continue; - } - /* 4. data chunk is inside the free chunk */ - /* -> free chunk is splitted into two */ - if (chunk_offset>current_free_chunk->start_offset && chunk_end_offset<current_free_chunk->end_offset) { - new_free_chunk = (free_chunk *)g_malloc(sizeof(free_chunk)); - new_free_chunk->start_offset = chunk_end_offset + 1; - new_free_chunk->end_offset = current_free_chunk->end_offset; - current_free_chunk->end_offset = chunk_offset-1; - file->free_chunk_list = g_slist_insert(file->free_chunk_list, new_free_chunk, i + 1); - file->data_gathered += chunk_length; - continue; - } - /* 5.- data chunk overlaps the end part of free chunk */ - /* -> free chunk shrinks from the end */ - if (chunk_offset>current_free_chunk->start_offset && chunk_offset<=current_free_chunk->end_offset && chunk_end_offset>=current_free_chunk->end_offset) { - file->data_gathered += current_free_chunk->end_offset-chunk_offset+1; - current_free_chunk->end_offset = chunk_offset-1; - continue; - } - /* 6.- data chunk is after the free chunk */ - /* -> free chunk is not altered and no new data gathered */ - if (chunk_offset>current_free_chunk->end_offset) { - continue; - } - } - - /* Now, let's insert the data chunk into memory - ...first, we shall be able to allocate the memory */ - if (!entry->payload_data) { - /* This is a New file */ - if (calculated_size > G_MAXSIZE) { - /* - * The argument to g_try_malloc() is - * a gsize, the maximum value of which is - * G_MAXSIZE. If the calculated size is - * bigger than that, we just say the attempt - * to allocate memory failed. - */ - entry->payload_data = NULL; - } else { - entry->payload_data = (guint8 *)g_try_malloc((gsize)calculated_size); - entry->payload_len = calculated_size; - } - if (!entry->payload_data) { - /* Memory error */ - file->is_out_of_memory = TRUE; - } - } else { - /* This is an existing file in memory */ - if (calculated_size > (guint64) entry->payload_len && - !file->is_out_of_memory) { - /* We need more memory */ - if (calculated_size > G_MAXSIZE) { - /* - * As for g_try_malloc(), so for - * g_try_realloc(). - */ - dest_memory_addr = NULL; - } else { - dest_memory_addr = g_try_realloc( - entry->payload_data, - (gsize)calculated_size); - } - if (!dest_memory_addr) { - /* Memory error */ - file->is_out_of_memory = TRUE; - /* We don't have memory for this file. - Free the current file content from memory */ - g_free(entry->payload_data); - entry->payload_data = NULL; - entry->payload_len = 0; - } else { - entry->payload_data = (guint8 *)dest_memory_addr; - entry->payload_len = calculated_size; - } - } - } - /* ...then, put the chunk of the file in the right place */ - if (!file->is_out_of_memory) { - dest_memory_addr = entry->payload_data + chunk_offset; - memmove(dest_memory_addr, eo_info->payload_data, eo_info->payload_len); - } + guint64 calculated_size = chunk_offset + chunk_length; + gpointer dest_memory_addr; + + /* Let's recalculate the file length and data gathered */ + if ((file->data_gathered == 0) && (nfreechunks == 0)) { + /* If this is the first entry for this file, we first + create an initial free chunk */ + new_free_chunk = (free_chunk *)g_malloc(sizeof(free_chunk)); + new_free_chunk->start_offset = 0; + new_free_chunk->end_offset = MAX(file->file_length, chunk_end_offset+1) - 1; + file->free_chunk_list = NULL; + file->free_chunk_list = g_slist_append(file->free_chunk_list, new_free_chunk); + nfreechunks += 1; + } else { + if (chunk_end_offset > file->file_length-1) { + new_free_chunk = (free_chunk *)g_malloc(sizeof(free_chunk)); + new_free_chunk->start_offset = file->file_length; + new_free_chunk->end_offset = chunk_end_offset; + file->free_chunk_list = g_slist_append(file->free_chunk_list, new_free_chunk); + nfreechunks += 1; + } + } + file->file_length = MAX(file->file_length, chunk_end_offset+1); + + /* Recalculate each free chunk according with the incoming data chunk */ + for (i=0; i<nfreechunks; i++) { + current_free_chunk = (free_chunk *)g_slist_nth_data(file->free_chunk_list, i); + /* 1. data chunk before the free chunk? */ + /* -> free chunk is not altered and no new data gathered */ + if (chunk_end_offset<current_free_chunk->start_offset) { + continue; + } + /* 2. data chunk overlaps the first part of free_chunk */ + /* -> free chunk shrinks from the beginning */ + if (chunk_offset<=current_free_chunk->start_offset && chunk_end_offset>=current_free_chunk->start_offset && chunk_end_offset<current_free_chunk->end_offset) { + file->data_gathered += chunk_end_offset-current_free_chunk->start_offset+1; + current_free_chunk->start_offset=chunk_end_offset+1; + continue; + } + /* 3. data chunk overlaps completely the free chunk */ + /* -> free chunk is removed */ + if (chunk_offset<=current_free_chunk->start_offset && chunk_end_offset>=current_free_chunk->end_offset) { + file->data_gathered += current_free_chunk->end_offset-current_free_chunk->start_offset+1; + file->free_chunk_list = g_slist_remove(file->free_chunk_list, current_free_chunk); + nfreechunks -= 1; + if (nfreechunks == 0) { /* The free chunk list is empty */ + g_slist_free(file->free_chunk_list); + file->free_chunk_list = NULL; + break; + } + i--; + continue; + } + /* 4. data chunk is inside the free chunk */ + /* -> free chunk is splitted into two */ + if (chunk_offset>current_free_chunk->start_offset && chunk_end_offset<current_free_chunk->end_offset) { + new_free_chunk = (free_chunk *)g_malloc(sizeof(free_chunk)); + new_free_chunk->start_offset = chunk_end_offset + 1; + new_free_chunk->end_offset = current_free_chunk->end_offset; + current_free_chunk->end_offset = chunk_offset-1; + file->free_chunk_list = g_slist_insert(file->free_chunk_list, new_free_chunk, i + 1); + file->data_gathered += chunk_length; + continue; + } + /* 5.- data chunk overlaps the end part of free chunk */ + /* -> free chunk shrinks from the end */ + if (chunk_offset>current_free_chunk->start_offset && chunk_offset<=current_free_chunk->end_offset && chunk_end_offset>=current_free_chunk->end_offset) { + file->data_gathered += current_free_chunk->end_offset-chunk_offset+1; + current_free_chunk->end_offset = chunk_offset-1; + continue; + } + /* 6.- data chunk is after the free chunk */ + /* -> free chunk is not altered and no new data gathered */ + if (chunk_offset>current_free_chunk->end_offset) { + continue; + } + } + + /* Now, let's insert the data chunk into memory + ...first, we shall be able to allocate the memory */ + if (!entry->payload_data) { + /* This is a New file */ + if (calculated_size > G_MAXSIZE) { + /* + * The argument to g_try_malloc() is + * a gsize, the maximum value of which is + * G_MAXSIZE. If the calculated size is + * bigger than that, we just say the attempt + * to allocate memory failed. + */ + entry->payload_data = NULL; + } else { + entry->payload_data = (guint8 *)g_try_malloc((gsize)calculated_size); + entry->payload_len = calculated_size; + } + if (!entry->payload_data) { + /* Memory error */ + file->is_out_of_memory = TRUE; + } + } else { + /* This is an existing file in memory */ + if (calculated_size > (guint64) entry->payload_len && + !file->is_out_of_memory) { + /* We need more memory */ + if (calculated_size > G_MAXSIZE) { + /* + * As for g_try_malloc(), so for + * g_try_realloc(). + */ + dest_memory_addr = NULL; + } else { + dest_memory_addr = g_try_realloc( + entry->payload_data, + (gsize)calculated_size); + } + if (!dest_memory_addr) { + /* Memory error */ + file->is_out_of_memory = TRUE; + /* We don't have memory for this file. + Free the current file content from memory */ + g_free(entry->payload_data); + entry->payload_data = NULL; + entry->payload_len = 0; + } else { + entry->payload_data = (guint8 *)dest_memory_addr; + entry->payload_len = calculated_size; + } + } + } + /* ...then, put the chunk of the file in the right place */ + if (!file->is_out_of_memory) { + dest_memory_addr = entry->payload_data + chunk_offset; + memmove(dest_memory_addr, eo_info->payload_data, eo_info->payload_len); + } } /* We use this function to obtain the index in the GSL of a given file */ static int find_incoming_file(GSList *GSL_active_files_p, active_file *incoming_file) { - int i, row, last; - active_file *in_list_file; - - row = -1; - last = g_slist_length(GSL_active_files_p) - 1; - - /* We lookup in reverse order because it is more likely that the file - is one of the latest */ - for (i=last; i>=0; i--) { - in_list_file = (active_file *)g_slist_nth_data(GSL_active_files_p, i); - /* The best-working criteria of two identical files is that the file - that is the same of the file that we are analyzing is the last one - in the list that has the same tid and the same fid */ - /* note that we have excluded in_list_file->uid == incoming_file->uid - from the comparison, because a file can be opened by different - SMB users and it is still the same file */ - if (in_list_file->tid == incoming_file->tid && - in_list_file->fid == incoming_file->fid) { - row = i; - break; - } - } - - return row; + int i, row, last; + active_file *in_list_file; + + row = -1; + last = g_slist_length(GSL_active_files_p) - 1; + + /* We lookup in reverse order because it is more likely that the file + is one of the latest */ + for (i=last; i>=0; i--) { + in_list_file = (active_file *)g_slist_nth_data(GSL_active_files_p, i); + /* The best-working criteria of two identical files is that the file + that is the same of the file that we are analyzing is the last one + in the list that has the same tid and the same fid */ + /* note that we have excluded in_list_file->uid == incoming_file->uid + from the comparison, because a file can be opened by different + SMB users and it is still the same file */ + if (in_list_file->tid == incoming_file->tid && + in_list_file->fid == incoming_file->fid) { + row = i; + break; + } + } + + return row; } /* This is the function answering to the registered tap listener call */ gboolean eo_smb_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data) { -export_object_list_t *object_list = (export_object_list_t *)tapdata; -const smb_eo_t *eo_info = (const smb_eo_t *)data; - -export_object_entry_t *entry; -export_object_entry_t *current_entry; -active_file incoming_file; -gint active_row; -active_file *new_file; -active_file *current_file; -guint8 contains; -gboolean is_supported_filetype; -gfloat percent; - -gchar *aux_smb_fid_type_string; - - if (eo_info->smbversion==1) { - /* Is this an eo_smb supported file_type? (right now we only support FILE) */ - is_supported_filetype = (eo_info->fid_type == SMB_FID_TYPE_FILE); - aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb_fid_types)); - - /* What kind of data this packet contains? */ - switch(eo_info->cmd) { - case SMB_COM_READ_ANDX: - case SMB_COM_READ: - contains = SMB_EO_CONTAINS_READS; - break; - case SMB_COM_WRITE_ANDX: - case SMB_COM_WRITE: - contains = SMB_EO_CONTAINS_WRITES; - break; - default: - contains = SMB_EO_CONTAINS_NOTHING; - break; - } - } else { - /* Is this an eo_smb supported file_type? (right now we only support FILE) */ - is_supported_filetype = (eo_info->fid_type == SMB2_FID_TYPE_FILE ); - aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb2_fid_types)); - - /* What kind of data this packet contains? */ - switch(eo_info->cmd) { - case SMB2_COM_READ: - contains = SMB_EO_CONTAINS_READS; - break; - case SMB2_COM_WRITE: - contains = SMB_EO_CONTAINS_WRITES; - break; - default: - contains = SMB_EO_CONTAINS_NOTHING; - break; - } - } - - - /* Is this data from an already tracked file or not? */ - incoming_file.tid = eo_info->tid; - incoming_file.uid = eo_info->uid; - incoming_file.fid = eo_info->fid; - active_row = find_incoming_file(GSL_active_files, &incoming_file); - - if (active_row == -1) { /* This is a new-tracked file */ - /* Construct the entry in the list of active files */ - entry = (export_object_entry_t *)g_malloc(sizeof(export_object_entry_t)); - entry->payload_data = NULL; - entry->payload_len = 0; - new_file = (active_file *)g_malloc(sizeof(active_file)); - new_file->tid = incoming_file.tid; - new_file->uid = incoming_file.uid; - new_file->fid = incoming_file.fid; - new_file->file_length = eo_info->end_of_file; - new_file->flag_contains = contains; - new_file->free_chunk_list = NULL; - new_file->data_gathered = 0; - new_file->is_out_of_memory = FALSE; - entry->pkt_num = pinfo->fd->num; - - entry->hostname=g_filename_display_name(g_strcanon(eo_info->hostname,LEGAL_FILENAME_CHARS,'?')); - entry->filename=g_filename_display_name(g_strcanon(eo_info->filename,LEGAL_FILENAME_CHARS,'?')); - - /* Insert the first chunk in the chunk list of this file */ - if (is_supported_filetype) { - insert_chunk(new_file, entry, eo_info); - } - - if (new_file->is_out_of_memory) { - entry->content_type = - g_strdup_printf("%s (%"G_GUINT64_FORMAT"?/%"G_GUINT64_FORMAT") %s [mem!!]", - aux_smb_fid_type_string, - new_file->data_gathered, - new_file->file_length, - try_val_to_str(contains, smb_eo_contains_string)); - } else { - if (new_file->file_length > 0) { - percent = (gfloat) (100*new_file->data_gathered/new_file->file_length); - } else { - percent = 0.0f; - } - - entry->content_type = - g_strdup_printf("%s (%"G_GUINT64_FORMAT"/%"G_GUINT64_FORMAT") %s [%5.2f%%]", - aux_smb_fid_type_string, - new_file->data_gathered, - new_file->file_length, - try_val_to_str(contains, smb_eo_contains_string), - percent); - } - - object_list_add_entry(object_list, entry); - GSL_active_files = g_slist_append(GSL_active_files, new_file); - } - else if (is_supported_filetype) { - current_file = (active_file *)g_slist_nth_data(GSL_active_files, active_row); - /* Recalculate the current file flags */ - current_file->flag_contains = current_file->flag_contains|contains; - current_entry = object_list_get_entry(object_list, active_row); - - insert_chunk(current_file, current_entry, eo_info); - - /* Modify the current_entry object_type string */ - if (current_file->is_out_of_memory) { - current_entry->content_type = - g_strdup_printf("%s (%"G_GUINT64_FORMAT"?/%"G_GUINT64_FORMAT") %s [mem!!]", - aux_smb_fid_type_string, - current_file->data_gathered, - current_file->file_length, - try_val_to_str(current_file->flag_contains, smb_eo_contains_string)); - } else { - percent = (gfloat) (100*current_file->data_gathered/current_file->file_length); - current_entry->content_type = - g_strdup_printf("%s (%"G_GUINT64_FORMAT"/%"G_GUINT64_FORMAT") %s [%5.2f%%]", - aux_smb_fid_type_string, - current_file->data_gathered, - current_file->file_length, - try_val_to_str(current_file->flag_contains, smb_eo_contains_string), - percent); - } - } - - return TRUE; /* State changed - window should be redrawn */ + export_object_list_t *object_list = (export_object_list_t *)tapdata; + const smb_eo_t *eo_info = (const smb_eo_t *)data; + + export_object_entry_t *entry; + export_object_entry_t *current_entry; + active_file incoming_file; + gint active_row; + active_file *new_file; + active_file *current_file; + guint8 contains; + gboolean is_supported_filetype; + gfloat percent; + + gchar *aux_smb_fid_type_string; + + if (eo_info->smbversion==1) { + /* Is this an eo_smb supported file_type? (right now we only support FILE) */ + is_supported_filetype = (eo_info->fid_type == SMB_FID_TYPE_FILE); + aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb_fid_types)); + + /* What kind of data this packet contains? */ + switch(eo_info->cmd) { + case SMB_COM_READ_ANDX: + case SMB_COM_READ: + contains = SMB_EO_CONTAINS_READS; + break; + case SMB_COM_WRITE_ANDX: + case SMB_COM_WRITE: + contains = SMB_EO_CONTAINS_WRITES; + break; + default: + contains = SMB_EO_CONTAINS_NOTHING; + break; + } + } else { + /* Is this an eo_smb supported file_type? (right now we only support FILE) */ + is_supported_filetype = (eo_info->fid_type == SMB2_FID_TYPE_FILE ); + aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb2_fid_types)); + + /* What kind of data this packet contains? */ + switch(eo_info->cmd) { + case SMB2_COM_READ: + contains = SMB_EO_CONTAINS_READS; + break; + case SMB2_COM_WRITE: + contains = SMB_EO_CONTAINS_WRITES; + break; + default: + contains = SMB_EO_CONTAINS_NOTHING; + break; + } + } + + + /* Is this data from an already tracked file or not? */ + incoming_file.tid = eo_info->tid; + incoming_file.uid = eo_info->uid; + incoming_file.fid = eo_info->fid; + active_row = find_incoming_file(GSL_active_files, &incoming_file); + + if (active_row == -1) { /* This is a new-tracked file */ + /* Construct the entry in the list of active files */ + entry = (export_object_entry_t *)g_malloc(sizeof(export_object_entry_t)); + entry->payload_data = NULL; + entry->payload_len = 0; + new_file = (active_file *)g_malloc(sizeof(active_file)); + new_file->tid = incoming_file.tid; + new_file->uid = incoming_file.uid; + new_file->fid = incoming_file.fid; + new_file->file_length = eo_info->end_of_file; + new_file->flag_contains = contains; + new_file->free_chunk_list = NULL; + new_file->data_gathered = 0; + new_file->is_out_of_memory = FALSE; + entry->pkt_num = pinfo->fd->num; + + entry->hostname=g_filename_display_name(g_strcanon(eo_info->hostname,LEGAL_FILENAME_CHARS,'?')); + entry->filename=g_filename_display_name(g_strcanon(eo_info->filename,LEGAL_FILENAME_CHARS,'?')); + + /* Insert the first chunk in the chunk list of this file */ + if (is_supported_filetype) { + insert_chunk(new_file, entry, eo_info); + } + + if (new_file->is_out_of_memory) { + entry->content_type = + g_strdup_printf("%s (%"G_GUINT64_FORMAT"?/%"G_GUINT64_FORMAT") %s [mem!!]", + aux_smb_fid_type_string, + new_file->data_gathered, + new_file->file_length, + try_val_to_str(contains, smb_eo_contains_string)); + } else { + if (new_file->file_length > 0) { + percent = (gfloat) (100*new_file->data_gathered/new_file->file_length); + } else { + percent = 0.0f; + } + + entry->content_type = + g_strdup_printf("%s (%"G_GUINT64_FORMAT"/%"G_GUINT64_FORMAT") %s [%5.2f%%]", + aux_smb_fid_type_string, + new_file->data_gathered, + new_file->file_length, + try_val_to_str(contains, smb_eo_contains_string), + percent); + } + + object_list_add_entry(object_list, entry); + GSL_active_files = g_slist_append(GSL_active_files, new_file); + } + else if (is_supported_filetype) { + current_file = (active_file *)g_slist_nth_data(GSL_active_files, active_row); + /* Recalculate the current file flags */ + current_file->flag_contains = current_file->flag_contains|contains; + current_entry = object_list_get_entry(object_list, active_row); + + insert_chunk(current_file, current_entry, eo_info); + + /* Modify the current_entry object_type string */ + if (current_file->is_out_of_memory) { + current_entry->content_type = + g_strdup_printf("%s (%"G_GUINT64_FORMAT"?/%"G_GUINT64_FORMAT") %s [mem!!]", + aux_smb_fid_type_string, + current_file->data_gathered, + current_file->file_length, + try_val_to_str(current_file->flag_contains, smb_eo_contains_string)); + } else { + percent = (gfloat) (100*current_file->data_gathered/current_file->file_length); + current_entry->content_type = + g_strdup_printf("%s (%"G_GUINT64_FORMAT"/%"G_GUINT64_FORMAT") %s [%5.2f%%]", + aux_smb_fid_type_string, + current_file->data_gathered, + current_file->file_length, + try_val_to_str(current_file->flag_contains, smb_eo_contains_string), + percent); + } + } + + return TRUE; /* State changed - window should be redrawn */ } @@ -438,24 +438,24 @@ gchar *aux_smb_fid_type_string; void eo_smb_cleanup(void) { -int i, last; -active_file *in_list_file; - - /* Free any previous data structures used in previous invocation to the - export_object_smb function */ - last = g_slist_length(GSL_active_files); - if (GSL_active_files) { - for (i=last-1; i>=0; i--) { - in_list_file = (active_file *)g_slist_nth_data(GSL_active_files, i); - if (in_list_file->free_chunk_list) { - g_slist_free(in_list_file->free_chunk_list); - in_list_file->free_chunk_list = NULL; - } - g_free(in_list_file); - } - g_slist_free(GSL_active_files); - GSL_active_files = NULL; - } + int i, last; + active_file *in_list_file; + + /* Free any previous data structures used in previous invocation to the + export_object_smb function */ + last = g_slist_length(GSL_active_files); + if (GSL_active_files) { + for (i=last-1; i>=0; i--) { + in_list_file = (active_file *)g_slist_nth_data(GSL_active_files, i); + if (in_list_file->free_chunk_list) { + g_slist_free(in_list_file->free_chunk_list); + in_list_file->free_chunk_list = NULL; + } + g_free(in_list_file); + } + g_slist_free(GSL_active_files); + GSL_active_files = NULL; + } } /* diff --git a/ui/iface_lists.c b/ui/iface_lists.c index 1cf3dfeffb..5f0241d44f 100644 --- a/ui/iface_lists.c +++ b/ui/iface_lists.c @@ -160,12 +160,12 @@ scan_local_interfaces(void (*update_cb)(void)) */ if_string = g_strdup_printf("%s", if_info->friendly_name); #else - /* - * On UN*X, if we have a friendly name, show it along - * with the interface name; the interface name is short - * and somewhat friendly, and many UN*X users are used - * to interface names, so we should show it. - */ + /* + * On UN*X, if we have a friendly name, show it along + * with the interface name; the interface name is short + * and somewhat friendly, and many UN*X users are used + * to interface names, so we should show it. + */ if_string = g_strdup_printf("%s: %s", if_info->friendly_name, if_info->name); #endif } else if (if_info->vendor_description != NULL) { @@ -400,24 +400,24 @@ scan_local_interfaces(void (*update_cb)(void)) void fill_in_local_interfaces(void(*update_cb)(void)) { - GTimeVal start_time; - GTimeVal end_time; - float elapsed; - static gboolean initialized = FALSE; + GTimeVal start_time; + GTimeVal end_time; + float elapsed; + static gboolean initialized = FALSE; - /* record the time we started, so we can log total time later */ - g_get_current_time(&start_time); - g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() starts"); + /* record the time we started, so we can log total time later */ + g_get_current_time(&start_time); + g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() starts"); if (!initialized) { - /* do the actual work */ + /* do the actual work */ scan_local_interfaces(update_cb); initialized = TRUE; } - /* log how long it took */ + /* log how long it took */ g_get_current_time(&end_time); elapsed = (float) ((end_time.tv_sec - start_time.tv_sec) + - ((end_time.tv_usec - start_time.tv_usec) / 1e6)); + ((end_time.tv_usec - start_time.tv_usec) / 1e6)); g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "fill_in_local_interfaces() ends, taking %.3fs", elapsed); } diff --git a/ui/time_shift.c b/ui/time_shift.c index 67c091d7d1..177a11b935 100644 --- a/ui/time_shift.c +++ b/ui/time_shift.c @@ -34,59 +34,59 @@ #include "ui/ui_util.h" -#define SHIFT_POS 0 -#define SHIFT_NEG 1 -#define SHIFT_SETTOZERO 1 -#define SHIFT_KEEPOFFSET 0 - -#define CHECK_YEARS(Y) \ - if (*Y < 1970) { \ - return "Years must be larger than 1970"; \ - } -#define CHECK_MONTHS(M) \ - if (*M < 1 || *M > 12) { \ - return "Months must be between [1..12]"; \ - } -#define CHECK_DAYS(D) \ - if (*D < 1 || *D > 31) { \ - return "Days must be between [1..31]"; \ - } -#define CHECK_HOURS(h) \ - if (*h < 0 || *h > 23) { \ - return "Hours must be between [0..23]"; \ - } -#define CHECK_HOUR(h) \ - if (*h < 0) { \ - return "Negative hours. Have you specified more than " \ - "one minus character?"; \ - } -#define CHECK_MINUTE(m) \ - if (*m < 0 || *m > 59) { \ - return "Minutes must be between [0..59]"; \ - } -#define CHECK_SECOND(s) \ - if (*s < 0 || *s > 59) { \ - return "Seconds must be between [0..59]"; \ - } +#define SHIFT_POS 0 +#define SHIFT_NEG 1 +#define SHIFT_SETTOZERO 1 +#define SHIFT_KEEPOFFSET 0 + +#define CHECK_YEARS(Y) \ + if (*Y < 1970) { \ + return "Years must be larger than 1970"; \ + } +#define CHECK_MONTHS(M) \ + if (*M < 1 || *M > 12) { \ + return "Months must be between [1..12]"; \ + } +#define CHECK_DAYS(D) \ + if (*D < 1 || *D > 31) { \ + return "Days must be between [1..31]"; \ + } +#define CHECK_HOURS(h) \ + if (*h < 0 || *h > 23) { \ + return "Hours must be between [0..23]"; \ + } +#define CHECK_HOUR(h) \ + if (*h < 0) { \ + return "Negative hours. Have you specified more than " \ + "one minus character?"; \ + } +#define CHECK_MINUTE(m) \ + if (*m < 0 || *m > 59) { \ + return "Minutes must be between [0..59]"; \ + } +#define CHECK_SECOND(s) \ + if (*s < 0 || *s > 59) { \ + return "Seconds must be between [0..59]"; \ + } static void modify_time_perform(frame_data *fd, int neg, nstime_t *offset, int settozero) { - /* The actual shift */ - if (settozero == SHIFT_SETTOZERO) { - nstime_subtract(&(fd->abs_ts), &(fd->shift_offset)); - nstime_set_zero(&(fd->shift_offset)); - } - - if (neg == SHIFT_POS) { - nstime_add(&(fd->abs_ts), offset); - nstime_add(&(fd->shift_offset), offset); - } else if (neg == SHIFT_NEG) { - nstime_subtract(&(fd->abs_ts), offset); - nstime_subtract(&(fd->shift_offset), offset); - } else { - fprintf(stderr, "Modify_time_perform: neg = %d?\n", neg); - } + /* The actual shift */ + if (settozero == SHIFT_SETTOZERO) { + nstime_subtract(&(fd->abs_ts), &(fd->shift_offset)); + nstime_set_zero(&(fd->shift_offset)); + } + + if (neg == SHIFT_POS) { + nstime_add(&(fd->abs_ts), offset); + nstime_add(&(fd->shift_offset), offset); + } else if (neg == SHIFT_NEG) { + nstime_subtract(&(fd->abs_ts), offset); + nstime_subtract(&(fd->shift_offset), offset); + } else { + fprintf(stderr, "Modify_time_perform: neg = %d?\n", neg); + } } /* @@ -103,31 +103,31 @@ modify_time_perform(frame_data *fd, int neg, nstime_t *offset, int settozero) */ static void calcNT3(nstime_t *OT1, nstime_t *OT3, nstime_t *NT1, nstime_t *NT3, - nstime_t *deltaOT, nstime_t *deltaNT) + nstime_t *deltaOT, nstime_t *deltaNT) { - long double fnt, fot, f, secs, nsecs; - - fnt = (long double)deltaNT->secs + (deltaNT->nsecs / 1000000000.0L); - fot = (long double)deltaOT->secs + (deltaOT->nsecs / 1000000000.0L); - f = fnt / fot; - - nstime_copy(NT3, OT3); - nstime_subtract(NT3, OT1); - - secs = f * (long double)NT3->secs; - nsecs = f * (long double)NT3->nsecs; - nsecs += (secs - floorl(secs)) * 1000000000.0L; - while (nsecs > 1000000000L) { - secs += 1; - nsecs -= 1000000000L; - } - while (nsecs < 0) { - secs -= 1; - nsecs += 1000000000L; - } - NT3->secs = (time_t)secs; - NT3->nsecs = (int)nsecs; - nstime_add(NT3, NT1); + long double fnt, fot, f, secs, nsecs; + + fnt = (long double)deltaNT->secs + (deltaNT->nsecs / 1000000000.0L); + fot = (long double)deltaOT->secs + (deltaOT->nsecs / 1000000000.0L); + f = fnt / fot; + + nstime_copy(NT3, OT3); + nstime_subtract(NT3, OT1); + + secs = f * (long double)NT3->secs; + nsecs = f * (long double)NT3->nsecs; + nsecs += (secs - floorl(secs)) * 1000000000.0L; + while (nsecs > 1000000000L) { + secs += 1; + nsecs -= 1000000000L; + } + while (nsecs < 0) { + secs -= 1; + nsecs += 1000000000L; + } + NT3->secs = (time_t)secs; + NT3->nsecs = (int)nsecs; + nstime_add(NT3, NT1); } const gchar * @@ -231,10 +231,10 @@ time_string_parse(const gchar *time_text, int *year, int *month, int *day, gbool static const gchar * time_string_to_nstime(const gchar *time_text, nstime_t *packettime, nstime_t *nstime) { - int h, m, Y, M, D; - long double f; - struct tm tm, *tmptm; - time_t tt; + int h, m, Y, M, D; + long double f; + struct tm tm, *tmptm; + time_t tt; const gchar *err_str; if ((err_str = time_string_parse(time_text, &Y, &M, &D, NULL, &h, &m, &f)) != NULL) @@ -270,13 +270,13 @@ time_string_to_nstime(const gchar *time_text, nstime_t *packettime, nstime_t *ns const gchar * time_shift_all(capture_file *cf, const gchar *offset_text) { - nstime_t offset; - long double offset_float = 0; - guint32 i; - frame_data *fd; + nstime_t offset; + long double offset_float = 0; + guint32 i; + frame_data *fd; gboolean neg; - int h, m; - long double f; + int h, m; + long double f; const gchar *err_str; if (!cf || !offset_text) @@ -300,7 +300,7 @@ time_shift_all(capture_file *cf, const gchar *offset_text) for (i = 1; i <= cf->count; i++) { if ((fd = frame_data_sequence_find(cf->frames, i)) == NULL) - continue; /* Shouldn't happen */ + continue; /* Shouldn't happen */ modify_time_perform(fd, neg ? SHIFT_NEG : SHIFT_POS, &offset, SHIFT_KEEPOFFSET); } packet_list_queue_draw(); @@ -311,9 +311,9 @@ time_shift_all(capture_file *cf, const gchar *offset_text) const gchar * time_shift_settime(capture_file *cf, guint packet_num, const gchar *time_text) { - nstime_t set_time, diff_time, packet_time; - frame_data *fd, *packetfd; - guint32 i; + nstime_t set_time, diff_time, packet_time; + frame_data *fd, *packetfd; + guint32 i; const gchar *err_str; if (!cf || !time_text) @@ -344,7 +344,7 @@ time_shift_settime(capture_file *cf, guint packet_num, const gchar *time_text) /* Set everything back to the original time */ for (i = 1; i <= cf->count; i++) { if ((fd = frame_data_sequence_find(cf->frames, i)) == NULL) - continue; /* Shouldn't happen */ + continue; /* Shouldn't happen */ modify_time_perform(fd, SHIFT_POS, &diff_time, SHIFT_SETTOZERO); } @@ -355,10 +355,10 @@ time_shift_settime(capture_file *cf, guint packet_num, const gchar *time_text) const gchar * time_shift_adjtime(capture_file *cf, guint packet1_num, const gchar *time1_text, guint packet2_num, const gchar *time2_text) { - nstime_t nt1, nt2, ot1, ot2, nt3; - nstime_t dnt, dot, d3t; - frame_data *fd, *packet1fd, *packet2fd; - guint32 i; + nstime_t nt1, nt2, ot1, ot2, nt3; + nstime_t dnt, dot, d3t; + frame_data *fd, *packet1fd, *packet2fd; + guint32 i; const gchar *err_str; if (!cf || !time1_text || !time2_text) @@ -416,7 +416,7 @@ time_shift_adjtime(capture_file *cf, guint packet1_num, const gchar *time1_text, for (i = 1; i <= cf->count; i++) { if ((fd = frame_data_sequence_find(cf->frames, i)) == NULL) - continue; /* Shouldn't happen */ + continue; /* Shouldn't happen */ /* Set everything back to the original time */ nstime_subtract(&(fd->abs_ts), &(fd->shift_offset)); @@ -438,9 +438,9 @@ time_shift_adjtime(capture_file *cf, guint packet1_num, const gchar *time1_text, const gchar * time_shift_undo(capture_file *cf) { - guint32 i; - frame_data *fd; - nstime_t nulltime; + guint32 i; + frame_data *fd; + nstime_t nulltime; if (!cf) return "Nothing to work with."; @@ -452,7 +452,7 @@ time_shift_undo(capture_file *cf) for (i = 1; i <= cf->count; i++) { if ((fd = frame_data_sequence_find(cf->frames, i)) == NULL) - continue; /* Shouldn't happen */ + continue; /* Shouldn't happen */ modify_time_perform(fd, SHIFT_NEG, &nulltime, SHIFT_SETTOZERO); } packet_list_queue_draw(); diff --git a/ui/win32/console_win32.c b/ui/win32/console_win32.c index 7e69616697..c768868b0f 100644 --- a/ui/win32/console_win32.c +++ b/ui/win32/console_win32.c @@ -60,51 +60,51 @@ static gboolean stdin_capture = FALSE; /* Don't grab stdin & stdout if TRUE */ static gboolean needs_redirection(int std_handle) { - HANDLE fd; - DWORD handle_type; - DWORD error; - - fd = GetStdHandle(std_handle); - if (fd == NULL) { - /* - * No standard handle. According to Microsoft's - * documentation for GetStdHandle(), one reason for - * this would be that the process is "a service on - * an interactive desktop"; I'm not sure whether - * such a process should be popping up a console. - * - * However, it also appears to be the case for - * the standard input and standard error, but - * *not* the standard output, for something run - * with a double-click in Windows Explorer, - * sow we'll say it needs redirection. - */ - return TRUE; - } - if (fd == INVALID_HANDLE_VALUE) { - /* - * OK, I'm not when this would happen; return - * "no redirection" for now. - */ - return FALSE; - } - handle_type = GetFileType(fd); - if (handle_type == FILE_TYPE_UNKNOWN) { - error = GetLastError(); - if (error == ERROR_INVALID_HANDLE) { - /* - * OK, this appears to be the case where we're - * running something in a mode that needs a - * console. - */ - return TRUE; - } - } - - /* - * Assume no redirection is needed for all other cases. - */ - return FALSE; + HANDLE fd; + DWORD handle_type; + DWORD error; + + fd = GetStdHandle(std_handle); + if (fd == NULL) { + /* + * No standard handle. According to Microsoft's + * documentation for GetStdHandle(), one reason for + * this would be that the process is "a service on + * an interactive desktop"; I'm not sure whether + * such a process should be popping up a console. + * + * However, it also appears to be the case for + * the standard input and standard error, but + * *not* the standard output, for something run + * with a double-click in Windows Explorer, + * sow we'll say it needs redirection. + */ + return TRUE; + } + if (fd == INVALID_HANDLE_VALUE) { + /* + * OK, I'm not when this would happen; return + * "no redirection" for now. + */ + return FALSE; + } + handle_type = GetFileType(fd); + if (handle_type == FILE_TYPE_UNKNOWN) { + error = GetLastError(); + if (error == ERROR_INVALID_HANDLE) { + /* + * OK, this appears to be the case where we're + * running something in a mode that needs a + * console. + */ + return TRUE; + } + } + + /* + * Assume no redirection is needed for all other cases. + */ + return FALSE; } /* The code to create and desstroy console windows should not be necessary, |