Ejemplo n.º 1
0
static int hostap_set_ieee8021x(void *priv, struct wpa_bss_params *params)
{
	struct hostap_driver_data *drv = priv;
	int enabled = params->enabled;

	/* enable kernel driver support for IEEE 802.1X */
	if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_IEEE_802_1X, enabled)) {
		printf("Could not setup IEEE 802.1X support in kernel driver."
		       "\n");
		return -1;
	}

	if (!enabled)
		return 0;

	/* use host driver implementation of encryption to allow
	 * individual keys and passing plaintext EAPOL frames */
	if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_DECRYPT, 1) ||
	    hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_ENCRYPT, 1)) {
		printf("Could not setup host-based encryption in kernel "
		       "driver.\n");
		return -1;
	}

	return 0;
}
Ejemplo n.º 2
0
static int hostap_set_privacy(void *priv, int enabled)
{
	struct hostap_drvier_data *drv = priv;

	return hostap_ioctl_prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED,
					enabled);
}
Ejemplo n.º 3
0
static void * hostap_init(struct hostapd_data *hapd)
{
    struct hostap_driver_data *drv;

    drv = os_zalloc(sizeof(struct hostap_driver_data));
    if (drv == NULL) {
        printf("Could not allocate memory for hostapd driver data\n");
        return NULL;
    }

    drv->hapd = hapd;
    drv->ioctl_sock = drv->sock = -1;
    memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));

    drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
    if (drv->ioctl_sock < 0) {
        perror("socket[PF_INET,SOCK_DGRAM]");
        free(drv);
        return NULL;
    }

    if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) {
        printf("Could not enable hostapd mode for interface %s\n",
               drv->iface);
        close(drv->ioctl_sock);
        free(drv);
        return NULL;
    }

    if (hapd->conf->assoc_ap &&
            hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 1)) {
        printf("Could not enable hostapd STA mode for interface %s\n",
               drv->iface);
        close(drv->ioctl_sock);
        free(drv);
        return NULL;
    }

    if (hostap_init_sockets(drv)) {
        close(drv->ioctl_sock);
        free(drv);
        return NULL;
    }

    return drv;
}
Ejemplo n.º 4
0
static void hostap_driver_deinit(void *priv)
{
    struct hostap_driver_data *drv = priv;

    (void) hostap_set_iface_flags(drv, 0);
    (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0);
    (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0);

    if (drv->ioctl_sock >= 0)
        close(drv->ioctl_sock);

    if (drv->sock >= 0)
        close(drv->sock);

    os_free(drv->generic_ie);

    free(drv);
}
Ejemplo n.º 5
0
static void * hostap_init(struct hostapd_data *hapd,
			  struct wpa_init_params *params)
{
	struct hostap_driver_data *drv;

	drv = os_zalloc(sizeof(struct hostap_driver_data));
	if (drv == NULL) {
		printf("Could not allocate memory for hostapd driver data\n");
		return NULL;
	}

	drv->hapd = hapd;
	drv->ioctl_sock = drv->sock = -1;
	memcpy(drv->iface, params->ifname, sizeof(drv->iface));

	drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
	if (drv->ioctl_sock < 0) {
		wpa_printf(MSG_ERROR, "socket[PF_INET,SOCK_DGRAM]: %s",
			   strerror(errno));
		os_free(drv);
		return NULL;
	}

	if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 1)) {
		wpa_printf(MSG_ERROR,
			   "Could not enable hostapd mode for interface %s",
			   drv->iface);
		close(drv->ioctl_sock);
		os_free(drv);
		return NULL;
	}

	if (hostap_init_sockets(drv, params->own_addr) ||
	    hostap_wireless_event_init(drv)) {
		close(drv->ioctl_sock);
		os_free(drv);
		return NULL;
	}

	return drv;
}