first commit of chan_h323

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@724 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Jeremy McNamara 22 years ago
parent 9baba73625
commit 2b32a1bbb7

@ -0,0 +1,39 @@
Build
0.1.0
-- Intergration into the mainline Asterisk codebase
-- Remove reduandant debug info
-- Add Caller*id support
-- Inband DTMF
-- Retool port usage (to avoid possible seg fault condition)
0.0.6
-- Configurable support for user-input (DTMF)
-- Reworked Gatekeeper support
-- Native bridging (but is still broken, help!)
-- Locally implement a non-broken G.723.1 Capability
-- Utilize the cleaner RTP method implemented by Mark
-- AllowGkRouted, thanks to Panny from http://hotlinks.co.uk
-- Clened up inbound call flow
-- Prefix, E.164 and Gateway support
-- Multi-homed support
-- Killed more seg's
0.0.5
-- Added H.323 Alias support
-- Clened up inbound call flow
-- Fixed RTP port logic
-- Stomped on possible seg fault conditions thanks to Iain Stevenson
0.0.4
-- Fixed one-way audio on inbound calls. Found
race condition in monitor thread.
0.0.3
-- Changed name to chan_h323
-- Also renamed file names to futher avoid confusion
0.0.2
-- First public offering
-- removed most hardcoded values
-- lots of changes to alias/exension operation
0.0.1
-- initial build, lots of hardcoded crap
-- Proof of concept for External RTP

@ -0,0 +1,53 @@
# include the Makefile of OpenH323
ifndef OPENH323DIR
OPENH323DIR=$(HOME)/openh323
endif
ifndef PWLIBDIR
PWLIBDIR=$(HOME)/pwlib
endif
ifndef ASTERISKDIR
ASTERISKDIR= /usr/lib/asterisk/modules
endif
CFLAGS += -DNDEBUG -DDO_CRASH -DDEBUG_THREADS
CFLAGS = -pipe -Wall -fPIC -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -DP_LINUX -D_REENTRANT -D_GNU_SOURCE
# This needs to be updated to deal with more than just little endian machines
CFLAGS += -march=$(shell uname -m) -DPBYTE_ORDER=PLITTLE_ENDIAN
CFLAGS += -DP_HAS_SEMAPHORES -DP_SSL -DP_PTHREADS
CFLAGS += -DPHAS_TEMPLATES -DPTRACING -DP_USE_PRAGMA
CFLAGS += -I$(PWLIBDIR)/include/ptlib/unix -I$(PWLIBDIR)/include
CFLAGS += -I$(OPENH323DIR)/include -Wno-missing-prototypes -Wno-missing-declarations
all: chan_h323.so
noshared: chan_h323_s.so
optnoshared: chan_h323_s.so
debug: chan_h323_d.so
install: all
install -m 755 chan_h323.so $(ASTERISKDIR)
chan_h323.o: chan_h323.c
$(CC) -g -c -o $@ $(CFLAGS) $<
ast_h323.o: ast_h323.cpp
g++ -g -c -o $@ $(CFLAGS) $<
chan_h323.so: chan_h323.o ast_h323.o
g++ -shared -Xlinker -x -o chan_h323.so chan_h323.o ast_h323.o -L$(PWLIBDIR)/lib -lpt_linux_x86_r -L$(OPENH323DIR)/lib -lh323_linux_x86_r -L/usr/lib -lpthread -ldl -lcrypto -lssl -lexpat
chan_h323_d.so: chan_h323.o ast_h323.o
g++ -shared -Xlinker -x -o chan_h323.so chan_h323.o ast_h323.o -L$(PWLIBDIR)/lib -lpt_linux_x86_d -L$(OPENH323DIR)/lib -lh323_linux_x86_d -L/usr/lib -lpthread -ldl -lcrypto -lssl -lexpat
chan_h323_s.so: chan_h323.o ast_h323.o
g++ -shared -Xlinker -x -o chan_h323.so chan_h323.o ast_h323.o -L$(PWLIBDIR)/lib -lpt_linux_x86_r_s -L$(OPENH323DIR)/lib -lh323_linux_x86_r_s -L/usr/lib -lpthread -ldl -lcrypto -lssl -lexpat
clean:
rm -f *.o *.so core.*

