Home | History | Annotate | Download | only in ap

Lines Matching defs:iapp

2  * hostapd / IEEE 802.11F-2003 Inter-Access Point Protocol (IAPP)
24 * Level 3: support for encryption and authentication of IAPP messages
29 * - implement counters etc. for IAPP MIB
30 * - verify endianness of fields in IAPP messages; are they big-endian as
33 * - TCP connection for IAPP MOVE, CACHE
34 * - broadcast ESP for IAPP ADD-notify
35 * - ESP for IAPP MOVE messages
56 #include "iapp.h"
177 u16 identifier; /* next IAPP identifier */
184 static void iapp_send_add(struct iapp_data *iapp, u8 *mac_addr, u16 seq_num)
191 /* Send IAPP ADD-notify to remove possible association from other APs
197 hdr->identifier = host_to_be16(iapp->identifier++);
209 addr.sin_addr.s_addr = iapp->multicast.s_addr;
211 if (sendto(iapp->udp_sock, buf, (char *) (add + 1) - buf, 0,
213 perror("sendto[IAPP-ADD]");
217 static void iapp_send_layer2_update(struct iapp_data *iapp, u8 *addr)
239 if (send(iapp->packet_sock, &msg, sizeof(msg), 0) < 0)
245 * iapp_new_station - IAPP processing for a new STA
246 * @iapp: IAPP data
249 void iapp_new_station(struct iapp_data *iapp, struct sta_info *sta)
254 if (iapp == NULL)
260 /* IAPP-ADD.request(MAC Address, Sequence Number, Timeout) */
261 hostapd_logger(iapp->hapd, sta->addr, HOSTAPD_MODULE_IAPP,
262 HOSTAPD_LEVEL_DEBUG, "IAPP-ADD.request(seq=%d)", seq);
263 iapp_send_layer2_update(iapp, sta->addr);
264 iapp_send_add(iapp, sta->addr, seq);
268 /* IAPP-MOVE.request(MAC Address, Sequence Number, Old AP,
271 /* TODO: Send IAPP-MOVE to the old AP; Map Old AP BSSID to
277 static void iapp_process_add_notify(struct iapp_data *iapp,
285 printf("Invalid IAPP-ADD packet length %d (expected %lu)\n",
290 sta = ap_get_sta(iapp->hapd, add->mac_addr);
292 /* IAPP-ADD.indication(MAC Address, Sequence Number) */
293 hostapd_logger(iapp->hapd, add->mac_addr, HOSTAPD_MODULE_IAPP,
295 "Received IAPP ADD-notify (seq# %d) from %s:%d%s",
304 * to this AP is newer than the one advertised in IAPP-ADD. Although,
307 hostapd_logger(iapp->hapd, add->mac_addr, HOSTAPD_MODULE_IAPP,
309 "Removing STA due to IAPP ADD-notify");
310 ap_sta_disconnect(iapp->hapd, sta, NULL, 0);
315 * iapp_receive_udp - Process IAPP UDP frames
317 * @eloop_ctx: IAPP data (struct iapp_data *)
322 struct iapp_data *iapp = eloop_ctx;
329 /* Handle incoming IAPP frames (over UDP/IP) */
332 len = recvfrom(iapp->udp_sock, buf, sizeof(buf), 0,
339 if (from.sin_addr.s_addr == iapp->own.s_addr)
340 return; /* ignore own IAPP messages */
342 hostapd_logger(iapp->hapd, NULL, HOSTAPD_MODULE_IAPP,
344 "Received %d byte IAPP frame from %s%s\n",
353 hostapd_logger(iapp->hapd, NULL, HOSTAPD_MODULE_IAPP,
359 printf("Dropping IAPP frame with unknown version %d\n",
364 printf("Underflow IAPP frame (hlen=%d len=%d)\n", hlen, len);
368 printf("Ignoring %d extra bytes from IAPP frame\n",
375 iapp_process_add_notify(iapp, &from, hdr, hlen - sizeof(*hdr));
380 /* IAPP-MOVE.indication(MAC Address, New BSSID,
385 printf("Unknown IAPP command %d\n", hdr->command);
397 struct iapp_data *iapp;
400 iapp = os_zalloc(sizeof(*iapp));
401 if (iapp == NULL)
403 iapp->hapd = hapd;
404 iapp->udp_sock = iapp->packet_sock = -1;
407 * open socket for sending and receiving IAPP frames over TCP
410 iapp->udp_sock = socket(PF_INET, SOCK_DGRAM, 0);
411 if (iapp->udp_sock < 0) {
413 iapp_deinit(iapp);
419 if (ioctl(iapp->udp_sock, SIOCGIFINDEX, &ifr) != 0) {
421 iapp_deinit(iapp);
426 if (ioctl(iapp->udp_sock, SIOCGIFADDR, &ifr) != 0) {
428 iapp_deinit(iapp);
435 iapp_deinit(iapp);
438 iapp->own.s_addr = paddr->sin_addr.s_addr;
440 if (ioctl(iapp->udp_sock, SIOCGIFBRDADDR, &ifr) != 0) {
442 iapp_deinit(iapp);
449 iapp_deinit(iapp);
452 inet_aton(IAPP_MULTICAST, &iapp->multicast);
457 if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr,
460 iapp_deinit(iapp);
465 mreq.imr_multiaddr = iapp->multicast;
468 if (setsockopt(iapp->udp_sock, SOL_IP, IP_ADD_MEMBERSHIP, &mreq,
471 iapp_deinit(iapp);
475 iapp->packet_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
476 if (iapp->packet_sock < 0) {
478 iapp_deinit(iapp);
485 if (bind(iapp->packet_sock, (struct sockaddr *) &addr,
488 iapp_deinit(iapp);
492 if (eloop_register_read_sock(iapp->udp_sock, iapp_receive_udp,
493 iapp, NULL)) {
494 printf("Could not register read socket for IAPP.\n");
495 iapp_deinit(iapp);
499 printf("IEEE 802.11F (IAPP) using interface %s\n", iface);
502 * RADIUS Initiate-Accept or Initiate-Reject. IAPP port should actually
504 * is received, IAPP is not started. */
506 return iapp;
510 void iapp_deinit(struct iapp_data *iapp)
514 if (iapp == NULL)
517 if (iapp->udp_sock >= 0) {
519 mreq.imr_multiaddr = iapp->multicast;
522 if (setsockopt(iapp->udp_sock, SOL_IP, IP_DROP_MEMBERSHIP,
527 eloop_unregister_read_sock(iapp->udp_sock);
528 close(iapp->udp_sock);
530 if (iapp->packet_sock >= 0) {
531 eloop_unregister_read_sock(iapp->packet_sock);
532 close(iapp->packet_sock);
534 os_free(iapp);