hostapd
l2_packet.h
1 /*
2  * WPA Supplicant - Layer2 packet interface definition
3  * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  *
8  * This file defines an interface for layer 2 (link layer) packet sending and
9  * receiving. l2_packet_linux.c is one implementation for such a layer 2
10  * implementation using Linux packet sockets and l2_packet_pcap.c another one
11  * using libpcap and libdnet. When porting %wpa_supplicant to other operating
12  * systems, a new l2_packet implementation may need to be added.
13  */
14 
15 #ifndef L2_PACKET_H
16 #define L2_PACKET_H
17 
26 struct l2_packet_data;
27 
28 #ifdef _MSC_VER
29 #pragma pack(push, 1)
30 #endif /* _MSC_VER */
31 
32 struct l2_ethhdr {
33  u8 h_dest[ETH_ALEN];
34  u8 h_source[ETH_ALEN];
35  be16 h_proto;
36 } STRUCT_PACKED;
37 
38 #ifdef _MSC_VER
39 #pragma pack(pop)
40 #endif /* _MSC_VER */
41 
42 enum l2_packet_filter_type {
43  L2_PACKET_FILTER_DHCP,
44  L2_PACKET_FILTER_NDISC,
45 };
46 
64 struct l2_packet_data * l2_packet_init(
65  const char *ifname, const u8 *own_addr, unsigned short protocol,
66  void (*rx_callback)(void *ctx, const u8 *src_addr,
67  const u8 *buf, size_t len),
68  void *rx_callback_ctx, int l2_hdr);
69 
76 struct l2_packet_data * l2_packet_init_bridge(
77  const char *br_ifname, const char *ifname, const u8 *own_addr,
78  unsigned short protocol,
79  void (*rx_callback)(void *ctx, const u8 *src_addr,
80  const u8 *buf, size_t len),
81  void *rx_callback_ctx, int l2_hdr);
82 
87 void l2_packet_deinit(struct l2_packet_data *l2);
88 
95 int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr);
96 
109 int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
110  const u8 *buf, size_t len);
111 
126 int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len);
127 
128 
140 void l2_packet_notify_auth_start(struct l2_packet_data *l2);
141 
151 int l2_packet_set_packet_filter(struct l2_packet_data *l2,
152  enum l2_packet_filter_type type);
153 
154 #endif /* L2_PACKET_H */
Definition: l2_packet_freebsd.c:36
Definition: l2_packet.h:32