Lines Matching defs:iapp
2 * hostapd / IEEE 802.11F-2003 Inter-Access Point Protocol (IAPP)
18 * Level 3: support for encryption and authentication of IAPP messages
23 * - implement counters etc. for IAPP MIB
24 * - verify endianness of fields in IAPP messages; are they big-endian as
27 * - TCP connection for IAPP MOVE, CACHE
28 * - broadcast ESP for IAPP ADD-notify
29 * - ESP for IAPP MOVE messages
50 #include "iapp.h"
171 u16 identifier; /* next IAPP identifier */
178 static void iapp_send_add(struct iapp_data *iapp, u8 *mac_addr, u16 seq_num)
185 /* Send IAPP ADD-notify to remove possible association from other APs
191 hdr->identifier = host_to_be16(iapp->identifier++);
203 addr.sin_addr.s_addr = iapp->multicast.s_addr;
205 if (sendto(iapp->udp_sock, buf, (char *) (add + 1) - buf, 0,
207 perror("sendto[IAPP-ADD]");
211 static void iapp_send_layer2_update(struct iapp_data *iapp, u8 *addr)
233 if (send(iapp->packet_sock, &msg, sizeof(msg), 0) < 0)
239 * iapp_new_station - IAPP processing for a new STA
240 * @iapp: IAPP data
243 void iapp_new_station(struct iapp_data *iapp, struct sta_info *sta)
248 if (iapp == NULL)
254 /* IAPP-ADD.request(MAC Address, Sequence Number, Timeout) */
255 hostapd_logger(iapp->hapd, sta->addr, HOSTAPD_MODULE_IAPP,
256 HOSTAPD_LEVEL_DEBUG, "IAPP-ADD.request(seq=%d)", seq);
257 iapp_send_layer2_update(iapp, sta->addr);
258 iapp_send_add(iapp, sta->addr, seq);
262 /* IAPP-MOVE.request(MAC Address, Sequence Number, Old AP,
265 /* TODO: Send IAPP-MOVE to the old AP; Map Old AP BSSID to
271 static void iapp_process_add_notify(struct iapp_data *iapp,
279 printf("Invalid IAPP-ADD packet length %d (expected %lu)\n",
284 sta = ap_get_sta(iapp->hapd, add->mac_addr);
286 /* IAPP-ADD.indication(MAC Address, Sequence Number) */
287 hostapd_logger(iapp->hapd, add->mac_addr, HOSTAPD_MODULE_IAPP,
289 "Received IAPP ADD-notify (seq# %d) from %s:%d%s",
298 * to this AP is newer than the one advertised in IAPP-ADD. Although,
301 hostapd_logger(iapp->hapd, add->mac_addr, HOSTAPD_MODULE_IAPP,
303 "Removing STA due to IAPP ADD-notify");
304 ap_sta_disconnect(iapp->hapd, sta, NULL, 0);
309 * iapp_receive_udp - Process IAPP UDP frames
311 * @eloop_ctx: IAPP data (struct iapp_data *)
316 struct iapp_data *iapp = eloop_ctx;
323 /* Handle incoming IAPP frames (over UDP/IP) */
326 len = recvfrom(iapp->udp_sock, buf, sizeof(buf), 0,
333 if (from.sin_addr.s_addr == iapp->own.s_addr)
334 return; /* ignore own IAPP messages */
336 hostapd_logger(iapp->hapd, NULL, HOSTAPD_MODULE_IAPP,
338 "Received %d byte IAPP frame from %s%s\n",
347 hostapd_logger(iapp->hapd, NULL, HOSTAPD_MODULE_IAPP,
353 printf("Dropping IAPP frame with unknown version %d\n",
358 printf("Underflow IAPP frame (hlen=%d len=%d)\n", hlen, len);
362 printf("Ignoring %d extra bytes from IAPP frame\n",
369 iapp_process_add_notify(iapp, &from, hdr, hlen - sizeof(*hdr));
374 /* IAPP-MOVE.indication(MAC Address, New BSSID,
379 printf("Unknown IAPP command %d\n", hdr->command);
391 struct iapp_data *iapp;
394 iapp = os_zalloc(sizeof(*iapp));
395 if (iapp == NULL)
397 iapp->hapd = hapd;
398 iapp->udp_sock = iapp->packet_sock = -1;
401 * open socket for sending and receiving IAPP frames over TCP
404 iapp->udp_sock = socket(PF_INET, SOCK_DGRAM, 0);
405 if (iapp->udp_sock < 0) {
407 iapp_deinit(iapp);
413 if (ioctl(iapp->udp_sock, SIOCGIFINDEX, &ifr) != 0) {
415 iapp_deinit(iapp);
420 if (ioctl(iapp->udp_sock, SIOCGIFADDR, &ifr) != 0) {
422 iapp_deinit(iapp);
429 iapp_deinit(iapp);
432 iapp->own.s_addr = paddr->sin_addr.s_addr;
434 if (ioctl(iapp->udp_sock, SIOCGIFBRDADDR, &ifr) != 0) {
436 iapp_deinit(iapp);
443 iapp_deinit(iapp);
446 inet_aton(IAPP_MULTICAST, &iapp->multicast);
451 if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr,
454 iapp_deinit(iapp);
459 mreq.imr_multiaddr = iapp->multicast;
462 if (setsockopt(iapp->udp_sock, SOL_IP, IP_ADD_MEMBERSHIP, &mreq,
465 iapp_deinit(iapp);
469 iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
470 if (iapp->packet_sock < 0) {
472 iapp_deinit(iapp);
479 if (bind(iapp->packet_sock, (struct sockaddr *) &addr,
482 iapp_deinit(iapp);
486 if (eloop_register_read_sock(iapp->udp_sock, iapp_receive_udp,
487 iapp, NULL)) {
488 printf("Could not register read socket for IAPP.\n");
489 iapp_deinit(iapp);
493 printf("IEEE 802.11F (IAPP) using interface %s\n", iface);
496 * RADIUS Initiate-Accept or Initiate-Reject. IAPP port should actually
498 * is received, IAPP is not started. */
500 return iapp;
504 void iapp_deinit(struct iapp_data *iapp)
508 if (iapp == NULL)
511 if (iapp->udp_sock >= 0) {
513 mreq.imr_multiaddr = iapp->multicast;
516 if (setsockopt(iapp->udp_sock, SOL_IP, IP_DROP_MEMBERSHIP,
521 eloop_unregister_read_sock(iapp->udp_sock);
522 close(iapp->udp_sock);
524 if (iapp->packet_sock >= 0) {
525 eloop_unregister_read_sock(iapp->packet_sock);
526 close(iapp->packet_sock);
528 os_free(iapp);