xref: /titanic_51/usr/src/uts/common/inet/ip_arp.h (revision f4ce81cfdad23bacfdb147be77d8d5fbe7673847)
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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _IP_ARP_H
28 #define	_IP_ARP_H
29 
30 /*
31  * Data-structures and functions related to the IP STREAMS queue that handles
32  * packets with the SAP set to 0x806 (ETHERTYPE_ARP).
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <sys/types.h>
40 #include <inet/ip.h>
41 #include <inet/ip_ndp.h>
42 #include <sys/stream.h>
43 
44 #ifdef _KERNEL
45 extern struct streamtab dummymodinfo;
46 
47 struct arl_ill_common_s;
48 /*
49  * The arl_s structure tracks the state of the associated ARP stream.
50  */
51 typedef struct arl_s {
52 	queue_t		*arl_rq;
53 	queue_t		*arl_wq;
54 	ip_stack_t	*arl_ipst;
55 	zoneid_t	arl_zoneid;
56 	cred_t		*arl_credp;
57 	ip_m_t		arl_media;
58 	struct arl_ill_common_s *arl_common;
59 	int		arl_muxid;
60 	uint_t		arl_ppa;
61 	t_uscalar_t	arl_sap;
62 	t_uscalar_t	arl_sap_length;
63 	uint_t	arl_phys_addr_length;
64 	char		*arl_name;
65 	int		arl_name_length;
66 	t_uscalar_t	arl_mactype;
67 #define	arl_first_mp_to_free	arl_dlpi_deferred
68 	mblk_t		*arl_dlpi_deferred;
69 	mblk_t		*arl_unbind_mp;
70 	mblk_t		*arl_detach_mp;
71 #define	arl_last_mp_to_free	arl_detach_mp
72 	uint_t		arl_state_flags;
73 	uint_t
74 		arl_needs_attach:1,
75 		arl_dlpi_style_set:1,
76 		arl_pad_to_bit_31:30;
77 	uint_t		arl_refcnt;
78 	kcondvar_t	arl_cv;
79 	t_uscalar_t	arl_dlpi_pending;
80 	kmutex_t	arl_lock;
81 	int		arl_error;
82 } arl_t;
83 
84 /*
85  * The arl_ill_common_t structure is a super-structure that contains pointers
86  * to a pair of matching ill_t, arl_t structures. Given an arl_t (or
87  * ill_t) the corresponding ill_t (or arl_t) must be obtained by
88  * synchronizing on the ai_lock,  and ensuring that the desired ill/arl
89  * pointer is non-null, not condemned. The arl_ill_common_t is allocated in
90  * arl_init() and freed only when both the ill_t and the arl_t structures
91  * become NULL.
92  * Lock hierarchy: the ai_lock must be take before the ill_lock or arl_lock.
93  */
94 
95 typedef struct arl_ill_common_s {
96 	kmutex_t	ai_lock;
97 	ill_t		*ai_ill;
98 	arl_t		*ai_arl;
99 	kcondvar_t	ai_ill_unplumb_done; /* sent from ip_modclose() */
100 } arl_ill_common_t;
101 
102 extern	boolean_t	arp_no_defense;
103 
104 extern	struct module_info arp_mod_info;
105 extern	int		arp_ll_up(ill_t *);
106 extern	int		arp_ll_down(ill_t *);
107 extern	boolean_t	arp_announce(ncec_t *);
108 extern	boolean_t	arp_probe(ncec_t *);
109 extern	int		arp_request(ncec_t *, in_addr_t, ill_t *);
110 extern	void		arp_failure(mblk_t *, ip_recv_attr_t *);
111 extern	int		arl_wait_for_info_ack(arl_t *);
112 extern	int		arl_init(queue_t *, arl_t *);
113 extern	void		arl_set_muxid(ill_t *, int);
114 extern	int		arl_get_muxid(ill_t *);
115 extern	void		arp_send_replumb_conf(ill_t *);
116 extern	void		arp_unbind_complete(ill_t *);
117 extern  ill_t		*arl_to_ill(arl_t *);
118 #endif
119 
120 #define	ARP_RETRANS_TIMER	500 /* time in milliseconds */
121 
122 /* The following are arl_state_flags */
123 #define	ARL_LL_SUBNET_PENDING	0x01	/* Waiting for DL_INFO_ACK from drv */
124 #define	ARL_CONDEMNED		0x02	/* No more new ref's to the ILL */
125 #define	ARL_DL_UNBIND_IN_PROGRESS	0x04	/* UNBIND_REQ is sent */
126 #define	ARL_LL_BIND_PENDING	0x0020	/* BIND sent */
127 #define	ARL_LL_UP		0x0040	/* BIND acked */
128 #define	ARL_LL_DOWN		0x0080
129 #define	ARL_LL_UNBOUND		0x0100	/* UNBIND acked */
130 #define	ARL_LL_REPLUMBING	0x0200	/* replumb in progress */
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif /* _IP_ARP_H */
137