1ping_setopt(3) liboping ping_setopt(3)
2
3
4
6 ping_setopt - Set options for a liboping object
7
9 #include <oping.h>
10
11 int ping_setopt (pingobj_t *obj, int opt, void *val);
12
14 The ping_setopt method sets options that apply to all hosts associated
15 with the object obj and hosts that are yet to be added to the object.
16
17 The obj argument is a pointer to an liboping object, as returned by
18 ping_construct(3).
19
20 The opt argument specifies the option to set. Use one of the following
21 constants. You can check if the required constant is supported by the
22 library at compile time using "#ifdef". It is recommended to check for
23 desired features using the "OPING_VERSION" define.
24
25 PING_OPT_TIMEOUT
26 The time to wait for a "echo reply" to be received; in seconds. In
27 this case the memory pointed to by val is interpreted as a double
28 value and must be greater than zero. The default is
29 PING_DEF_TIMEOUT.
30
31 PING_OPT_TTL
32 The value written into the time-to-live (= TTL) field of generated
33 ICMP packets. The memory pointed to by val is interpreted as an
34 integer. Valid values are 1 through 255. Default is PING_DEF_TTL.
35
36 PING_OPT_AF
37 The address family to use. The memory pointed to by val is
38 interpreted as an integer and must be either AF_UNSPEC, AF_INET, or
39 AF_INET6. This option only affects hosts that are being added after
40 this option has been set. Default is PING_DEF_AF. If you change
41 this option, and a source address is set (see PING_OPT_SOURCE) that
42 setting will be reset.
43
44 PING_OPT_DATA
45 Set the data to send. The value passed must be a char-pointer to a
46 null-terminated string. By default a 56 byte long string is used so
47 that the packet size of an ICMPv4 packet is exactly 64 bytes.
48 That's the behavior of the ping(1) command.
49
50 PING_OPT_SOURCE
51 Set the source address to use. The value passed must be a char-
52 pointer to a null-terminated string specifying either a numerical
53 network address or network hostname. This option will ignore the
54 address family setting (as set with PING_OPT_AF) and will set the
55 object's address family according to the source address assigned.
56
57 PING_OPT_DEVICE
58 Set the outgoing network device to be used. The value passed must
59 be a char-pointer to a null-terminated string specifying an
60 interface name (e. g. "eth0"). Please note that this might not be
61 supported by all operating systems. In that case, ping_setopt sets
62 the error to "operation not supported".
63
64 PING_OPT_QOS
65 Sets the Quality of Service flags that should be used when crafting
66 ICMP and ICMPv6 packets. The memory pointed to by val is
67 interpreted as a "uint8_t". The byte is passed to setsockopt(2)
68 without modification, using the "IP_TOS" (IPv4) or "IPV6_TCLASS"
69 (IPv6) option. It is the caller's responsibility to chose a valid
70 bit combination. For details, read the ip(7) and ipv6(7) manual
71 pages, as well as RFC 2474.
72
73 PING_OPT_MARK
74 Mark (as in netfilter) outgoing packets using the SO_MARK socket
75 option. Takes an int* pointer as a value. Setting this requires
76 CAP_NET_ADMIN under Linux. Fails with "operation not supported" on
77 platforms which don't have SO_MARK.
78
79 The val argument is a pointer to the new value. It must not be NULL. It
80 is dereferenced depending on the value of the opt argument, see above.
81 The memory pointed to by val is not changed.
82
84 ping_setopt returns zero upon success or less than zero upon failure.
85
87 ping_construct(3), liboping(3)
88
90 liboping is written by Florian "octo" Forster <ff at octo.it>. Its
91 homepage can be found at <http://noping.cc/>.
92
93 Copyright (c) 2006-2017 by Florian "octo" Forster.
94
95
96
971.10.0 2017-05-11 ping_setopt(3)