diff options
Diffstat (limited to 'wiretap/nettrace_3gpp_32_423.c')
-rw-r--r-- | wiretap/nettrace_3gpp_32_423.c | 141 |
1 files changed, 70 insertions, 71 deletions
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c index e923475800..12cefccb88 100644 --- a/wiretap/nettrace_3gpp_32_423.c +++ b/wiretap/nettrace_3gpp_32_423.c @@ -157,41 +157,40 @@ nettrace_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) nettrace_3gpp_32_423_file_info_t *file_info = (nettrace_3gpp_32_423_file_info_t *)wth->priv; - frame_buffer_saved = file_info->wth_tmp_file->frame_buffer; - file_info->wth_tmp_file->frame_buffer = wth->frame_buffer; + frame_buffer_saved = file_info->wth_tmp_file->rec_data; + file_info->wth_tmp_file->rec_data = wth->rec_data; /* we read the created pcapng file instead */ result = wtap_read(file_info->wth_tmp_file, err, err_info, data_offset); - file_info->wth_tmp_file->frame_buffer = frame_buffer_saved; + file_info->wth_tmp_file->rec_data = frame_buffer_saved; if (!result) return result; - wth->phdr.rec_type = file_info->wth_tmp_file->phdr.rec_type; - wth->phdr.presence_flags = file_info->wth_tmp_file->phdr.presence_flags; - wth->phdr.ts = file_info->wth_tmp_file->phdr.ts; - wth->phdr.caplen = file_info->wth_tmp_file->phdr.caplen; - wth->phdr.len = file_info->wth_tmp_file->phdr.len; - wth->phdr.pkt_encap = file_info->wth_tmp_file->phdr.pkt_encap; - wth->phdr.pkt_tsprec = file_info->wth_tmp_file->phdr.pkt_tsprec; - wth->phdr.interface_id = file_info->wth_tmp_file->phdr.interface_id; - wth->phdr.opt_comment = file_info->wth_tmp_file->phdr.opt_comment; - wth->phdr.drop_count = file_info->wth_tmp_file->phdr.drop_count; - wth->phdr.pack_flags = file_info->wth_tmp_file->phdr.pack_flags; - wth->phdr.ft_specific_data = file_info->wth_tmp_file->phdr.ft_specific_data; + wth->rec.rec_type = file_info->wth_tmp_file->rec.rec_type; + wth->rec.presence_flags = file_info->wth_tmp_file->rec.presence_flags; + wth->rec.ts = file_info->wth_tmp_file->rec.ts; + wth->rec.rec_header.packet_header.caplen = file_info->wth_tmp_file->rec.rec_header.packet_header.caplen; + wth->rec.rec_header.packet_header.len = file_info->wth_tmp_file->rec.rec_header.packet_header.len; + wth->rec.rec_header.packet_header.pkt_encap = file_info->wth_tmp_file->rec.rec_header.packet_header.pkt_encap; + wth->rec.tsprec = file_info->wth_tmp_file->rec.tsprec; + wth->rec.rec_header.packet_header.interface_id = file_info->wth_tmp_file->rec.rec_header.packet_header.interface_id; + wth->rec.opt_comment = file_info->wth_tmp_file->rec.opt_comment; + wth->rec.rec_header.packet_header.drop_count = file_info->wth_tmp_file->rec.rec_header.packet_header.drop_count; + wth->rec.rec_header.packet_header.pack_flags = file_info->wth_tmp_file->rec.rec_header.packet_header.pack_flags; return result; } static gboolean -nettrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) +nettrace_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct Buffer *frame_buffer_saved; gboolean result; nettrace_3gpp_32_423_file_info_t *file_info = (nettrace_3gpp_32_423_file_info_t *)wth->priv; - frame_buffer_saved = file_info->wth_tmp_file->frame_buffer; - file_info->wth_tmp_file->frame_buffer = wth->frame_buffer; + frame_buffer_saved = file_info->wth_tmp_file->rec_data; + file_info->wth_tmp_file->rec_data = wth->rec_data; - result = wtap_seek_read(file_info->wth_tmp_file, seek_off, phdr, buf, err, err_info); - file_info->wth_tmp_file->frame_buffer = frame_buffer_saved; + result = wtap_seek_read(file_info->wth_tmp_file, seek_off, rec, buf, err, err_info); + file_info->wth_tmp_file->rec_data = frame_buffer_saved; return result; } @@ -219,7 +218,7 @@ nettrace_close(wtap *wth) #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) static guint8* -nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) +nettrace_parse_begin_time(guint8 *curr_pos, wtap_rec *rec) { /* Time vars*/ guint year, month, day, hour, minute, second, ms; @@ -244,7 +243,7 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) scan_found = sscanf(curr_pos, "%4u-%2u-%2uT%2u:%2u:%2u%3d:%2u", &year, &month, &day, &hour, &minute, &second, &UTCdiffh, &UTCdiffm); - phdr->ts.nsecs = 0; + rec->ts.nsecs = 0; if (scan_found != 8) { /* Found this format in a file: * beginTime="2013-09-11T15:45:00,666+02:00"/> @@ -253,13 +252,13 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) &year, &month, &day, &hour, &minute, &second, &ms, &UTCdiffh, &UTCdiffm); if (scan_found == 9) { - phdr->ts.nsecs = ms * 1000; + rec->ts.nsecs = ms * 1000; /* Use the code below to set the time stamp */ scan_found = 8; } else { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse second time format, scan_found %u", scan_found); */ return curr_pos; } @@ -270,34 +269,34 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) /* Fill in remaining fields and return it in a time_t */ tm.tm_year = year - 1900; if (month < 1 || month > 12) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, month is %u", month); */ return curr_pos; } tm.tm_mon = month - 1; /* Zero count*/ if (day > ((month == 2 && isleap(year)) ? 29 : days_in_month[month - 1])) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, %u-%02u-%2u is not a valid day", year, month, day); */ return curr_pos; } tm.tm_mday = day; if (hour > 23) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, hour is %u", hour); */ return curr_pos; } tm.tm_hour = hour; if (minute > 59) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, minute is %u", minute); */ return curr_pos; } @@ -307,9 +306,9 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) * Yes, 60, for leap seconds - POSIX's and Windows' * refusal to believe in them nonwithstanding. */ - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; /* g_warning("Failed to parse time, second is %u", second); */ return curr_pos; } @@ -317,21 +316,21 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) tm.tm_isdst = -1; /* daylight saving time info not known */ /* Get seconds from this time */ - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = mktime(&tm); + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = mktime(&tm); UTCdiffsec = (abs(UTCdiffh) * 60 * 60) + (UTCdiffm * 60); if (UTCdiffh < 0) { - phdr->ts.secs = phdr->ts.secs - UTCdiffsec; + rec->ts.secs = rec->ts.secs - UTCdiffsec; } else { - phdr->ts.secs = phdr->ts.secs + UTCdiffsec; + rec->ts.secs = rec->ts.secs + UTCdiffsec; } } else { /* g_warning("Failed to parse time, only %u fields", scan_found); */ - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; } return curr_pos; @@ -344,7 +343,7 @@ nettrace_parse_begin_time(guint8 *curr_pos, struct wtap_pkthdr *phdr) * </rawMsg> */ static wtap_open_return_val -write_packet_data(wtap_dumper *wdh, struct wtap_pkthdr *phdr, int *err, gchar **err_info, guint8 *file_buf, time_t start_time, int ms, exported_pdu_info_t *exported_pdu_info, char name_str[64]) +write_packet_data(wtap_dumper *wdh, wtap_rec *rec, int *err, gchar **err_info, guint8 *file_buf, time_t start_time, int ms, exported_pdu_info_t *exported_pdu_info, char name_str[64]) { char *curr_pos, *next_pos; char proto_name_str[16]; @@ -653,22 +652,22 @@ write_packet_data(wtap_dumper *wdh, struct wtap_pkthdr *phdr, int *err, gchar ** curr_pos++; } /* Construct the phdr */ - memset(phdr, 0, sizeof(struct wtap_pkthdr)); - phdr->rec_type = REC_TYPE_PACKET; + memset(rec, 0, sizeof *rec); + rec->rec_type = REC_TYPE_PACKET; if (start_time == 0) { - phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ - phdr->ts.secs = 0; - phdr->ts.nsecs = 0; + rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ + rec->ts.secs = 0; + rec->ts.nsecs = 0; } else { - phdr->presence_flags = WTAP_HAS_TS; - phdr->ts.secs = start_time; - phdr->ts.nsecs = ms * 1000000; + rec->presence_flags = WTAP_HAS_TS; + rec->ts.secs = start_time; + rec->ts.nsecs = ms * 1000000; } - phdr->caplen = pkt_data_len + exp_pdu_tags_len; - phdr->len = pkt_data_len + exp_pdu_tags_len; + rec->rec_header.packet_header.caplen = pkt_data_len + exp_pdu_tags_len; + rec->rec_header.packet_header.len = pkt_data_len + exp_pdu_tags_len; - if (!wtap_dump(wdh, phdr, packet_buf, err, err_info)) { + if (!wtap_dump(wdh, rec, packet_buf, err, err_info)) { switch (*err) { case WTAP_ERR_UNWRITABLE_REC_DATA: @@ -711,7 +710,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ guint8 *packet_buf = NULL; int wrt_err; gchar *wrt_err_info = NULL; - struct wtap_pkthdr phdr; + wtap_rec rec; time_t start_time; int scan_found; unsigned second, ms; @@ -842,8 +841,8 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ /* Null-terminate buffer; we'll be processing it as a string. */ packet_buf[packet_size + 12] = '\0'; - /* Create the packet header */ - memset(&phdr, 0, sizeof(struct wtap_pkthdr)); + /* Create the record header */ + memset(&rec, 0, sizeof rec); /* Read the file header of the input file, currently we only need the beginTime*/ @@ -857,18 +856,18 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ curr_pos = strstr(curr_pos, "<traceCollec beginTime=\""); curr_pos = curr_pos + 24; - curr_pos = nettrace_parse_begin_time(curr_pos, &phdr); + curr_pos = nettrace_parse_begin_time(curr_pos, &rec); - start_time = phdr.ts.secs; + start_time = rec.ts.secs; - /* set rest of the pkt hdr data */ - phdr.rec_type = REC_TYPE_PACKET; + /* set rest of the record hdr data */ + rec.rec_type = REC_TYPE_PACKET; - phdr.caplen = packet_size + 12; - phdr.len = packet_size + 12; + rec.rec_header.packet_header.caplen = packet_size + 12; + rec.rec_header.packet_header.len = packet_size + 12; /* XXX: report errors! */ - if (!wtap_dump(wdh_exp_pdu, &phdr, packet_buf, &wrt_err, &wrt_err_info)) { + if (!wtap_dump(wdh_exp_pdu, &rec, packet_buf, &wrt_err, &wrt_err_info)) { switch (wrt_err) { case WTAP_ERR_UNWRITABLE_REC_DATA: @@ -1035,7 +1034,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ } curr_pos = curr_pos + 7; /* Add the raw msg*/ - temp_val = write_packet_data(wdh_exp_pdu, &phdr, &wrt_err, &wrt_err_info, curr_pos, start_time, ms, &exported_pdu_info, name_str); + temp_val = write_packet_data(wdh_exp_pdu, &rec, &wrt_err, &wrt_err_info, curr_pos, start_time, ms, &exported_pdu_info, name_str); if (temp_val != WTAP_OPEN_MINE){ result = temp_val; goto end; |