SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
modules.cpp
Go to the documentation of this file.
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 
17 #include <sipwitch-config.h>
18 #include <ucommon/ucommon.h>
19 #include <ucommon/export.h>
20 #include <sipwitch/modules.h>
21 #include <sipwitch/control.h>
22 #include <ctype.h>
23 #include <errno.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 namespace sipwitch {
29 
31 service::callback(MODULE_RUNLEVEL)
32 {
33 }
34 
36 service::callback(GENERIC_RUNLEVEL)
37 {
38 }
39 
40 srv::address *modules::generic::resolve(const char *uri, struct addrinfo *hints)
41 {
42  return NULL;
43 }
44 
46 {
47 }
48 
50 {
51 }
52 
53 void modules::sipwitch::period(long slice)
54 {
55 }
56 
57 bool modules::sipwitch::announce(MappedRegistry *rr, const char *msgtype, const char *event, const char *expires, const char *msgbody)
58 {
59  return false;
60 }
61 
63 {
64 }
65 
66 bool modules::sipwitch::authenticate(voip::reg_t id, const char *realm)
67 {
68  return false;
69 }
70 
71 char *modules::sipwitch::referLocal(MappedRegistry *rr, const char *target, char *buffer, size_t size)
72 {
73  return NULL;
74 }
75 
76 char *modules::sipwitch::referRemote(MappedRegistry *rr, const char *target, char *buffer, size_t size)
77 {
78  return NULL;
79 }
80 
81 void modules::errlog(shell::loglevel_t level, const char *text)
82 {
83  linked_pointer<service::callback> cb = service::getModules();
84 
85  while(is(cb)) {
86  cb->errlog(level, text);
87  cb.next();
88  }
89 }
90 
91 void modules::cdrlog(FILE *fp, cdr *call)
92 {
93  DateTimeString dt(call->starting);
94  const char *buf = dt.c_str();
95 
96  if(call->type == cdr::STOP) {
97  shell::debug(1, "call %08x:%u %s %s %s %ld %s %s %s %s",
98  call->sequence, call->cid, call->network, call->reason, buf,
99  call->duration, call->ident, call->dialed, call->joined, call->display);
100  }
101 
102  linked_pointer<service::callback> cb = service::getModules();
103 
104  while(is(cb)) {
105  cb->cdrlog(call);
106  cb.next();
107  }
108 
109  if(!fp || call->type != cdr::STOP)
110  return;
111 
112  fprintf(fp, "%08x:%u %s %s %s %ld %s %s %s %s\n",
113  call->sequence, call->cid, call->network, call->reason, buf,
114  call->duration, call->ident, call->dialed, call->joined, call->display);
115 }
116 
117 } // end namespace
118 
Used for definitions of plugin modules.
Some convenience methods for manipulating SIP uri's.
Definition: uri.h:55
#define GENERIC_RUNLEVEL
Definition: service.h:358
virtual bool announce(MappedRegistry *user, const char *type, const char *event, const char *expires, const char *body)
Announce a SIP publish event from a registered user to plugins.
Definition: modules.cpp:57
virtual void expiring(MappedRegistry *user)
Notify plugins a user registration has been expired or released.
Definition: modules.cpp:49
static void cdrlog(FILE *file, cdr *call)
Post cdr record to a file.
Definition: modules.cpp:91
Representation of a mapped active user record.
Definition: mapped.h:95
unsigned cid
Internal call sequence identifiers.
Definition: cdr.h:102
virtual void registration(voip::reg_t id, regmode_t reg)
Notify plugins about reply messages from external registrations.
Definition: modules.cpp:62
enum sipwitch::cdr::@0 type
Start or end of call?
time_t starting
Time the call was received.
Definition: cdr.h:107
virtual char * referLocal(MappedRegistry *user, const char *target, char *buffer, size_t size)
Enables plugin to redirect locally dialed destination to new uri.
Definition: modules.cpp:71
static LinkedObject * getModules(void)
Definition: service.h:270
generic()
Construct a generic service instance.
Definition: modules.cpp:35
char reason[16]
Reason the call was terminated.
Definition: cdr.h:97
sipwitch()
Create a service instance and add to runtime list of services to start and stop.
Definition: modules.cpp:30
#define MODULE_RUNLEVEL
Definition: service.h:357
static void errlog(shell::loglevel_t level, const char *text)
Module access to error logging system.
Definition: modules.cpp:81
char joined[MAX_IDENT_SIZE]
Call destination eventually joined to.
Definition: cdr.h:82
char dialed[MAX_IDENT_SIZE]
Destination requested on our switch.
Definition: cdr.h:77
virtual void period(long slice)
Period service request.
Definition: modules.cpp:53
char display[MAX_DISPLAY_SIZE]
Display name of calling party.
Definition: cdr.h:87
char ident[MAX_IDENT_SIZE]
Ident of calling parting.
Definition: cdr.h:72
unsigned sequence
Definition: cdr.h:102
int reg_t
Definition: voip.h:59
System configuration instance and service functions.
Definition: service.h:78
Manage control interface.
virtual srv::address * resolve(const char *uri, struct addrinfo *hints)
New srv resolver plugin.
Definition: modules.cpp:40
Interface class for call detail records.
Definition: cdr.h:56
virtual void activating(MappedRegistry *user)
Notify plugins a user registration is being activated.
Definition: modules.cpp:45
unsigned long duration
Total duration of the call in seconds.
Definition: cdr.h:112
virtual bool authenticate(voip::reg_t id, const char *realm)
Used to verify authentication of a registered session.
Definition: modules.cpp:66
virtual char * referRemote(MappedRegistry *user, const char *target, char *buffer, size_t size)
Enables plugin to remap users dialing remote destinations.
Definition: modules.cpp:76
char network[MAX_NETWORK_SIZE *2]
Subnet interface the caller appeared on.
Definition: cdr.h:92