ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] Replace ntohl() with g_ntohl()

Date: Mon, 6 Nov 2006 21:13:52 -0600
Patch attached to convert usage of ntohl() -> g_ntohl(). On HP-UX,
ntohl() isn't available unless you -D_XOPEN_SOURCE_EXTENDED but there
are other uses of g_ntohl().

-- 
albert chin (china@xxxxxxxxxxxxxxxxxx)
Index: gtk/sctp_graph_dlg.c
===================================================================
--- gtk/sctp_graph_dlg.c	(revision 19843)
+++ gtk/sctp_graph_dlg.c	(working copy)
@@ -199,7 +199,7 @@
 			{
 				sack_header =(struct sack_chunk_header *)tlist->data;
 				nr=ntohs(sack_header->nr_of_gaps);
-				tsnumber = ntohl(sack_header->cum_tsn_ack);
+				tsnumber = g_ntohl(sack_header->cum_tsn_ack);
 
 				if (sack->secs>=u_data->io->x1_tmp_sec)
 				{
@@ -310,7 +310,7 @@
 		{
 			type = ((struct chunk_header *)tlist->data)->type;
 			if (type == SCTP_DATA_CHUNK_ID)
-				tsnumber = ntohl(((struct data_chunk_header *)tlist->data)->tsn);
+				tsnumber = g_ntohl(((struct data_chunk_header *)tlist->data)->tsn);
 			if (tsnumber>=min_tsn && tsnumber<=max_tsn && tsn->secs>=min_secs)
 			{
 					if (u_data->io->uoff)
Index: epan/dissectors/packet-dcom-cba-acco.c
===================================================================
--- epan/dissectors/packet-dcom-cba-acco.c	(revision 19843)
+++ epan/dissectors/packet-dcom-cba-acco.c	(working copy)
@@ -582,7 +582,7 @@
         g_free(ip_str);
         return NULL;
     }
-    ip = ntohl(ip);
+    ip = g_ntohl(ip);
 
     pdev = cba_pdev_add(pinfo, (char *) &ip);
     delim++;
Index: epan/dissectors/packet-dcom.c
===================================================================
--- epan/dissectors/packet-dcom.c	(revision 19843)
+++ epan/dissectors/packet-dcom.c	(working copy)
@@ -1773,7 +1773,7 @@
         /* XXX - this conversion is ugly */
         if (inet_aton(szStr, &ipaddr)) {
             if(get_host_ipaddr(szStr, &curr_ip)) {
-                curr_ip = ntohl(curr_ip);
+                curr_ip = g_ntohl(curr_ip);
 
     	        /*expert_add_info_format(pinfo, NULL, PI_UNDECODED, PI_WARN, "DUALSTRINGARRAY: IP:%s", 
                     ip_to_str( (gchar *) &curr_ip));*/
Index: epan/dissectors/packet-fcswils.c
===================================================================
--- epan/dissectors/packet-fcswils.c	(revision 19843)
+++ epan/dissectors/packet-fcswils.c	(working copy)
@@ -722,8 +722,8 @@
     /* We skip the initial 4 bytes as we don't care about the opcode */
     tvb_memcpy (tvb, (guint8 *)&elp, 4, FC_SWILS_ELP_SIZE);
     
-    elp.r_a_tov = ntohl (elp.r_a_tov);
-    elp.e_d_tov = ntohl (elp.e_d_tov);
+    elp.r_a_tov = g_ntohl (elp.r_a_tov);
+    elp.e_d_tov = g_ntohl (elp.e_d_tov);
     elp.isl_flwctrl_mode = ntohs (elp.isl_flwctrl_mode);
     elp.flw_ctrl_parmlen = ntohs (elp.flw_ctrl_parmlen);