Commit Graph

17 Commits

Author SHA1 Message Date
João Valverde 14a1dfbe10 wsutil/inet_addr: Refactor to use C99/POSIX types
Rewrite ws_inet_pton{4,6} and ws_inet_ntop{4,6} without
GLib types.

Check for strerrorname_np() and use that is available,
to simplify error handling.

Add some minimal tests.
2021-12-27 19:02:50 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
João Valverde 4aff36d501 Replace g_assert() with ws_assert() in places 2021-06-06 20:05:26 +00:00
Guy Harris 57a1514ac7 Cast away the return value of g_strlcpy() and g_strlcat().
Most of the time, the return value tells us nothing useful, as we've
already decided that we're perfectly willing to live with string
truncation.  Hopefully this keeps Coverity from whining that those
routines could return an error code (NARRATOR: They don't) and thus that
we're ignoring the possibility of failure (as indicated, we've already
decided that we can live with string truncation, so truncation is *NOT*
a failure).
2021-04-30 03:19:19 -07:00
João Valverde b2bb8bf4e0 Replace g_assert(0) with g_assert_not_reached() 2021-03-05 14:54:58 +00:00
Dario Lombardo fab15cd64f wsutil: fix compilation on freebsd.
Change-Id: Iadb3f3daa1095ac9cc971f79ba4d288e8d835a44
Reviewed-on: https://code.wireshark.org/review/27864
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-28 21:40:18 +00:00
Guy Harris d08d0a87c5 Eliminate some unneeded header checks.
sys/stat.h and sys/types.h date back to V7 UNIX, so they should be
present on all UN*Xes, and we're assuming they're available on Windows,
so, unless and until we ever support platforms that are neither UN*Xes
nor Windows, we don't need to check for them.

Remove the CMake checks for them, remove the HAVE_ values from
cmakeconfig.h.in, and remove all tests for the HAVE_ values.

Change-Id: I90bb2aab37958553673b03b52f4931d3b304b9d0
Reviewed-on: https://code.wireshark.org/review/27603
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-16 22:03:09 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Michael Mann 3d673da88c Convert to using use SPDX identifier on wsutil directory
Change-Id: Id73e641499e75bc1afc1dea29682418156f461fe
Reviewed-on: https://code.wireshark.org/review/24751
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-10 04:36:29 +00:00
João Valverde 9a464fd9bd Avoid asserting with EAFNOSUPPORT
We require support for AF_INET/AF_INET6 to run and assume this is available
on all supported platforms. If and when reality clashes with that assumption just
avoid aborting. Errors are to be expected as long as they don't produce a crash.

Change-Id: I5c107b1a8fd64441eb96f48381412e180b66feb7
Reviewed-on: https://code.wireshark.org/review/24187
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-30 19:38:37 +00:00
João Valverde 62b870a722 Do not assert in ws_inet_ntop()
Change-Id: I9d420c5f6bc29ce94855017739169dc8e8ce4d48
Reviewed-on: https://code.wireshark.org/review/24173
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-29 21:10:23 +00:00
João Valverde ac804b59e2 Improve our inet_ntop() wrapper
Also fix buffer length define, as it is not guaranteed to be 46 on
Windows (it never was guaranteed anyway for the libc implementation,
but the likelyhood of being greater was small).

Change-Id: I2db705d86f825765ed32ec70b8d22058b5d629e8
Reviewed-on: https://code.wireshark.org/review/24074
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-26 14:39:00 +00:00
Guy Harris 458c3c026e Add a ws_in6_addr typedef for struct e_in6_addr.
That allows a parallel typedef of ws_in4_addr for guint32.

Change-Id: I03b230247065e0e3840eb87635315a8e523ef562
Reviewed-on: https://code.wireshark.org/review/24073
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-10-26 08:50:34 +00:00
João Valverde eae216ef1d Remove replacement inet_pton/inet_ntop
Should be available on every platform we support.

Change-Id: Ib65d78e351d22d581b427e5e93fc8d5e5348b260
Reviewed-on: https://code.wireshark.org/review/24047
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-25 21:03:56 +00:00
Guy Harris 6ac40522af Make sure config.h is included before inet_addr.h.
Otherwise, _FILE_OFFSET_BITS might be defined by a header file included
by inet_addr.h before it gets defined by config.h.

Change-Id: I5987b3f1493b81fd2d427d9792b9606117b255d0
Reviewed-on: https://code.wireshark.org/review/19018
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-02 10:33:42 +00:00
João Valverde eb9d2b0092 Fix implicit conversion from 64 to 32 bits
Change size_t to something that is guaranteed to fit in a socklen_t.

Fix incorrect AC_DEFINE too.

Change-Id: I710f32fb1e5bd4f51843d380aa8ed8b6acd98c02
Reviewed-on: https://code.wireshark.org/review/14009
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-19 21:47:04 +00:00
João Valverde 8bee8bad81 Add inet_pton/inet_ntop interface to libwsutil
Change-Id: Ifc344ed33f2f7ca09a6912a5adb49dc35f07c81f
Reviewed-on: https://code.wireshark.org/review/13881
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-19 15:55:09 +00:00