Merge from vendor branch TCPDUMP:
[dragonfly.git] / contrib / bind-9.3 / lib / isc / include / isc / interfaceiter.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: interfaceiter.h,v 1.10.206.1 2004/03/06 08:14:42 marka Exp $ */
19
20 #ifndef ISC_INTERFACEITER_H
21 #define ISC_INTERFACEITER_H 1
22
23 /*****
24  ***** Module Info
25  *****/
26
27 /*
28  * Interface iterator
29  *
30  * Iterate over the list of network interfaces.
31  *
32  * Interfaces whose address family is not supported are ignored and never
33  * returned by the iterator.  Interfaces whose netmask, interface flags,
34  * or similar cannot be obtained are also ignored, and the failure is logged.
35  *
36  * Standards:
37  *      The API for scanning varies greatly among operating systems.
38  *      This module attempts to hide the differences.
39  */
40
41 /***
42  *** Imports
43  ***/
44
45 #include <isc/lang.h>
46 #include <isc/netaddr.h>
47 #include <isc/types.h>
48
49 /*
50  * Public structure describing a network interface.
51  */
52
53 struct isc_interface {
54         char name[32];                  /* Interface name, null-terminated. */
55         unsigned int af;                /* Address family. */
56         isc_netaddr_t address;          /* Local address. */
57         isc_netaddr_t netmask;          /* Network mask. */
58         isc_netaddr_t dstaddress;       /* Destination address
59                                            (point-to-point only). */
60         isc_uint32_t flags;             /* Flags; see below. */
61 };
62
63 /* Interface flags. */
64
65 #define INTERFACE_F_UP                  0x00000001U
66 #define INTERFACE_F_POINTTOPOINT        0x00000002U
67 #define INTERFACE_F_LOOPBACK            0x00000004U
68
69 /***
70  *** Functions
71  ***/
72
73 ISC_LANG_BEGINDECLS
74
75 isc_result_t
76 isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp);
77 /*
78  * Create an iterator for traversing the operating system's list
79  * of network interfaces.
80  *
81  * Returns:
82  *      ISC_R_SUCCESS
83  *      ISC_R_NOMEMORY
84  *      Various network-related errors
85  */
86
87 isc_result_t
88 isc_interfaceiter_first(isc_interfaceiter_t *iter);
89 /*
90  * Position the iterator on the first interface.
91  *
92  * Returns:
93  *      ISC_R_SUCCESS           Success.
94  *      ISC_R_NOMORE            There are no interfaces.
95  */
96
97 isc_result_t
98 isc_interfaceiter_current(isc_interfaceiter_t *iter,
99                           isc_interface_t *ifdata);
100 /*
101  * Get information about the interface the iterator is currently
102  * positioned at and store it at *ifdata.
103  *
104  * Requires:
105  *      The iterator has been successfully positioned using
106  *      isc_interface_iter_first() / isc_interface_iter_next().
107  *
108  * Returns:
109  *      ISC_R_SUCCESS           Success.
110  */
111
112 isc_result_t
113 isc_interfaceiter_next(isc_interfaceiter_t *iter);
114 /*
115  * Position the iterator on the next interface.
116  *
117  * Requires:
118  *      The iterator has been successfully positioned using
119  *      isc_interface_iter_first() / isc_interface_iter_next().
120  *
121  * Returns:
122  *      ISC_R_SUCCESS           Success.
123  *      ISC_R_NOMORE            There are no more interfaces.
124  */
125
126 void
127 isc_interfaceiter_destroy(isc_interfaceiter_t **iterp);
128 /*
129  * Destroy the iterator.
130  */
131
132 ISC_LANG_ENDDECLS
133
134 #endif /* ISC_INTERFACEITER_H */