Bayonne2 / Common C++ 2 Framework
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bayonne.h
Go to the documentation of this file.
1 // Copyright (C) 2005 Open Source Telecom Corp.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // ccScript. If you copy code from other releases into a copy of GNU
28 // ccScript, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU ccScript, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
38 #ifndef CCXX_BAYONNE_H_
39 #define CCXX_BAYONNE_H_
40 
41 #ifndef CCXX_SCRIPT3_H_
42 #include <cc++/script3.h>
43 #endif
44 
45 #ifndef CCXX_CCAUDIO2_H_
46 #include <cc++/audio2.h>
47 #endif
48 
49 #ifndef CCXX_SOCKET_H_
50 #include <cc++/socket.h>
51 #endif
52 
53 #define BAYONNE_RELEASE 1 // release check sequence
54 #define NO_TIMESLOT 0xffff
55 #define MAX_DTMF 32
56 #define MAX_LIST 256
57 #define MAX_LIBINPUT 256
58 #define MAX_PATHNAME 256
59 #define MIN_AUDIOFEED (120 * 8) // 120 millisecond starting
60 #define MAX_AUDIOFEED (600 * 8) // 600 millisecond buffer
61 #define RPC_MAX_PARAMS 96
62 
63 #ifdef WIN32
64 #define PFD_INVALID INVALID_HANDLE_VALUE
65 #else
66 #define PFD_INVALID -1
67 #endif
68 
69 #if SCRIPT_RIPPLE_LEVEL < 2
70 #error "ccscript 3 0.8.0 or later required"
71 #endif
72 
73 #ifdef DEBUG
74 #define SLOG_DEBUG(x, ...) slog.debug(x, __VA_ARGS__)
75 #else
76 #define SLOG_DEBUG(x, ...)
77 #endif
78 
79 namespace ost {
80 
89 
97 {
98 private:
101  const char *id;
103 
104 protected:
105  unsigned long position, count;
107 
108  void cleanup();
109 
110  StreamingBuffer(const char *id, timeout_t size = 600, Rate rate = rate8khz);
111  virtual ~StreamingBuffer();
112 
113  virtual Linear putBuffer(timeout_t duration);
114  virtual void clearBuffer(timeout_t duration);
115 
116 public:
124  static StreamingBuffer *get(const char *id, Rate rate);
125 
131  virtual bool isActive(void);
132 
139  virtual unsigned long getPosition(timeout_t framing);
140 
148  virtual Linear getBuffer(unsigned long *mark, timeout_t duration);
149 };
150 
151 
160 {
161 public:
162  StaticKeydata(const char *path, Keydata::Define *defkeys = NULL, const char *homepath = NULL);
163 
164  inline const char *getString(const char *id)
165  {return getLast(id);};
166 
167  inline long getValue(const char *id)
168  {return getLong(id);};
169 
170  inline bool getBoolean(const char *id)
171  {return getBool(id);};
172 };
173 
184 {
185 private:
186  friend class __EXPORT BayonneConfig;
187  friend class __EXPORT ReconfigKeydata;
190  const char *keypath;
191  const char *homepath;
194  void loadConfig(void);
195 
196 protected:
197  virtual void updateConfig(Keydata *keydata);
198 
199 public:
200  DynamicKeydata(const char *keypath, Keydata::Define *def = NULL, const char *homepath = NULL);
201 
202  const char *getString(const char *key, char *buf, size_t size);
203  long getValue(const char *key);
204  bool isKey(const char *key);
205  bool getBoolean(const char *key);
206 
207  static void reload(void);
208 };
209 
219 {
220 protected:
221  // use only in updateConfig method...
222  const char *updatedString(const char *id);
223  long updatedValue(const char *id);
224  timeout_t updatedSecTimer(const char *id);
225  timeout_t updatedMsecTimer(const char *id);
226  bool updatedBoolean(const char *id);
227 
228 public:
229  inline const char *getInitial(const char *id)
230  {return StaticKeydata::getString(id);};
231  inline void setInitial(const char *id, const char *val)
232  {StaticKeydata::setValue(id, val);};
233 
234  ReconfigKeydata(const char *keypath, Keydata::Define *def = NULL);
235 
236  const char *getString(const char *key, char *buf, size_t size);
237  timeout_t getSecTimer(const char *key);
238  timeout_t getMsecTimer(const char *key);
239  long getValue(const char *key);
240  bool isKey(const char *key);
241  bool getBoolean(const char *key);
242 };
243 
251 class __EXPORT Bayonne : public Script
252 {
253 private:
254  static SOCKET trap_so4;
255  static unsigned trap_count4;
256  static struct sockaddr_in trap_addr4[8];
257 
258 #ifdef CCXX_IPV6
259  static SOCKET trap_so6;
260  static unsigned trap_count6;
261  static struct sockaddr_in6 trap_addr6[8];
262 #endif
263 
264 public:
265  static char dtmf_keymap[256];
266 
267  static void snmptrap(unsigned id, const char *descr = NULL);
268 
269 #ifdef WIN32
270  typedef WORD timeslot_t;
271  typedef DWORD rpcint_t;
272 #else
273  typedef uint16_t timeslot_t;
274  typedef int32_t rpcint_t;
275 #endif
277 
278 protected:
281  static char *status;
283  static unsigned ts_trk;
284  static unsigned ts_ext;
288  static std::ostream *logging;
289  static const char *path_prompts;
290  static const char *path_tmpfs;
291  static const char *path_tmp;
292  static unsigned idle_count;
293  static unsigned idle_limit;
294  static bool shutdown_flag;
295  static char sla[64];
296  static time_t start_time;
297  static time_t reload_time;
298 
299 public:
303  static unsigned compile_count;
304  static volatile bool image_loaded;
305 
307  static const char *init_voicelib;
308  static const char *trap_community;
310 
314  typedef enum
315  {
322  IF_POTS=IF_PSTN
323  } interface_t;
324 
328  typedef enum
329  {
330  NONE, /* idle */
331  INCOMING, /* inbound call */
332  OUTGOING, /* outbound call */
333  PICKUP, /* station pickup */
334  FORWARDED, /* inbound forwarded call */
335  RECALL, /* inbound hold recall */
336  DIRECT, /* node/endpoint direct */
337  RINGING, /* ringing incoming join */
338  VIRTUAL /* virtual channel driver */
339  } calltype_t;
340 
344  typedef enum
345  {
350  BR_NONE
351  } bridge_t;
352 
358  typedef enum
359  {
360  STATE_INITIAL = 0,
401 
402  STATE_SUSPEND = STATE_DOWN,
403  STATE_STANDBY = STATE_DOWN,
404  STATE_LIBEXEC = STATE_EXEC,
405  STATE_RINGING = STATE_RING,
406  STATE_RUNNING = STATE_STEP,
407  STATE_THREADING = STATE_THREAD
408  } state_t;
409 
414  typedef enum
415  {
416  SIGNAL_EXIT = 0,
420 
434  SIGNAL_OVERRIDE = SIGNAL_A,
436  SIGNAL_FLASH = SIGNAL_B,
438  SIGNAL_IMMEDIATE = SIGNAL_C,
440  SIGNAL_PRIORITY = SIGNAL_D,
441 
446 
451 
455 
456  SIGNAL_HANGUP = SIGNAL_EXIT
457  } signal_t;
458 
464  typedef enum
465  {
466  // msgport management events, server control...
467 
468  MSGPORT_WAKEUP = 0, // wakeup a waiting message port
469  MSGPORT_SHUTDOWN, // notify msgport of server shutdown
470  MSGPORT_LOGGING, // enable driver event logging
471  MSGPORT_REGISTER, // update registrations
472 
473  // primary event identifiers
474 
475  ENTER_STATE = 100, // newly entered state handler
477  EXIT_THREAD, // thread death notify
478  EXIT_TIMER, // timer notified exit
479  EXIT_PARTING, // exit a join...
480  NULL_EVENT, // generic null event pusher
481  ERROR_STATE, // generic enter with error
489 
490  // primary session control events
491 
492  START_DIRECT = 200, // start a script, directed
493  START_INCOMING, // start an incoming script
494  START_OUTGOING, // start selected script, outbound
495  START_RECALL, // start a recalled call
496  START_FORWARDED, // start a forwarded call
497  START_RINGING, // start a ringing call
498  START_HUNTING, // start a hunting call
499  START_REFER, // start a refer session
515 
516  START_SCRIPT = START_INCOMING,
517  START_SELECTED = START_OUTGOING,
518  START_TRANSFER = START_REFER,
519 
520  // libexec specific events
521 
522  ENTER_LIBEXEC = 300,
540 
541  // primary driver events
542 
543  TIMER_EXPIRED = 400, // trunk timer expired
561 
562  // primary call processing events
563 
564  CALL_DETECT = 500,
570  CALL_HOLDING=CALL_HOLD,
595 
596  // some timeslot specific control and dial events
597 
598  START_RING = 600,
600  CLEAR_TIMESLOT, // garbage collect
614 
615  DIAL_MACHINE = DIAL_PAM,
616 
617  // basic audio stuff
618 
619  AUDIO_IDLE = 700,
627  DTMF_KEYSYNC, /* timing sync event */
633  DTMF_GENDOWN, /* peer */
634  DTMF_GENUP, /* peer */
635  AUDIO_SYNC, /* peer */
636  AUDIO_RECONNECT, /* re-invite event... */
637  AUDIO_DISCONNECT, /* audio holding re-invite */
638  PEER_RECONNECT, /* peer re-invite notice */
639  PEER_DISCONNECT, /* peer holding notice */
640  PEER_REFER, /* referred by peer */
641  DTMF_GENTONE = DTMF_GENUP,
642 
643  // make modes and special timeslot stuff
644 
645  MAKE_TEST = 800,
658  RELOCATE_REQUEST, // queued event
659  RELOCATE_ACCEPT, // hunting reply
660  RELOCATE_REJECT, // a kind of disconnect
661  START_RELOCATE, // start timeslot for relocation
667 
668  // aliasing
669 
670  ENTER_RESUME = MAKE_UP,
671  ENTER_SUSPEND = MAKE_DOWN,
672 
673  // master control events
674 
675  SYSTEM_DOWN = 900,
676 
677  // driver specific events and anomalies
678 
679  DRIVER_SPECIFIC = 1000 // oddball events
680 
681  } event_t;
682 
683  typedef enum
684  {
685  RESULT_SUCCESS = 0,
691  RESULT_BADPATH = 254,
692  RESULT_OFFLINE = 255
693  } result_t;
694 
695  typedef struct
696  {
697  Line line;
698  char text[MAX_LIBINPUT];
699  const char *list[MAX_LIBINPUT / 2];
700  } libaudio_t;
701 
702  typedef struct
703  {
704  const char *remote;
705  const char *userid;
706  const char *type;
707  const char *status;
708  unsigned short active_calls, call_limit;
709  unsigned long attempts_iCount, attempts_oCount;
710  unsigned long complete_iCount, complete_oCount;
711  time_t updated;
712  } regauth_t;
713 
721  typedef struct
722  {
725  uint16 seq;
726 
727  union
728  {
729  // used to invoke attach. The image refcount
730  // is assumed to already be inc'd! If no
731  // scr is passed, then uses default or search
732  // vars passed in sym, value pairs
733  struct
734  {
738  const char *dialing;
739  } start;
740 
741  struct
742  {
743  ScriptImage *img;
744  Script::Name *scr;
745  BayonneSession *parent;
747  } hunt;
748 
749  struct
750  {
753  } relocate;
754 
755  struct
756  {
757  const char *tid;
758 #ifdef WIN32
759  HANDLE pfd;
760 #else
761  const char *fname;
762 #endif
763  int pid, result;
764  } libexec;
765 
766  struct
767  {
768  const char *tid;
769  const char *errmsg;
770  } liberror;
771 
772  struct
773  {
775  int digit;
776  } dtmf;
777 
778  struct
779  {
780  const char *err;
781  const char *msg;
782  } cpa;
783 
784  struct
785  {
786  const char *name;
787  bool exit;
788  } tone;
789 
790  struct
791  {
792  std::ostream *output;
793  const char *logstate;
794  } debug;
795 
796  struct
797  {
798  const char *encoding;
800  } reconnect;
801 
802  const char *dialing;
803  const char *name;
804  const char *errmsg;
808  void *data;
809  };
810 
811  } Event;
812 
817  {
818  private:
819  static Mutex locker;
820  static Ring *free;
822 
823  Ring() {};
824  public:
825  BayonneDriver *driver;
826  const char *ring_id;
827  unsigned count;
830 
831  static Ring *attach(BayonneDriver *d, const char *id, Ring *list);
832  static void detach(Ring *list);
833  static Ring *find(Ring *list, BayonneSession *s);
834  static void start(Ring *list, BayonneSession *s);
835  };
836 
842  {
843  private:
844  static unsigned long stamp;
845 
846  public:
847  Traffic();
848 
849  static inline unsigned long getStamp(void)
850  {return stamp;};
851 
852  volatile unsigned long iCount, oCount;
853  };
854 
858  typedef void (*rpcmethod_t)(BayonneRPC *rpc);
859 
863  typedef struct
864  {
865  const char *name;
866  rpcmethod_t method;
867  const char *help;
868  const char *signature;
869  } RPCDefine;
870 
876  {
877  private:
878  friend class __EXPORT BayonneRPC;
879  static RPCNode *first;
880  static unsigned count;
883  const char *prefix;
884 
885  public:
886  static inline RPCNode *getFirst(void)
887  {return first;};
888 
889  inline RPCNode *getNext(void)
890  {return next;};
891 
892  inline const char *getPrefix(void)
893  {return prefix;};
894 
895  inline RPCDefine *getMethods(void)
896  {return methods;};
897 
898  static inline unsigned getCount(void)
899  {return count;};
900 
901  RPCNode(const char *prefix, RPCDefine *dispatch);
902  };
903 
909  typedef bool (BayonneSession::*Handler)(Event *event);
910 
915  typedef struct
916  {
917  const char *name;
918  Handler handler;
919  char flag;
920  } statetab;
921 
929  typedef struct
930  {
931  Handler handler, logstate;
932  const char *name;
934  bool peering;
936  unsigned stack;
938 #ifdef WIN32
939  HANDLE pfd;
940 #else
941  int pfd;
942 #endif
944  int pid;
946  bool refer;
947 
948  union
949  {
950  struct
951  {
952  unsigned count;
954  } wait;
955 
956  struct
957  {
960  timeout_t total, silence, intersilence;
961  long lastnum;
962  bool exitkey;
963  bool compress;
964  bool trigger;
965  const char *pos;
966  const char *exit;
967  const char *menu;
968  const char *note;
969  union {
970  const char *list[MAX_LIST];
971  struct {
972  const char *pathv[4];
973  char path1[128];
974  char path2[128];
975  char meta[MAX_LIST * 2];
976  };
977  };
978  } audio;
979 
980  struct
981  {
984  const char *var;
985  const char *exit;
986  const char *format;
987  const char *ignore;
988  const char *route;
989  unsigned count, size, required;
990  } input;
991 
992  struct
993  {
994  const char *var;
995  const char *menu;
996  } inkey;
997 
998  struct
999  {
1000  const char *sequence;
1001  bool flashing;
1002  bool dialing, exiting, hangup, dtmf, refer;
1003  char *syncdigit;
1006  char digits[64];
1007  char sessionid[16];
1008  } tone;
1009 
1010  struct
1011  {
1012  timeout_t on, off, interdigit;
1013  unsigned pos;
1014  bool flashing;
1015  bool dialing;
1016  unsigned char digits[64];
1017  } pulse;
1018 
1019  struct
1020  {
1021  const char *dial;
1022  const char *exit;
1023  bool dtmf, drop, hangup, refer;
1025  timeout_t answer_timer, hunt_timer;
1027  unsigned index;
1028  char digits[64];
1029  } join;
1030 
1031  struct
1032  {
1033  const char *ref;
1034  char buf[MAX_LIST * sizeof(char *)];
1035  } url;
1036  };
1037 
1038  } State;
1039 
1043  static statetab states[];
1044 
1050 
1055 
1061  static volatile unsigned short total_active_calls;
1062 
1070  static void allocate(timeslot_t timeslots, ScriptCommand *pointer = NULL, timeslot_t overdraft = 0);
1071 
1072  static const char *getRegistryId(const char *id);
1073 
1074  static BayonneDriver *getDriverTag(const char *id);
1075 
1076  static Audio::Encoding getEncoding(const char *cp);
1077 
1081  static void allocateLocal(void);
1082 
1086  static void addConfig(const char *cfgfile);
1087 
1094  void md5_hash(char *out, const char *source);
1095 
1099  static void waitLoaded(void);
1100 
1106  static unsigned long uptime(void);
1107 
1113  static ScriptCompiler *reload(void);
1114 
1118  static void down(void);
1119 
1126  static bool service(const char *service);
1127 
1133  static const char *getRunLevel(void);
1134 
1142  static BayonneSession *getSession(timeslot_t timeslot);
1143 
1150  static ScriptImage **getLocalImage(timeslot_t timeslot);
1151 
1163  static BayonneSession *startDialing(const char *dial,
1164  const char *name, const char *caller, const char *display,
1165  BayonneSession *parent = NULL, const char *manager = NULL,
1166  const char *secret = NULL);
1167 
1176  static BayonneSession *getSid(const char *id);
1177 
1185  static timeslot_t toTimeslot(const char *id);
1186 
1192  static inline timeslot_t getTimeslotsUsed(void)
1193  {return Bayonne::ts_used;};
1194 
1200  static inline timeslot_t getTimeslotCount(void)
1201  {return Bayonne::ts_count;};
1202 
1209  static inline timeslot_t getAvailTimeslots(void)
1210  {return Bayonne::ts_count - Bayonne::ts_used;};
1211 
1219  static Handler getState(const char *name);
1220 
1227  static int getDigit(char dtmf);
1228 
1235  static char getChar(int dtmf);
1236 
1247  static bool matchDigits(const char *digits, const char *match, bool partial = false);
1248 
1254  static ScriptImage *useImage(void);
1255 
1262  static void endImage(ScriptImage *image);
1263 
1270  static bool loadPlugin(const char *path);
1271 
1278  static bool loadMonitor(const char *path);
1279 
1286  static bool loadAudio(const char *path);
1287 
1288  static void errlog(const char *level, const char *fmt, ...);
1289 
1290  static bool getUserdata(void);
1291 
1292  static void addTrap4(const char *addr);
1293 #ifdef CCXX_IPV6
1294  static void addTrap6(const char *addr);
1295 #endif
1296 };
1297 
1306 {
1307 protected:
1310  const char *zeroconf_type;
1312 
1313 public:
1314  typedef enum
1315  {
1318  ZEROCONF_IPV4
1319  } zeroconf_family_t;
1320 
1321 protected:
1323 
1324  BayonneZeroconf(const char *type, zeroconf_family_t family = ZEROCONF_IPANY);
1325 
1326 public:
1332  static inline BayonneZeroconf *getFirst(void)
1333  {return zeroconf_first;};
1334 
1340  inline BayonneZeroconf *getNext(void)
1341  {return zeroconf_next;};
1342 
1348  inline const char *getType(void)
1349  {return zeroconf_type;};
1350 
1356  inline tpport_t getPort(void)
1357  {return zeroconf_port;};
1358 
1360  {return zeroconf_family;};
1361 };
1362 
1371 {
1372 private:
1374 
1376  const char *id;
1377 
1378 public:
1379  BayonneConfig(const char *id, Keydata::Define *def, const char *path);
1380  BayonneConfig(const char *id, const char *path);
1381  void setEnv(const char *id);
1382  static BayonneConfig *get(const char *id);
1383  static void rebuild(ScriptImage *img);
1384 };
1385 
1394 {
1395 protected:
1398  const char *id;
1399 
1400  static const char *getToken(BayonneSession *s, Line *l, unsigned *idx);
1401  static unsigned addItem(BayonneSession *s, unsigned count, const char *text);
1402  static const char *getLast(BayonneSession *s, unsigned count);
1403 
1404 public:
1412  BayonneTranslator(const char *iso);
1413 
1414  virtual ~BayonneTranslator();
1415 
1422  static BayonneTranslator *get(const char *name);
1423 
1428  static inline BayonneTranslator *getFirst(void)
1429  {return first;};
1430 
1437  {return next;};
1438 
1446  static BayonneTranslator *loadTranslator(const char *iso);
1447 
1456  virtual unsigned digits(BayonneSession *sessiob, unsigned count, const char *string);
1457 
1466  virtual unsigned spell(BayonneSession *session, unsigned count, const char *string);
1467 
1476  virtual unsigned sayorder(BayonneSession *session, unsigned count, const char *string);
1477 
1486  virtual unsigned number(BayonneSession *session, unsigned count, const char *string);
1487 
1497  virtual unsigned saynumber(BayonneSession *session, unsigned count, const char *string);
1498 
1507  virtual unsigned saycount(BayonneSession *session, unsigned count, const char *string);
1508 
1517  virtual unsigned sayhour(BayonneSession *session, unsigned count, const char *string);
1518 
1527  virtual unsigned saytime(BayonneSession *session, unsigned count, const char *string);
1528 
1537  virtual unsigned weekday(BayonneSession *session, unsigned count, const char *string);
1538 
1539  /*
1540  * Translate a string with a date into spoken date without year.
1541  *
1542  * @param session to save list of prompts.
1543  * @param count of current prompts used.
1544  * @param string to be processed.
1545  * @return new count of prompts used.
1546  */
1547  virtual unsigned sayday(BayonneSession *session, unsigned count, const char *string);
1548 
1557  virtual unsigned saydate(BayonneSession *session, unsigned count, const char *string);
1558 
1567  virtual unsigned saybool(BayonneSession *session, unsigned count, const char *string);
1568 
1577  virtual unsigned phone(BayonneSession *session, unsigned count, const char *string);
1578 
1587  virtual unsigned extension(BayonneSession *session, unsigned count, const char *string);
1588 
1596  virtual const char *speak(BayonneSession *session, Line *line = NULL);
1597 
1603  inline const char *getId(void)
1604  {return id;};
1605 };
1606 
1607 
1616 {
1617 protected:
1618  char filename[MAX_PATHNAME];
1619  const char **list;
1620  char *getContinuation(void);
1621 
1622 public:
1628 
1634 
1638  char vlib[60];
1639 
1640  const char *extension, *voicelib, *libext, *prefixdir, *offset;
1643  char var_position[14];
1644 
1648  BayonneAudio();
1649 
1657  const char *getFilename(const char *name, bool write = false);
1658 
1663  void cleanup(void);
1664 
1671  void play(const char **list, Mode mode = modeRead);
1672 
1680  void record(const char *name, Mode mode = modeCreate, const char *annotation = NULL);
1681 
1688  const char *getVoicelib(const char *iso);
1689 
1695  inline AudioCodec *getCodec(void)
1696  {return codec;};
1697 };
1698 
1709 class __EXPORT BayonneMsgport : public Thread, public Buffer, public Bayonne
1710 {
1711 public:
1715  virtual ~BayonneMsgport();
1716 
1722  BayonneMsgport(BayonneDriver *driver);
1723 
1729  void update(void);
1730 
1735  void initial(void);
1736 
1737 protected:
1740  unsigned msgsize, msghead, msgtail;
1742  char msgname[16];
1743 
1747  void shutdown(void);
1748 
1756  virtual timeout_t getTimeout(Event *event);
1757 
1758  void run(void);
1759 
1760  size_t onWait(void *buf);
1761  size_t onPost(void *buf);
1762  size_t onPeek(void *buf);
1763 };
1764 
1772 class __EXPORT BayonneDriver : public Bayonne, public ReconfigKeydata, public Mutex
1773 {
1774 protected:
1775  friend class __EXPORT BayonneSession;
1776  friend class __EXPORT BayonneMsgport;
1781  static Semaphore oink; // the pig has been kicked!
1782  static bool protocols;
1783 
1784  BayonneSession *firstIdle, *lastIdle, *highIdle;
1787  const char *name;
1789  unsigned avail;
1790  unsigned span, spans;
1791  bool running;
1792  static bool stopping;
1793  std::ostream *logevents;
1794 
1796  size_t audio_stack;
1798 
1799  timeout_t pickup_timer, hangup_timer, seize_timer, ring_timer, hunt_timer;
1800  timeout_t reset_timer, release_timer, flash_timer, interdigit_timer;
1801  unsigned answer_count;
1802 
1807  virtual void reloadDriver(void);
1808 
1813  virtual void startDriver(void);
1814 
1818  virtual void stopDriver(void);
1819 
1824  void relistIdle(void);
1825 
1826 public:
1835  virtual bool isAuthorized(const char *userid, const char *secret);
1836 
1837  virtual bool deregister(const char *id);
1838  virtual bool reregister(const char *id, const char *uri, const char *secret, timeout_t expires);
1839 
1840  Traffic call_attempts, call_complete;
1841  volatile unsigned short active_calls;
1842 
1851  BayonneDriver(Keydata::Define *pairs, const char *key, const char *id, bool virt = false);
1852 
1856  ~BayonneDriver();
1857 
1861  static inline bool useProtocols(void)
1862  {return protocols;}
1863 
1867  static bool isStopping(void)
1868  {return stopping;};
1869 
1873  static inline BayonneDriver *getTrunking(void)
1874  {return trunkDriver;}
1875 
1879  static inline BayonneDriver *getPrimary(void)
1880  {return firstDriver;}
1881 
1889  static BayonneDriver *authorize(const char *userid, const char *secret);
1890 
1894  inline BayonneDriver *getNext(void)
1895  {return nextDriver;};
1896 
1897  static inline BayonneDriver *getRoot(void)
1898  {return firstDriver;};
1899 
1903  static inline BayonneDriver *getProtocol(void)
1904  {return protoDriver;}
1905 
1911  BayonneSession *getIdle(void);
1912 
1918  virtual bool suspend(void);
1919 
1925  virtual bool resume(void);
1926 
1930  virtual void reregister(void);
1931 
1939  virtual const char *registerScript(ScriptImage *image, Line *line);
1940 
1948  virtual const char *assignScript(ScriptImage *image, Line *line);
1949 
1956  static BayonneDriver *get(const char *id);
1957 
1964  static BayonneDriver *loadDriver(const char *id);
1965 
1972  static BayonneDriver *loadTrunking(const char *id);
1973 
1981  static BayonneDriver *loadProtocol(const char *id, unsigned timeslots = 0);
1982 
1990  static unsigned list(char **items, unsigned max);
1991 
1995  static void start(void);
1996 
2000  static void stop(void);
2001 
2005  static void reload(void);
2006 
2013  static void add(BayonneSession *session);
2014 
2021  static void del(BayonneSession *session);
2022 
2028  inline timeslot_t getFirst(void)
2029  {return timeslot;};
2030 
2036  inline timeslot_t getCount(void)
2037  {return count;};
2038 
2044  inline unsigned getSpanFirst(void)
2045  {return span;};
2046 
2052  inline unsigned getSpansUsed(void)
2053  {return spans;};
2054 
2060  inline const char *getName(void)
2061  {return name;};
2062 
2070  {return reset_timer;};
2071 
2078  {return release_timer;};
2079 
2086  {return hangup_timer;};
2087 
2094  {return pickup_timer;};
2095 
2102  {return seize_timer;};
2103 
2110  {return hunt_timer;};
2111 
2118  {return flash_timer;};
2119 
2126  {return interdigit_timer;};
2127 
2136  {return ring_timer;};
2137 
2143  inline unsigned getAnswerCount(void)
2144  {return answer_count;};
2145 
2152  BayonneSpan *getSpan(unsigned id);
2153 
2161  BayonneSession *getTimeslot(timeslot_t id);
2162 
2169  {return msgport;};
2170 
2176  inline size_t getAudioStack(void)
2177  {return audio_stack;};
2178 
2184  inline int getAudioPriority(void)
2185  {return audio_priority;};
2186 
2193  {return audio_level;};
2194 
2200  inline void setLogging(std::ostream *output)
2201  {logevents = output;};
2202 
2209  inline bool isSpanable(unsigned span);
2210 
2221  virtual bool getDestination(const char *target, const char *dial, char *output, size_t size);
2222 
2228  inline unsigned getAvail(void)
2229  {return avail;}
2230 
2238  virtual bool isExternal(const char *dest);
2239 
2246  virtual bool isRegistered(const char *dest);
2247 
2254  virtual bool isAvailable(const char *dest);
2255 
2263  virtual bool isReachable(const char *proxy);
2264 
2274  virtual unsigned getRegistration(regauth_t *data, unsigned count, const char *id = NULL);
2275 };
2276 
2284 class __EXPORT BayonneSpan : public Bayonne, public Keydata
2285 {
2286 protected:
2287  friend class __EXPORT BayonneSession;
2288  friend class __EXPORT BayonneDriver;
2289 
2292  static unsigned spans;
2293  static BayonneSpan **index;
2294 
2295  unsigned id;
2298  timeslot_t timeslot, count, used; // timeslots
2299 
2300 public:
2301  Traffic call_attempts, call_complete;
2302  volatile unsigned short active_calls;
2303 
2310  BayonneSpan(BayonneDriver *driver, timeslot_t timeslots);
2311 
2318  static BayonneSpan *get(unsigned id);
2319 
2326  BayonneSession *getTimeslot(timeslot_t id);
2327 
2333  static void allocate(unsigned total = 0);
2334 
2340  static inline unsigned getSpans(void)
2341  {return spans;};
2342 
2348  inline timeslot_t getFirst(void)
2349  {return timeslot;};
2350 
2356  inline timeslot_t getCount(void)
2357  {return count;};
2358 
2364  inline unsigned getId(void)
2365  {return id;};
2366 
2372  inline BayonneDriver *getDriver(void)
2373  {return driver;};
2374 
2380  inline unsigned getAvail(void)
2381  {return count - used;}
2382 
2388  virtual bool suspend(void);
2389 
2395  virtual bool resume(void);
2396 
2402  virtual bool reset(void);
2403 };
2404 
2412 {
2413 private:
2414  friend class __EXPORT BayonneSession;
2416 
2417  class Image : public ScriptImage
2418  {
2419  public:
2420  inline Image() : ScriptImage(NULL, NULL) {};
2421  unsigned gatherPrefix(const char *prefix, const char **list, unsigned max);
2422  };
2423 
2424 protected:
2425  virtual const char *submit(const char **data);
2426 
2427  virtual ScriptCompiler *compiler(void);
2428 
2429  virtual unsigned destinations(Image *img, const char **array, unsigned max);
2430 
2431  virtual bool isDestination(Image *img, const char *name);
2432 
2433  BayonneSession *session(ScriptInterp *interp);
2434 
2435  bool scriptEvent(ScriptInterp *interp, const char *evt);
2436 
2437  bool digitEvent(ScriptInterp *interp, const char *evt);
2438 
2439  BayonneBinder(const char *id);
2440 
2441  virtual void makeCall(BayonneSession *child);
2442 
2443  virtual void dropCall(BayonneSession *child);
2444 
2445  virtual Name *getIncoming(ScriptImage *img, BayonneSession *s, Event *event);
2446 
2447 public:
2448  static const char *submitRequest(const char **data);
2449 
2450  static ScriptCompiler *getCompiler(void);
2451 
2452  static unsigned gatherDestinations(ScriptImage *img, const char **index, unsigned max);
2453 
2454  static bool isDestination(const char *name);
2455 };
2456 
2465 {
2466 private:
2467  friend class __EXPORT ScriptEngine;
2468  friend class __EXPORT BayonneMsgport;
2470  friend class __EXPORT BayonneDriver;
2471  friend class __EXPORT Bayonne;
2472 
2474 
2475  BayonneSession *nextIdle, *prevIdle;
2476  bool isAvail;
2477 
2478 protected:
2482 
2483  std::ostream *logevents, *logtrace;
2484  Ring *ring;
2490  uint8 seq;
2491  uint16 evseq;
2492  uint32 tseq;
2493  bool offhook, dtmf, answered, starting, holding, connecting, referring;
2494  time_t audiotimer, starttime;
2500 
2501 // Name *getScript(const char *scr);
2502 
2510  bool requiresDTMF(void);
2511 
2516  void enterCall(void);
2517 
2525  void exitCall(const char *reason);
2526 
2532  virtual bool enableDTMF(void);
2533 
2537  virtual void disableDTMF(void);
2538 
2547  virtual const char *checkAudio(bool live);
2548 
2555  virtual bool filterPosting(Event *event);
2556 
2557  virtual bool enterCommon(Event *event);
2558  virtual bool enterInitial(Event *event);
2559  virtual bool enterFinal(Event *event);
2560  virtual bool enterIdle(Event *event);
2561  virtual bool enterReset(Event *event);
2562  virtual bool enterRelease(Event *event);
2563  virtual bool enterRinging(Event *event);
2564  virtual bool enterPickup(Event *event);
2565  virtual bool enterAnswer(Event *event);
2566  virtual bool enterSeize(Event *event);
2567  virtual bool enterHunting(Event *event);
2568  virtual bool enterHangup(Event *event);
2569  virtual bool enterTone(Event *event);
2570  virtual bool enterReconnect(Event *event);
2571  virtual bool enterDTMF(Event *event);
2572  virtual bool enterPlay(Event *event);
2573  virtual bool enterRecord(Event *event);
2574  virtual bool enterJoin(Event *event);
2575  virtual bool enterWait(Event *event);
2576  virtual bool enterDial(Event *event);
2577  virtual bool enterBusy(Event *event);
2578  virtual bool enterStandby(Event *event);
2579  virtual bool enterXfer(Event *event);
2580  virtual bool enterRefer(Event *event);
2581  virtual bool enterHold(Event *event);
2582  virtual bool enterRecall(Event *event);
2583 
2588  void check(void);
2589 
2590  void renameRecord(void);
2591  bool stateInitial(Event *event);
2592  bool stateFinal(Event *event);
2593  bool stateIdle(Event *event);
2594  bool stateIdleReset(Event *event);
2595  bool stateReset(Event *event);
2596  bool stateRelease(Event *event);
2597  bool stateBusy(Event *event);
2598  bool stateStandby(Event *event);
2599  bool stateRinging(Event *event);
2600  bool statePickup(Event *event);
2601  bool stateAnswer(Event *event);
2602  bool stateSeize(Event *event);
2603  bool stateHunting(Event *event);
2604  bool stateRunning(Event *event);
2605  bool stateLibexec(Event *event);
2606  bool stateLibreset(Event *event);
2607  bool stateLibwait(Event *event);
2608  bool stateWaitkey(Event *event);
2609  bool stateThreading(Event *event);
2610  bool stateHangup(Event *event);
2611  bool stateCollect(Event *event);
2612  bool stateSleep(Event *event);
2613  bool stateStart(Event *event);
2614  bool stateClear(Event *event);
2615  bool stateInkey(Event *event);
2616  bool stateInput(Event *event);
2617  bool stateRead(Event *event);
2618  bool stateDial(Event *event);
2619  bool stateXfer(Event *event);
2620  bool stateRefer(Event *event);
2621  bool stateHold(Event *event);
2622  bool stateRecall(Event *event);
2623  bool stateTone(Event *event);
2624  bool stateDTMF(Event *event);
2625  bool statePlay(Event *event);
2626  bool stateRecord(Event *event);
2627  bool stateJoin(Event *event);
2628  bool stateWait(Event *event);
2629  bool stateConnect(Event *event);
2630  bool stateReconnect(Event *event);
2631  bool stateCalling(Event *event);
2632 
2639  bool putEvent(Event *event);
2640 
2646  void libWrite(const char *string);
2647 
2648  void libClose(const char *string);
2649 
2650  bool isLibexec(const char *tsid);
2651 
2652  timeout_t getLibexecTimeout(void);
2653 
2654  const char *getWritepath(char *buf = NULL, size_t len = 0);
2655 
2656  void incIncomingAttempts(void);
2657 
2658  void incOutgoingAttempts(void);
2659 
2660  void incIncomingComplete(void);
2661 
2662  void incOutgoingComplete(void);
2663 
2664  void incActiveCalls(void);
2665 
2666  void decActiveCalls(void);
2667 
2668 public:
2669  Traffic call_attempts, call_complete;
2670 
2671  inline bool isDTMF(void)
2672  {return dtmf;};
2673 
2674  inline bool isPeering(void)
2675  {return state.peering;};
2676 
2677  inline BayonneSpan *getSpan(void)
2678  {return span;};
2679 
2681  {return timeslot;};
2682 
2683  inline ScriptEngine *getEngine(void)
2684  {return vm;};
2685 
2692  const char *getExternal(const char *option);
2693 
2701  bool addSymbol(const char *id, const char *value);
2702 
2709  bool clearSymbol(const char *id);
2710 
2716  inline uint16 getEventSequence(void)
2717  {return evseq;};
2718 
2719  static const char *getGlobal(const char *id);
2720  static bool setGlobal(const char *id, const char *value);
2721  static bool sizeGlobal(const char *id, unsigned size);
2722  static bool addGlobal(const char *id, const char *value);
2723  static bool clearGlobal(const char *id);
2724 
2725 protected:
2732  ScriptInterp *getInterp(const char *id);
2733 
2740  ScriptSymbols *getSymbols(const char *id);
2741 
2746 
2754  Name *attachStart(Event *event);
2755 
2759  unsigned getId(void);
2760 
2765  void setSid(void);
2766 
2770  void setState(state_t);
2771 
2776  void setRunning(void);
2777 
2784  bool setReconnect(const char *enc, timeout_t framing);
2785 
2786 
2790  bool recallReconnect(void);
2791 
2796  void setConnecting(const char *evname = NULL);
2797 
2806  bool setLibexec(result_t result);
2807 
2816  bool setLibreset(result_t result);
2817 
2818 public:
2825  {return translator;};
2826 
2830  inline void startConnecting(void)
2831  {connecting = true;};
2832 
2833 protected:
2840  inline libaudio_t *getLibaudio(void)
2841  {return state.libaudio;};
2842 
2846  void finalize(void);
2847 
2853  bool exit(void);
2854 
2855  char var_date[12];
2856  char var_time[12];
2857  char var_duration[12];
2858  char var_callid[12];
2859  char var_tid[14];
2860  char var_sid[16];
2861  char var_pid[16];
2862  char var_recall[16];
2863  char var_joined[16];
2864  char var_rings[4];
2865  char var_timeslot[8];
2866  char var_spanid[8];
2867  char var_bankid[4];
2868  char var_spantsid[12];
2869  const char *voicelib;
2870  char *dtmf_digits; // dtmf sym space;
2871  unsigned digit_count, ring_count;
2872  time_t time_joined;
2873 
2874  State state;
2875 
2876 public:
2884  BayonneSession(BayonneDriver *driver, timeslot_t timeslot, BayonneSpan *span = NULL);
2885 
2889  virtual ~BayonneSession();
2890 
2891  const char *getDigits(void);
2892 
2893  inline const char *defVoicelib(void)
2894  {return voicelib;}
2895 
2896  inline const char *getSessionId(void)
2897  {return var_sid;};
2898 
2899  inline const char *getSessionParent(void)
2900  {return var_pid;};
2901 
2902  inline const char *getSessionJoined(void)
2903  {return var_joined;};
2904 
2905  inline time_t getSessionStart(void)
2906  {return starttime;};
2907 
2911  void initialevent(void);
2912 
2916  void initialize(void);
2917 
2921  void detach(void);
2922 
2926  inline time_t getJoined(void)
2927  {return time_joined;};
2928 
2934  inline BayonneDriver *getDriver(void)
2935  {return driver;}
2936 
2943  virtual timeout_t getRemaining(void) = 0;
2944 
2951  virtual void startTimer(timeout_t timer) = 0;
2952 
2957  virtual void stopTimer(void) = 0;
2958 
2964  virtual void setOffhook(bool state);
2965 
2969  virtual void makeIdle(void);
2970 
2976  void part(event_t reason);
2977 
2984  virtual bool postEvent(Event *event);
2985 
2986 
2987  bool matchLine(Line *line);
2988 
2994  virtual void queEvent(Event *event);
2995 
2999  virtual void startThread(void);
3000 
3004  virtual void enterThread(ScriptThread *thr);
3005 
3009  virtual void exitThread(const char *msg);
3010 
3014  virtual void clrAudio(void);
3015 
3019  virtual timeout_t getToneFraming(void);
3020 
3024  virtual const char *audioEncoding(void);
3025 
3029  virtual const char *audioExtension(void);
3030 
3034  virtual timeout_t audioFraming(void);
3035 
3042  const char *getAudio(bool live = true);
3043 
3048  void branching(void);
3049 
3055  inline bool isOffhook(void)
3056  {return offhook;};
3057 
3064  {return iface;};
3065 
3071  inline bridge_t getBridge(void)
3072  {return bridge;};
3073 
3079  inline calltype_t getType(void)
3080  {return type;};
3081 
3087  inline timeslot_t getSlot(void)
3088  {return timeslot;};
3089 
3095  inline bool isIdle(void)
3096  {return isAvail;};
3097 
3103  bool isRefer(void);
3104 
3110  bool isJoined(void);
3111 
3117  bool isAssociated(void);
3118 
3124  void associate(BayonneSession *s);
3125 
3126  inline bool isHolding(void)
3127  {return holding;};
3128 
3132  bool isDisconnecting(void);
3133 
3139  timeout_t getJoinTimer(void);
3140 
3147  bool signalScript(signal_t signal);
3148 
3154  virtual bool peerLinear(void);
3155 
3165  virtual bool peerAudio(Audio::Encoded encoded);
3166 
3176  virtual bool setPeering(Audio::Encoding encoding, timeout_t framing);
3177 
3178  const char *getKeyString(const char *id);
3179  bool getKeyBool(const char *id);
3180  long getKeyValue(const char *id);
3181  timeout_t getSecTimeout(const char *id);
3182  timeout_t getMSecTimeout(const char *id);
3183  timeout_t getTimeoutValue(const char *opt = NULL);
3184  timeout_t getTimeoutKeyword(const char *kw);
3185  const char *getExitKeyword(const char *def);
3186  const char *getMenuKeyword(const char *def);
3187 
3188  unsigned getInputCount(const char *digits, unsigned max);
3189 
3197  uint32 newTid(void);
3198 
3204  inline const char *getTid(void)
3205  {return var_tid;};
3206 
3213  bool digitEvent(const char *event);
3214 
3215  inline bool stringEvent(const char *evt)
3216  {return scriptEvent(evt);}
3217 
3223  char getDigit(void);
3224 
3226 };
3227 
3236 {
3237 protected:
3238  BayonneRPC();
3239  virtual ~BayonneRPC();
3240 
3241  struct params
3242  {
3243  char *name[RPC_MAX_PARAMS];
3244  char *map[RPC_MAX_PARAMS];
3245  char *value[RPC_MAX_PARAMS];
3246  unsigned short param[RPC_MAX_PARAMS];
3247  unsigned count;
3248  short argc;
3249  } params;
3250 
3251  bool parseCall(char *cp);
3252 
3253 public:
3254  virtual void setComplete(BayonneSession *s);
3255 
3256  struct {
3257  char *buffer;
3258  size_t bufsize;
3259  size_t bufused;
3260  const char *agent_id;
3261  const char *protocol;
3262  bool authorized; // transport authorized
3263  const char *userid; // null if anonymous
3264  BayonneDriver *driver; // authorizing driver
3265  } transport;
3266 
3267  struct {
3268  unsigned code;
3269  const char *string;
3270  } result;
3271 
3272  struct {
3273  const char *prefix; // xmlrpc has prefix, soap NULL
3274  const char *method;
3275  const char *tranid;
3276  const char *action;
3277  const char *resuri;
3278  } header;
3279 
3280  inline unsigned getCount(void)
3281  {return params.argc;};
3282 
3283  const char *getParamId(unsigned short param, unsigned short offset);
3284  const char *getIndexed(unsigned short param, unsigned short offset = 0);
3285  const char *getNamed(unsigned short param, const char *member);
3286  const char *getMapped(const char *map, const char *member);
3287 
3288  friend size_t xmlwrite(char **buf, size_t *max, const char *fmt, ...);
3289  bool buildResponse(const char *fmt, ...);
3290  void sendSuccess(void);
3291  void sendFault(int code, const char *string);
3292 
3293  inline void transportFault(unsigned code, const char *string)
3294  {result.code = code; result.string = string;};
3295 
3296  bool invokeXMLRPC(void);
3297 };
3298 
3299 size_t xmlwrite(char **buf, size_t *max, const char *fmt, ...);
3300 
3310 {
3311 private:
3312  friend class __EXPORT BayonneSession;
3313 
3317  friend void startServices(void);
3318  friend void stopServices(void);
3319 
3320 protected:
3321  BayonneService(int pri, size_t stack);
3322 
3326  virtual void stopService(void);
3327 
3331  virtual void startService(void);
3332 
3336  virtual void detachSession(BayonneSession *s);
3337 
3341  virtual void attachSession(BayonneSession *s);
3342 
3346  virtual void enteringCall(BayonneSession *child);
3347 
3351  virtual void exitingCall(BayonneSession *child);
3352 
3353 public:
3357  static void start(void);
3358 
3362  static void stop(void);
3363 };
3364 
3374 {
3375 protected:
3376  friend class __EXPORT BayonneSession;
3377 
3384  virtual bool signalEngine(Bayonne::signal_t signal) = 0;
3385 
3390  virtual void releaseEngine(void) = 0;
3391 
3396  virtual void disconnectEngine(void) = 0;
3397 
3406  virtual bool stepEngine(void) = 0;
3407 
3411  virtual ~ScriptEngine() = 0;
3412 
3413  /*
3414  * Clears vm session.
3415  */
3416  inline void clearEngine(BayonneSession *s)
3417  {s->vm = NULL;};
3418 
3422  inline void setEngine(BayonneSession *s)
3423  {s->vm = this;};
3424 };
3425 
3426 
3427 } // namespace
3428 
3429 #endif
unsigned long complete_oCount
Definition: bayonne.h:710
timeout_t getRingTimer(void)
Get the timer to wait for next ring before deciding a call has dissapeared.
Definition: bayonne.h:2135
Bayonne services are used for threaded modules which may be installed at runtime. ...
Definition: bayonne.h:3309
timeout_t seize_timer
Definition: bayonne.h:1799
const char * prefix
Definition: bayonne.h:3273
Mode
File processing mode, whether to skip missing files, etc.
Definition: audio2.h:162
timeslot_t getCount(void)
Return total number of server timeslots in this span.
Definition: bayonne.h:2356
int32_t rpcint_t
Definition: bayonne.h:274
AudioCodec * getCodec(void)
Get audio codec used.
Definition: bayonne.h:1695
BayonneTranslator * getNext()
Get next translator.
Definition: bayonne.h:1436
Bayonne RPC arguments, may be passed through to binders from webservice sessions for extensions to so...
Definition: bayonne.h:3235
const char * signature
Definition: bayonne.h:868
BayonneSession * session
Definition: bayonne.h:828
unsigned count
Definition: bayonne.h:827
static Semaphore oink
Definition: bayonne.h:1781
const char * getSessionId(void)
Definition: bayonne.h:2896
BayonneSession * replace
Definition: bayonne.h:752
RPCNode * getNext(void)
Definition: bayonne.h:889
class __EXPORT BayonneRPC
Definition: bayonne.h:87
unsigned getAnswerCount(void)
Get the number of rings to wait before answering.
Definition: bayonne.h:2143
std::ostream * logtrace
Definition: bayonne.h:2483
unsigned spans
Definition: bayonne.h:1790
static timeslot_t ts_used
Definition: bayonne.h:287
static BayonneDriver * getPrimary(void)
Return the first loaded driver.
Definition: bayonne.h:1879
static char * status
Definition: bayonne.h:281
bool stringEvent(const char *evt)
Definition: bayonne.h:3215
static unsigned long stamp
Definition: bayonne.h:844
__EXPORT AppLog & debug(AppLog &sl)
Manipulator for debug level.
Definition: applog.h:525
Generic audio class to hold master data types and various useful class encapsulated friend functions ...
Definition: audio2.h:88
AudioTone * tone
Current tone object to use for generation of audio tones, dtmf dialing sequences, etc...
Definition: bayonne.h:1627
timeout_t interval
Definition: bayonne.h:953
const char * tranid
Definition: bayonne.h:3275
timeout_t getPickupTimer(void)
Get the pickup timer to wait for channel pickup.
Definition: bayonne.h:2093
AudioStream accesses AudioFile base class content as fixed frames of streaming linear samples...
Definition: audio2.h:1509
int16_t Level
Definition: audio2.h:101
unsigned long attempts_oCount
Definition: bayonne.h:709
const char * userid
Definition: bayonne.h:3263
BayonneTranslator * translator
Translator in effect for this session.
Definition: bayonne.h:2745
timeout_t getResetTimer(void)
Get the reset timer for this driver when resetting a thread in the step state.
Definition: bayonne.h:2069
const char * format
Definition: bayonne.h:986
class __EXPORT BayonneService
Definition: bayonne.h:85
const char * id
Definition: bayonne.h:101
static const char * trap_community
Definition: bayonne.h:308
static bool isStopping(void)
Return is stopping flag.
Definition: bayonne.h:1867
Script::Name * scr
Definition: bayonne.h:736
static time_t start_time
Definition: bayonne.h:296
unsigned char * Encoded
Definition: audio2.h:143
#define MAX_LIST
Definition: bayonne.h:56
BayonneSession * pid
Definition: bayonne.h:805
tpport_t getPort(void)
Get the binding service port number.
Definition: bayonne.h:1356
Encoding
Audio encoding formats.
Definition: audio2.h:180
BayonneMsgport * msgport
Definition: bayonne.h:2486
static BayonneTranslator * first
Definition: bayonne.h:1396
interface_t
Telephony endpoint interface identifiers.
Definition: bayonne.h:314
int HANDLE
Definition: serial.h:60
static ThreadLock reloading
A mutex to serialize reload requests.
Definition: bayonne.h:1054
Traffic call_complete
Definition: bayonne.h:1840
static BayonneSpan * last
Definition: bayonne.h:2291
static BayonneSpan * first
Definition: bayonne.h:2290
static BayonneDriver * getRoot(void)
Definition: bayonne.h:1897
const char * id
Definition: bayonne.h:1398
const char * sequence
Definition: bayonne.h:1000
BayonneAudio audio
Definition: bayonne.h:3225
BayonneSession * current
Definition: bayonne.h:751
Rate
Audio encoding rate, samples per second.
Definition: audio2.h:148
rpcint_t rpcbool_t
Definition: bayonne.h:276
time_t getSessionStart(void)
Definition: bayonne.h:2905
const char * zeroconf_type
Definition: bayonne.h:1310
std::ostream * logevents
Definition: bayonne.h:1793
const char * msg
Definition: bayonne.h:781
const char * ring_id
Definition: bayonne.h:826
The codec class is a virtual used for transcoding audio samples between linear frames (or other known...
Definition: audio2.h:1733
This is a class used for collecting statistics for call traffic measurement, such as might be used by...
Definition: bayonne.h:841
BayonneSpan * getSpan(void)
Definition: bayonne.h:2677
static BayonneDriver * protoDriver
Definition: bayonne.h:1780
const char * err
Definition: bayonne.h:780
Bayonne specific reloaded keydata class.
Definition: bayonne.h:218
static timeout_t reset_timer
Definition: bayonne.h:301
BayonneSpan * next
Definition: bayonne.h:2297
const char ** list
Definition: bayonne.h:1619
const char * remote
Definition: bayonne.h:704
int getAudioPriority(void)
Get the thread priority to use for audio threads for this driver.
Definition: bayonne.h:2184
static bool protocols
Definition: bayonne.h:1782
int16_t * Linear
Definition: audio2.h:103
static bool shutdown_flag
Definition: bayonne.h:294
static unsigned compile_count
Definition: bayonne.h:303
unsigned short tpport_t
Transport Protocol Ports.
Definition: address.h:86
static std::ostream * logging
Definition: bayonne.h:288
The principle driver node for a given collection of spans and sessions of a given Bayonne driver fami...
Definition: bayonne.h:1772
static ScriptImage ** localimages
Definition: bayonne.h:280
This is a structure used to initialize XMLRPC method tables.
Definition: bayonne.h:863
timeslot_t timeslot
Definition: bayonne.h:2489
timeout_t getSeizeTimer(void)
Get the sieze time to wait for dialtone on outbound call.
Definition: bayonne.h:2101
A semaphore is generally used as a synchronization object between multiple threads or to protect a li...
Definition: thread.h:733
const char * pos
Definition: bayonne.h:965
Generic Bayonne master class to reference various useful data types and core static members used for ...
Definition: bayonne.h:251
BayonneSession * peer
Definition: bayonne.h:806
static Traffic total_call_complete
Definition: bayonne.h:1060
static Mutex locker
Definition: bayonne.h:819
timeout_t interdigit
Definition: bayonne.h:982
static BayonneDriver * getTrunking(void)
Return primary trunk driver, if driver trunking...
Definition: bayonne.h:1873
The Mutex class is used to protect a section of code so that at any given time only a single thread c...
Definition: thread.h:186
size_t xmlwrite(char **buf, size_t *max, const char *fmt,...)
timeout_t getInterdigit(void)
Get default dtmf interdigit timer to use.
Definition: bayonne.h:2125
BayonneSession * child
Definition: bayonne.h:807
__EXPORT char * find(const char *cs, char *str, size_t len=0)
uint16_t timeslot_t
Definition: bayonne.h:273
static BayonneConfig * first
Definition: bayonne.h:1373
void setLogging(std::ostream *output)
Set driver logging.
Definition: bayonne.h:2200
RPCDefine * methods
Definition: bayonne.h:882
Threaded step execute scripting engine framework.
static Mutex globalLock
Definition: bayonne.h:2481
BayonneDriver * driver
Definition: bayonne.h:2296
class __EXPORT BayonneSpan
Definition: bayonne.h:84
BayonneZeroconf * getNext(void)
Get the next zeroconf binding to iterate an object list.
Definition: bayonne.h:1340
BayonneTranslator * translator
Current language translator in effect for the current set of autio prompts.
Definition: bayonne.h:1633
libaudio_t * getLibaudio(void)
Get the libaudio object.
Definition: bayonne.h:2840
Audio::Mode mode
Definition: bayonne.h:958
static unsigned getCount(void)
Definition: bayonne.h:898
static BayonneSpan ** index
Definition: bayonne.h:2293
#define MAX_LIBINPUT
Definition: bayonne.h:57
A derivable class to hold compiled script images for active processes.
Definition: script3.h:1150
static Ring * free
Definition: bayonne.h:820
const char * agent_id
Definition: bayonne.h:3260
bool isPeering(void)
Definition: bayonne.h:2674
static ScriptSymbols * globalSyms
Definition: bayonne.h:2480
const char * ref
Definition: bayonne.h:1033
class __EXPORT BayonneDriver
Definition: bayonne.h:82
calltype_t
Type of call session being processed.
Definition: bayonne.h:328
const char * route
Definition: bayonne.h:988
const char * getName(void)
Get the name of the driver.
Definition: bayonne.h:2060
timeslot_t getCount(void)
Get the total number of timeslots this driver uses.
Definition: bayonne.h:2036
interface_t iface
Definition: bayonne.h:2495
static BayonneService * last
Definition: bayonne.h:3315
char * buffer
Definition: bayonne.h:3257
static volatile unsigned short total_active_calls
Definition: bayonne.h:1061
static bool useProtocols(void)
Return flag for protocols active.
Definition: bayonne.h:1861
void wait(signo_t signo)
static const char * path_tmpfs
Definition: bayonne.h:290
Keydata objects are used to load and hold "configuration" data for a given application.
Definition: misc.h:352
unsigned long timeout_t
Definition: thread.h:74
Traffic call_complete
Definition: bayonne.h:2669
Keydata::Define * defkeys
Definition: bayonne.h:193
static bool stopping
Definition: bayonne.h:1792
A list of each state and a description.
Definition: bayonne.h:915
unsigned getAvail(void)
Get available timeslots.
Definition: bayonne.h:2228
static BayonneTranslator * getFirst(void)
Get first translator.
Definition: bayonne.h:1428
BayonneSpan * span
Definition: bayonne.h:2488
static BayonneDriver * firstDriver
Definition: bayonne.h:1777
static DynamicKeydata * firstConfig
Definition: bayonne.h:188
This class is used to bind services that are to be published with zeroconf, such as by the avahi modu...
Definition: bayonne.h:1305
rpcmethod_t method
Definition: bayonne.h:866
static BayonneBinder * binder
Definition: bayonne.h:2415
const char * method
Definition: bayonne.h:3274
BayonneService * next
Definition: bayonne.h:3316
void startConnecting(void)
Start connecting child...
Definition: bayonne.h:2830
A bayonne config class, used for special purposes, especially during script compiles.
Definition: bayonne.h:1370
BayonneDriver * getNext(void)
Get next driver...
Definition: bayonne.h:1894
timeout_t getHuntTimer(void)
Get the hunting timer.
Definition: bayonne.h:2109
std::ostream * output
Definition: bayonne.h:792
BayonneSession * peer
Definition: bayonne.h:2487
unsigned getAvail(void)
Get number of call slots still available.
Definition: bayonne.h:2380
size_t getAudioStack(void)
Get the size of the stack for audio threads.
Definition: bayonne.h:2176
static unsigned getSpans(void)
Return total spans in use.
Definition: bayonne.h:2340
ScriptImage * img
Definition: bayonne.h:735
const char * keypath
Definition: bayonne.h:190
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be ...
Definition: buffer.h:81
class __EXPORT BayonneTranslator
Definition: bayonne.h:86
signal_t
Signaled interpreter events.
Definition: bayonne.h:414
A derivable class to hold compiled script images for active processes.
Definition: script3.h:914
calltype_t getType(void)
Return call type on session.
Definition: bayonne.h:3079
static BayonneDriver * lastDriver
Definition: bayonne.h:1778
static StreamingBuffer * first
Definition: bayonne.h:99
timeslot_t getFirst(void)
Get the first server timeslot of this span.
Definition: bayonne.h:2348
timeout_t reset_timer
Definition: bayonne.h:1800
unsigned avail
Definition: bayonne.h:1789
const char * getPrefix(void)
Definition: bayonne.h:892
static BayonneDriver * trunkDriver
Definition: bayonne.h:1779
bool isIdle(void)
Return if the session is currently idle.
Definition: bayonne.h:3095
static unsigned count
Definition: bayonne.h:880
Audio::Level getAudioLevel(void)
Get the audio level for silence detection.
Definition: bayonne.h:2192
timeslot_t getSlot(void)
Return server timeslot this session uses.
Definition: bayonne.h:3087
const char * resuri
Definition: bayonne.h:3277
#define RPC_MAX_PARAMS
Definition: bayonne.h:61
interface_t getInterface(void)
Return interface type of this session.
Definition: bayonne.h:3063
const char * getSessionJoined(void)
Definition: bayonne.h:2902
timeout_t framing
Definition: bayonne.h:799
tpport_t zeroconf_port
Definition: bayonne.h:1311
class __EXPORT BayonneMsgport
Definition: bayonne.h:81
zeroconf_family_t zeroconf_family
Definition: bayonne.h:1322
BayonneDriver * driver
Definition: bayonne.h:2485
static RPCNode * getFirst(void)
Definition: bayonne.h:886
const char * name
Definition: bayonne.h:865
bridge_t
Type of bridge used for joining ports.
Definition: bayonne.h:344
const char * tid
Definition: bayonne.h:757
void clearEngine(BayonneSession *s)
Definition: bayonne.h:3416
This is a little class used to associate XMLRPC call method tables with our server.
Definition: bayonne.h:875
const char * protocol
Definition: bayonne.h:3261
unsigned code
Definition: bayonne.h:3268
static unsigned trap_count4
Definition: bayonne.h:255
timeout_t duration
Definition: bayonne.h:774
bool isDTMF(void)
Definition: bayonne.h:2671
This is an internal ring class for synchronized ringing.
Definition: bayonne.h:816
BayonneSession * parent
Definition: bayonne.h:737
timeslot_t tsfirst
Definition: bayonne.h:1741
Framework for portable audio processing and file handling classes.
Script::Name * script
Definition: bayonne.h:829
static timeslot_t getTimeslotsUsed(void)
Return total library timeslots used (highest used).
Definition: bayonne.h:1192
class __EXPORT Event
Definition: thread.h:141
const char * dial
Definition: bayonne.h:1021
const char * ignore
Definition: bayonne.h:987
Generic script class to hold master data types and various useful class encpasulated friend functions...
Definition: script3.h:99
BayonneMsgport * getMsgport(void)
Return the message port bound with this driver.
Definition: bayonne.h:2168
const char * getInitial(const char *id)
Definition: bayonne.h:229
const char * note
Definition: bayonne.h:968
Encoding encoding
Definition: bayonne.h:1641
static BayonneTranslator * init_translator
Definition: bayonne.h:306
static SOCKET trap_so4
Definition: bayonne.h:254
A core class to support language translation services in Bayonne phrasebook.
Definition: bayonne.h:1393
state_t
Call processing states offered in core library.
Definition: bayonne.h:358
const char * fname
Definition: bayonne.h:761
const char * name
Definition: bayonne.h:917
static BayonneTranslator langNone
Definition: bayonne.h:2479
The ThreadLock class impliments a thread rwlock for optimal reader performance on systems which have ...
Definition: thread.h:357
unsigned msgtail
Definition: bayonne.h:1740
const char * help
Definition: bayonne.h:867
static ScriptCommand * server
Definition: bayonne.h:282
static unsigned ts_trk
Definition: bayonne.h:283
const char * name
Definition: bayonne.h:932
libaudio_t * libaudio
Definition: bayonne.h:945
Bayonne specific dynamic keydata class.
Definition: bayonne.h:183
BayonneDriver * nextDriver
Definition: bayonne.h:1786
const char * homepath
Definition: bayonne.h:191
A span is a collection of ports under a single control interface or communication channel...
Definition: bayonne.h:2284
static AtomicCounter libexec_count
Definition: bayonne.h:309
static timeslot_t ts_limit
Definition: bayonne.h:285
Bayonnne specific static keydata class.
Definition: bayonne.h:159
static Mutex serialize
A mutex to serialize any direct console I/O operations.
Definition: bayonne.h:1049
RPCDefine * getMethods(void)
Definition: bayonne.h:895
BayonneDriver * driver
Definition: bayonne.h:3264
const char * errmsg
Definition: bayonne.h:769
timeout_t total
Definition: bayonne.h:960
static const char * path_tmp
Definition: bayonne.h:291
unsigned stack
Definition: bayonne.h:936
The AudioTone class is used to create a frame of audio encoded single or dualtones.
Definition: audio2.h:774
bool isOffhook(void)
Return hook state.
Definition: bayonne.h:3055
size_t audio_stack
Definition: bayonne.h:1796
timeslot_t getFirst(void)
Get first server timeslot this driver uses.
Definition: bayonne.h:2028
Offers interface bridge for embedded scripting engines through an abstract interface.
Definition: bayonne.h:3373
const char * voicelib
Definition: bayonne.h:1640
class __EXPORT BayonneSession
Definition: bayonne.h:83
The primary session object representing a server timeslot and active communication endpoint in Bayonn...
Definition: bayonne.h:2464
event_t
Primary event identifiers.
Definition: bayonne.h:464
static BayonneSession ** timeslots
Definition: bayonne.h:279
ScriptEngine * vm
Definition: bayonne.h:2499
#define __EXPORT
Definition: audio2.h:51
timeout_t synctimer
Definition: bayonne.h:1004
#define MAX_PATHNAME
Definition: bayonne.h:58
ScriptEngine * getEngine(void)
Definition: bayonne.h:2683
void transportFault(unsigned code, const char *string)
Definition: bayonne.h:3293
bool getBoolean(const char *id)
Definition: bayonne.h:170
volatile unsigned short active_calls
Definition: bayonne.h:1841
BayonneDriver * msgdriver
Definition: bayonne.h:1738
const char * encoding
Definition: bayonne.h:798
static timeslot_t ts_count
Definition: bayonne.h:286
zeroconf_family_t getFamily(void)
Definition: bayonne.h:1359
const char * menu
Definition: bayonne.h:967
timeout_t duration
Definition: bayonne.h:1005
timeslot_t timeslot
Definition: bayonne.h:1788
timeout_t getFlashTimer(void)
Get the programmed flash timer to signal trunk flash.
Definition: bayonne.h:2117
static time_t reload_time
Definition: bayonne.h:297
Every thread of execution in an application is created by instantiating an object of a class derived ...
Definition: thread.h:1093
The Event class implements a feature originally found in the WIN32 API; event notification.
Definition: thread.h:869
static unsigned long getStamp(void)
Definition: bayonne.h:849
const char * var
Definition: bayonne.h:984
struct timespec * getTimeout(struct timespec *spec, timeout_t timeout)
BayonneSession * lastIdle
Definition: bayonne.h:1784
static const char * path_prompts
Definition: bayonne.h:289
volatile unsigned short active_calls
Definition: bayonne.h:2302
result_t result
Definition: bayonne.h:943
const char * status
Definition: bayonne.h:707
BayonneZeroconf * zeroconf_next
Definition: bayonne.h:1309
BayonneConfig * next
Definition: bayonne.h:1375
const char * logstate
Definition: bayonne.h:793
unsigned getSpansUsed(void)
Get the number of span objects used by driver.
Definition: bayonne.h:2052
static timeslot_t getAvailTimeslots(void)
Return remaining timeslots available to allocate driver ports into.
Definition: bayonne.h:1209
Streaming buffer for audio, to be used in bgm audio sources.
Definition: bayonne.h:96
static timeslot_t getTimeslotCount(void)
Return total timeslots allocated for the server.
Definition: bayonne.h:1200
static BayonneZeroconf * zeroconf_first
Definition: bayonne.h:1308
calltype_t type
Definition: bayonne.h:2497
int SOCKET
Definition: socket.h:60
timeslot_t getTimeslot(void)
Definition: bayonne.h:2680
timeout_t framing
Definition: bayonne.h:1642
timeout_t lastdigit
Definition: bayonne.h:983
time_t getJoined(void)
Return time this call is joined or 0 if not child node.
Definition: bayonne.h:2926
void setInitial(const char *id, const char *val)
Definition: bayonne.h:231
An intermediary binder class for Bayonne engine.
Definition: bayonne.h:2411
const char * getId(void)
Get the id string.
Definition: bayonne.h:1603
const char * defVoicelib(void)
Definition: bayonne.h:2893
unsigned getSpanFirst(void)
Get the first span id used.
Definition: bayonne.h:2044
const char * prefix
Definition: bayonne.h:883
BayonneDriver * getDriver(void)
Get driver associated with this span.
Definition: bayonne.h:2372
BayonneDriver * getDriver(void)
Return driver associated with this session.
Definition: bayonne.h:2934
Bayonne Msgports are used to queue and post session events which normally have to be passed through a...
Definition: bayonne.h:1709
static timeout_t step_timer
Definition: bayonne.h:300
static unsigned idle_limit
Definition: bayonne.h:293
timeout_t hunt_timer
Definition: bayonne.h:1025
size_t bufused
Definition: bayonne.h:3259
const char * dialing
Definition: bayonne.h:738
DynamicKeydata * nextConfig
Definition: bayonne.h:189
const char * exit
Definition: bayonne.h:966
static unsigned spans
Definition: bayonne.h:2292
static Traffic total_call_attempts
master traffic counters for call attempts and call completions.
Definition: bayonne.h:1059
unsigned long position
Definition: bayonne.h:105
static timeout_t exec_timer
Definition: bayonne.h:302
BayonneTranslator * next
Definition: bayonne.h:1397
bridge_t getBridge(void)
Return bridge type for joins.
Definition: bayonne.h:3071
The AtomicCounter class offers thread-safe manipulation of an integer counter.
Definition: thread.h:535
const char * voicelib
Definition: bayonne.h:2869
static BayonneService * first
Definition: bayonne.h:3314
const char * getSessionParent(void)
Definition: bayonne.h:2899
timeout_t getHangupTimer(void)
Get the hangup timer for hang time before going idle.
Definition: bayonne.h:2085
static unsigned ts_ext
Definition: bayonne.h:284
const char * name
Definition: bayonne.h:1787
void setEngine(BayonneSession *s)
Set vm session.
Definition: bayonne.h:3422
const char * action
Definition: bayonne.h:3276
unsigned getCount(void)
Definition: bayonne.h:3280
const char * getType(void)
Get the binding protocol description, usually "_svc._proto".
Definition: bayonne.h:1348
unsigned getId(void)
Get the id associated with this span.
Definition: bayonne.h:2364
timeslot_t used
Definition: bayonne.h:2298
BayonneSession * peer
Definition: bayonne.h:1024
unsigned answer_count
Definition: bayonne.h:1801
const char * getString(const char *id)
Definition: bayonne.h:164
unsigned short call_limit
Definition: bayonne.h:708
uint16 getEventSequence(void)
Get event sequence id.
Definition: bayonne.h:2716
Network addresses and sockets related classes.
void setValue(const char *sym, const char *data)
Set (replace) the value of a given keyword.
timeout_t timeout
Definition: bayonne.h:933
static unsigned idle_count
Definition: bayonne.h:292
const char * name
Definition: bayonne.h:786
Keydata * keys
Definition: bayonne.h:192
static const char * init_voicelib
Definition: bayonne.h:307
timeout_t getReleaseTimer(void)
Get the release timer when releasing a trunk.
Definition: bayonne.h:2077
unsigned long timeout_t
Definition: audio2.h:104
static volatile bool image_loaded
Definition: bayonne.h:304
Audio::Level level
Definition: bayonne.h:959
unsigned count
Definition: bayonne.h:952
static BayonneZeroconf * getFirst(void)
Get the first zeroconf binding, used by zeroconf plugins.
Definition: bayonne.h:1332
The event data structure includes the event identifier and any paramaters.
Definition: bayonne.h:721
Audio::Level audio_level
Definition: bayonne.h:1797
bool isHolding(void)
Definition: bayonne.h:3126
StreamingBuffer * next
Definition: bayonne.h:100
Traffic call_complete
Definition: bayonne.h:2301
BayonneMsgport * msgport
Definition: bayonne.h:1785
static BayonneDriver * getProtocol(void)
Return primary protocol driver...
Definition: bayonne.h:1903
This class holds the bound keyword set for a given Bayonne style script interpreter.
Definition: script3.h:343
const char * string
Definition: bayonne.h:3269
timeslot_t timeslot
Definition: bayonne.h:724
Handler logstate
Definition: bayonne.h:931
Offers core Bayonne audio processing in a self contained class.
Definition: bayonne.h:1615
const char * userid
Definition: bayonne.h:705
long getValue(const char *id)
Definition: bayonne.h:167
size_t bufsize
Definition: bayonne.h:3258
static RPCNode * first
Definition: bayonne.h:879
unsigned id
Definition: bayonne.h:2295
const char * type
Definition: bayonne.h:706
const char * id
Definition: bayonne.h:1376
unsigned ring_count
Definition: bayonne.h:2871
BayonneTranslator * getTranslator(void)
Get the current language translator.
Definition: bayonne.h:2824
const char * getTid(void)
Get the current transaction identifier string for the session.
Definition: bayonne.h:3204