Lines Matching refs:sm
454 * @sm: WPS UPnP state machine from upnp_wps_device_init()
457 * subscribed UPnP control points. sm->wlanevent must have been set with the
460 static void upnp_wps_device_send_event(struct upnp_wps_device_sm *sm)
473 if (dl_list_empty(&sm->subscriptions)) {
479 if (now.sec != sm->last_event_sec) {
480 sm->last_event_sec = now.sec;
481 sm->num_events_in_sec = 1;
483 sm->num_events_in_sec++;
491 if (sm->num_events_in_sec > MAX_EVENTS_PER_SEC &&
492 sm->wlanevent_type ==
497 sm->num_events_in_sec);
506 if (sm->wlanevent)
507 buf_size += os_strlen(sm->wlanevent);
514 wpabuf_put_property(buf, "WLANEvent", sm->wlanevent);
520 dl_list_for_each_safe(s, tmp, &sm->subscriptions, struct subscription,
523 sm->wlanevent_type == UPNP_WPS_WLANEVENT_TYPE_PROBE);
545 dl_list_for_each(iface, &s->sm->interfaces,
553 static void subscription_list_age(struct upnp_wps_device_sm *sm, time_t now)
556 dl_list_for_each_safe(s, tmp, &sm->subscriptions,
570 struct subscription * subscription_find(struct upnp_wps_device_sm *sm,
574 dl_list_for_each(s, &sm->subscriptions, struct subscription, list) {
635 if (s->sm->wlanevent == NULL) {
650 s->sm->wlanevent = (char *)
657 wlan_event = s->sm->wlanevent;
688 * @sm: WPS UPnP state machine from upnp_wps_device_init()
692 struct subscription * subscription_start(struct upnp_wps_device_sm *sm,
701 subscription_list_age(sm, now);
704 if (dl_list_len(&sm->subscriptions) >= MAX_SUBSCRIPTIONS) {
705 s = dl_list_first(&sm->subscriptions, struct subscription,
721 s->sm = sm;
736 dl_list_add_tail(&sm->subscriptions, &s->list);
752 event_send_all_later(sm);
758 struct subscription * subscription_renew(struct upnp_wps_device_sm *sm,
763 struct subscription *s = subscription_find(sm, uuid);
770 dl_list_add_tail(&sm->subscriptions, &s->list);
777 * @sm: WPS UPnP state machine from upnp_wps_device_init()
787 int upnp_wps_device_send_wlan_event(struct upnp_wps_device_sm *sm,
802 if (!sm)
829 os_free(sm->wlanevent);
830 sm->wlanevent = val;
831 sm->wlanevent_type = ev_type;
832 upnp_wps_device_send_event(sm);
975 * @sm: WPS UPnP state machine from upnp_wps_device_init()
977 static void upnp_wps_device_stop(struct upnp_wps_device_sm *sm)
979 if (!sm || !sm->started)
983 web_listener_stop(sm);
984 ssdp_listener_stop(sm);
985 upnp_wps_free_msearchreply(&sm->msearch_replies);
986 upnp_wps_free_subscriptions(&sm->subscriptions, NULL);
988 advertisement_state_machine_stop(sm, 1);
990 event_send_stop_all(sm);
991 os_free(sm->wlanevent);
992 sm->wlanevent = NULL;
993 os_free(sm->ip_addr_text);
994 sm->ip_addr_text = NULL;
995 if (sm->multicast_sd >= 0)
996 close(sm->multicast_sd);
997 sm->multicast_sd = -1;
999 sm->started = 0;
1005 * @sm: WPS UPnP state machine from upnp_wps_device_init()
1009 static int upnp_wps_device_start(struct upnp_wps_device_sm *sm, char *net_if)
1011 if (!sm || !net_if)
1014 if (sm->started)
1015 upnp_wps_device_stop(sm);
1017 sm->multicast_sd = -1;
1018 sm->ssdp_sd = -1;
1019 sm->started = 1;
1020 sm->advertise_count = 0;
1027 if (get_netif_info(net_if, &sm->ip_addr, &sm->ip_addr_text,
1028 sm->mac_addr)) {
1037 if (web_listener_start(sm))
1041 if (ssdp_listener_start(sm))
1045 if (ssdp_open_multicast(sm) < 0)
1053 if (advertisement_state_machine_start(sm))
1059 upnp_wps_device_stop(sm);
1065 upnp_wps_get_iface(struct upnp_wps_device_sm *sm, void *priv)
1068 dl_list_for_each(iface, &sm->interfaces,
1079 * @sm: WPS UPnP state machine from upnp_wps_device_init()
1082 void upnp_wps_device_deinit(struct upnp_wps_device_sm *sm, void *priv)
1087 if (!sm)
1090 iface = upnp_wps_get_iface(sm, priv);
1097 if (dl_list_len(&sm->interfaces) == 1) {
1100 upnp_wps_device_stop(sm);
1102 upnp_wps_free_subscriptions(&sm->subscriptions,
1117 if (dl_list_empty(&sm->interfaces)) {
1118 os_free(sm->root_dir);
1119 os_free(sm->desc_url);
1120 os_free(sm);
1138 struct upnp_wps_device_sm *sm;
1158 sm = shared_upnp_device;
1161 sm = os_zalloc(sizeof(*sm));
1162 if (!sm) {
1170 shared_upnp_device = sm;
1172 dl_list_init(&sm->msearch_replies);
1173 dl_list_init(&sm->subscriptions);
1174 dl_list_init(&sm->interfaces);
1178 dl_list_add(&sm->interfaces, &iface->list);
1180 if (start && upnp_wps_device_start(sm, net_if)) {
1181 upnp_wps_device_deinit(sm, priv);
1186 return sm;
1192 * @sm: WPS UPnP state machine from upnp_wps_device_init()
1195 int upnp_wps_subscribers(struct upnp_wps_device_sm *sm)
1197 return !dl_list_empty(&sm->subscriptions);
1201 int upnp_wps_set_ap_pin(struct upnp_wps_device_sm *sm, const char *ap_pin)
1204 if (sm == NULL)
1207 dl_list_for_each(iface, &sm->interfaces,