int fst_global_init(void) { dl_list_init(&fst_global_groups_list); dl_list_init(&fst_global_ctrls_list); fst_session_global_init(); return 0; }
int main(){ srand(time(0)); //Creating memory managers mm_t *MM = malloc(sizeof(mm_t)); mm_init(MM,1500,sizeof(node)); mm_t *MM2 = malloc(sizeof(mm_t)); mm_init(MM2,3,sizeof(dl_list)); //Creating Lists dl_list *dl_1 = mm_get(MM2); dl_list *dl_2 = mm_get(MM2); dl_list *dl_3 = mm_get(MM2); dl_list_init(dl_1); dl_list_init(dl_2); dl_list_init(dl_3); int i; for(i = 0; i<500; i++) insert_item(dl_1,i,MM); print_list(dl_1); for(i = 0; i<500; i++) insert_item(dl_2,rand()%500,MM); print_list(dl_2); for(i = 0; i<500; i++) insert_item(dl_3,get_element(dl_1,i)+get_element(dl_2,i),MM); print_list(dl_3); //Deleting items from list 1 for(i = 0; i<100; i++) delete_item(dl_1,get_element(dl_3,i),MM); print_list(dl_1); //Joining lists join_lists(dl_2,dl_1); join_lists(dl_3,dl_2); print_list(dl_3); empty_list(dl_3,MM); //Deallocating and freeing mm_put(MM,dl_1); mm_put(MM,dl_2); mm_put(MM,dl_3); free(MM); free(MM2); return 0; }
int eloop_init(void) { os_memset(&eloop, 0, sizeof(eloop)); dl_list_init(&eloop.timeout); return 0; }
void hostapd_config_defaults_bss(struct hostapd_bss_config *bss) { dl_list_init(&bss->anqp_elem); bss->logger_syslog_level = HOSTAPD_LEVEL_INFO; bss->logger_stdout_level = HOSTAPD_LEVEL_INFO; bss->logger_syslog = (unsigned int) -1; bss->logger_stdout = (unsigned int) -1; bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED; bss->wep_rekeying_period = 300; /* use key0 in individual key and key1 in broadcast key */ bss->broadcast_key_idx_min = 1; bss->broadcast_key_idx_max = 2; bss->eap_reauth_period = 3600; bss->wpa_group_rekey = 600; bss->wpa_gmk_rekey = 86400; bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK; bss->wpa_pairwise = WPA_CIPHER_TKIP; bss->wpa_group = WPA_CIPHER_TKIP; bss->rsn_pairwise = 0; bss->max_num_sta = MAX_STA_COUNT; bss->dtim_period = 2; bss->radius_server_auth_port = 1812; bss->eap_sim_db_timeout = 1; bss->ap_max_inactivity = AP_MAX_INACTIVITY; bss->eapol_version = EAPOL_VERSION; bss->max_listen_interval = 65535; bss->pwd_group = 19; /* ECC: GF(p=256) */ #ifdef CONFIG_IEEE80211W bss->assoc_sa_query_max_timeout = 1000; bss->assoc_sa_query_retry_timeout = 201; bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC; #endif /* CONFIG_IEEE80211W */ #ifdef EAP_SERVER_FAST /* both anonymous and authenticated provisioning */ bss->eap_fast_prov = 3; bss->pac_key_lifetime = 7 * 24 * 60 * 60; bss->pac_key_refresh_time = 1 * 24 * 60 * 60; #endif /* EAP_SERVER_FAST */ /* Set to -1 as defaults depends on HT in setup */ bss->wmm_enabled = -1; #ifdef CONFIG_IEEE80211R bss->ft_over_ds = 1; #endif /* CONFIG_IEEE80211R */ bss->radius_das_time_window = 300; bss->sae_anti_clogging_threshold = 5; }
int os_program_init(void) { #ifdef WPA_TRACE dl_list_init(&alloc_list); #endif /* WPA_TRACE */ return 0; }
int os_program_init(void) { #ifdef ANDROID /* * We ignore errors here since errors are normal if we * are already running as non-root. */ #ifdef ANDROID_SETGROUPS_OVERRIDE gid_t groups[] = { ANDROID_SETGROUPS_OVERRIDE }; #else /* ANDROID_SETGROUPS_OVERRIDE */ gid_t groups[] = { AID_INET, AID_WIFI, AID_KEYSTORE }; #endif /* ANDROID_SETGROUPS_OVERRIDE */ struct __user_cap_header_struct header; struct __user_cap_data_struct cap; setgroups(ARRAY_SIZE(groups), groups); prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0); setgid(AID_WIFI); setuid(AID_WIFI); header.version = _LINUX_CAPABILITY_VERSION; header.pid = 0; cap.effective = cap.permitted = (1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW); cap.inheritable = 0; capset(&header, &cap); #endif /* ANDROID */ #ifdef WPA_TRACE dl_list_init(&alloc_list); #endif /* WPA_TRACE */ return 0; }
/** * wpa_bss_anqp_clone - Clone an ANQP data structure * @anqp: ANQP data structure from wpa_bss_anqp_alloc() * Returns: Cloned ANQP data structure or %NULL on failure */ static struct wpa_bss_anqp * wpa_bss_anqp_clone(struct wpa_bss_anqp *anqp) { struct wpa_bss_anqp *n; n = os_zalloc(sizeof(*n)); if (n == NULL) return NULL; #define ANQP_DUP(f) if (anqp->f) n->f = wpabuf_dup(anqp->f) #ifdef CONFIG_INTERWORKING dl_list_init(&n->anqp_elems); ANQP_DUP(capability_list); ANQP_DUP(venue_name); ANQP_DUP(network_auth_type); ANQP_DUP(roaming_consortium); ANQP_DUP(ip_addr_type_availability); ANQP_DUP(nai_realm); ANQP_DUP(anqp_3gpp); ANQP_DUP(domain_name); #endif /* CONFIG_INTERWORKING */ #ifdef CONFIG_HS20 ANQP_DUP(hs20_capability_list); ANQP_DUP(hs20_operator_friendly_name); ANQP_DUP(hs20_wan_metrics); ANQP_DUP(hs20_connection_capability); ANQP_DUP(hs20_operating_class); ANQP_DUP(hs20_osu_providers_list); #endif /* CONFIG_HS20 */ #undef ANQP_DUP return n; }
static struct wpa_ssid * wpa_config_read_network(FILE *f, int *line, int id) { struct wpa_ssid *ssid; int errors = 0, end = 0; char buf[2000], *pos, *pos2; wpa_printf(MSG_MSGDUMP, "Line: %d - start of a new network block", *line); ssid = os_zalloc(sizeof(*ssid)); if (ssid == NULL) return NULL; dl_list_init(&ssid->psk_list); ssid->id = id; wpa_config_set_network_defaults(ssid); while (wpa_config_get_line(buf, sizeof(buf), f, line, &pos)) { if (os_strcmp(pos, "}") == 0) { end = 1; break; } pos2 = os_strchr(pos, '='); if (pos2 == NULL) { wpa_printf(MSG_ERROR, "Line %d: Invalid SSID line " "'%s'.", *line, pos); errors++; continue; } *pos2++ = '\0'; if (*pos2 == '"') { if (os_strchr(pos2 + 1, '"') == NULL) { wpa_printf(MSG_ERROR, "Line %d: invalid " "quotation '%s'.", *line, pos2); errors++; continue; } } if (wpa_config_set(ssid, pos, pos2, *line) < 0) errors++; } if (!end) { wpa_printf(MSG_ERROR, "Line %d: network block was not " "terminated properly.", *line); errors++; } errors += wpa_config_validate_network(ssid, *line); if (errors) { wpa_config_free_ssid(ssid); ssid = NULL; } return ssid; }
int eloop_init(void) { os_memset(&eloop, 0, sizeof (eloop)); dl_list_init(&eloop.timeout); #ifdef WPA_TRACE signal(SIGSEGV, eloop_sigsegv_handler); #endif /* WPA_TRACE */ return 0; }
struct gas_server * gas_server_init(void *ctx, void (*tx)(void *ctx, int freq, const u8 *da, struct wpabuf *buf, unsigned int wait_time)) { struct gas_server *gas; gas = os_zalloc(sizeof(*gas)); if (!gas) return NULL; gas->ctx = ctx; gas->tx = tx; dl_list_init(&gas->handlers); dl_list_init(&gas->responses); return gas; }
static void *bgscan_learn_init(struct wpa_supplicant *wpa_s, const char *params, const struct wpa_ssid *ssid) { struct bgscan_learn_data *data; data = os_zalloc(sizeof(*data)); if (data == NULL) { return NULL; } dl_list_init(&data->bss); data->wpa_s = wpa_s; data->ssid = ssid; if (bgscan_learn_get_params(data, params) < 0) { os_free(data->fname); os_free(data); return NULL; } if (data->short_interval <= 0) { data->short_interval = 30; } if (data->long_interval <= 0) { data->long_interval = 30; } if (bgscan_learn_load(data) < 0) { os_free(data->fname); os_free(data); return NULL; } wpa_printf(MSG_DEBUG, "bgscan learn: Signal strength threshold %d " "Short bgscan interval %d Long bgscan interval %d", data->signal_threshold, data->short_interval, data->long_interval); if (data->signal_threshold && wpa_drv_signal_monitor(wpa_s, data->signal_threshold, 4) < 0) { wpa_printf(MSG_ERROR, "bgscan learn: Failed to enable " "signal strength monitoring"); } data->supp_freqs = bgscan_learn_get_supp_freqs(wpa_s); data->scan_interval = data->short_interval; if (data->signal_threshold) { /* Poll for signal info to set initial scan interval */ struct wpa_signal_info siginfo; if (wpa_drv_signal_poll(wpa_s, &siginfo) == 0 && siginfo.current_signal >= data->signal_threshold) { data->scan_interval = data->long_interval; } } eloop_register_timeout(data->scan_interval, 0, bgscan_learn_timeout, data, NULL); /* * This function is called immediately after an association, so it is * reasonable to assume that a scan was completed recently. This makes * us skip an immediate new scan in cases where the current signal * level is below the bgscan threshold. */ os_get_reltime(&data->last_bgscan); return data; }
/** * pals_rx_port_open */ pals_rx_port_t *pals_rx_port_open(pals_task_t *task, const char *name) { pals_rx_port_t *p; const pals_env_t *env = task->env; const struct pals_env_con *con; int ret; int msg_rate; const struct pals_env_task *sender; con = pals_env_find_con(env, name); if (con == NULL || !pals_env_con_is_peer(con, task->id)) { errno = EINVAL; return NULL; } p = calloc(1, sizeof(pals_rx_port_t)); if (p == NULL) { #ifdef PALS_DEBUG perror("calloc"); #endif return NULL; } p->task = task; p->con = con; if (task->rx_msg_len < con->len) task->rx_msg_len = con->len; sender = &env->tasks[con->sender]; msg_rate = gcd(sender->rate, task->rate); p->period = env->period/msg_rate; p->s_rate = sender->rate/msg_rate; p->r_rate = task->rate/msg_rate; if (con->n_peers == 1) { ret = _task_rx_sock_open(task); } else { ret = _task_mcast_rx_sock_open(task); } if (ret < 0) { #ifdef PALS_DEBUG perror("open_rx_sock"); #endif free(p); return NULL; } dl_list_init(&p->msg_list); task->rx_ports[con->id] = p; return p; }
int main() { int ret; struct nl_cb * nl_cb; struct nl_handle * nl_handle; struct netlink_data * netlink; int ioctl_sock = -1; struct dl_list interfaces; int if_add_ifindex = -1; dl_list_init(&interfaces); /* * global_init */ ret = netlink_init_nl80211_event_rtm(&netlink,NULL,nl80211_event_rtm_newlink,nl80211_event_rtm_dellink); if (ret == -1 || netlink == NULL) { goto err; } ret = nl80211_init_event(&nl_cb, &nl_handle); if (ret == -1) { wpa_printf(MSG_DEBUG, "nl80211: Init failure "); goto err; } wpa_printf(MSG_INFO, "nl80211: wait for event... "); nl_cb_set(nl_cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); nl_cb_set(nl_cb, NL_CB_VALID, NL_CB_CUSTOM, process_event, NULL); eloop_register_wrapper(nl_socket_get_fd(nl_handle), nl80211_event_receive, nl_cb, nl_handle); ioctl_sock = init_ioctl_sock(); if (ioctl_sock < 0) { perror("socket(PF_INET,SOCK_DGRAM)"); goto err; } /* * hapd_init */ eloop_run(); return 0; err: netlink_deinit(netlink); nl_destroy_handles(&nl_handle); nl_cb_put(nl_cb); if (ioctl_sock >= 0) { close(ioctl_sock); } return -1; }
/** * wpa_bss_anqp_alloc - Allocate ANQP data structure for a BSS entry * Returns: Allocated ANQP data structure or %NULL on failure * * The allocated ANQP data structure has its users count set to 1. It may be * shared by multiple BSS entries and each shared entry is freed with * wpa_bss_anqp_free(). */ struct wpa_bss_anqp * wpa_bss_anqp_alloc(void) { struct wpa_bss_anqp *anqp; anqp = os_zalloc(sizeof(*anqp)); if (anqp == NULL) return NULL; #ifdef CONFIG_INTERWORKING dl_list_init(&anqp->anqp_elems); #endif /* CONFIG_INTERWORKING */ anqp->users = 1; return anqp; }
struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr) { struct sta_info *sta; sta = ap_get_sta(hapd, addr); if (sta) return sta; wpa_printf(MSG_DEBUG, " New STA"); if (hapd->num_sta >= hapd->conf->max_num_sta) { /* FIX: might try to remove some old STAs first? */ wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)", hapd->num_sta, hapd->conf->max_num_sta); return NULL; } sta = os_zalloc(sizeof(struct sta_info)); if (sta == NULL) { wpa_printf(MSG_ERROR, "malloc failed"); return NULL; } sta->acct_interim_interval = hapd->conf->acct_interim_interval; if (accounting_sta_get_id(hapd, sta) < 0) { os_free(sta); return NULL; } if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_INACTIVITY_TIMER)) { wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout " "for " MACSTR " (%d seconds - ap_max_inactivity)", __func__, MAC2STR(addr), hapd->conf->ap_max_inactivity); eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, ap_handle_timer, hapd, sta); } /* initialize STA info data */ os_memcpy(sta->addr, addr, ETH_ALEN); sta->next = hapd->sta_list; hapd->sta_list = sta; hapd->num_sta++; ap_sta_hash_add(hapd, sta); ap_sta_remove_in_other_bss(hapd, sta); sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ; dl_list_init(&sta->ip6addr); #ifdef CONFIG_TAXONOMY sta_track_claim_taxonomy_info(hapd->iface, addr, &sta->probe_ie_taxonomy); #endif /* CONFIG_TAXONOMY */ return sta; }
/** * gas_query_init - Initialize GAS query component * @wpa_s: Pointer to wpa_supplicant data * Returns: Pointer to GAS query data or %NULL on failure */ struct gas_query * gas_query_init(struct wpa_supplicant *wpa_s) { struct gas_query *gas; gas = os_zalloc(sizeof(*gas)); if (gas == NULL) return NULL; gas->wpa_s = wpa_s; dl_list_init(&gas->pending); return gas; }
} END_TEST START_TEST (sources) { event_loop el = event_loop_new(); INIT_SOURCE(ts2); dl_list_init(&ts3.list); event_loop_add_source(el, (event_source)&ts2); event_loop_add_source(el, (event_source)&ts1); event_loop_add_source(el, (event_source)&ts3); ck_assert_int_eq(el->list.prev, &ts3.list); ck_assert_int_eq(el->list.prev->prev, &ts1.list); ck_assert_int_eq(el->list.prev->prev->prev, &ts2.list); ck_assert_int_eq(el->list.prev->prev->prev->prev, &el->list); ck_assert_int_eq(el->list.next, &ts2.list); ck_assert_int_eq(el->list.next->next, &ts1.list); ck_assert_int_eq(el->list.next->next->next, &ts3.list); ck_assert_int_eq(el->list.next->next->next->next, &el->list); event_loop_del_source(el, (event_source)&ts1); ck_assert_int_eq(el->list.prev, &ts3.list); ck_assert_int_eq(el->list.prev->prev, &ts2.list); ck_assert_int_eq(el->list.prev->prev->prev, &el->list); ck_assert_int_eq(el->list.next, &ts2.list); ck_assert_int_eq(el->list.next->next, &ts3.list); ck_assert_int_eq(el->list.next->next->next, &el->list); event_loop_del_source(el, dl_list_entry(el->list.next, struct event_source, list)); ck_assert_int_eq(el->list.prev, &ts3.list); ck_assert_int_eq(el->list.prev->prev, &el->list); ck_assert_int_eq(el->list.next, &ts3.list); ck_assert_int_eq(el->list.next->next, &el->list); dl_list_del(&ts3.list); ck_assert_int_eq(el->list.prev, &el->list); ck_assert_int_eq(el->list.next, &el->list); ck_assert_int_eq(ts1.list.next, &ts1.list); ck_assert_int_eq(ts1.list.prev, &ts1.list); ck_assert_int_eq(ts2.list.next, &ts2.list); ck_assert_int_eq(ts2.list.prev, &ts2.list); ck_assert_int_eq(ts3.list.next, &ts3.list); ck_assert_int_eq(ts3.list.prev, &ts3.list); } END_TEST
struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid) { struct wlantest_bss *bss; if (bssid[0] & 0x01) return NULL; /* Skip group addressed frames */ bss = bss_find(wt, bssid); if (bss) return bss; bss = os_zalloc(sizeof(*bss)); if (bss == NULL) return NULL; dl_list_init(&bss->sta); dl_list_init(&bss->pmk); dl_list_init(&bss->tdls); os_memcpy(bss->bssid, bssid, ETH_ALEN); dl_list_add(&wt->bss, &bss->list); wpa_printf(MSG_DEBUG, "Discovered new BSS - " MACSTR, MAC2STR(bss->bssid)); return bss; }
/** * event_add - Add a new event to a queue * @s: Subscription * @data: Event data (is copied; caller retains ownership) * @probereq: Whether this is a Probe Request event * Returns: 0 on success, -1 on error, 1 on max event queue limit reached */ int event_add(struct subscription *s, const struct wpabuf *data, int probereq) { struct wps_event_ *e; unsigned int len; len = dl_list_len(&s->event_queue); if (len >= MAX_EVENTS_QUEUED) { wpa_printf(MSG_DEBUG, "WPS UPnP: Too many events queued for " "subscriber %p", s); if (probereq) return 1; /* Drop oldest entry to allow EAP event to be stored. */ e = event_dequeue(s); if (!e) return 1; event_delete(e); } if (s->last_event_failed && probereq && len > 0) { /* * Avoid queuing frames for subscribers that may have left * without unsubscribing. */ wpa_printf(MSG_DEBUG, "WPS UPnP: Do not queue more Probe " "Request frames for subscription %p since last " "delivery failed", s); return -1; } e = os_zalloc(sizeof(*e)); if (e == NULL) return -1; dl_list_init(&e->list); e->s = s; e->data = wpabuf_dup(data); if (e->data == NULL) { os_free(e); return -1; } e->subscriber_sequence = s->next_subscriber_sequence++; if (s->next_subscriber_sequence == 0) s->next_subscriber_sequence++; wpa_printf(MSG_DEBUG, "WPS UPnP: Queue event %p for subscriber %p " "(queue len %u)", e, s, len + 1); dl_list_add_tail(&s->event_queue, &e->list); event_send_all_later(s->sm); return 0; }
static struct tls_netconn *net_alloc_socket(struct tls_netconn *conn) { int sock=-1, i=0, j=0; u32 cpu_sr; struct tls_netconn * conn_t = NULL; for (i = 0; i < TLS_MAX_NETCONN_NUM; i++) { if(p_net_conn[i] == NULL) { sock = i; break; } } if (i == TLS_MAX_NETCONN_NUM){ return NULL; } if(conn != NULL) { j = dl_list_len(&conn->list); if(j>=4) { sock = -1; } } if(sock < 0) return NULL; cpu_sr = tls_os_set_critical(); conn_t = tls_mem_alloc(sizeof(struct tls_netconn)); tls_os_release_critical(cpu_sr); if (NULL != conn_t) { p_net_conn[sock] = conn_t; memset(conn_t, 0, sizeof(struct tls_netconn)); conn_t->used = true; conn_t->state = NETCONN_STATE_NONE; conn_t->skt_num = sock + 1;//TLS_MAX_NETCONN_NUM + dl_list_init(&conn_t->list); if (sys_sem_new(&conn_t->op_completed, 0) != ERR_OK) { net_free_socket(conn_t); } } TLS_DBGPRT_INFO("net_alloc_socket conn ptr = 0x%x\n", conn_t); return conn_t; // return NULL; }
/*************************************************************************** * Function: Tcpip_stack_init * * Description: This function is init ip stack. * * Input: * ipaddr: * netmask: * gateway: * Output: * * Return: * netif: Init IP Stack OK * NULL : Init IP Statck Fail Because no memory * Date : 2014-6-4 ****************************************************************************/ struct netif *Tcpip_stack_init() { #if TLS_CONFIG_APSTA struct netif *nif4apsta = NULL; #endif /*Register Ethernet Rx Data callback From wifi*/ tls_ethernet_data_rx_callback(ethernetif_input); #if TLS_CONFIG_APSTA tls_ethernet_ip_rx_callback(alg_input); #endif /* Setup lwIP. */ tcpip_init(NULL, NULL); #if TLS_CONFIG_APSTA /* add net info for apsta's ap */ nif4apsta = (struct netif *)tls_mem_alloc(sizeof(struct netif)); if (nif4apsta == NULL) return NULL; #endif /*Add Net Info to Netif, default */ nif = (struct netif *)tls_mem_alloc(sizeof(struct netif)); if (nif == NULL) { #if TLS_CONFIG_APSTA tls_mem_free(nif4apsta); #endif return NULL; } #if TLS_CONFIG_APSTA memset(nif4apsta, 0, sizeof(struct netif)); nif->next = nif4apsta; netifapi_netif_add(nif4apsta, IPADDR_ANY, IPADDR_ANY, IPADDR_ANY, NULL, ethernetif_init, tcpip_input); netif_set_status_callback(nif4apsta, netif_status_changed); #endif memset(nif, 0, sizeof(struct netif)); netifapi_netif_add(nif, IPADDR_ANY,IPADDR_ANY,IPADDR_ANY,NULL,ethernetif_init,tcpip_input); netifapi_netif_set_default(nif); dl_list_init(&netif_status_event.list); netif_set_status_callback(nif, netif_status_changed); tls_wifi_status_change_cb_register(wifi_status_changed); return nif; }
static void wlantest_init(struct wlantest *wt) { int i; os_memset(wt, 0, sizeof(*wt)); wt->monitor_sock = -1; wt->ctrl_sock = -1; for (i = 0; i < MAX_CTRL_CONNECTIONS; i++) wt->ctrl_socks[i] = -1; dl_list_init(&wt->passphrase); dl_list_init(&wt->bss); dl_list_init(&wt->secret); dl_list_init(&wt->radius); dl_list_init(&wt->pmk); dl_list_init(&wt->ptk); dl_list_init(&wt->wep); }
int os_program_init(void) { #ifndef QCA_ICS_PORTING //+-FLUG #ifdef ANDROID /* * We ignore errors here since errors are normal if we * are already running as non-root. */ gid_t groups[] = { AID_INET, AID_WIFI, AID_KEYSTORE }; struct __user_cap_header_struct header; struct __user_cap_data_struct cap; setgroups(sizeof(groups)/sizeof(groups[0]), groups); prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0); setgid(AID_WIFI); setuid(AID_WIFI); header.version = _LINUX_CAPABILITY_VERSION; header.pid = 0; cap.effective = cap.permitted = (1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW); cap.inheritable = 0; capset(&header, &cap); #endif /* ANDROID */ #endif /* QCA_ICS_PORTING */ //+-FLUG #ifdef WPA_TRACE dl_list_init(&alloc_list); #endif /* WPA_TRACE */ #ifdef NO_JOBCTRL /* * If SHELL doesn't support job-control. Changing another PGID to aviod to * terminate the program accidnetly. */ if (getpid() != getpgrp()) { setpgid(0, 0); //printf("Change to another PGID %d \n", getpgrp()); } #endif return 0; }
static void acs_cleanup(struct hostapd_iface *iface) { int i; struct hostapd_channel_data *chan; for (i = 0; i < iface->current_mode->num_channels; i++) { chan = &iface->current_mode->channels[i]; if (chan->flag & HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED) acs_clean_chan_surveys(chan); dl_list_init(&chan->survey_list); chan->flag |= HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED; chan->min_nf = 0; } iface->chans_surveyed = 0; iface->acs_num_completed_scans = 0; }
int eloop_init(void) { os_memset(&eloop, 0, sizeof(eloop)); dl_list_init(&eloop.timeout); #ifdef CONFIG_ELOOP_EPOLL eloop.epollfd = epoll_create1(0); if (eloop.epollfd < 0) { wpa_printf(MSG_ERROR, "%s: epoll_create1 failed. %s\n", __func__, strerror(errno)); return -1; } eloop.readers.type = EVENT_TYPE_READ; eloop.writers.type = EVENT_TYPE_WRITE; eloop.exceptions.type = EVENT_TYPE_EXCEPTION; #endif /* CONFIG_ELOOP_EPOLL */ #ifdef WPA_TRACE signal(SIGSEGV, eloop_sigsegv_handler); #endif /* WPA_TRACE */ return 0; }
void wps_er_ap_add(struct wps_er *er, const u8 *uuid, struct in_addr *addr, const char *location, int max_age) { struct wps_er_ap *ap; ap = wps_er_ap_get(er, addr, uuid); if (ap) { /* Update advertisement timeout */ eloop_cancel_timeout(wps_er_ap_timeout, er, ap); eloop_register_timeout(max_age, 0, wps_er_ap_timeout, er, ap); return; } ap = os_zalloc(sizeof(*ap)); if (ap == NULL) return; dl_list_init(&ap->sta); ap->er = er; ap->id = ++er->next_ap_id; ap->location = os_strdup(location); if (ap->location == NULL) { os_free(ap); return; } dl_list_add(&er->ap, &ap->list); ap->addr.s_addr = addr->s_addr; os_memcpy(ap->uuid, uuid, WPS_UUID_LEN); eloop_register_timeout(max_age, 0, wps_er_ap_timeout, er, ap); wpa_printf(MSG_DEBUG, "WPS ER: Added AP entry for %s (%s)", inet_ntoa(ap->addr), ap->location); /* Fetch device description */ ap->http = http_client_url(ap->location, NULL, 10000, wps_er_http_dev_desc_cb, ap); }
struct ctrl_iface_priv * wpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s) { struct ctrl_iface_priv *priv; priv = os_zalloc(sizeof(*priv)); if (priv == NULL) return NULL; dl_list_init(&priv->ctrl_dst); dl_list_init(&priv->msg_queue); priv->wpa_s = wpa_s; priv->sock = -1; if (wpa_s->conf->ctrl_interface == NULL) return priv; #ifdef ANDROID if (wpa_s->global->params.ctrl_interface) { int same = 0; if (wpa_s->global->params.ctrl_interface[0] == '/') { if (os_strcmp(wpa_s->global->params.ctrl_interface, wpa_s->conf->ctrl_interface) == 0) same = 1; } else if (os_strncmp(wpa_s->global->params.ctrl_interface, "@android:", 9) == 0 || os_strncmp(wpa_s->global->params.ctrl_interface, "@abstract:", 10) == 0) { char *pos; /* * Currently, Android uses @android:wpa_* as the naming * convention for the global ctrl interface. This logic * needs to be revisited if the above naming convention * is modified. */ pos = os_strchr(wpa_s->global->params.ctrl_interface, '_'); if (pos && os_strcmp(pos + 1, wpa_s->conf->ctrl_interface) == 0) same = 1; } if (same) { /* * The invalid configuration combination might be * possible to hit in an Android OTA upgrade case, so * instead of refusing to start the wpa_supplicant * process, do not open the per-interface ctrl_iface * and continue with the global control interface that * was set from the command line since the Wi-Fi * framework will use it for operations. */ wpa_printf(MSG_ERROR, "global ctrl interface %s matches ctrl interface %s - do not open per-interface ctrl interface", wpa_s->global->params.ctrl_interface, wpa_s->conf->ctrl_interface); return priv; } } #endif /* ANDROID */ if (wpas_ctrl_iface_open_sock(wpa_s, priv) < 0) { os_free(priv); return NULL; } return priv; }
struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname, const char *filter) { struct wps_er *er; struct in_addr addr; er = os_zalloc(sizeof(*er)); if (er == NULL) return NULL; dl_list_init(&er->ap); dl_list_init(&er->ap_unsubscribing); dl_list_init(&er->ap_settings); er->multicast_sd = -1; er->ssdp_sd = -1; os_strlcpy(er->ifname, ifname, sizeof(er->ifname)); er->wps = wps; if (os_get_random((unsigned char *) &er->event_id, sizeof(er->event_id)) < 0) { wps_er_deinit(er, NULL, NULL); return NULL; } /* Limit event_id to < 32 bits to avoid issues with atoi() */ er->event_id &= 0x0fffffff; if (filter) { if (inet_aton(filter, &er->filter_addr) == 0) { wpa_printf(MSG_INFO, "WPS UPnP: Invalid filter " "address %s", filter); wps_er_deinit(er, NULL, NULL); return NULL; } wpa_printf(MSG_DEBUG, "WPS UPnP: Only accepting connections " "with %s", filter); } if (get_netif_info(ifname, &er->ip_addr, &er->ip_addr_text, er->mac_addr)) { wpa_printf(MSG_INFO, "WPS UPnP: Could not get IP/MAC address " "for %s. Does it have IP address?", ifname); wps_er_deinit(er, NULL, NULL); return NULL; } if (wps_er_ssdp_init(er) < 0) { wpa_printf(MSG_INFO, "WPS UPnP: SSDP initialization failed"); wps_er_deinit(er, NULL, NULL); return NULL; } addr.s_addr = er->ip_addr; er->http_srv = http_server_init(&addr, -1, wps_er_http_req, er); if (er->http_srv == NULL) { wpa_printf(MSG_INFO, "WPS UPnP: HTTP initialization failed"); wps_er_deinit(er, NULL, NULL); return NULL; } er->http_port = http_server_get_port(er->http_srv); wpa_printf(MSG_DEBUG, "WPS ER: Start (ifname=%s ip_addr=%s)", er->ifname, er->ip_addr_text); return er; }
static struct wpa_ssid * wpa_config_read_network(HKEY hk, const TCHAR *netw, int id) { HKEY nhk; LONG ret; DWORD i; struct wpa_ssid *ssid; int errors = 0; ret = RegOpenKeyEx(hk, netw, 0, KEY_QUERY_VALUE, &nhk); if (ret != ERROR_SUCCESS) { wpa_printf(MSG_DEBUG, "Could not open wpa_supplicant config " "network '" TSTR "'", netw); return NULL; } wpa_printf(MSG_MSGDUMP, "Start of a new network '" TSTR "'", netw); ssid = os_zalloc(sizeof(*ssid)); if (ssid == NULL) { RegCloseKey(nhk); return NULL; } dl_list_init(&ssid->psk_list); ssid->id = id; wpa_config_set_network_defaults(ssid); for (i = 0; ; i++) { TCHAR name[255], data[1024]; DWORD namelen, datalen, type; namelen = 255; datalen = sizeof(data); ret = RegEnumValue(nhk, i, name, &namelen, NULL, &type, (LPBYTE) data, &datalen); if (ret == ERROR_NO_MORE_ITEMS) break; if (ret != ERROR_SUCCESS) { wpa_printf(MSG_ERROR, "RegEnumValue failed: 0x%x", (unsigned int) ret); break; } if (namelen >= 255) namelen = 255 - 1; name[namelen] = TEXT('\0'); if (datalen >= 1024) datalen = 1024 - 1; data[datalen] = TEXT('\0'); wpa_unicode2ascii_inplace(name); wpa_unicode2ascii_inplace(data); if (wpa_config_set(ssid, (char *) name, (char *) data, 0) < 0) errors++; } RegCloseKey(nhk); if (ssid->passphrase) { if (ssid->psk_set) { wpa_printf(MSG_ERROR, "Both PSK and passphrase " "configured for network '" TSTR "'.", netw); errors++; } wpa_config_update_psk(ssid); } if ((ssid->group_cipher & WPA_CIPHER_CCMP) && !(ssid->pairwise_cipher & WPA_CIPHER_CCMP) && !(ssid->pairwise_cipher & WPA_CIPHER_NONE)) { /* Group cipher cannot be stronger than the pairwise cipher. */ wpa_printf(MSG_DEBUG, "Removed CCMP from group cipher " "list since it was not allowed for pairwise " "cipher for network '" TSTR "'.", netw); ssid->group_cipher &= ~WPA_CIPHER_CCMP; } if (errors) { wpa_config_free_ssid(ssid); ssid = NULL; } return ssid; }
void hs20_init(struct wpa_supplicant *wpa_s) { dl_list_init(&wpa_s->icon_head); }