1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * HISTORY
25 *
26 */
27
28#ifndef _IONETWORKLIB_H
29#define _IONETWORKLIB_H
30
31#include <IOKit/IOKitLib.h>
32#include <IOKit/network/IONetworkData.h>
33#include <IOKit/network/IONetworkMedium.h>
34#include <IOKit/network/IONetworkStats.h>
35#include <IOKit/network/IOEthernetStats.h>
36#include <IOKit/network/IONetworkUserClient.h>
37
38typedef UInt32 IONDHandle;
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/*! @function IONetworkOpen
45    @abstract Open a connection to an IONetworkInterface object.
46    An IONetworkUserClient object is created to manage the connection. */
47
48    IOReturn IONetworkOpen(io_object_t obj, io_connect_t * con);
49
50/*! @function IONetworkClose
51    @abstract Close the connection to an IONetworkInterface object. */
52
53    IOReturn IONetworkClose(io_connect_t con);
54
55/*! @function IONetworkWriteData
56    @abstract Write to the buffer of a network data object.
57    @param conObj The connection object.
58    @param dataHandle The handle of a network data object.
59    @param srcBuf The data to write is taken from this buffer.
60    @param inSize The size of the source buffer.
61    @result kIOReturnSuccess on success, or an error code otherwise. */
62
63    IOReturn IONetworkWriteData(io_connect_t conObj,
64                                IONDHandle   dataHandle,
65                                UInt8 *      srcBuf,
66                                UInt32       inSize);
67
68/*! @function IONetworkReadData
69    @abstract Read the buffer of a network data object.
70    @param conObj The connection object.
71    @param dataHandle The handle of a network data object.
72    @param destBuf The buffer where the data read shall be written to.
73    @param inOutSizeP Pointer to an integer that the caller must initialize
74           to contain the size of the buffer. This function will overwrite
75           it with the actual number of bytes written to the buffer.
76    @result kIOReturnSuccess on success, or an error code otherwise. */
77
78    IOReturn IONetworkReadData(io_connect_t conObj,
79                                IONDHandle   dataHandle,
80                                UInt8 *      destBuf,
81                                UInt32 *     inOutSizeP);
82
83/*! @function IONetworkResetData
84    @abstract Fill the buffer of a network data object with zeroes.
85    @param conObject The connection object.
86    @param dataHandle The handle of a network data object.
87    @result kIOReturnSuccess on success, or an error code otherwise. */
88
89    IOReturn IONetworkResetData(io_connect_t conObject, IONDHandle dataHandle);
90
91/*! @function IONetworkGetDataCapacity
92    @abstract Get the capacity (in bytes) of a network data object.
93    @param conObject The connection object.
94    @param dataHandle The handle of a network data object.
95    @param capacityP Upon success, the capacity is written to this address.
96    @result kIOReturnSuccess on success, or an error code otherwise. */
97
98    IOReturn IONetworkGetDataCapacity(io_connect_t conObject,
99                                      IONDHandle   dataHandle,
100                                      UInt32 *     capacityP);
101
102/*! @function IONetworkGetDataHandle
103    @abstract Get the handle of a network data object with the given name.
104    @param conObject The connection object.
105    @param dataName The name of the network data object.
106    @param dataHandleP Upon success, the handle is written to this address.
107    @result kIOReturnSuccess on success, or an error code otherwise. */
108
109    IOReturn IONetworkGetDataHandle(io_connect_t conObject,
110                                    const char * dataName,
111                                    IONDHandle * dataHandleP);
112
113/*! @function IONetworkSetPacketFiltersMask
114    @abstract Set the packet filters for a given filter group.
115    @discussion A network controller may support a number of packets filters
116    that can accept or reject a type of packet seen on the network. A filter
117    group identifies a set of related filters, such as all filters that will
118    allow a packet to pass upstream based on the destination address encoded
119    within the packet. This function allows an user-space program to set the
120    filtering performed by a given filter group.
121    @param connect The connection object returned from IONetworkOpen().
122    @param filterGroup The name of the packet filter group.
123    @param filtersMask A mask of filters to set.
124    @param options No options are currently defined.
125    @result An IOReturn error code. */
126
127	IOReturn IONetworkSetPacketFiltersMask( io_connect_t    connect,
128                                            const io_name_t filterGroup,
129                                            UInt32          filtersMask,
130                                            IOOptionBits    options );
131
132/*! @enum IONetworkPacketFilterOptions
133    @constant kIONetworkSupportedPacketFilters Indicate the filters that are
134    supported by the hardware. */
135
136    enum {
137        kIONetworkSupportedPacketFilters = 0x0001
138    };
139
140/*! @function IONetworkGetPacketFiltersMask
141    @abstract Get the packet filters for a given filter group.
142    @discussion A network controller may support a number of packets filters
143    that can accept or reject a type of packet seen on the network. A filter
144    group identifies a set of related filters, such as all filters that will
145    allow a packet to pass upstream based on the destination address encoded
146    within the packet. This function allows an user-space program to get the
147    filtering performed by a given filter group.
148    @param connect The connection object returned from IONetworkOpen().
149    @param filterGroup The name of the packet filter group.
150    @param filtersMask Pointer to the return value containing a mask of
151    packet filters.
152    @param options kIONetworkSupportedPacketFilters may be set to fetch the
153    filters that are supported by the hardware.
154    @result An IOReturn error code. */
155
156    IOReturn IONetworkGetPacketFiltersMask( io_connect_t    connect,
157                                            const io_name_t filterGroup,
158                                            UInt32 *        filtersMask,
159                                            IOOptionBits    options );
160
161#ifdef __cplusplus
162}
163#endif
164
165#endif /* !_IONETWORKLIB_H */
166