]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ntp/include/isc/interfaceiter.h
This commit was generated by cvs2svn to compensate for changes in r169942,
[FreeBSD/FreeBSD.git] / contrib / ntp / include / isc / interfaceiter.h
1 /*
2  * Copyright (C) 1999-2001  Internet Software Consortium.
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11  * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: interfaceiter.h,v 1.10 2001/01/09 21:57:01 bwelling 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 broadcast;        /* Broadcast address. */
59         isc_netaddr_t dstaddress;       /* Destination address
60                                            (point-to-point only). */
61         isc_uint32_t flags;             /* Flags; see below. */
62 };
63
64 /* Interface flags. */
65
66 #define INTERFACE_F_UP                  0x00000001U /* Interface is up */
67 #define INTERFACE_F_POINTTOPOINT        0x00000002U /*this is point-to-point interface*/
68 #define INTERFACE_F_LOOPBACK            0x00000004U /* this is loopback interface */
69 #define INTERFACE_F_BROADCAST           0x00000008U /* Broadcast is  supported */
70 #define INTERFACE_F_MULTICAST           0x00000010U /* multicast is supported */
71
72 /***
73  *** Functions
74  ***/
75
76 ISC_LANG_BEGINDECLS
77
78 isc_result_t
79 isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp);
80 /*
81  * Create an iterator for traversing the operating system's list
82  * of network interfaces.
83  *
84  * Returns:
85  *      ISC_R_SUCCESS
86  *      ISC_R_NOMEMORY
87  *      Various network-related errors
88  */
89
90 isc_result_t
91 isc_interfaceiter_first(isc_interfaceiter_t *iter);
92 /*
93  * Position the iterator on the first interface.
94  *
95  * Returns:
96  *      ISC_R_SUCCESS           Success.
97  *      ISC_R_NOMORE            There are no interfaces.
98  */
99
100 isc_result_t
101 isc_interfaceiter_current(isc_interfaceiter_t *iter,
102                           isc_interface_t *ifdata);
103 /*
104  * Get information about the interface the iterator is currently
105  * positioned at and store it at *ifdata.
106  *
107  * Requires:
108  *      The iterator has been successfully positioned using
109  *      isc_interface_iter_first() / isc_interface_iter_next().
110  *
111  * Returns:
112  *      ISC_R_SUCCESS           Success.
113  */
114
115 isc_result_t
116 isc_interfaceiter_next(isc_interfaceiter_t *iter);
117 /*
118  * Position the iterator on the next interface.
119  *
120  * Requires:
121  *      The iterator has been successfully positioned using
122  *      isc_interface_iter_first() / isc_interface_iter_next().
123  *
124  * Returns:
125  *      ISC_R_SUCCESS           Success.
126  *      ISC_R_NOMORE            There are no more interfaces.
127  */
128
129 void
130 isc_interfaceiter_destroy(isc_interfaceiter_t **iterp);
131 /*
132  * Destroy the iterator.
133  */
134
135 ISC_LANG_ENDDECLS
136
137 #endif /* ISC_INTERFACEITER_H */