aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xchannels/Makefile4
-rwxr-xr-xconfigs/modem.conf.sample42
-rwxr-xr-xinclude/asterisk/vmodem.h108
3 files changed, 152 insertions, 2 deletions
diff --git a/channels/Makefile b/channels/Makefile
index 7d68f258f..1f0b790d2 100755
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -3,7 +3,7 @@
#
# Makefile for Channel backends (dynamically loaded)
#
-# Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+# Copyright (C) 1999, Mark Spencer
#
# Mark Spencer <markster@linux-support.net>
#
@@ -11,7 +11,7 @@
# the GNU General Public License
#
-CHANNEL_LIBS=chan_vofr.so chan_ixj.so
+CHANNEL_LIBS=chan_vofr.so chan_ixj.so chan_modem.so chan_modem_aopen.so
CFLAGS+=#-DVOFRDUMPER
diff --git a/configs/modem.conf.sample b/configs/modem.conf.sample
new file mode 100755
index 000000000..27b3230f4
--- /dev/null
+++ b/configs/modem.conf.sample
@@ -0,0 +1,42 @@
+;
+; Internet Phone Jack
+;
+; Configuration file
+;
+[interfaces]
+;
+; By default, incoming calls should come in on the "remote" context
+;
+context=remote
+;
+; Modem Drivers to load
+;
+driver=aopen
+;
+; We can optionally override the auto detection. This is necessary
+; particularly if asterisk does not know about our kind of modem.
+;
+;type=autodetect
+;type=aopen
+;
+; We can strip a given number of digits on outgoing dialing, so, for example
+; you can have it dial "8871042" when given "98871042".
+;
+stripmsd=1
+;
+; Type of dialing
+;
+;dialtype=tone
+dialtype=pulse
+;
+; Mode selection. "Immediate" means that as soon as you dial, you're connected
+; and the line is considered up. "Ring" means we wait until the ring cadence
+; occurs at least once. "Answer" means we wait until the other end picks up.
+;
+;mode=answer
+;mode=ring
+mode=immediate
+;
+; List all devices we can use.
+;
+device=/dev/ttyS3
diff --git a/include/asterisk/vmodem.h b/include/asterisk/vmodem.h
new file mode 100755
index 000000000..a45fbdf71
--- /dev/null
+++ b/include/asterisk/vmodem.h
@@ -0,0 +1,108 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Voice Modem Definitions
+ *
+ * Copyright (C) 1999, Mark Spencer
+ *
+ * Mark Spencer <markster@linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#ifndef _ASTERISK_VMODEM_H
+#define _ASTERISK_VMODEM_H
+
+#include <asterisk/frame.h>
+#include <asterisk/channel.h>
+
+#define CHAR_DLE 0x10
+#define CHAR_ETX 0x03
+
+#define MODEM_DEV_TELCO 0
+#define MODEM_DEV_TELCO_SPK 4
+#define MODEM_DEV_SPKRPHONE 6
+#define MODEM_DEV_HANDSET 9
+
+/* Thirty millisecond sections */
+#define MODEM_MAX_LEN 30
+#define MODEM_MAX_BUF MODEM_MAX_LEN * 16
+
+#define AST_MAX_INIT_STR 256
+
+struct ast_modem_pvt;
+
+struct ast_modem_driver {
+ char *name;
+ char **idents;
+ int formats;
+ int fullduplex;
+ void (*incusecnt)();
+ void (*decusecnt)();
+ char * (*identify)(struct ast_modem_pvt *);
+ int (*init)(struct ast_modem_pvt *);
+ int (*setdev)(struct ast_modem_pvt *, int dev);
+ struct ast_frame * (*read)(struct ast_modem_pvt *);
+ int (*write)(struct ast_modem_pvt *, struct ast_frame *fr);
+ int (*dial)(struct ast_modem_pvt *, char *);
+ int (*answer)(struct ast_modem_pvt *);
+ int (*hangup)(struct ast_modem_pvt *);
+ int (*startrec)(struct ast_modem_pvt *);
+ int (*stoprec)(struct ast_modem_pvt *);
+ int (*startpb)(struct ast_modem_pvt *);
+ int (*stoppb)(struct ast_modem_pvt *);
+ int (*setsilence)(struct ast_modem_pvt *, int onoff);
+ int (*dialdigit)(struct ast_modem_pvt *, char digit);
+ struct ast_modem_driver *next;
+};
+
+#define MODEM_MODE_IMMEDIATE 0
+#define MODEM_MODE_WAIT_RING 1
+#define MODEM_MODE_WAIT_ANSWER 2
+
+struct ast_modem_pvt {
+ int fd; /* Raw file descriptor for this device */
+ FILE *f; /* FILE * representation of device */
+ struct ast_channel *owner; /* Channel we belong to, possibly NULL */
+ char dev[256]; /* Device name */
+ struct ast_frame fr; /* Frame */
+ char offset[AST_FRIENDLY_OFFSET];
+ char obuf[MODEM_MAX_BUF]; /* Outgoing buffer */
+ int tail;
+ char dialtype; /* Pulse or tone dialling */
+ char dialtimeout; /* Time to wait for dial timeout */
+ int obuflen;
+ int mode; /* Immediate, or wait for an answer */
+ int ministate; /* State of modem in miniature */
+ int stripmsd; /* Digits to strip on outgoing numbers */
+ char context[AST_MAX_EXTENSION];
+ char cid[AST_MAX_EXTENSION]; /* Caller ID if available */
+ char initstr[AST_MAX_INIT_STR]; /* Modem initialization String */
+ char response[256]; /* Static response buffer */
+ struct ast_modem_driver *mc; /* Modem Capability */
+ struct ast_modem_pvt *next; /* Next channel in list */
+};
+
+/* Register a driver */
+extern int ast_register_modem_driver(struct ast_modem_driver *mc);
+
+/* Unregister a driver */
+extern int ast_unregister_modem_driver(struct ast_modem_driver *mc);
+
+/* Send the command cmd (length len, or 0 if pure ascii) on modem */
+extern int ast_modem_send(struct ast_modem_pvt *p, char *cmd, int len);
+
+/* Wait for result to occur. Return non-zero if times out or error, last
+ response is stored in p->response */
+extern int ast_modem_expect(struct ast_modem_pvt *p, char *result, int timeout);
+
+/* Wait for result to occur. response is stored in p->response */
+extern int ast_modem_read_response(struct ast_modem_pvt *p, int timeout);
+
+/* Used by modem drivers to start up the PBX on a RING */
+extern struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state);
+
+/* Trim off trailing mess */
+extern void ast_modem_trim(char *s);
+#endif