diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-11-29 18:44:00 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-11-29 18:44:00 +0000 |
commit | 288efa5128341fab8907f3a2969a0bed95ae65cf (patch) | |
tree | 4f2793ffad03689cc6c0efa8744ef4d750ebaf66 | |
parent | 9c9a03842876c311833792a5a2a6ebcedbf531aa (diff) | |
download | wireshark-288efa5128341fab8907f3a2969a0bed95ae65cf.tar.gz |
Expand macros: htoles(), htolel(), htolell()
svn path=/trunk/; revision=53651
-rw-r--r-- | epan/dissectors/packet-usb.c | 19 | ||||
-rw-r--r-- | wiretap/5views.c | 46 | ||||
-rw-r--r-- | wiretap/lanalyzer.c | 52 | ||||
-rw-r--r-- | wiretap/netmon.c | 52 | ||||
-rw-r--r-- | wiretap/netscaler.c | 12 | ||||
-rw-r--r-- | wiretap/netxray.c | 40 | ||||
-rw-r--r-- | wiretap/ngsniffer.c | 14 | ||||
-rw-r--r-- | wiretap/tnef.c | 2 | ||||
-rw-r--r-- | wiretap/visual.c | 30 | ||||
-rw-r--r-- | wiretap/wtap-int.h | 5 | ||||
-rw-r--r-- | wsutil/pint.h | 4 |
11 files changed, 133 insertions, 143 deletions
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index f59667df7b..46f8629116 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -30,7 +30,6 @@ #include "isprint.h" #include <glib.h> -#include <wsutil/pint.h> #include <epan/packet.h> #include <epan/exceptions.h> #include <epan/etypes.h> @@ -1190,7 +1189,7 @@ get_usb_iface_conv_info(packet_info *pinfo, guint8 interface_num) conversation_t *conversation; guint32 if_port; - if_port = htolel(INTERFACE_PORT | interface_num); + if_port = GUINT32_TO_LE(INTERFACE_PORT | interface_num); if (pinfo->srcport == NO_ENDPOINT) { conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst, pinfo->srcport, if_port); @@ -1772,7 +1771,7 @@ dissect_usb_endpoint_descriptor(packet_info *pinfo, proto_tree *parent_tree, * but the new endpoint. */ usb_addr.device = ((const usb_address_t *)(pinfo->src.data))->device; - usb_addr.endpoint = htolel(endpoint); + usb_addr.endpoint = GUINT32_TO_LE(endpoint); SET_ADDRESS(&tmp_addr, AT_USB, USB_ADDR_LEN, (char *)&usb_addr); conversation = get_usb_conversation(pinfo, &tmp_addr, &pinfo->dst, usb_addr.endpoint, pinfo->destport); } else { @@ -1783,7 +1782,7 @@ dissect_usb_endpoint_descriptor(packet_info *pinfo, proto_tree *parent_tree, * but the new endpoint. */ usb_addr.device = ((const usb_address_t *)(pinfo->dst.data))->device; - usb_addr.endpoint = htolel(endpoint); + usb_addr.endpoint = GUINT32_TO_LE(endpoint); SET_ADDRESS(&tmp_addr, AT_USB, USB_ADDR_LEN, (char *)&usb_addr); conversation = get_usb_conversation(pinfo, &pinfo->src, &tmp_addr, pinfo->srcport, usb_addr.endpoint); } @@ -2796,11 +2795,11 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, if (is_request) { src_addr.device = 0xffffffff; src_addr.endpoint = src_endpoint = NO_ENDPOINT; - dst_addr.device = htolel(tmp_addr); - dst_addr.endpoint = dst_endpoint = htolel(endpoint); + dst_addr.device = GUINT32_TO_LE(tmp_addr); + dst_addr.endpoint = dst_endpoint = GUINT32_TO_LE(endpoint); } else { - src_addr.device = htolel(tmp_addr); - src_addr.endpoint = src_endpoint = htolel(endpoint); + src_addr.device = GUINT32_TO_LE(tmp_addr); + src_addr.endpoint = src_endpoint = GUINT32_TO_LE(endpoint); dst_addr.device = 0xffffffff; dst_addr.endpoint = dst_endpoint = NO_ENDPOINT; } @@ -2987,7 +2986,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, static address endpoint_addr; endpoint = usb_trans_info->setup.wIndex & 0x0f; - dst_addr.endpoint = dst_endpoint = htolel(endpoint); + dst_addr.endpoint = dst_endpoint = GUINT32_TO_LE(endpoint); SET_ADDRESS(&endpoint_addr, AT_USB, USB_ADDR_LEN, (char *)&dst_addr); conversation = get_usb_conversation(pinfo, &pinfo->src, &endpoint_addr, pinfo->srcport, dst_endpoint); @@ -3075,7 +3074,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent, static address endpoint_addr; endpoint = usb_trans_info->setup.wIndex & 0x0f; - src_addr.endpoint = src_endpoint = htolel(endpoint); + src_addr.endpoint = src_endpoint = GUINT32_TO_LE(endpoint); SET_ADDRESS(&endpoint_addr, AT_USB, USB_ADDR_LEN, (char *)&src_addr); conversation = get_usb_conversation(pinfo, &endpoint_addr, &pinfo->dst, src_endpoint, pinfo->destport); diff --git a/wiretap/5views.c b/wiretap/5views.c index 10a5ecc86c..2359e4ae4a 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -372,18 +372,18 @@ static gboolean _5views_dump(wtap_dumper *wdh, /* Frame Header */ /* constant fields */ - HeaderFrame.Key = htolel(CST_5VW_RECORDS_HEADER_KEY); - HeaderFrame.HeaderSize = htoles(sizeof(t_5VW_TimeStamped_Header)); - HeaderFrame.HeaderType = htoles(CST_5VW_TIMESTAMPED_HEADER_TYPE); - HeaderFrame.RecType = htolel(CST_5VW_CAPTURES_RECORD | CST_5VW_SYSTEM_RECORD); - HeaderFrame.RecSubType = htolel(CST_5VW_FRAME_RECORD); - HeaderFrame.RecNb = htolel(1); + HeaderFrame.Key = GUINT32_TO_LE(CST_5VW_RECORDS_HEADER_KEY); + HeaderFrame.HeaderSize = GUINT16_TO_LE(sizeof(t_5VW_TimeStamped_Header)); + HeaderFrame.HeaderType = GUINT16_TO_LE(CST_5VW_TIMESTAMPED_HEADER_TYPE); + HeaderFrame.RecType = GUINT32_TO_LE(CST_5VW_CAPTURES_RECORD | CST_5VW_SYSTEM_RECORD); + HeaderFrame.RecSubType = GUINT32_TO_LE(CST_5VW_FRAME_RECORD); + HeaderFrame.RecNb = GUINT32_TO_LE(1); /* record-dependent fields */ - HeaderFrame.Utc = htolel(phdr->ts.secs); - HeaderFrame.NanoSecondes = htolel(phdr->ts.nsecs); - HeaderFrame.RecSize = htolel(phdr->len); - HeaderFrame.RecInfo = htolel(0); + HeaderFrame.Utc = GUINT32_TO_LE(phdr->ts.secs); + HeaderFrame.NanoSecondes = GUINT32_TO_LE(phdr->ts.nsecs); + HeaderFrame.RecSize = GUINT32_TO_LE(phdr->len); + HeaderFrame.RecInfo = GUINT32_TO_LE(0); /* write the record header */ if (!wtap_dump_file_write(wdh, &HeaderFrame, @@ -408,37 +408,37 @@ static gboolean _5views_dump_close(wtap_dumper *wdh, int *err) return FALSE; /* fill in the Info_Header */ - file_hdr.Info_Header.Signature = htolel(CST_5VW_INFO_HEADER_KEY); - file_hdr.Info_Header.Size = htolel(sizeof(t_5VW_Info_Header)); /* Total size of Header in bytes (included Signature) */ - file_hdr.Info_Header.Version = htolel(CST_5VW_INFO_RECORD_VERSION); /* Identify version and so the format of this record */ - file_hdr.Info_Header.DataSize = htolel(sizeof(t_5VW_Attributes_Header) + file_hdr.Info_Header.Signature = GUINT32_TO_LE(CST_5VW_INFO_HEADER_KEY); + file_hdr.Info_Header.Size = GUINT32_TO_LE(sizeof(t_5VW_Info_Header)); /* Total size of Header in bytes (included Signature) */ + file_hdr.Info_Header.Version = GUINT32_TO_LE(CST_5VW_INFO_RECORD_VERSION); /* Identify version and so the format of this record */ + file_hdr.Info_Header.DataSize = GUINT32_TO_LE(sizeof(t_5VW_Attributes_Header) + sizeof(guint32) + sizeof(t_5VW_Attributes_Header) + sizeof(guint32)); /* Total size of data included in the Info Record (except the header size) */ - file_hdr.Info_Header.FileType = htolel(wtap_encap[wdh->encap]); /* Type of the file */ + file_hdr.Info_Header.FileType = GUINT32_TO_LE(wtap_encap[wdh->encap]); /* Type of the file */ file_hdr.Info_Header.Reserved[0] = 0; /* Reserved for future use */ file_hdr.Info_Header.Reserved[1] = 0; /* Reserved for future use */ file_hdr.Info_Header.Reserved[2] = 0; /* Reserved for future use */ /* fill in the HeaderDateCreation */ - file_hdr.HeaderDateCreation.Type = htolel(CST_5VW_IA_DATE_CREATION); /* Id of the attribute */ - file_hdr.HeaderDateCreation.Size = htoles(sizeof(guint32)); /* Size of the data part of the attribute (not including header size) */ - file_hdr.HeaderDateCreation.Nb = htoles(1); /* Number of elements */ + file_hdr.HeaderDateCreation.Type = GUINT32_TO_LE(CST_5VW_IA_DATE_CREATION); /* Id of the attribute */ + file_hdr.HeaderDateCreation.Size = GUINT16_TO_LE(sizeof(guint32)); /* Size of the data part of the attribute (not including header size) */ + file_hdr.HeaderDateCreation.Nb = GUINT16_TO_LE(1); /* Number of elements */ /* fill in the Time field */ #ifdef _WIN32 _tzset(); #endif - file_hdr.Time = htolel(time(NULL)); + file_hdr.Time = GUINT32_TO_LE(time(NULL)); /* fill in the Time field */ - file_hdr.HeaderNbFrames.Type = htolel(CST_5VW_IA_CAP_INF_NB_TRAMES_STOCKEES); /* Id of the attribute */ - file_hdr.HeaderNbFrames.Size = htoles(sizeof(guint32)); /* Size of the data part of the attribute (not including header size) */ - file_hdr.HeaderNbFrames.Nb = htoles(1); /* Number of elements */ + file_hdr.HeaderNbFrames.Type = GUINT32_TO_LE(CST_5VW_IA_CAP_INF_NB_TRAMES_STOCKEES); /* Id of the attribute */ + file_hdr.HeaderNbFrames.Size = GUINT16_TO_LE(sizeof(guint32)); /* Size of the data part of the attribute (not including header size) */ + file_hdr.HeaderNbFrames.Nb = GUINT16_TO_LE(1); /* Number of elements */ /* fill in the number of frames saved */ - file_hdr.TramesStockeesInFile = htolel(_5views->nframes); + file_hdr.TramesStockeesInFile = GUINT32_TO_LE(_5views->nframes); /* Write the file header. */ if (!wtap_dump_file_write(wdh, &file_hdr, sizeof(t_5VW_Capture_Header), diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 4e7104c6d1..9fc6fc49ad 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -674,9 +674,9 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, len = phdr->caplen + (phdr->caplen ? LA_PacketRecordSize : 0); - if (!s16write(wdh, htoles(0x1005), err)) + if (!s16write(wdh, GUINT16_TO_LE(0x1005), err)) return FALSE; - if (!s16write(wdh, htoles(len), err)) + if (!s16write(wdh, GUINT16_TO_LE(len), err)) return FALSE; tv.tv_sec = (long int) phdr->ts.secs; @@ -700,24 +700,24 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, x += (double) td.tv_sec * 1000000; x *= 2; - if (!s16write(wdh, htoles(0x0001), err)) /* pr.rx_channels */ + if (!s16write(wdh, GUINT16_TO_LE(0x0001), err)) /* pr.rx_channels */ return FALSE; - if (!s16write(wdh, htoles(0x0008), err)) /* pr.rx_errors */ + if (!s16write(wdh, GUINT16_TO_LE(0x0008), err)) /* pr.rx_errors */ return FALSE; - if (!s16write(wdh, htoles(phdr->len + 4), err)) /* pr.rx_frm_len */ + if (!s16write(wdh, GUINT16_TO_LE(phdr->len + 4), err)) /* pr.rx_frm_len */ return FALSE; - if (!s16write(wdh, htoles(phdr->caplen), err)) /* pr.rx_frm_sln */ + if (!s16write(wdh, GUINT16_TO_LE(phdr->caplen), err)) /* pr.rx_frm_sln */ return FALSE; for (i = 0; i < 3; i++) { - if (!s16write(wdh, htoles((guint16) x), err)) /* pr.rx_time[i] */ + if (!s16write(wdh, GUINT16_TO_LE((guint16) x), err)) /* pr.rx_time[i] */ return FALSE; x /= 0xffff; } - if (!s32write(wdh, htolel(++itmp->pkts), err)) /* pr.pktno */ + if (!s32write(wdh, GUINT32_TO_LE(++itmp->pkts), err)) /* pr.pktno */ return FALSE; - if (!s16write(wdh, htoles(itmp->lastlen), err)) /* pr.prlen */ + if (!s16write(wdh, GUINT16_TO_LE(itmp->lastlen), err)) /* pr.prlen */ return FALSE; itmp->lastlen = len; @@ -838,21 +838,21 @@ static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err) sizeof LA_DisplayOptionsFake, err)) return FALSE; /*-----------------------------------------------------------------*/ - if (!s16write(wdh, htoles(RT_Summary), err)) /* rid */ + if (!s16write(wdh, GUINT16_TO_LE(RT_Summary), err)) /* rid */ return FALSE; - if (!s16write(wdh, htoles(SummarySize), err)) /* rlen */ + if (!s16write(wdh, GUINT16_TO_LE(SummarySize), err)) /* rlen */ return FALSE; if (!s8write(wdh, (guint8) fT->tm_mday, err)) /* s.datcre.day */ return FALSE; if (!s8write(wdh, (guint8) (fT->tm_mon+1), err)) /* s.datcre.mon */ return FALSE; - if (!s16write(wdh, htoles(fT->tm_year + 1900), err)) /* s.datcre.year */ + if (!s16write(wdh, GUINT16_TO_LE(fT->tm_year + 1900), err)) /* s.datcre.year */ return FALSE; if (!s8write(wdh, (guint8) fT->tm_mday, err)) /* s.datclo.day */ return FALSE; if (!s8write(wdh, (guint8) (fT->tm_mon+1), err)) /* s.datclo.mon */ return FALSE; - if (!s16write(wdh, htoles(fT->tm_year + 1900), err)) /* s.datclo.year */ + if (!s16write(wdh, GUINT16_TO_LE(fT->tm_year + 1900), err)) /* s.datclo.year */ return FALSE; if (!s8write(wdh, (guint8) fT->tm_sec, err)) /* s.timeopn.second */ return FALSE; @@ -876,13 +876,13 @@ static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err) return FALSE; if (!s0write(wdh, 6, err)) /* EAddr == 0 */ return FALSE; - if (!s16write(wdh, htoles(1), err)) /* s.mxseqno */ + if (!s16write(wdh, GUINT16_TO_LE(1), err)) /* s.mxseqno */ return FALSE; - if (!s16write(wdh, htoles(0), err)) /* s.slcoffo */ + if (!s16write(wdh, GUINT16_TO_LE(0), err)) /* s.slcoffo */ return FALSE; - if (!s16write(wdh, htoles(1514), err)) /* s.mxslc */ + if (!s16write(wdh, GUINT16_TO_LE(1514), err)) /* s.mxslc */ return FALSE; - if (!s32write(wdh, htolel(itmp->pkts), err)) /* s.totpktt */ + if (!s32write(wdh, GUINT32_TO_LE(itmp->pkts), err)) /* s.totpktt */ return FALSE; /* * statrg == 0; ? -1 @@ -891,33 +891,33 @@ static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err) */ if (!s0write(wdh, 12, err)) return FALSE; - if (!s32write(wdh, htolel(itmp->pkts), err)) /* sr.s.mxpkta[1] */ + if (!s32write(wdh, GUINT32_TO_LE(itmp->pkts), err)) /* sr.s.mxpkta[1] */ return FALSE; if (!s0write(wdh, 34*4, err)) /* s.mxpkta[2-33]=0 */ return FALSE; - if (!s16write(wdh, htoles(board_type), err)) + if (!s16write(wdh, GUINT16_TO_LE(board_type), err)) return FALSE; if (!s0write(wdh, 20, err)) /* board_version == 0 */ return FALSE; /*-----------------------------------------------------------------*/ - if (!s16write(wdh, htoles(RT_SubfileSummary), err)) /* ssr.rid */ + if (!s16write(wdh, GUINT16_TO_LE(RT_SubfileSummary), err)) /* ssr.rid */ return FALSE; - if (!s16write(wdh, htoles(LA_SubfileSummaryRecordSize-4), err)) /* ssr.rlen */ + if (!s16write(wdh, GUINT16_TO_LE(LA_SubfileSummaryRecordSize-4), err)) /* ssr.rlen */ return FALSE; - if (!s16write(wdh, htoles(1), err)) /* ssr.seqno */ + if (!s16write(wdh, GUINT16_TO_LE(1), err)) /* ssr.seqno */ return FALSE; - if (!s32write(wdh, htolel(itmp->pkts), err)) /* ssr.totpkts */ + if (!s32write(wdh, GUINT32_TO_LE(itmp->pkts), err)) /* ssr.totpkts */ return FALSE; /*-----------------------------------------------------------------*/ if (!wtap_dump_file_write(wdh, &LA_CyclicInformationFake, sizeof LA_CyclicInformationFake, err)) return FALSE; /*-----------------------------------------------------------------*/ - if (!s16write(wdh, htoles(RT_Index), err)) /* rid */ + if (!s16write(wdh, GUINT16_TO_LE(RT_Index), err)) /* rid */ return FALSE; - if (!s16write(wdh, htoles(LA_IndexRecordSize -4), err)) /* rlen */ + if (!s16write(wdh, GUINT16_TO_LE(LA_IndexRecordSize -4), err)) /* rlen */ return FALSE; - if (!s16write(wdh, htoles(LA_IndexSize), err)) /* idxsp */ + if (!s16write(wdh, GUINT16_TO_LE(LA_IndexSize), err)) /* idxsp */ return FALSE; if (!s0write(wdh, LA_IndexRecordSize - 6, err)) return FALSE; diff --git a/wiretap/netmon.c b/wiretap/netmon.c index 4b41f35168..1c006752a3 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -1111,17 +1111,17 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, switch (wdh->file_type_subtype) { case WTAP_FILE_TYPE_SUBTYPE_NETMON_1_x: - rec_1_x_hdr.ts_delta = htolel(secs*1000 + (nsecs + 500000)/1000000); - rec_1_x_hdr.orig_len = htoles(phdr->len + atm_hdrsize); - rec_1_x_hdr.incl_len = htoles(phdr->caplen + atm_hdrsize); + rec_1_x_hdr.ts_delta = GUINT32_TO_LE(secs*1000 + (nsecs + 500000)/1000000); + rec_1_x_hdr.orig_len = GUINT16_TO_LE(phdr->len + atm_hdrsize); + rec_1_x_hdr.incl_len = GUINT16_TO_LE(phdr->caplen + atm_hdrsize); hdrp = &rec_1_x_hdr; hdr_size = sizeof rec_1_x_hdr; break; case WTAP_FILE_TYPE_SUBTYPE_NETMON_2_x: - rec_2_x_hdr.ts_delta = htolell(secs*1000000 + (nsecs + 500)/1000); - rec_2_x_hdr.orig_len = htolel(phdr->len + atm_hdrsize); - rec_2_x_hdr.incl_len = htolel(phdr->caplen + atm_hdrsize); + rec_2_x_hdr.ts_delta = GUINT64_TO_LE(secs*1000000 + (nsecs + 500)/1000); + rec_2_x_hdr.orig_len = GUINT32_TO_LE(phdr->len + atm_hdrsize); + rec_2_x_hdr.incl_len = GUINT32_TO_LE(phdr->caplen + atm_hdrsize); hdrp = &rec_2_x_hdr; hdr_size = sizeof rec_2_x_hdr; break; @@ -1195,7 +1195,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } netmon->frame_table[netmon->frame_table_index] = - htolel(netmon->frame_table_offset); + GUINT32_TO_LE(netmon->frame_table_offset); /* * Is this the last record we can write? @@ -1294,31 +1294,31 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err) * type in the file header is irrelevant. Set it * to 1, just as Network Monitor does. */ - file_hdr.network = htoles(1); + file_hdr.network = GUINT16_TO_LE(1); } else - file_hdr.network = htoles(wtap_encap[wdh->encap]); + file_hdr.network = GUINT16_TO_LE(wtap_encap[wdh->encap]); tm = localtime(&netmon->first_record_time.secs); if (tm != NULL) { - file_hdr.ts_year = htoles(1900 + tm->tm_year); - file_hdr.ts_month = htoles(tm->tm_mon + 1); - file_hdr.ts_dow = htoles(tm->tm_wday); - file_hdr.ts_day = htoles(tm->tm_mday); - file_hdr.ts_hour = htoles(tm->tm_hour); - file_hdr.ts_min = htoles(tm->tm_min); - file_hdr.ts_sec = htoles(tm->tm_sec); + file_hdr.ts_year = GUINT16_TO_LE(1900 + tm->tm_year); + file_hdr.ts_month = GUINT16_TO_LE(tm->tm_mon + 1); + file_hdr.ts_dow = GUINT16_TO_LE(tm->tm_wday); + file_hdr.ts_day = GUINT16_TO_LE(tm->tm_mday); + file_hdr.ts_hour = GUINT16_TO_LE(tm->tm_hour); + file_hdr.ts_min = GUINT16_TO_LE(tm->tm_min); + file_hdr.ts_sec = GUINT16_TO_LE(tm->tm_sec); } else { - file_hdr.ts_year = htoles(1900 + 0); - file_hdr.ts_month = htoles(0 + 1); - file_hdr.ts_dow = htoles(0); - file_hdr.ts_day = htoles(0); - file_hdr.ts_hour = htoles(0); - file_hdr.ts_min = htoles(0); - file_hdr.ts_sec = htoles(0); + file_hdr.ts_year = GUINT16_TO_LE(1900 + 0); + file_hdr.ts_month = GUINT16_TO_LE(0 + 1); + file_hdr.ts_dow = GUINT16_TO_LE(0); + file_hdr.ts_day = GUINT16_TO_LE(0); + file_hdr.ts_hour = GUINT16_TO_LE(0); + file_hdr.ts_min = GUINT16_TO_LE(0); + file_hdr.ts_sec = GUINT16_TO_LE(0); } - file_hdr.ts_msec = htoles(netmon->first_record_time.nsecs/1000000); - file_hdr.frametableoffset = htolel(netmon->frame_table_offset); + file_hdr.ts_msec = GUINT16_TO_LE(netmon->first_record_time.nsecs/1000000); + file_hdr.frametableoffset = GUINT32_TO_LE(netmon->frame_table_offset); file_hdr.frametablelength = - htolel(netmon->frame_table_index * sizeof *netmon->frame_table); + GUINT32_TO_LE(netmon->frame_table_index * sizeof *netmon->frame_table); if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err)) return FALSE; diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c index 4e53ab6e93..36aa11a645 100644 --- a/wiretap/netscaler.c +++ b/wiretap/netscaler.c @@ -1352,9 +1352,9 @@ static gboolean nstrace_add_signature(wtap_dumper *wdh, int *err) nspr_signature_v10_t sig10; /* populate the record */ - val16b = htoles(NSPR_SIGNATURE_V10); + val16b = GUINT16_TO_LE(NSPR_SIGNATURE_V10); memcpy(sig10.phd.ph_RecordType, &val16b, sizeof sig10.phd.ph_RecordType); - val16b = htoles(nspr_signature_v10_s); + val16b = GUINT16_TO_LE(nspr_signature_v10_s); memcpy(sig10.phd.ph_RecordSize, &val16b, sizeof sig10.phd.ph_RecordSize); memset(sig10.sig_Signature, 0, NSPR_SIGSIZE_V10); g_strlcpy(sig10.sig_Signature, NSPR_SIGSTR_V10, NSPR_SIGSIZE_V10); @@ -1408,16 +1408,16 @@ nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, nspr_abstime_v10_t abs10; /* populate the record */ - val16 = htoles(NSPR_ABSTIME_V10); + val16 = GUINT16_TO_LE(NSPR_ABSTIME_V10); memcpy(abs10.phd.ph_RecordType, &val16, sizeof abs10.phd.ph_RecordType); - val16 = htoles(nspr_abstime_v10_s); + val16 = GUINT16_TO_LE(nspr_abstime_v10_s); memcpy(abs10.phd.ph_RecordSize, &val16, sizeof abs10.phd.ph_RecordSize); memcpy(&reltime, ((const nspr_pktracefull_v10_t *)pd)->fp_RelTimeHr, sizeof reltime); nsg_creltime = ns_hrtime2nsec(reltime); memset(abs10.abs_RelTime, 0, sizeof abs10.abs_RelTime); - abstime = htolel((guint32)phdr->ts.secs - (guint32)(nsg_creltime/1000000000)); + abstime = GUINT32_TO_LE((guint32)phdr->ts.secs - (guint32)(nsg_creltime/1000000000)); memcpy(abs10.abs_Time, &abstime, sizeof abs10.abs_Time); /* Write the record into the file */ @@ -1440,7 +1440,7 @@ nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, nsg_creltime = ns_hrtime2nsec(reltime); memset(abs20.abs_RelTime, 0, sizeof abs20.abs_RelTime); - abstime = htolel((guint32)phdr->ts.secs - (guint32)(nsg_creltime/1000000000)); + abstime = GUINT32_TO_LE((guint32)phdr->ts.secs - (guint32)(nsg_creltime/1000000000)); memcpy(abs20.abs_RelTime, &abstime, sizeof abs20.abs_RelTime); /* Write the record into the file */ diff --git a/wiretap/netxray.c b/wiretap/netxray.c index 2d4481260e..959ae97f33 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -1540,11 +1540,11 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh, timestamp = ((guint64)phdr->ts.secs - (guint64)netxray->start.secs)*1000000 + ((guint64)phdr->ts.nsecs)/1000; t32 = (guint32)(timestamp%G_GINT64_CONSTANT(4294967296)); - rec_hdr.timelo = htolel(t32); + rec_hdr.timelo = GUINT32_TO_LE(t32); t32 = (guint32)(timestamp/G_GINT64_CONSTANT(4294967296)); - rec_hdr.timehi = htolel(t32); - rec_hdr.orig_len = htoles(phdr->len); - rec_hdr.incl_len = htoles(phdr->caplen); + rec_hdr.timehi = GUINT32_TO_LE(t32); + rec_hdr.orig_len = GUINT16_TO_LE(phdr->len); + rec_hdr.incl_len = GUINT16_TO_LE(phdr->caplen); if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof(rec_hdr), err)) return FALSE; @@ -1583,14 +1583,14 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err) /* "sniffer" version ? */ memset(&file_hdr, '\0', sizeof file_hdr); memcpy(file_hdr.version, vers_1_1, sizeof vers_1_1); - file_hdr.start_time = htolel(netxray->start.secs); - file_hdr.nframes = htolel(netxray->nframes); - file_hdr.start_offset = htolel(CAPTUREFILE_HEADER_SIZE); + file_hdr.start_time = GUINT32_TO_LE(netxray->start.secs); + file_hdr.nframes = GUINT32_TO_LE(netxray->nframes); + file_hdr.start_offset = GUINT32_TO_LE(CAPTUREFILE_HEADER_SIZE); /* XXX - large files? */ - file_hdr.end_offset = htolel((guint32)filelen); + file_hdr.end_offset = GUINT32_TO_LE((guint32)filelen); file_hdr.network = wtap_encap_to_netxray_1_1_encap(wdh->encap); - file_hdr.timelo = htolel(0); - file_hdr.timehi = htolel(0); + file_hdr.timelo = GUINT32_TO_LE(0); + file_hdr.timehi = GUINT32_TO_LE(0); memset(hdr_buf, '\0', sizeof hdr_buf); memcpy(hdr_buf, &file_hdr, sizeof(file_hdr)); @@ -1702,11 +1702,11 @@ static gboolean netxray_dump_2_0(wtap_dumper *wdh, timestamp = ((guint64)phdr->ts.secs - (guint64)netxray->start.secs)*1000000 + ((guint64)phdr->ts.nsecs)/1000; t32 = (guint32)(timestamp%G_GINT64_CONSTANT(4294967296)); - rec_hdr.timelo = htolel(t32); + rec_hdr.timelo = GUINT32_TO_LE(t32); t32 = (guint32)(timestamp/G_GINT64_CONSTANT(4294967296)); - rec_hdr.timehi = htolel(t32); - rec_hdr.orig_len = htoles(phdr->len); - rec_hdr.incl_len = htoles(phdr->caplen); + rec_hdr.timehi = GUINT32_TO_LE(t32); + rec_hdr.orig_len = GUINT16_TO_LE(phdr->len); + rec_hdr.incl_len = GUINT16_TO_LE(phdr->caplen); switch (phdr->pkt_encap) { @@ -1763,14 +1763,14 @@ static gboolean netxray_dump_close_2_0(wtap_dumper *wdh, int *err) /* "sniffer" version ? */ memset(&file_hdr, '\0', sizeof file_hdr); memcpy(file_hdr.version, vers_2_001, sizeof vers_2_001); - file_hdr.start_time = htolel(netxray->start.secs); - file_hdr.nframes = htolel(netxray->nframes); - file_hdr.start_offset = htolel(CAPTUREFILE_HEADER_SIZE); + file_hdr.start_time = GUINT32_TO_LE(netxray->start.secs); + file_hdr.nframes = GUINT32_TO_LE(netxray->nframes); + file_hdr.start_offset = GUINT32_TO_LE(CAPTUREFILE_HEADER_SIZE); /* XXX - large files? */ - file_hdr.end_offset = htolel((guint32)filelen); + file_hdr.end_offset = GUINT32_TO_LE((guint32)filelen); file_hdr.network = wtap_encap_to_netxray_2_0_encap(wdh->encap); - file_hdr.timelo = htolel(0); - file_hdr.timehi = htolel(0); + file_hdr.timelo = GUINT32_TO_LE(0); + file_hdr.timehi = GUINT32_TO_LE(0); switch (wdh->encap) { case WTAP_ENCAP_PPP_WITH_PHDR: diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index a1d34cd6b0..8c649e8f0d 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -2153,10 +2153,10 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* "sniffer" version ? */ maj_vers = 4; min_vers = 0; - version.maj_vers = htoles(maj_vers); - version.min_vers = htoles(min_vers); + version.maj_vers = GUINT16_TO_LE(maj_vers); + version.min_vers = GUINT16_TO_LE(min_vers); version.time = 0; - version.date = htoles(start_date); + version.date = GUINT16_TO_LE(start_date); version.type = 4; version.network = wtap_encap[wdh->encap]; version.format = 1; @@ -2190,10 +2190,10 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, t_low = (guint16)((t >> 0) & 0xFFFF); t_med = (guint16)((t >> 16) & 0xFFFF); t_high = (guint8)((t >> 32) & 0xFF); - rec_hdr.time_low = htoles(t_low); - rec_hdr.time_med = htoles(t_med); + rec_hdr.time_low = GUINT16_TO_LE(t_low); + rec_hdr.time_med = GUINT16_TO_LE(t_med); rec_hdr.time_high = t_high; - rec_hdr.size = htoles(phdr->caplen); + rec_hdr.size = GUINT16_TO_LE(phdr->caplen); switch (wdh->encap) { case WTAP_ENCAP_LAPB: @@ -2229,7 +2229,7 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, break; } rec_hdr.flags = 0; - rec_hdr.true_size = phdr->len != phdr->caplen ? htoles(phdr->len) : 0; + rec_hdr.true_size = phdr->len != phdr->caplen ? GUINT16_TO_LE(phdr->len) : 0; rec_hdr.rsvd = 0; if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err)) return FALSE; diff --git a/wiretap/tnef.c b/wiretap/tnef.c index c726381fcc..22cced79a8 100644 --- a/wiretap/tnef.c +++ b/wiretap/tnef.c @@ -108,7 +108,7 @@ int tnef_open(wtap *wth, int *err, gchar **err_info) return (*err != 0) ? -1 : 0; } - if (htolel(magic) != TNEF_SIGNATURE) + if (GUINT32_TO_LE(magic) != TNEF_SIGNATURE) /* Not a tnef file */ return 0; diff --git a/wiretap/visual.c b/wiretap/visual.c index 12e4c06c8e..af47c9925b 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -709,11 +709,11 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, /* Calculate milliseconds since capture start. */ delta_msec = phdr->ts.nsecs / 1000000; delta_msec += ( (guint32) phdr->ts.secs - visual->start_time) * 1000; - vpkt_hdr.ts_delta = htolel(delta_msec); + vpkt_hdr.ts_delta = GUINT32_TO_LE(delta_msec); /* Fill in the length fields. */ - vpkt_hdr.orig_len = htoles(phdr->len); - vpkt_hdr.incl_len = htoles(phdr->caplen); + vpkt_hdr.orig_len = GUINT16_TO_LE(phdr->len); + vpkt_hdr.incl_len = GUINT16_TO_LE(phdr->caplen); /* Fill in the encapsulation hint for the file's media type. */ switch (wdh->encap) @@ -757,7 +757,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, ((pseudo_header->x25.flags & FROM_DCE) ? 0x00 : PS_SENT); break; } - vpkt_hdr.status = htolel(packet_status); + vpkt_hdr.status = GUINT32_TO_LE(packet_status); /* Write the packet header. */ if (!wtap_dump_file_write(wdh, &vpkt_hdr, hdr_size, err)) @@ -775,7 +775,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, visual->index_table = (guint32 *)g_realloc(visual->index_table, visual->index_table_size * sizeof *visual->index_table); } - visual->index_table[visual->index_table_index] = htolel(visual->next_offset); + visual->index_table[visual->index_table_index] = GUINT32_TO_LE(visual->next_offset); /* Update the table index and offset for the next frame. */ visual->index_table_index++; @@ -825,36 +825,36 @@ static gboolean visual_dump_close(wtap_dumper *wdh, int *err) /* Initialize the file header with zeroes for the reserved fields. */ memset(&vfile_hdr, '\0', sizeof vfile_hdr); - vfile_hdr.num_pkts = htolel(visual->index_table_index); - vfile_hdr.start_time = htolel(visual->start_time); - vfile_hdr.max_length = htoles(65535); - vfile_hdr.file_flags = htoles(1); /* indexes are present */ - vfile_hdr.file_version = htoles(1); + vfile_hdr.num_pkts = GUINT32_TO_LE(visual->index_table_index); + vfile_hdr.start_time = GUINT32_TO_LE(visual->start_time); + vfile_hdr.max_length = GUINT16_TO_LE(65535); + vfile_hdr.file_flags = GUINT16_TO_LE(1); /* indexes are present */ + vfile_hdr.file_version = GUINT16_TO_LE(1); g_strlcpy(vfile_hdr.description, "Wireshark file", 64); /* Translate the encapsulation type */ switch (wdh->encap) { case WTAP_ENCAP_ETHERNET: - vfile_hdr.media_type = htoles(6); + vfile_hdr.media_type = GUINT16_TO_LE(6); break; case WTAP_ENCAP_TOKEN_RING: - vfile_hdr.media_type = htoles(9); + vfile_hdr.media_type = GUINT16_TO_LE(9); break; case WTAP_ENCAP_LAPB: - vfile_hdr.media_type = htoles(16); + vfile_hdr.media_type = GUINT16_TO_LE(16); break; case WTAP_ENCAP_PPP: /* PPP is differentiated from CHDLC in PktHdr */ case WTAP_ENCAP_PPP_WITH_PHDR: case WTAP_ENCAP_CHDLC_WITH_PHDR: - vfile_hdr.media_type = htoles(22); + vfile_hdr.media_type = GUINT16_TO_LE(22); break; case WTAP_ENCAP_FRELAY_WITH_PHDR: - vfile_hdr.media_type = htoles(32); + vfile_hdr.media_type = GUINT16_TO_LE(32); break; } diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 2477ec7007..4d6195a2be 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -177,11 +177,6 @@ extern gint wtap_num_file_types; (p)[0] = tmp; \ } -/* Turn host-byte-order values into little-endian values. */ -#define htoles(s) GUINT16_TO_LE(s) -#define htolel(l) GUINT32_TO_LE(l) -#define htolell(ll) GUINT64_TO_LE(ll) - /* Pointer versions of ntohs and ntohl. Given a pointer to a member of a * byte array, returns the value of the two or four bytes at the pointer. * The pletoh[sl] versions return the little-endian representation. diff --git a/wsutil/pint.h b/wsutil/pint.h index 6714c29272..d7d6972558 100644 --- a/wsutil/pint.h +++ b/wsutil/pint.h @@ -150,8 +150,4 @@ ((((x)&0xFF00)>>8) | \ (((x)&0x00FF)<<8)) -/* Turn host-byte-order values into little-endian values. */ -#define htoles(s) GUINT16_TO_LE(s) -#define htolel(l) GUINT32_TO_LE(l) - #endif /* PINT_H */ |