blob: 3ef745eeba0a34a0abc9f6df3beb6b66f4b2aec8 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/**
* @file baresip.c Top-level baresip struct
*
* Copyright (C) 2010 - 2016 Creytiv.com
*/
#include <re.h>
#include <baresip.h>
#include "core.h"
/*
* Top-level struct that holds all other subsystems
* (move this instance to main.c later)
*/
static struct baresip {
struct network *net;
struct contacts contacts;
struct commands commands;
struct player *player;
struct list mnatl;
struct list mencl;
} baresip;
int baresip_init(struct config *cfg, bool prefer_ipv6)
{
int err;
if (!cfg)
return EINVAL;
baresip.net = mem_deref(baresip.net);
list_init(&baresip.mnatl);
list_init(&baresip.mencl);
/* Initialise Network */
err = net_alloc(&baresip.net, &cfg->net,
prefer_ipv6 ? AF_INET6 : AF_INET);
if (err) {
warning("ua: network init failed: %m\n", err);
return err;
}
err = contact_init(&baresip.contacts);
if (err)
return err;
err = cmd_init(&baresip.commands);
if (err)
return err;
err = play_init(&baresip.player);
if (err)
return err;
return 0;
}
void baresip_close(void)
{
baresip.player = mem_deref(baresip.player);
cmd_close(&baresip.commands);
contact_close(&baresip.contacts);
baresip.net = mem_deref(baresip.net);
}
struct network *baresip_network(void)
{
return baresip.net;
}
struct contacts *baresip_contacts(void)
{
return &baresip.contacts;
}
struct commands *baresip_commands(void)
{
return &baresip.commands;
}
struct player *baresip_player(void)
{
return baresip.player;
}
struct list *baresip_mnatl(void)
{
return &baresip.mnatl;
}
struct list *baresip_mencl(void)
{
return &baresip.mencl;
}
|