1 /*
2  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
8  * Sun elects to license this software under the BSD license.
9  * See README for more details.
10  */
11 #ifndef __L2_PACKET_H
12 #define	__L2_PACKET_H
13 
14 #ifdef	__cplusplus
15 extern "C" {
16 #endif
17 
18 #include <sys/types.h>
19 #include <net/if.h>
20 #include <libdlpi.h>
21 
22 #define	IEEE80211_MTU_MAX	2304
23 
24 struct l2_packet_data {
25 	dlpi_handle_t	dh;	/* dlpi handle for EAPOL frames */
26 	char		ifname[DLPI_LINKNAME_MAX];
27 	uint8_t		own_addr[IEEE80211_ADDR_LEN];
28 	void		(*rx_callback)(void *, unsigned char *,
29 	    unsigned char *, size_t);
30 	void		*rx_callback_ctx;
31 };
32 
33 #pragma pack(1)
34 struct l2_ethhdr {
35 	uint8_t h_dest[IEEE80211_ADDR_LEN];
36 	uint8_t h_source[IEEE80211_ADDR_LEN];
37 	uint16_t h_proto;
38 };
39 #pragma pack()
40 
41 struct l2_packet_data *l2_packet_init(
42 	const char *, unsigned short,
43 	void (*rx_callback)(void *, unsigned char *,
44 			    unsigned char *, size_t),
45 	void *);
46 void l2_packet_deinit(struct l2_packet_data *);
47 
48 int l2_packet_get_own_addr(struct l2_packet_data *, uint8_t *);
49 int l2_packet_send(struct l2_packet_data *, uint8_t *, size_t);
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #endif /* __L2_PACKET_H */
56