comparison usr/src/cmd/cmd-inet/lib/nwamd/structures.h @ 0:c9caec207d52 b86

Initial porting based on b86
author Koji Uno <koji.uno@sun.com>
date Tue, 02 Jun 2009 18:56:50 +0900
parents
children 1a15d5aaf794
comparison
equal deleted inserted replaced
-1:000000000000 0:c9caec207d52
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
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
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 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _STRUCTURES_H
28 #define _STRUCTURES_H
29
30 #pragma ident "@(#)structures.h 1.4 08/01/22 SMI"
31
32 #include <net/if.h>
33 #include <libscf.h>
34 #include <libdlwlan.h>
35
36 /*
37 * XXX More work on the state machine is needed. In the future,
38 * events will be more like EV_NEWADDR, identifying the actual
39 * event that we care about, rather than the source of the event
40 * that we originally implemented. For example, EV_ROUTING should
41 * be split into EV_LINK_UP and EV_LINK_DOWN. It's a bit of a mix
42 * right now.
43 */
44 enum np_event_type {
45 EV_ROUTING,
46 EV_SYS,
47 EV_TIMER,
48 EV_SHUTDOWN,
49 EV_NEWADDR
50 };
51
52 enum interface_type {
53 IF_UNKNOWN,
54 IF_WIRED,
55 IF_WIRELESS,
56 IF_TUN
57 };
58
59 struct np_event {
60 enum np_event_type npe_type;
61 char *npe_name;
62 struct np_event *npe_next;
63 };
64
65 /*
66 * This structure is used to represent the current state of the system. We
67 * maintain these for IPv4 as proxies for links in the system. This is
68 * differentiated from the LLP which contains the intended configuration of
69 * the system.
70 *
71 * Currently these are stored on ifs_head with the wired interfaces sorted
72 * together and the wireless ones sorted together with ifs_wired and
73 * ifs_wireless pointed at these sublists. Access to these lists is not
74 * currently MT-safe.
75 *
76 * We explicitly do not maintain IPv6 interface structures. In the current
77 * state machine, IPv6 interfaces are completely dependent on their IPv4
78 * counterparts. For example, we make a decision to bring up an interface
79 * based on routing socket messages read from an AF_INET socket; we will
80 * always bring up v4, and may additionally bring up v6. Also, when we
81 * start up, we find all interfaces in the system by doing 'ifconfig -a
82 * plumb', which will plumb v4 on all links; we always keep the v4 interface
83 * plumbed, taking it up and down depending on whether it's currently in use
84 * or not. v6 interfaces are not plumbed initially; when we decide a link
85 * should be active (and its llp tells us to do v6), we'll mark the (already
86 * existing) v4 interface up, and 'plumb up' the v6 interface. Conversely,
87 * when a link is no longer active, we 'down unplumb' the v6 interface, but
88 * only 'down' the v4 interface.
89 */
90 struct interface {
91 char *if_name;
92 datalink_id_t if_linkid;
93 sa_family_t if_family;
94 uint64_t if_flags;
95 uint32_t if_lflags;
96 enum interface_type if_type;
97 uint32_t if_timer_expire;
98 struct sockaddr *if_ipaddr;
99 struct interface *if_next;
100 };
101
102 /*
103 * interface local flag values
104 */
105 /*
106 * IF_DHCPFAILED: indicates that we timed out a dhcp request. Will be
107 * cleared if the request eventually succeeds, or if the IFF_RUNNING flag
108 * is toggled off/on (i.e. the cable is unplugged/plugged)
109 */
110 #define IF_DHCPFAILED 0x01
111 /*
112 * IF_DHCPSTARTED: much like IFF_DHCPRUNNING; but means specifically that
113 * we have inititated dhcp on this interface. Used to prevent overlapping
114 * invocations of dhcp.
115 */
116 #define IF_DHCPSTARTED 0x02
117 /*
118 * IF_DHCPACQUIRED: indicates that dhcp successfully acquired a lease.
119 */
120 #define IF_DHCPACQUIRED 0x04
121
122 #define IF_DHCPFLAGS (IF_DHCPFAILED | IF_DHCPSTARTED | IF_DHCPACQUIRED)
123
124 /*
125 * visited_wlans are stored on visited_wlan_list of type visisted_wlans_list.
126 * Access is protected by wifi_mutex.
127 */
128 struct visited_wlans {
129 struct wireless_lan *wifi_net;
130 struct visited_wlans *next;
131 };
132
133 struct visited_wlans_list {
134 struct visited_wlans *head;
135 int total;
136 };
137
138 typedef enum {
139 IPV4SRC_STATIC,
140 IPV4SRC_DHCP
141 } ipv4src_t;
142
143 /*
144 * This structure contains the intended configuration of the system as
145 * differentiated from the actual IPv4 configuration of the system represented
146 * by the interface structures.
147 *
148 * llp structures are held on the list llp_head. Access to this list is
149 * protected by llp_lock.
150 */
151 typedef struct llp {
152 struct llp *llp_next;
153 char llp_lname[LIFNAMSIZ];
154 int llp_pri; /* lower number => higher priority */
155 enum interface_type llp_type;
156 ipv4src_t llp_ipv4src;
157 char *llp_ipv4addrstr; /* if ipsrc is STATIC */
158 char *llp_ipv6addrstr; /* if the user provided a static addr */
159 boolean_t llp_ipv6onlink; /* true if we plumb up a v6 interface */
160 } llp_t;
161
162 /*
163 * These entries are user allocated and should be managed by whomever
164 * originates the structure.
165 */
166 struct wireless_lan {
167 char *essid;
168 char *bssid;
169 char *signal_strength;
170 char *raw_key;
171 dladm_wlan_key_t *cooked_key;
172 dladm_wlan_secmode_t sec_mode;
173 char *wl_if_name;
174 };
175
176 /*
177 * A holder for all the resources needed to get a property value
178 * using libscf.
179 */
180 typedef struct scf_resources {
181 scf_handle_t *sr_handle;
182 scf_instance_t *sr_inst;
183 scf_snapshot_t *sr_snap;
184 scf_propertygroup_t *sr_pg;
185 scf_property_t *sr_prop;
186 scf_value_t *sr_val;
187 } scf_resources_t;
188
189
190 #endif /* _STRUCTURES_H */