1ZIFLIST(3) CZMQ Manual ZIFLIST(3)
2
3
4
6 ziflist - Class for list of network interfaces available on system
7
9 // This is a stable class, and may not change except for emergencies. It
10 // is provided in stable builds.
11 // This class has draft methods, which may change over time. They are not
12 // in stable releases, by default. Use --enable-drafts to enable.
13 // Get a list of network interfaces currently defined on the system
14 CZMQ_EXPORT ziflist_t *
15 ziflist_new (void);
16
17 // Destroy a ziflist instance
18 CZMQ_EXPORT void
19 ziflist_destroy (ziflist_t **self_p);
20
21 // Reload network interfaces from system
22 CZMQ_EXPORT void
23 ziflist_reload (ziflist_t *self);
24
25 // Return the number of network interfaces on system
26 CZMQ_EXPORT size_t
27 ziflist_size (ziflist_t *self);
28
29 // Get first network interface, return NULL if there are none
30 CZMQ_EXPORT const char *
31 ziflist_first (ziflist_t *self);
32
33 // Get next network interface, return NULL if we hit the last one
34 CZMQ_EXPORT const char *
35 ziflist_next (ziflist_t *self);
36
37 // Return the current interface IP address as a printable string
38 CZMQ_EXPORT const char *
39 ziflist_address (ziflist_t *self);
40
41 // Return the current interface broadcast address as a printable string
42 CZMQ_EXPORT const char *
43 ziflist_broadcast (ziflist_t *self);
44
45 // Return the current interface network mask as a printable string
46 CZMQ_EXPORT const char *
47 ziflist_netmask (ziflist_t *self);
48
49 // Return the list of interfaces.
50 CZMQ_EXPORT void
51 ziflist_print (ziflist_t *self);
52
53 // Self test of this class.
54 CZMQ_EXPORT void
55 ziflist_test (bool verbose);
56
57 #ifdef CZMQ_BUILD_DRAFT_API
58 // *** Draft method, for development use, may change without warning ***
59 // Get a list of network interfaces currently defined on the system
60 // Includes IPv6 interfaces
61 // Caller owns return value and must destroy it when done.
62 CZMQ_EXPORT ziflist_t *
63 ziflist_new_ipv6 (void);
64
65 // *** Draft method, for development use, may change without warning ***
66 // Reload network interfaces from system, including IPv6
67 CZMQ_EXPORT void
68 ziflist_reload_ipv6 (ziflist_t *self);
69
70 // *** Draft method, for development use, may change without warning ***
71 // Return true if the current interface uses IPv6
72 CZMQ_EXPORT bool
73 ziflist_is_ipv6 (ziflist_t *self);
74
75 #endif // CZMQ_BUILD_DRAFT_API
76 Please add '@interface' section in './../src/ziflist.c'.
77
79 The ziflist class takes a snapshot of the network interfaces that the
80 system currently supports (this can change arbitrarily, especially on
81 mobile devices). The caller can then access the network interface
82 information using an iterator that works like zlistx. Only stores those
83 interfaces with broadcast capability, and ignores the loopback
84 interface.
85
86 Please add @discuss section in ./../src/ziflist.c.
87
89 From ziflist_test method.
90
91 ziflist_t *iflist = ziflist_new ();
92 assert (iflist);
93
94 size_t items = ziflist_size (iflist);
95
96 if (verbose) {
97 printf ("ziflist: interfaces=%zu\n", ziflist_size (iflist));
98 const char *name = ziflist_first (iflist);
99 while (name) {
100 printf (" - name=%s address=%s netmask=%s broadcast=%s\n",
101 name, ziflist_address (iflist), ziflist_netmask (iflist), ziflist_broadcast (iflist));
102 name = ziflist_next (iflist);
103 }
104 }
105 ziflist_reload (iflist);
106 assert (items == ziflist_size (iflist));
107 ziflist_destroy (&iflist);
108
109 #if defined (__WINDOWS__)
110 zsys_shutdown();
111 #endif
112
113
115 The czmq manual was written by the authors in the AUTHORS file.
116
118 Main web site:
119
120 Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
121
123 Copyright (c) the Contributors as noted in the AUTHORS file. This file
124 is part of CZMQ, the high-level C binding for 0MQ:
125 http://czmq.zeromq.org. This Source Code Form is subject to the terms
126 of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
127 distributed with this file, You can obtain one at
128 http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
129 distribution.
130
132 1. zeromq-dev@lists.zeromq.org
133 mailto:zeromq-dev@lists.zeromq.org
134
135
136
137CZMQ 4.2.1 10/31/2019 ZIFLIST(3)