Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / include / isc / interfaceiter.h
blob76f52d822b4900a9a305661a13209db4459e0a34
1 /* $NetBSD: interfaceiter.h,v 1.2 2003/12/04 16:23:36 drochner Exp $ */
3 /*
4 * Copyright (C) 1999-2001 Internet Software Consortium.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
11 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
12 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
17 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 /* Id: interfaceiter.h,v 1.10 2001/01/09 21:57:01 bwelling Exp */
22 #ifndef ISC_INTERFACEITER_H
23 #define ISC_INTERFACEITER_H 1
25 /*****
26 ***** Module Info
27 *****/
30 * Interface iterator
32 * Iterate over the list of network interfaces.
34 * Interfaces whose address family is not supported are ignored and never
35 * returned by the iterator. Interfaces whose netmask, interface flags,
36 * or similar cannot be obtained are also ignored, and the failure is logged.
38 * Standards:
39 * The API for scanning varies greatly among operating systems.
40 * This module attempts to hide the differences.
43 /***
44 *** Imports
45 ***/
47 #include <isc/lang.h>
48 #include <isc/netaddr.h>
49 #include <isc/types.h>
52 * Public structure describing a network interface.
55 struct isc_interface {
56 char name[32]; /* Interface name, null-terminated. */
57 unsigned int af; /* Address family. */
58 isc_netaddr_t address; /* Local address. */
59 isc_netaddr_t netmask; /* Network mask. */
60 isc_netaddr_t broadcast; /* Broadcast address. */
61 isc_netaddr_t dstaddress; /* Destination address
62 (point-to-point only). */
63 isc_uint32_t flags; /* Flags; see below. */
64 unsigned int ifindex; /* Interface Index */
65 unsigned int scopeid; /* Scope id for Multicasting */
68 /* Interface flags. */
70 #define INTERFACE_F_UP 0x00000001U /* Interface is up */
71 #define INTERFACE_F_POINTTOPOINT 0x00000002U /*this is point-to-point interface*/
72 #define INTERFACE_F_LOOPBACK 0x00000004U /* this is loopback interface */
73 #define INTERFACE_F_BROADCAST 0x00000008U /* Broadcast is supported */
74 #define INTERFACE_F_MULTICAST 0x00000010U /* multicast is supported */
76 /***
77 *** Functions
78 ***/
80 ISC_LANG_BEGINDECLS
82 isc_result_t
83 isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp);
85 * Create an iterator for traversing the operating system's list
86 * of network interfaces.
88 * Returns:
89 * ISC_R_SUCCESS
90 * ISC_R_NOMEMORY
91 * Various network-related errors
94 isc_result_t
95 isc_interfaceiter_first(isc_interfaceiter_t *iter);
97 * Position the iterator on the first interface.
99 * Returns:
100 * ISC_R_SUCCESS Success.
101 * ISC_R_NOMORE There are no interfaces.
104 isc_result_t
105 isc_interfaceiter_current(isc_interfaceiter_t *iter,
106 isc_interface_t *ifdata);
108 * Get information about the interface the iterator is currently
109 * positioned at and store it at *ifdata.
111 * Requires:
112 * The iterator has been successfully positioned using
113 * isc_interface_iter_first() / isc_interface_iter_next().
115 * Returns:
116 * ISC_R_SUCCESS Success.
119 isc_result_t
120 isc_interfaceiter_next(isc_interfaceiter_t *iter);
122 * Position the iterator on the next interface.
124 * Requires:
125 * The iterator has been successfully positioned using
126 * isc_interface_iter_first() / isc_interface_iter_next().
128 * Returns:
129 * ISC_R_SUCCESS Success.
130 * ISC_R_NOMORE There are no more interfaces.
133 void
134 isc_interfaceiter_destroy(isc_interfaceiter_t **iterp);
136 * Destroy the iterator.
139 ISC_LANG_ENDDECLS
141 #endif /* ISC_INTERFACEITER_H */