ping_setopt(3)
π ping_setopt β the liboping options-setter, bestie edition β¨
okay so this is ping_setopt(3) from the liboping manual, and it's genuinely one of my faves because it's the lil' control panel for your ping object. let's get into it π
πΈ NAME πΈ
ping_setopt β set options for a liboping object. that's it, that's the vibe.
β¨ SYNOPSIS β¨
#include <oping.h>
int ping_setopt (pingobj_t *obj, int opt, void *val);
π¦ DESCRIPTION π¦
so basically ping_setopt sets options that apply to all hosts already chillin' with the object obj, and the hosts that haven't even been added yet. future hosts? covered. periodt. π
the obj argument is a pointer to a liboping object, exactly the kind you get back from ping_construct(3).
the opt argument says which option you're setting. use one of these constants, bestie. you can check at compile time whether the library even supports the one you want by using #ifdef β and honestly it's recommended that you check for the features you want using the OPING_VERSION define. iykyk π
the options, one by one π«Ά
PING_OPT_TIMEOUTβ how long to wait for an "echo reply" to come back, measured in seconds. herevalpoints at memory that gets read as adouble, and it must be greater than zero. the default isPING_DEF_TIMEOUT. β³PING_OPT_TTLβ the value that gets written into the time-to-live (= TTL) field of the generated ICMP packets. the memoryvalpoints at is read as aninteger. valid values go from1through255. default isPING_DEF_TTL. πPING_OPT_AFβ the address family to use.valpoints at memory read as aninteger, and it must be eitherAF_UNSPEC,AF_INET, orAF_INET6. heads up: this one only affects hosts that get added after you set it. default isPING_DEF_AF. and ooh β if you change this option and a source address is already set (seePING_OPT_SOURCE), that setting will be reset. no takebacks π«PING_OPT_DATAβ sets the data to send. the value you pass has to be achar-pointer to a null-terminated string. by default a56byte long string is used, so that the packet size of an ICMPv4 packet is exactly64bytes β that's literally the behavior of theping(1)command. iconic. π¦PING_OPT_SOURCEβ sets the source address to use. the value you pass has to be achar-pointer to a null-terminated string, and that string specifies either a numerical network address or a network hostname. this option ignores the address family setting (the one fromPING_OPT_AF) and sets the object's address family according to whichever source address you assigned. it does its own thing fr fr π§PING_OPT_DEVICEβ sets the outgoing network device to be used. the value you pass has to be achar-pointer to a null-terminated string naming an interface (e. g."eth0"). > β οΈ please note: this might not be supported by all operating systems. in that case,ping_setoptsets the error to"operation not supported". πPING_OPT_QOSβ sets the Quality of Service flags that should be used when crafting ICMP and ICMPv6 packets. the memoryvalpoints at is read as a"uint8_t". that byte gets passed tosetsockopt(2)without modification, using the"IP_TOS"(IPv4) or"IPV6_TCLASS"(IPv6) option. > π¨ it is the caller's responsibility to choose a valid bit combination β that's on you, bestie. for the details, go read theip(7)andipv6(7)manual pages, plus RFC 2474. πPING_OPT_MARKβ marks (as in netfilter) outgoing packets using theSO_MARKsocket option. takes anint*pointer as its value. > π setting this requiresCAP_NET_ADMINunder Linux. and on platforms that don't haveSO_MARK, it fails with"operation not supported". π
about val π
the val argument is a pointer to the new value. it must not be NULL. it gets dereferenced depending on what opt is set to (see alllll the way above βοΈ). and good news: the memory that val points to is not changed. your data is safe, bestie. π
π RETURN VALUE π
ping_setopt returns zero upon success, or less than zero upon failure. short and sweet.
π₯ SEE ALSO π₯
π AUTHOR π
liboping is written by Florian "octo" Forster <ff at octo.it>. its homepage can be found at <http://noping.cc/>. π
Copyright (c) 2006-2017 by Florian "octo" Forster.
okay that's the whole page, bestie β we ate that up π
β¨ this was liboping version 1.10.0, dated 2017-05-11, and that's the ping_setopt(3) tea. mwah π«Άπ
π¦ where this page comes from
- alpine 3.24: liboping-doc 1.10.0-r2 Β· LGPL-2.0-or-later
- epel 10: liboping-devel 1.10.0-33.el10_0 Β· GPL-2.0-only
- epel 9: liboping-devel 1.10.0-19.el9 Β· GPLv2
- fedora 43: liboping-devel 1.10.0-35.fc43 Β· GPL-2.0-only
- fedora 43: liboping-devel 1.10.0-35.fc43 Β· GPL-2.0-only
- fedora 44: liboping-devel 1.10.0-36.fc44 Β· GPL-2.0-only
- fedora 44: liboping-devel 1.10.0-36.fc44 Β· GPL-2.0-only
- nixos 26.05: liboping 1.10.0
- nixpkgs unstable: liboping 1.10.0
- opensuse-leap 16.0: liboping-devel 1.10.0-bp160.1.14 Β· LGPL-2.1-only
- opensuse-leap 16.0: liboping-devel 1.10.0-bp160.1.14 Β· LGPL-2.1-only
- opensuse-leap 16.0: liboping-devel 1.10.0-bp160.1.14 Β· LGPL-2.1-only
- opensuse-leap 16.0: liboping-devel 1.10.0-bp160.1.14 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms