SIP Witch 1.9.15: modules.cpp Source File

SIP Witch 1.9.15
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 
30  modules::sipwitch::sipwitch() :
31 service::callback(MODULE_RUNLEVEL)
32 {
33 }
34 
35  modules::generic::generic() :
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 
45  void modules::sipwitch::activating(MappedRegistry *rr)
46 {
47 }
48 
49  void modules::sipwitch::expiring(MappedRegistry *rr)
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 
62  void modules::sipwitch::registration(voip::reg_t id, regmode_t mode)
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 
modules.h
Used for definitions of plugin modules.
sipwitch::uri
Some convenience methods for manipulating SIP uri's.
Definition: uri.h:55
GENERIC_RUNLEVEL
#define GENERIC_RUNLEVEL
Definition: service.h:358
sipwitch::modules::sipwitch::announce
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
sipwitch::modules::sipwitch::expiring
virtual void expiring(MappedRegistry *user)
Notify plugins a user registration has been expired or released.
Definition: modules.cpp:49
sipwitch::modules::cdrlog
static void cdrlog(FILE *file, cdr *call)
Post cdr record to a file.
Definition: modules.cpp:91
sipwitch::MappedRegistry
Representation of a mapped active user record.
Definition: mapped.h:95
sipwitch::cdr::cid
unsigned cid
Internal call sequence identifiers.
Definition: cdr.h:102
sipwitch::modules::sipwitch::registration
virtual void registration(voip::reg_t id, regmode_t reg)
Notify plugins about reply messages from external registrations.
Definition: modules.cpp:62
sipwitch::cdr::type
enum sipwitch::cdr::@0 type
Start or end of call?
sipwitch::cdr::starting
time_t starting
Time the call was received.
Definition: cdr.h:107
sipwitch::modules::sipwitch::referLocal
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
sipwitch::service::getModules
static LinkedObject * getModules(void)
Definition: service.h:270
sipwitch::modules::generic::generic
generic()
Construct a generic service instance.
Definition: modules.cpp:35
sipwitch::cdr::reason
char reason[16]
Reason the call was terminated.
Definition: cdr.h:97
sipwitch::modules::sipwitch::sipwitch
sipwitch()
Create a service instance and add to runtime list of services to start and stop.
Definition: modules.cpp:30
MODULE_RUNLEVEL
#define MODULE_RUNLEVEL
Definition: service.h:357
sipwitch::modules::errlog
static void errlog(shell::loglevel_t level, const char *text)
Module access to error logging system.
Definition: modules.cpp:81
sipwitch::cdr::joined
char joined[MAX_IDENT_SIZE]
Call destination eventually joined to.
Definition: cdr.h:82
sipwitch::cdr::dialed
char dialed[MAX_IDENT_SIZE]
Destination requested on our switch.
Definition: cdr.h:77
sipwitch::modules::sipwitch::period
virtual void period(long slice)
Period service request.
Definition: modules.cpp:53
sipwitch::cdr::display
char display[MAX_DISPLAY_SIZE]
Display name of calling party.
Definition: cdr.h:87
sipwitch::cdr::ident
char ident[MAX_IDENT_SIZE]
Ident of calling parting.
Definition: cdr.h:72
sipwitch::cdr::sequence
unsigned sequence
Definition: cdr.h:102
sipwitch::voip::reg_t
int reg_t
Definition: voip.h:59
sipwitch::service
System configuration instance and service functions.
Definition: service.h:78
control.h
Manage control interface.
sipwitch::modules::generic::resolve
virtual srv::address * resolve(const char *uri, struct addrinfo *hints)
New srv resolver plugin.
Definition: modules.cpp:40
sipwitch::cdr
Interface class for call detail records.
Definition: cdr.h:56
sipwitch::modules::sipwitch::activating
virtual void activating(MappedRegistry *user)
Notify plugins a user registration is being activated.
Definition: modules.cpp:45
sipwitch::cdr::duration
unsigned long duration
Total duration of the call in seconds.
Definition: cdr.h:112
sipwitch::modules::sipwitch::authenticate
virtual bool authenticate(voip::reg_t id, const char *realm)
Used to verify authentication of a registered session.
Definition: modules.cpp:66
sipwitch::modules::sipwitch::referRemote
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
sipwitch::cdr::network
char network[MAX_NETWORK_SIZE *2]
Subnet interface the caller appeared on.
Definition: cdr.h:92

Generated on Dec 21, 2017 for sipwitch-1.9.15 (*.h and *.cpp), libosip2-5.0.0 (*.h) and libeXosip2-4.0.0 (*.h), by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /