1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
30 #ifndef _SIPWITCH_SERVICE_H_
31 #define _SIPWITCH_SERVICE_H_
32
33 #ifndef _UCOMMON_LINKED_H_
34 #include <ucommon/linked.h>
35 #endif
36
37 #ifndef _UCOMMON_THREAD_H_
38 #include <ucommon/thread.h>
39 #endif
40
41 #ifndef _UCOMMON_STRING_H_
42 #include <ucommon/string.h>
43 #endif
44
45 #ifndef _UCOMMON_FSYS_H_
46 #include <ucommon/fsys.h>
47 #endif
48
49 #ifndef _SIPWITCH_NAMESPACE_H_
51 #endif
52
53 #ifndef _SIPWITCH_MAPPED_H_
55 #endif
56
57 #ifndef _SIPWITCH_CONTROL_H_
59 #endif
60
61 #ifndef _SIPWITCH_CDR_H_
63 #endif
64
65 #define CONFIG_KEY_SIZE 177
66
67 namespace sipwitch {
68
79 {
80 public:
85
90
98
106 {
107 public:
109
111 {Id = (char *)tag;}
112 };
113
120 {
121 public:
125 };
126
131 {
132 private:
134
135 public:
140
141 inline operator bool()
const
142 {return node != NULL;}
143
145 {return node == NULL;}
146
148
150 {return node;}
151
153 {return node;}
154 };
155
160 {
161 public:
164
167 };
168
176 {
177 protected:
182
185
206 static char session_uuid[40];
207
208 callback(
int level = 0);
// default is priority
210
212 {return cfgp->alloc(size);}
213
215 {return cfgp->dup(s);}
216
219
221 {return active_flag;}
222
223 virtual void cdrlog(
cdr *call);
224 virtual void errlog(shell::loglevel_t level, const char *text);
225 virtual bool check(void);
226 virtual void snapshot(FILE *fp);
227 virtual void start(
service *cfg);
228 virtual void stop(
service *cfg);
229 virtual void reload(
service *cfg);
230 virtual void publish(
service *cfg);
231
232 public:
237
238 inline static void bind(
unsigned short port)
239 {sip_port = port;}
240
242 {sip_public = true;}
243
244 static void bind(const char *addr);
245
247 };
248
251
253
261 bool load(FILE *file,
keynode *node = NULL);
262
263 keynode *getPath(
const char *path);
268 keynode *getList(
const char *path);
269
272
275
281 static void publish(const char *addr);
282
283 static void published(struct sockaddr_storage *peer);
284 static const char *getValue(keynode *base, const char *id);
285 static void dump(FILE *fp, keynode *node, unsigned level);
286 static void snapshot(void);
287 static void dumpfile(void);
288 static bool period(long slice);
289 static void result(
const char *
value);
290 static void startup(void);
291 static void shutdown(void);
292 static long uptime(void);
293 static bool match(const char *digits, const char *pattern, bool partial);
294 static keynode *get(void);
295
296 static keynode *getProtected(const char *path);
297 static keynode *getUser(const char *uid);
298 static keynode *path(const char *p);
299 static keynode *list(const char *p);
300
302 {return getProtected("environ");}
303
305 {return &root;}
306
307 static string_t getContact(void);
308
310 {contact = dup(text);}
311
314
317
318 virtual void dump(FILE *fp);
319 virtual void confirm(void);
320 void commit(void);
321
322 static bool check(void);
323 static void release(keynode *node);
324
325 protected:
327
332 {
333 public:
336 };
337
342
345
351 void addAttributes(
keynode *node,
char *attrib);
352 };
353
354 #define RUNLEVELS (sizeof(callback::runlevels) / sizeof(LinkedObject *))
355 #define PRIORITY_RUNLEVEL 0
356 #define DEFAULT_RUNLEVEL 1
357 #define MODULE_RUNLEVEL (RUNLEVELS - 1)
358 #define GENERIC_RUNLEVEL (RUNLEVELS - 2)
359
360 } // namespace sipwitch
361
362 #endif
Some convenience methods for manipulating SIP uri's.
static volatile char * sip_publish
static voip::context_t udp_context
static volatile char * sip_contact
Pointer to a provisioned user xml subtree.
static voip::context_t tls_context
static volatile dialmode_t dialmode
static const char * getInterface(void)
Event message and supporting methods for plugins.
bool is_active(void) const
Used to splice new chains onto an existing xml tree.
static unsigned sip_prefix
Linked list of named xml node locations.
static void bind(unsigned short port)
static LinkedObject * getModules(void)
static voip::context_t tcp_context
static const char * sip_iface
Keyword and value pair definition lists.
Definitions for memory mapped objects that may be shared between processes.
void setContact(const char *text)
static LinkedObject * runlevels[4]
Basic server call detail record.
static const char * sip_realm
static void * alloc(service *cfgp, size_t size)
GNU SIP Witch library namespace.
static condlock_t locking
static keynode * getEnviron(void)
void reset(const char *tag)
Callback methods for objects managed under the service thread.
static LinkedObject * getGenerics(void)
static void setPublic(void)
static bool is_configured(void)
static unsigned short getPort(void)
static const char * sip_tlskey
static const char * sip_domain
static const char * sip_tlsdh
static const char * sip_tlsca
A pointer to a subtree in the xml configuration tree.
static char * dup(service *cfgp, const char *s)
static voip::context_t out_context
dialmode_t
Dialing mode supported.
static const char * sip_tlsdev
static const char * sip_tlscert
System configuration instance and service functions.
Manage control interface.
keynode * operator*() const
static unsigned short sip_port
const service * operator->() const
The current singleton instance of the active xml configuration tree.
Interface class for call detail records.
Common interfaces and clases for plugins.
static unsigned sip_range
static const char * sip_tlspwd
treemap< char * > keynode
Definition of a xml node.
keynode * operator->() const