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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26#ifndef _IP_ARP_H
27#define	_IP_ARP_H
28
29/*
30 * Data-structures and functions related to the IP STREAMS queue that handles
31 * packets with the SAP set to 0x806 (ETHERTYPE_ARP).
32 */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include <sys/types.h>
39#include <inet/ip.h>
40#include <inet/ip_ndp.h>
41#include <sys/stream.h>
42
43#ifdef _KERNEL
44extern struct streamtab dummymodinfo;
45
46struct arl_ill_common_s;
47/*
48 * The arl_s structure tracks the state of the associated ARP stream.
49 */
50typedef struct arl_s {
51	queue_t		*arl_rq;
52	queue_t		*arl_wq;
53	ip_stack_t	*arl_ipst;
54	zoneid_t	arl_zoneid;
55	cred_t		*arl_credp;
56	ip_m_t		arl_media;
57	struct arl_ill_common_s *arl_common;
58	int		arl_muxid;
59	uint_t		arl_ppa;
60	t_uscalar_t	arl_sap;
61	t_uscalar_t	arl_sap_length;
62	uint_t	arl_phys_addr_length;
63	char		*arl_name;
64	int		arl_name_length;
65	t_uscalar_t	arl_mactype;
66#define	arl_first_mp_to_free	arl_dlpi_deferred
67	mblk_t		*arl_dlpi_deferred;
68	mblk_t		*arl_unbind_mp;
69	mblk_t		*arl_detach_mp;
70#define	arl_last_mp_to_free	arl_detach_mp
71	uint_t		arl_state_flags;
72	uint_t
73		arl_needs_attach:1,
74		arl_dlpi_style_set:1,
75		arl_pad_to_bit_31:30;
76	uint_t		arl_refcnt;
77	kcondvar_t	arl_cv;
78	t_uscalar_t	arl_dlpi_pending;
79	kmutex_t	arl_lock;
80	int		arl_error;
81} arl_t;
82
83/*
84 * The arl_ill_common_t structure is a super-structure that contains pointers
85 * to a pair of matching ill_t, arl_t structures. Given an arl_t (or
86 * ill_t) the corresponding ill_t (or arl_t) must be obtained by
87 * synchronizing on the ai_lock,  and ensuring that the desired ill/arl
88 * pointer is non-null, not condemned. The arl_ill_common_t is allocated in
89 * arl_init() and freed only when both the ill_t and the arl_t structures
90 * become NULL.
91 * Lock hierarchy: the ai_lock must be take before the ill_lock or arl_lock.
92 */
93
94typedef struct arl_ill_common_s {
95	kmutex_t	ai_lock;
96	ill_t		*ai_ill;
97	arl_t		*ai_arl;
98	kcondvar_t	ai_ill_unplumb_done; /* sent from ip_modclose() */
99} arl_ill_common_t;
100
101extern	boolean_t	arp_no_defense;
102
103extern	struct module_info arp_mod_info;
104extern	int		arp_ll_up(ill_t *);
105extern	int		arp_ll_down(ill_t *);
106extern	boolean_t	arp_announce(ncec_t *);
107extern	boolean_t	arp_probe(ncec_t *);
108extern	int		arp_request(ncec_t *, in_addr_t, ill_t *);
109extern	void		arp_failure(mblk_t *, ip_recv_attr_t *);
110extern	int		arl_wait_for_info_ack(arl_t *);
111extern	int		arl_init(queue_t *, arl_t *);
112extern	void		arl_set_muxid(ill_t *, int);
113extern	int		arl_get_muxid(ill_t *);
114extern	void		arp_send_replumb_conf(ill_t *);
115extern	void		arp_unbind_complete(ill_t *);
116extern  ill_t		*arl_to_ill(arl_t *);
117extern	uint32_t	arp_hw_type(t_uscalar_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