]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/hostapd/driver_test.c
This commit was generated by cvs2svn to compensate for changes in r155429,
[FreeBSD/FreeBSD.git] / contrib / hostapd / driver_test.c
1 /*
2  * Host AP (software wireless LAN access point) user space daemon for
3  * Host AP kernel driver / Driver interface for development testing
4  * Copyright (c) 2004, Jouni Malinen <jkmaline@cc.hut.fi>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include <unistd.h>
20 #include <errno.h>
21 #include <sys/ioctl.h>
22 #include <netinet/in.h>
23 #include <signal.h>
24 #include <sys/types.h>
25 #include <sys/socket.h>
26
27 #include "hostapd.h"
28 #include "driver.h"
29
30
31 struct test_driver_data {
32         struct driver_ops ops;
33         struct hostapd_data *hapd;
34 };
35
36 static const struct driver_ops test_driver_ops;
37
38
39 static int test_driver_init(struct hostapd_data *hapd)
40 {
41         struct test_driver_data *drv;
42
43         drv = malloc(sizeof(struct test_driver_data));
44         if (drv == NULL) {
45                 printf("Could not allocate memory for test driver data\n");
46                 return -1;
47         }
48
49         memset(drv, 0, sizeof(*drv));
50         drv->ops = test_driver_ops;
51         drv->hapd = hapd;
52
53         hapd->driver = &drv->ops;
54         return 0;
55 }
56
57
58 static void test_driver_deinit(void *priv)
59 {
60         struct test_driver_data *drv = priv;
61
62         drv->hapd->driver = NULL;
63
64         free(drv);
65 }
66
67
68 static const struct driver_ops test_driver_ops = {
69         .name = "test",
70         .init = test_driver_init,
71         .deinit = test_driver_deinit,
72 };
73
74
75 void test_driver_register(void)
76 {
77         driver_register(test_driver_ops.name, &test_driver_ops);
78 }