blob: f70100e1ee90c3f85626d1acc29f33e44c2fd2b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
* libdect public API functions
*
* Copyright (c) 2009-2010 Patrick McHardy <kaber@trash.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/**
* @defgroup init Initialization
* @{
*/
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <libdect.h>
#include <netlink.h>
#include <utils.h>
#include <lce.h>
struct dect_handle *dect_alloc_handle(struct dect_ops *ops)
{
struct dect_handle *dh;
if (ops->malloc == NULL)
ops->malloc = malloc;
if (ops->free == NULL)
ops->free = free;
dh = ops->malloc(sizeof(*dh));
if (dh == NULL)
return NULL;
memset(dh, 0, sizeof(*dh));
dh->ops = ops;
init_list_head(&dh->links);
init_list_head(&dh->mme_list);
return dh;
}
EXPORT_SYMBOL(dect_alloc_handle);
int dect_init(struct dect_handle *dh, const char *cluster)
{
int err;
if (cluster == NULL)
cluster = "cluster0";
srand(time(NULL));
err = dect_netlink_init(dh, cluster);
if (err < 0)
goto err1;
err = dect_lce_init(dh);
if (err < 0)
goto err2;
return 0;
err2:
dect_netlink_exit(dh);
err1:
return err;
}
EXPORT_SYMBOL(dect_init);
void dect_close_handle(struct dect_handle *dh)
{
dect_lce_exit(dh);
dect_netlink_exit(dh);
dect_free(dh, dh);
}
EXPORT_SYMBOL(dect_close_handle);
/** @} */
|