Lines Matching refs:l2

29 static int wpa_priv_cmd(struct l2_packet_data *l2, int cmd,
43 msg.msg_name = &l2->priv_addr;
44 msg.msg_namelen = sizeof(l2->priv_addr);
46 if (sendmsg(l2->fd, &msg, 0) < 0) {
55 int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
57 os_memcpy(addr, l2->own_addr, ETH_ALEN);
62 int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
81 msg.msg_name = &l2->priv_addr;
82 msg.msg_namelen = sizeof(l2->priv_addr);
84 if (sendmsg(l2->fd, &msg, 0) < 0) {
96 struct l2_packet_data *l2 = eloop_ctx;
116 os_strncmp(from.sun_path, l2->priv_addr.sun_path,
123 l2->rx_callback(l2->rx_callback_ctx, buf, buf + ETH_ALEN,
134 struct l2_packet_data *l2;
146 l2 = os_zalloc(sizeof(struct l2_packet_data));
147 if (l2 == NULL)
149 l2->rx_callback = rx_callback;
150 l2->rx_callback_ctx = rx_callback_ctx;
153 l2->own_socket_path = os_malloc(len);
154 if (l2->own_socket_path == NULL) {
155 os_free(l2);
158 os_snprintf(l2->own_socket_path, len, "%s/wpa_privsep-l2-%d-%d",
161 l2->priv_addr.sun_family = AF_UNIX;
162 os_snprintf(l2->priv_addr.sun_path, sizeof(l2->priv_addr.sun_path),
165 l2->fd = socket(PF_UNIX, SOCK_DGRAM, 0);
166 if (l2->fd < 0) {
168 os_free(l2->own_socket_path);
169 l2->own_socket_path = NULL;
170 os_free(l2);
176 os_strlcpy(addr.sun_path, l2->own_socket_path, sizeof(addr.sun_path));
177 if (bind(l2->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
178 wpa_printf(MSG_ERROR, "l2-pkt-privsep: bind(PF_UNIX): %s",
185 if (wpa_priv_cmd(l2, PRIVSEP_CMD_L2_REGISTER, reg_cmd, sizeof(reg_cmd))
192 FD_SET(l2->fd, &rfds);
195 res = select(l2->fd + 1, &rfds, NULL, NULL, &tv);
201 if (FD_ISSET(l2->fd, &rfds)) {
202 res = recv(l2->fd, reply, sizeof(reply), 0);
217 os_memcpy(l2->own_addr, reply, ETH_ALEN);
219 eloop_register_read_sock(l2->fd, l2_packet_receive, l2, NULL);
221 return l2;
224 close(l2->fd);
225 l2->fd = -1;
226 unlink(l2->own_socket_path);
227 os_free(l2->own_socket_path);
228 l2->own_socket_path = NULL;
229 os_free(l2);
246 void l2_packet_deinit(struct l2_packet_data *l2)
248 if (l2 == NULL)
251 if (l2->fd >= 0) {
252 wpa_priv_cmd(l2, PRIVSEP_CMD_L2_UNREGISTER, NULL, 0);
253 eloop_unregister_read_sock(l2->fd);
254 close(l2->fd);
257 if (l2->own_socket_path) {
258 unlink(l2->own_socket_path);
259 os_free(l2->own_socket_path);
262 os_free(l2);
266 int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
273 void l2_packet_notify_auth_start(struct l2_packet_data *l2)
275 wpa_priv_cmd(l2, PRIVSEP_CMD_L2_NOTIFY_AUTH_START, NULL, 0);
279 int l2_packet_set_packet_filter(struct l2_packet_data *l2,