@ -0,0 +1,55 @@
Open H.323 Channel Driver for Asterisk
By Jeremy McNamara
The NuFone Network
First public release on November 10th, 2002
Developed using: RedHat 7.2/7.3/8.0
Open H.323 v1.11.8
PWLib v1.4.12
GCC 2.96/3.1
Dependancies: openssl-0.9.6b
openssl-devel-0.9.6b
expat-1.95
Notice: Whatever you do, DO NOT USE distrubution specific installs
of Open H.323 and PWLib. Check everything out of CVS. If you dont know
how to deal with cvs, learn. Also, if you are not using the listed
versions of Open H.323 or PWlib you are on your own, sorry. Older versions
will NOT work, but newer versions ~should~ work.
We have implemented this driver using Asterisk's RTP stack insted of trying
to implement a psudo sound card driver.
If you have trouble please contact 'JerJer' in #Asterisk on irc.freenode.net or
send and email to jj@indie.org
If you happen to be lucky enough to segfault this code please run a backtrace
and send me the gory details. Segmentation faults are not tolerated!
bt example:
# /usr/sbin/asterisk -vvvgc
...
[chan_h323.so]
Segmentation Fault (core dumped)
# ls core.*
core.1976
# gdb /usr/sbin/asterisk core.1976
...
(gdb) bt
Send whatever shows up right after the 'bt'
Also, a full debug screen output is almost needed. Make sure you are in the full console mode (-c) and turn on 'h.323
debug'. A nice way to capture everything is to use the utility called 'script' (man script)
Jeremy McNamara, President
The NuFone Network

@ -0,0 +1,14 @@
The NuFone Network's Open H.323 Channel Driver for Asterisk
TODO:
- Fix Gatekeeper re-registration seg (HELP)
- Track down why calls to invalid extensions always
get sent to 's' in context 'default'
- H.323 Native Bridging
- Gatekeeping support (started)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,249 @@
/*
* h323wrap.h
*
* OpenH323 Channel Driver for ASTERISK PBX.
* By Jeremy McNamara
* For The NuFone Network
*
* This code has been derived from code created by
* Michael Manousos and Mark Spencer
*
* This file is part of the chan_h323 driver for Asterisk
*
* chan_h323 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* chan_h323 is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <ptlib.h>
#include <h323.h>
#include <h323pdu.h>
#include <mediafmt.h>
#include <lid.h>
#include <list>
#include <string>
#include <algorithm>
#include "chan_h323.h"
/** These need to be redefined here because the C++
side of this driver is blind to the asterisk headers */
/*! G.723.1 compression */
#define AST_FORMAT_G723_1 (1 << 0)
/*! GSM compression */
#define AST_FORMAT_GSM (1 << 1)
/*! Raw mu-law data (G.711) */
#define AST_FORMAT_ULAW (1 << 2)
/*! Raw A-law data (G.711) */
#define AST_FORMAT_ALAW (1 << 3)
/*! MPEG-2 layer 3 */
#define AST_FORMAT_MP3 (1 << 4)
/*! ADPCM (whose?) */
#define AST_FORMAT_ADPCM (1 << 5)
/*! Raw 16-bit Signed Linear (8000 Hz) PCM */
#define AST_FORMAT_SLINEAR (1 << 6)
/*! LPC10, 180 samples/frame */
#define AST_FORMAT_LPC10 (1 << 7)
/*! G.729A audio */
#define AST_FORMAT_G729A (1 << 8)
/*! SpeeX Free Compression */
#define AST_FORMAT_SPEEX (1 << 9)
/**This class describes the G.723.1 codec capability.
*/
class H323_G7231Capability : public H323AudioCapability
{
PCLASSINFO(H323_G7231Capability, H323AudioCapability);
public:
H323_G7231Capability(
BOOL annexA = TRUE /// Enable Annex A silence insertion descriptors
);
Comparison Compare(const PObject & obj) const;
PObject * Clone() const;
virtual H323Codec * CreateCodec(
H323Codec::Direction direction /// Direction in which this instance runs
) const;
unsigned GetSubType() const;
PString GetFormatName() const;
BOOL OnSendingPDU(
H245_AudioCapability & pdu, /// PDU to set information on
unsigned packetSize /// Packet size to use in capability
) const;
BOOL OnReceivedPDU(
const H245_AudioCapability & pdu, /// PDU to get information from
unsigned & packetSize /// Packet size to use in capability
);
protected:
BOOL annexA;
};
class MyH323EndPoint : public H323EndPoint {
PCLASSINFO(MyH323EndPoint, H323EndPoint);
public:
int MakeCall(const PString &, PString &, unsigned int *, unsigned int);
BOOL ClearCall(const PString &);
// BOOL OnIncomingCall( H323Connection & connection, const H323SignalPDU &, H323SignalPDU &);
void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
void OnConnectionEstablished(H323Connection &, const PString &);
void OnConnectionCleared(H323Connection &, const PString &);
H323Connection * CreateConnection(unsigned, void *);
void SendUserTone(const PString &, char);
H323Capabilities GetCapabilities(void);
PStringArray SupportedPrefixes;
void SetEndpointTypeInfo( H225_EndpointType & info ) const;
void SetGateway(void);
};
class MyH323Connection : public H323Connection {
PCLASSINFO(MyH323Connection, H323Connection);
public:
MyH323Connection(MyH323EndPoint &, unsigned, unsigned, WORD);
~MyH323Connection();
H323Channel * CreateRealTimeLogicalChannel(const H323Capability &, H323Channel::Directions, unsigned,
const H245_H2250LogicalChannelParameters *);
H323Connection::AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
BOOL OnAlerting(const H323SignalPDU &, const PString &);
BOOL OnReceivedSignalSetup(const H323SignalPDU &);
void OnReceivedReleaseComplete(const H323SignalPDU &);
BOOL OnSendSignalSetup(H323SignalPDU &);
BOOL OnStartLogicalChannel(H323Channel &);
BOOL OnClosingLogicalChannel(H323Channel &);
void SendUserInputTone(char, unsigned);
void OnUserInputTone(char, unsigned, unsigned, unsigned);
void OnUserInputString(const PString &value);
PString sourceAliases;
PString destAliases;
PString sourceE164;
PString destE164;
PIPSocket::Address externalIpAddress; // IP address of media server
PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint
WORD externalPort; // local media server Data port (control is dataPort+1)
WORD remotePort; // remote endpoint Data port (control is dataPort+1)
};
#if 0
class MyGatekeeperServer : public H323GatekeeperServer
{
PCLASSINFO(MyGatekeeperServer, H323GatekeeperServer);
public:
MyGatekeeperServer(MyH323EndPoint & ep);
// Overrides
virtual H323GatekeeperCall * CreateCall(
const OpalGloballyUniqueID & callIdentifier,
H323GatekeeperCall::Direction direction
);
virtual BOOL TranslateAliasAddressToSignalAddress(
const H225_AliasAddress & alias,
H323TransportAddress & address
);
// new functions
BOOL Initialise();
private:
class RouteMap : public PObject {
PCLASSINFO(RouteMap, PObject);
public:
RouteMap(
const PString & alias,
const PString & host
);
RouteMap(
const RouteMap & map
) : alias(map.alias), regex(map.alias), host(map.host) { }
void PrintOn(
ostream & strm
) const;
BOOL IsValid() const;
BOOL IsMatch(
const PString & alias
) const;
const H323TransportAddress & GetHost() const { return host; }
private:
PString alias;
PRegularExpression regex;
H323TransportAddress host;
};
PList<RouteMap> routes;
PMutex reconfigurationMutex;
};
#endif
/**
* The MyProcess is a necessary descendant PProcess class so that the H323EndPoint
* objected to be created from within that class. (Who owns main() problem).
*/
class MyProcess : public PProcess {
PCLASSINFO(MyProcess, PProcess);
public:
MyProcess();
~MyProcess();
void Main();
};
/**
* This class handles the termination of a call.
* Note that OpenH323 Library requires that the termination
* of a call should be done inside a separate thread of execution.
*/
class ClearCallThread : public PThread {
PCLASSINFO(ClearCallThread, PThread);
public:
ClearCallThread(const char *tc);
~ClearCallThread();
void Main();
protected:
PString token;
};

File diff suppressed because it is too large Load Diff

@ -0,0 +1,186 @@
/*
* chan_oh323.h
*
* OpenH323 Channel Driver for ASTERISK PBX.
* By Jeremy McNamara
* For The NuFone Network
*
* This code has been derived from code created by
* Michael Manousos and Mark Spencer
*
* This file is part of the chan_oh323 driver for Asterisk
*
* chan_oh323 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* chan_oh323 is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <arpa/inet.h>
static struct sockaddr_in bindaddr;
/* structure to hold the valid asterisk users */
struct oh323_user {
char name[80];
char context[80];
char secret[80];
char callerid[80];
char accountcode[20];
int amaflags;
int noFastStart;
int noH245Tunneling;
int noSilenceSuppression;
int inUse;
int incominglimit;
int bridge;
int nat;
int dtmfmode;
struct ast_ha *ha;
struct sockaddr_in addr;
struct oh323_user *next;
};
/* structure to hold the valid asterisk peers
All peers are registered to a GK if there is one */
struct oh323_peer {
char name[80];
char context[80];
int noFastStart;
int noH245Tunneling;
int noSilenceSuppression;
int inUse;
int outgoinglimit;
int bridge;
int nat;
int dtmfmode;
struct sockaddr_in addr;
int delme;
struct oh323_peer *next;
};
/* structure to hold the H.323 aliases which get registered to
the H.323 endpoint and gatekeeper */
struct oh323_alias {
char name[80];
char e164[20]; /* tells a GK to route this E.164 to this alias */
char prefix[500]; /* tells a GK this alias supports these prefixes */
char secret[20]; /* the H.235 password to send to the GK for authentication */
char context[80];
struct oh323_alias *next;
};
/** call_option struct is filled from the
PBX application and passed through make_call
function*/
typedef struct call_options {
int noFastStart;
int noH245Tunnelling;
int noSilenceSuppression;
int jitter;
unsigned int port;
} call_options_t;
/** call_details struct call detail records
to asterisk for processing and used for matching up
asterisk channels to acutal h.323 connections */
typedef struct call_details {
unsigned int call_reference;
const char *call_token;
const char *call_source_aliases;
const char *call_dest_alias;
const char *call_source_e164;
const char *call_dest_e164;
const char *sourceIp;
} call_details_t;
/* This is a callback prototype function, called pass
DTMF down the RTP. */
typedef int (*send_digit_cb)(unsigned, char);
send_digit_cb on_send_digit;
/* This is a callback prototype function, called to collect
the external RTP port from Asterisk. */
typedef int (*on_connection_cb)(unsigned);
on_connection_cb on_create_connection;
/* This is a callback prototype function, called upon
an incoming call happens. */
typedef int (*setup_incoming_cb)(call_details_t);
setup_incoming_cb on_incoming_call;
/* This is a callback prototype function, called upon
an outbound call. */
typedef int (*setup_outbound_cb)(call_details_t);
setup_outbound_cb on_outgoing_call;
/* This is a callback prototype function, called when the openh323
OnStartLogicalChannel is invoked. */
typedef void (*start_logchan_cb)(unsigned int, const char *, int);
start_logchan_cb on_start_logical_channel;
/* This is a callback protoype function, called when the openh323
OnConnectionEstablished is inovked */
typedef void (*con_established_cb)(unsigned);
con_established_cb on_connection_established;
/* This is a callback prototype function, called when the openH323
OnConnectionCleared callback is invoked */
typedef void (*clear_con_cb)(call_details_t);
clear_con_cb on_connection_cleared;
/* debug flag */
int h323debug;
#define H323_DTMF_RFC2833 (1 << 0)
#define H323_DTMF_INBAND (1 << 1)
#ifdef __cplusplus
extern "C" {
#endif
void h323_gk_urq(void);
void h323_end_point_create(void);
void h323_end_process(void);
int end_point_exist(void);
void h323_debug(int, unsigned);
/* callback function handler*/
void h323_callback_register(setup_incoming_cb, setup_outbound_cb, on_connection_cb, start_logchan_cb, clear_con_cb, con_established_cb, send_digit_cb);
int h323_set_capability(int, int);
int h323_set_alias(struct oh323_alias *);
int h323_set_gk(int, char *, char *);
/* H323 listener related funcions */
int h323_start_listener(int, struct sockaddr_in, int);
void h323_native_bridge(const char *, char *, char *);
/* Send a DTMF tone to remote endpoint */
void h323_send_tone(const char *call_token, char tone);
/* H323 create and destroy sessions */
int h323_make_call(char *host, call_details_t *cd, call_options_t);
int h323_clear_call(const char *);
int h323_answering_call(const char *token, int);
int h323_show_codec(int fd, int argc, char *argv[]);
#ifdef __cplusplus
}
#endif

@ -0,0 +1,138 @@
; The NuFone Network's
; Open H.323 driver configuration
;
[general]
port = 1720
bindaddr = 0.0.0.0
;tos=lowdelay
;
; You may specify a global default AMA flag for iaxtel calls. It must be
; one of 'default', 'omit', 'billing', or 'documentation'. These flags
; are used in the generation of call detail records.
;
;amaflags = default
;
; You may specify a default account for Call Detail Records in addition
; to specifying on a per-user basis
;
;accountcode=lss0101
;
; You can fine tune codecs here using "allow" and "disallow" clauses
; with specific codecs. Use "all" to represent all formats.
;
;allow=all ; turns on all installed codecs
;disallow=g723.1 ; Hm... Proprietary, don't use it...
;allow=gsm ; Always allow GSM, it's cool :)
;allow=ulaw
;
; Options for broken H.323 stacks
;noFastStart = no
;noH245Tunneling = no
;noSilenceSuppression = no
;
; jitter buffer
;jitter = 100
;
; User-Input Mode (DTMF)
;
; valid entries are: rfc2833, inband
; default is rfc2833
;dtmfmode=rfc2833
;
; Set the gatekeeper
; DISCOVER - Find the Gk address using multicast
; DISABLE - Disable the use of a GK
; <IP address> or <Host name> - The acutal IP address or hostname of your GK
;gatekeeper = DISABLE
;
;
; Tell Asterisk whether or not to accept Gatekeeper
; routed calls or not. Normally this should always
; be set to yes, unless you want to have finer control
; over which users are allowed access to Asterisk.
; Default: YES
;
;AllowGKRouted = yes
;
; Default context gets used in siutations where you are using
; the GK routed model or no type=user was found. This gives you
; the ability to either play an invalid message or to simply not
; use user authentication at all.
;
;context=default
;
; H.323 Alias definitions
;
; Type 'h323' will register aliases to the endpoint
; and Gatekeeper, if there is one.
;
; Example: if someone calls time@your.asterisk.box.com
; Asterisk will send the call to the extension 'time'
; in the context default
;
; [default]
; exten => time,1,Answer
; exten => time,2,Playback,current-time
;
; Keyword's 'prefix' and 'e164' are only make sense when
; used with a gatekeeper. You can specify either a prefix
; or E.164 this endpoint is responsible for terminating.
;
; Example: The H.323 alias 'det-gw' will tell the gatekeeper
; to route any call with the prefix 1248 to this alias. Keyword
; e164 is used when you want to specifiy a full telephone
; number. So a call to the number 18102341212 would be
; routed to the H.323 alias 'time'.
;
;[time]
;type=h323
;e164=18102341212
;context=default
;
;[det-gw]
;type=h323
;prefix=1248,1313
;context=detroit
;
;
; Inbound H.323 calls from BillyBob would land in the incoming
; context with a maximum of 4 concurrent incoming calls
; using a password of 'supersecret'
;
; Note: If keywords 'outgoinglimit' or 'incominglimit' are omitted
; Asterisk will not enforce any maximum number of concurrent calls.
;
; If you wish to use Authentication you need to set the approprate
; auth keyword above.
;
;[BillyBob]
;type=user
;secret=supersecret
;context=incoming
;incominglimit=4
;
; Asterisk would allow 2 concurrent outgoing calls to JoeSmow
; using 192.168.1.15 as his IP and will use the context outbound
;
;[JoeSmo]
;type=peer
;host=192.168.1.15
;context=outgoing
;outgoinglimit=2
;
; Asterisk would allow 6 concurrent incoming calls to be
; recieved from and 4 concurrent outgoing calls to be placed
; to SouthOffice using 192.168.0.2 as his IP and
; 'securepassword' has the password and lands in the
; default context
;
;[SouthOffice]
;type=friend
;host=192.168.0.2
;secret=securepassword
;context=default
;incominglimit=6
;outgoinglimit=4
Loading…
Cancel
Save