From Harald Welte:
[obnox/wireshark/wip.git] / epan / ipv4.c
index 622d1e209b3b2ada6fbe2a8067ac864b26713d5b..26ff676d30d4aa719fce65f04bd8a5b7bf817600 100644 (file)
@@ -7,8 +7,8 @@
  *
  * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
@@ -49,24 +49,23 @@ ipv4_addr_new(void)
 void
 ipv4_addr_free(ipv4_addr *ipv4)
 {
-       if (ipv4)
-               g_free(ipv4);
+       g_free(ipv4);
 }
 
 void
-ipv4_addr_set_host_order_addr(ipv4_addr *ipv4, guint32 new_addr)
+ipv4_addr_set_host_order_addr(ipv4_addr *ipv4, const guint32 new_addr)
 {
        ipv4->addr = new_addr;
 }
 
 void
-ipv4_addr_set_net_order_addr(ipv4_addr *ipv4, guint32 new_addr)
+ipv4_addr_set_net_order_addr(ipv4_addr *ipv4, const guint32 new_addr)
 {
        ipv4->addr = g_ntohl(new_addr);
 }
 
 void
-ipv4_addr_set_netmask_bits(ipv4_addr *ipv4, guint new_nmask_bits)
+ipv4_addr_set_netmask_bits(ipv4_addr *ipv4, const guint new_nmask_bits)
 {
        static guint32 bitmasks[33] = {
                0x00000000,
@@ -97,11 +96,12 @@ ipv4_get_host_order_addr(ipv4_addr *ipv4)
        return ipv4->addr;
 }
 
+/* We're assuming the buffer is at least MAX_IP_STR_LEN (16 bytes) */
 void
 ipv4_addr_str_buf(const ipv4_addr *ipv4, gchar *buf)
 {
        guint32 ipv4_host_order = g_htonl(ipv4->addr);
-       ip_to_str_buf((guint8*)&ipv4_host_order, buf);
+       ip_to_str_buf((guint8*)&ipv4_host_order, buf, MAX_IP_STR_LEN);
 }