18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/*
28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Driver interface for RADIUS server or WPS ER only (no driver)
38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2008, Atheros Communications
48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * This software may be distributed under the terms of the BSD license.
6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * See README for more details.
78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "includes.h"
108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "common.h"
128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "driver.h"
138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstruct none_driver_data {
168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct hostapd_data *hapd;
178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	void *ctx;
188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void * none_driver_hapd_init(struct hostapd_data *hapd,
228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				    struct wpa_init_params *params)
238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct none_driver_data *drv;
258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	drv = os_zalloc(sizeof(struct none_driver_data));
278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (drv == NULL) {
288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Could not allocate memory for none "
298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "driver data");
308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return NULL;
318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	drv->hapd = hapd;
338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return drv;
358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void none_driver_hapd_deinit(void *priv)
398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct none_driver_data *drv = priv;
418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_free(drv);
438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic int none_driver_send_ether(void *priv, const u8 *dst, const u8 *src,
478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt				  u16 proto, const u8 *data, size_t data_len)
488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void * none_driver_init(void *ctx, const char *ifname)
548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct none_driver_data *drv;
568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	drv = os_zalloc(sizeof(struct none_driver_data));
588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (drv == NULL) {
598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Could not allocate memory for none "
608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "driver data");
618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return NULL;
628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	drv->ctx = ctx;
648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return drv;
668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtstatic void none_driver_deinit(void *priv)
708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct none_driver_data *drv = priv;
728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_free(drv);
748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtconst struct wpa_driver_ops wpa_driver_none_ops = {
788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.name = "none",
798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.desc = "no driver (RADIUS server/WPS ER)",
808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.hapd_init = none_driver_hapd_init,
818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.hapd_deinit = none_driver_hapd_deinit,
828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.send_ether = none_driver_send_ether,
838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.init = none_driver_init,
848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	.deinit = none_driver_deinit,
858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt};
86