~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to include/isc/interfaceiter.h

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        unsigned int ifindex;           /* Interface Index */
 
63
        unsigned int scopeid;           /* Scope id for Multicasting */
 
64
};
 
65
 
 
66
/* Interface flags. */
 
67
 
 
68
#define INTERFACE_F_UP                  0x00000001U /* Interface is up */
 
69
#define INTERFACE_F_POINTTOPOINT        0x00000002U /*this is point-to-point interface*/
 
70
#define INTERFACE_F_LOOPBACK            0x00000004U /* this is loopback interface */
 
71
#define INTERFACE_F_BROADCAST           0x00000008U /* Broadcast is  supported */
 
72
#define INTERFACE_F_MULTICAST           0x00000010U /* multicast is supported */
 
73
 
 
74
/***
 
75
 *** Functions
 
76
 ***/
 
77
 
 
78
ISC_LANG_BEGINDECLS
 
79
 
 
80
isc_result_t
 
81
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp);
 
82
/*
 
83
 * Create an iterator for traversing the operating system's list
 
84
 * of network interfaces.
 
85
 *
 
86
 * Returns:
 
87
 *      ISC_R_SUCCESS
 
88
 *      ISC_R_NOMEMORY
 
89
 *      Various network-related errors
 
90
 */
 
91
 
 
92
isc_result_t
 
93
isc_interfaceiter_first(isc_interfaceiter_t *iter);
 
94
/*
 
95
 * Position the iterator on the first interface.
 
96
 *
 
97
 * Returns:
 
98
 *      ISC_R_SUCCESS           Success.
 
99
 *      ISC_R_NOMORE            There are no interfaces.
 
100
 */
 
101
 
 
102
isc_result_t
 
103
isc_interfaceiter_current(isc_interfaceiter_t *iter,
 
104
                          isc_interface_t *ifdata);
 
105
/*
 
106
 * Get information about the interface the iterator is currently
 
107
 * positioned at and store it at *ifdata.
 
108
 *
 
109
 * Requires:
 
110
 *      The iterator has been successfully positioned using
 
111
 *      isc_interface_iter_first() / isc_interface_iter_next().
 
112
 *
 
113
 * Returns:
 
114
 *      ISC_R_SUCCESS           Success.
 
115
 */
 
116
 
 
117
isc_result_t
 
118
isc_interfaceiter_next(isc_interfaceiter_t *iter);
 
119
/*
 
120
 * Position the iterator on the next interface.
 
121
 *
 
122
 * Requires:
 
123
 *      The iterator has been successfully positioned using
 
124
 *      isc_interface_iter_first() / isc_interface_iter_next().
 
125
 *
 
126
 * Returns:
 
127
 *      ISC_R_SUCCESS           Success.
 
128
 *      ISC_R_NOMORE            There are no more interfaces.
 
129
 */
 
130
 
 
131
void
 
132
isc_interfaceiter_destroy(isc_interfaceiter_t **iterp);
 
133
/*
 
134
 * Destroy the iterator.
 
135
 */
 
136
 
 
137
ISC_LANG_ENDDECLS
 
138
 
 
139
#endif /* ISC_INTERFACEITER_H */