xref: /titanic_41/usr/src/cmd/cmd-inet/usr.lib/wpad/l2_packet.h (revision a399b7655a1d835aa8606c2b29e4e777baac8635)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
15 
16 #ifdef	__cplusplus
17 extern "C" {
18 #endif
19 
20 #include <sys/types.h>
21 #include <net/if.h>
22 #include <libdlpi.h>
23 
24 #define	IEEE80211_MTU_MAX	2304
25 
26 struct l2_packet_data {
27 	dlpi_handle_t	dh;	/* dlpi handle for EAPOL frames */
28 	char		ifname[DLPI_LINKNAME_MAX];
29 	uint8_t		own_addr[IEEE80211_ADDR_LEN];
30 	void		(*rx_callback)(void *, unsigned char *,
31 	    unsigned char *, size_t);
32 	void		*rx_callback_ctx;
33 };
34 
35 #pragma pack(1)
36 struct l2_ethhdr {
37 	uint8_t h_dest[IEEE80211_ADDR_LEN];
38 	uint8_t h_source[IEEE80211_ADDR_LEN];
39 	uint16_t h_proto;
40 };
41 #pragma pack()
42 
43 struct l2_packet_data *l2_packet_init(
44 	const char *, unsigned short,
45 	void (*rx_callback)(void *, unsigned char *,
46 			    unsigned char *, size_t),
47 	void *);
48 void l2_packet_deinit(struct l2_packet_data *);
49 
50 int l2_packet_get_own_addr(struct l2_packet_data *, uint8_t *);
51 int l2_packet_send(struct l2_packet_data *, uint8_t *, size_t);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif /* __L2_PACKET_H */
58