neti.h (381a2a9a) neti.h (f4b3ec61)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _SYS_NETI_H
27#define _SYS_NETI_H
28
29#pragma ident "%Z%%M% %I% %E% SMI"
30
31#include <netinet/in.h>
32#include <sys/int_types.h>
33#include <sys/queue.h>
34#include <sys/hook_impl.h>
23 * Use is subject to license terms.
24 */
25
26#ifndef _SYS_NETI_H
27#define _SYS_NETI_H
28
29#pragma ident "%Z%%M% %I% %E% SMI"
30
31#include <netinet/in.h>
32#include <sys/int_types.h>
33#include <sys/queue.h>
34#include <sys/hook_impl.h>
35#include <sys/netstack.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#define NETINFO_VERSION 1
41
42/*

--- 70 unchanged lines hidden (view full) ---

113
114
115/*
116 * net_info_t public interface
117 */
118typedef struct net_info {
119 int neti_version;
120 char *neti_protocol;
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#define NETINFO_VERSION 1
42
43/*

--- 70 unchanged lines hidden (view full) ---

114
115
116/*
117 * net_info_t public interface
118 */
119typedef struct net_info {
120 int neti_version;
121 char *neti_protocol;
121 int (*neti_getifname)(phy_if_t, char *, const size_t);
122 int (*neti_getmtu)(phy_if_t, lif_if_t);
123 int (*neti_getpmtuenabled)(void);
122 int (*neti_getifname)(phy_if_t, char *, const size_t,
123 netstack_t *);
124 int (*neti_getmtu)(phy_if_t, lif_if_t, netstack_t *);
125 int (*neti_getpmtuenabled)(netstack_t *);
124 int (*neti_getlifaddr)(phy_if_t, lif_if_t, size_t,
126 int (*neti_getlifaddr)(phy_if_t, lif_if_t, size_t,
125 net_ifaddr_t [], void *);
126 phy_if_t (*neti_phygetnext)(phy_if_t);
127 phy_if_t (*neti_phylookup)(const char *);
128 lif_if_t (*neti_lifgetnext)(phy_if_t, lif_if_t);
129 int (*neti_inject)(inject_t, net_inject_t *);
130 phy_if_t (*neti_routeto)(struct sockaddr *);
127 net_ifaddr_t [], void *, netstack_t *);
128 phy_if_t (*neti_phygetnext)(phy_if_t, netstack_t *);
129 phy_if_t (*neti_phylookup)(const char *, netstack_t *);
130 lif_if_t (*neti_lifgetnext)(phy_if_t, lif_if_t, netstack_t *);
131 int (*neti_inject)(inject_t, net_inject_t *, netstack_t *);
132 phy_if_t (*neti_routeto)(struct sockaddr *, netstack_t *);
131 int (*neti_ispartialchecksum)(mblk_t *);
132 int (*neti_isvalidchecksum)(mblk_t *);
133} net_info_t;
134
135
136/*
137 * Private data structures
138 */
139struct net_data {
140 LIST_ENTRY(net_data) netd_list;
141 net_info_t netd_info;
142 int netd_refcnt;
143 hook_family_int_t *netd_hooks;
133 int (*neti_ispartialchecksum)(mblk_t *);
134 int (*neti_isvalidchecksum)(mblk_t *);
135} net_info_t;
136
137
138/*
139 * Private data structures
140 */
141struct net_data {
142 LIST_ENTRY(net_data) netd_list;
143 net_info_t netd_info;
144 int netd_refcnt;
145 hook_family_int_t *netd_hooks;
146 netstack_t *netd_netstack;
144};
145
146
147typedef struct injection_s {
148 net_inject_t inj_data;
149 boolean_t inj_isv6;
147};
148
149
150typedef struct injection_s {
151 net_inject_t inj_data;
152 boolean_t inj_isv6;
153 void * inj_ptr;
150} injection_t;
151
152/*
153 * The ipif_id space is [0,MAX) but this interface wants to return [1,MAX] as
154 * a valid range of logical interface numbers so that it can return 0 to mean
155 * "end of list" with net_lifgetnext. Changing ipif_id's to use the [1,MAX]
156 * space is something to be considered for the future, if it is worthwhile.
157 */
158#define MAP_IPIF_ID(x) ((x) + 1)
159#define UNMAP_IPIF_ID(x) (((x) > 0) ? (x) - 1 : (x))
160
161
162/*
154} injection_t;
155
156/*
157 * The ipif_id space is [0,MAX) but this interface wants to return [1,MAX] as
158 * a valid range of logical interface numbers so that it can return 0 to mean
159 * "end of list" with net_lifgetnext. Changing ipif_id's to use the [1,MAX]
160 * space is something to be considered for the future, if it is worthwhile.
161 */
162#define MAP_IPIF_ID(x) ((x) + 1)
163#define UNMAP_IPIF_ID(x) (((x) > 0) ? (x) - 1 : (x))
164
165
166/*
167 * neti stack instances
168 */
169struct neti_stack {
170 krwlock_t nts_netlock;
171
172 /* list of net_data_t */
173 LIST_HEAD(netd_listhead, net_data) nts_netd_head;
174 netstack_t *nts_netstack;
175};
176typedef struct neti_stack neti_stack_t;
177
178
179/*
163 * Data management functions
164 */
180 * Data management functions
181 */
165extern net_data_t net_register(const net_info_t *);
182extern net_data_t net_register(const net_info_t *, netstackid_t);
183extern net_data_t net_register_impl(const net_info_t *, netstack_t *);
166extern int net_unregister(net_data_t);
184extern int net_unregister(net_data_t);
167extern net_data_t net_lookup(const char *);
185extern net_data_t net_lookup(const char *, netstackid_t);
186extern net_data_t net_lookup_impl(const char *, netstack_t *);
168extern int net_release(net_data_t);
187extern int net_release(net_data_t);
169extern net_data_t net_walk(net_data_t);
188extern net_data_t net_walk(net_data_t, netstackid_t);
189extern net_data_t net_walk_impl(net_data_t, netstack_t *);
170
171/*
172 * Accessor functions
173 */
174extern int net_register_family(net_data_t, hook_family_t *);
175extern int net_unregister_family(net_data_t, hook_family_t *);
176extern hook_event_token_t net_register_event(net_data_t, hook_event_t *);
177extern int net_unregister_event(net_data_t, hook_event_t *);

--- 20 unchanged lines hidden ---
190
191/*
192 * Accessor functions
193 */
194extern int net_register_family(net_data_t, hook_family_t *);
195extern int net_unregister_family(net_data_t, hook_family_t *);
196extern hook_event_token_t net_register_event(net_data_t, hook_event_t *);
197extern int net_unregister_event(net_data_t, hook_event_t *);

--- 20 unchanged lines hidden ---