dect
/
asterisk
Archived
13
0
Fork 0

Move Asterisk-addons modules into the main Asterisk source tree.

Someone asked yesterday, "is there a good reason why we can't just put these
modules in Asterisk?".  After a brief discussion, as long as the modules are
clearly set aside in their own directory and not enabled by default, it is
perfectly fine.

For more information about why a module goes in addons, see README-addons.txt.

chan_ooh323 does not currently compile as it is behind some trunk API updates.
However, it will not build by default, so it should be okay for now.


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@204413 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
russell 2009-06-30 16:40:38 +00:00
parent b85bdd32a7
commit e9d15cbea7
113 changed files with 190907 additions and 32 deletions

View File

@ -293,7 +293,7 @@ endif
# value directly to ASTCFLAGS
ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS)
MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res $(LOCAL_MOD_SUBDIRS)
MOD_SUBDIRS:=addons channels pbx apps codecs formats cdr cel bridges funcs tests main res $(LOCAL_MOD_SUBDIRS)
OTHER_SUBDIRS:=utils agi
SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)

27
README-addons.txt Normal file
View File

@ -0,0 +1,27 @@
===============================================================================
=== Asterisk Add-on Modules ===
===============================================================================
This document pertains to the modules that reside in the addons/
subdirectory of the source tree. By default, these modules are not compiled
and installed. If you choose to enable them, you must be aware of what
potential licensing and/or patent implications that has on your usage and
distribution of Asterisk.
Even though Asterisk is released as open source under the terms of the
GPLv2 (see LICENSE for details), no core functionality in Asterisk has any
dependencies on libraries that are licensed under the GPL. One reason a module
may be in the add-ons category is that it may have a GPL dependency. Since
these dependencies are not compatible with dual licensing of Asterisk, the
dependant modules are set aside to make it clear that they may not be used
with commercial versions of Asterisk, unless other licensing arrangements are
made with the copyright holders of those dependencies.
Another reason that modules may be set aside is that there may be
additional restrictions on the usage of the code imposed by the license or
related patents. The MySQL and MP3 modules are examples of this.
If you have any questions, contact your lawyer.
===============================================================================
===============================================================================

View File

@ -20,6 +20,11 @@
From 1.6.2 to 1.6.3:
* Asterisk-addons no longer exists as an independent package. Those modules
now live in the addons directory of the main Asterisk source tree. They
are not enabled by default. For more information about why modules live in
addons, see README-addons.txt.
* The rarely used 'event_log' and LOG_EVENT channel have been removed; the few
users of this channel in the tree have been converted to LOG_NOTICE or removed
(in cases where the same message was already generated to another channel).

43
addons/Makefile Normal file
View File

@ -0,0 +1,43 @@
#
# Asterisk -- A telephony toolkit for Linux.
#
# Makefile for Add-on Modules
#
# Copyright (C) 2009, Digium, Inc.
#
# This program is free software, distributed under the terms of
# the GNU General Public License
#
-include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps
MODULE_PREFIX=app bridge cdr cel chan codec format func pbx res test
MENUSELECT_CATEGORY=Addons
MENUSELECT_DESCRIPTION=Add-ons (See README-addons.txt)
H323OBJS:=ooCmdChannel.o ooLogChan.o ooUtils.o ooGkClient.o context.o \
ooDateTime.o decode.o dlist.o encode.o errmgmt.o \
memheap.o ootrace.o oochannels.o ooh245.o ooports.o \
ooq931.o ooCapability.o ooSocket.o perutil.o eventHandler.o \
ooCalls.o ooStackCmds.o ooh323.o ooh323ep.o printHandler.o \
rtctype.o ooTimer.o h323/H235-SECURITY-MESSAGESDec.o \
h323/H235-SECURITY-MESSAGESEnc.o h323/H323-MESSAGES.o h323/H323-MESSAGESDec.o \
h323/H323-MESSAGESEnc.o h323/MULTIMEDIA-SYSTEM-CONTROL.o \
h323/MULTIMEDIA-SYSTEM-CONTROLDec.o h323/MULTIMEDIA-SYSTEM-CONTROLEnc.o
H323CFLAGS:=-Iooh323c/src -Iooh323c/src/h323
all: _all
include $(ASTTOPDIR)/Makefile.moddir_rules
clean::
$(MAKE) -C mp3 clean
rm -f $(addprefix ooh323c/src/,$(H323OBJS))
$(if $(filter format_mp3,$(EMBEDDED_MODS)),modules.link,format_mp3.so): mp3/common.o mp3/dct64_i386.o mp3/decode_ntom.o mp3/layer3.o mp3/tabinit.o mp3/interface.o
chan_ooh323.o: ASTCFLAGS+=$(H323CFLAGS)
$(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): ASTCFLAGS+=$(H323CFLAGS)
$(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o

View File

@ -0,0 +1,611 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2004, Constantine Filin and Christos Ricudis
*
* Christos Ricudis <ricudis@itc.auth.gr>
* Constantine Filin <cf@intermedia.net>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief MYSQL dialplan application
* \ingroup applications
*/
/*** MODULEINFO
<depend>mysqlclient</depend>
<defaultenabled>no</defaultenabled>
***/
#include "asterisk.h"
#include <mysql/mysql.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/linkedlists.h"
#include "asterisk/chanvars.h"
#include "asterisk/lock.h"
#include "asterisk/options.h"
#include "asterisk/app.h"
#include "asterisk/config.h"
#define EXTRA_LOG 0
enum { NULLSTRING, NULLVALUE, EMPTYSTRING } nullvalue = NULLSTRING;
static const char app[] = "MYSQL";
static const char synopsis[] = "Do several mySQLy things";
static const char descrip[] =
"MYSQL(): Do several mySQLy things\n"
"Syntax:\n"
" MYSQL(Set timeout <num>)\n"
" Set the connection timeout, in seconds.\n"
" MYSQL(Connect connid dhhost dbuser dbpass dbname)\n"
" Connects to a database. Arguments contain standard MySQL parameters\n"
" passed to function mysql_real_connect. Connection identifer returned\n"
" in ${connid}\n"
" MYSQL(Query resultid ${connid} query-string)\n"
" Executes standard MySQL query contained in query-string using established\n"
" connection identified by ${connid}. Result of query is stored in ${resultid}.\n"
" MYSQL(Nextresult resultid ${connid}\n"
" If last query returned more than one result set, it stores the next\n"
" result set in ${resultid}. It's useful with stored procedures\n"
" MYSQL(Fetch fetchid ${resultid} var1 var2 ... varN)\n"
" Fetches a single row from a result set contained in ${result_identifier}.\n"
" Assigns returned fields to ${var1} ... ${varn}. ${fetchid} is set TRUE\n"
" if additional rows exist in result set.\n"
" MYSQL(Clear ${resultid})\n"
" Frees memory and datastructures associated with result set.\n"
" MYSQL(Disconnect ${connid})\n"
" Disconnects from named connection to MySQL.\n"
" On exit, always returns 0. Sets MYSQL_STATUS to 0 on success and -1 on error.\n";
/*
EXAMPLES OF USE :
exten => s,2,MYSQL(Connect connid localhost asterisk mypass credit)
exten => s,3,MYSQL(Query resultid ${connid} SELECT username,credit FROM credit WHERE callerid=${CALLERIDNUM})
exten => s,4,MYSQL(Fetch fetchid ${resultid} datavar1 datavar2)
exten => s,5,GotoIf(${fetchid}?6:8)
exten => s,6,Festival("User ${datavar1} currently has credit balance of ${datavar2} dollars.")
exten => s,7,Goto(s,4)
exten => s,8,MYSQL(Clear ${resultid})
exten => s,9,MYSQL(Disconnect ${connid})
*/
AST_MUTEX_DEFINE_STATIC(_mysql_mutex);
#define MYSQL_CONFIG "mysql.conf"
#define AST_MYSQL_ID_DUMMY 0
#define AST_MYSQL_ID_CONNID 1
#define AST_MYSQL_ID_RESID 2
#define AST_MYSQL_ID_FETCHID 3
static int autoclear = 0;
static void mysql_ds_destroy(void *data);
static void mysql_ds_fixup(void *data, struct ast_channel *oldchan, struct ast_channel *newchan);
static struct ast_datastore_info mysql_ds_info = {
.type = "APP_ADDON_SQL_MYSQL",
.destroy = mysql_ds_destroy,
.chan_fixup = mysql_ds_fixup,
};
struct ast_MYSQL_id {
struct ast_channel *owner;
int identifier_type; /* 0=dummy, 1=connid, 2=resultid */
int identifier;
void *data;
AST_LIST_ENTRY(ast_MYSQL_id) entries;
} *ast_MYSQL_id;
AST_LIST_HEAD(MYSQLidshead,ast_MYSQL_id) _mysql_ids_head;
static void mysql_ds_destroy(void *data)
{
/* Destroy any IDs owned by the channel */
struct ast_MYSQL_id *i;
if (AST_LIST_LOCK(&_mysql_ids_head)) {
ast_log(LOG_WARNING, "Unable to lock identifiers list\n");
} else {
AST_LIST_TRAVERSE_SAFE_BEGIN(&_mysql_ids_head, i, entries) {
if (i->owner == data) {
AST_LIST_REMOVE_CURRENT(entries);
if (i->identifier_type == AST_MYSQL_ID_CONNID) {
/* Drop connection */
mysql_close(i->data);
} else if (i->identifier_type == AST_MYSQL_ID_RESID) {
/* Drop result */
mysql_free_result(i->data);
}
ast_free(i);
}
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&_mysql_ids_head);
}
}
static void mysql_ds_fixup(void *data, struct ast_channel *oldchan, struct ast_channel *newchan)
{
/* Destroy any IDs owned by the channel */
struct ast_MYSQL_id *i;
if (AST_LIST_LOCK(&_mysql_ids_head)) {
ast_log(LOG_WARNING, "Unable to lock identifiers list\n");
} else {
AST_LIST_TRAVERSE_SAFE_BEGIN(&_mysql_ids_head, i, entries) {
if (i->owner == data) {
AST_LIST_REMOVE_CURRENT(entries);
if (i->identifier_type == AST_MYSQL_ID_CONNID) {
/* Drop connection */
mysql_close(i->data);
} else if (i->identifier_type == AST_MYSQL_ID_RESID) {
/* Drop result */
mysql_free_result(i->data);
}
ast_free(i);
}
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&_mysql_ids_head);
}
}
/* helpful procs */
static void *find_identifier(int identifier, int identifier_type)
{
struct MYSQLidshead *headp = &_mysql_ids_head;
struct ast_MYSQL_id *i;
void *res=NULL;
int found=0;
if (AST_LIST_LOCK(headp)) {
ast_log(LOG_WARNING, "Unable to lock identifiers list\n");
} else {
AST_LIST_TRAVERSE(headp, i, entries) {
if ((i->identifier == identifier) && (i->identifier_type == identifier_type)) {
found = 1;
res = i->data;
break;
}
}
if (!found) {
ast_log(LOG_WARNING, "Identifier %d, identifier_type %d not found in identifier list\n", identifier, identifier_type);
}
AST_LIST_UNLOCK(headp);
}
return res;
}
static int add_identifier(struct ast_channel *chan, int identifier_type, void *data)
{
struct ast_MYSQL_id *i = NULL, *j = NULL;
struct MYSQLidshead *headp = &_mysql_ids_head;
int maxidentifier = 0;
if (AST_LIST_LOCK(headp)) {
ast_log(LOG_WARNING, "Unable to lock identifiers list\n");
return -1;
} else {
i = malloc(sizeof(*i));
AST_LIST_TRAVERSE(headp, j, entries) {
if (j->identifier > maxidentifier) {
maxidentifier = j->identifier;
}
}
i->identifier = maxidentifier + 1;
i->identifier_type = identifier_type;
i->data = data;
i->owner = chan;
AST_LIST_INSERT_HEAD(headp, i, entries);
AST_LIST_UNLOCK(headp);
}
return i->identifier;
}
static int del_identifier(int identifier, int identifier_type)
{
struct ast_MYSQL_id *i;
struct MYSQLidshead *headp = &_mysql_ids_head;
int found = 0;
if (AST_LIST_LOCK(headp)) {
ast_log(LOG_WARNING, "Unable to lock identifiers list\n");
} else {
AST_LIST_TRAVERSE(headp, i, entries) {
if ((i->identifier == identifier) &&
(i->identifier_type == identifier_type)) {
AST_LIST_REMOVE(headp, i, entries);
free(i);
found = 1;
break;
}
}
AST_LIST_UNLOCK(headp);
}
if (found == 0) {
ast_log(LOG_WARNING, "Could not find identifier %d, identifier_type %d in list to delete\n", identifier, identifier_type);
return -1;
} else {
return 0;
}
}
static int set_asterisk_int(struct ast_channel *chan, char *varname, int id)
{
if (id >= 0) {
char s[12] = "";
snprintf(s, sizeof(s), "%d", id);
ast_debug(5, "MYSQL: setting var '%s' to value '%s'\n", varname, s);
pbx_builtin_setvar_helper(chan, varname, s);
}
return id;
}
static int add_identifier_and_set_asterisk_int(struct ast_channel *chan, char *varname, int identifier_type, void *data)
{
return set_asterisk_int(chan, varname, add_identifier(chan, identifier_type, data));
}
static int safe_scan_int(char **data, char *delim, int def)
{
char *end;
int res = def;
char *s = strsep(data, delim);
if (s) {
res = strtol(s, &end, 10);
if (*end)
res = def; /* not an integer */
}
return res;
}
static int aMYSQL_set(struct ast_channel *chan, char *data)
{
char *var, *tmp;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(set);
AST_APP_ARG(variable);
AST_APP_ARG(value);
);
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
if (args.argc == 3) {
var = alloca(6 + strlen(args.variable) + 1);
sprintf(var, "MYSQL_%s", args.variable);
/* Make the parameter case-insensitive */
for (tmp = var + 6; *tmp; tmp++)
*tmp = toupper(*tmp);
pbx_builtin_setvar_helper(chan, var, args.value);
}
return 0;
}
/* MYSQL operations */
static int aMYSQL_connect(struct ast_channel *chan, char *data)
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(connect);
AST_APP_ARG(connid);
AST_APP_ARG(dbhost);
AST_APP_ARG(dbuser);
AST_APP_ARG(dbpass);
AST_APP_ARG(dbname);
);
MYSQL *mysql;
int timeout;
const char *ctimeout;
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
if (args.argc != 6) {
ast_log(LOG_WARNING, "MYSQL_connect is missing some arguments\n");
return -1;
}
if (!(mysql = mysql_init(NULL))) {
ast_log(LOG_WARNING, "mysql_init returned NULL\n");
return -1;
}
ctimeout = pbx_builtin_getvar_helper(chan, "MYSQL_TIMEOUT");
if (ctimeout && sscanf(ctimeout, "%d", &timeout) == 1) {
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&timeout);
}
if (! mysql_real_connect(mysql, args.dbhost, args.dbuser, args.dbpass, args.dbname, 0, NULL,
#ifdef CLIENT_MULTI_STATEMENTS
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS
#elif defined(CLIENT_MULTI_QUERIES)
CLIENT_MULTI_QUERIES
#else
0
#endif
)) {
ast_log(LOG_WARNING, "mysql_real_connect(mysql,%s,%s,dbpass,%s,...) failed(%d): %s\n",
args.dbhost, args.dbuser, args.dbname, mysql_errno(mysql), mysql_error(mysql));
return -1;
}
add_identifier_and_set_asterisk_int(chan, args.connid, AST_MYSQL_ID_CONNID, mysql);
return 0;
}
static int aMYSQL_query(struct ast_channel *chan, char *data)
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(query);
AST_APP_ARG(resultid);
AST_APP_ARG(connid);
AST_APP_ARG(sql);
);
MYSQL *mysql;
MYSQL_RES *mysqlres;
int connid;
int mysql_query_res;
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
if (args.argc != 4 || (connid = atoi(args.connid)) == 0) {
ast_log(LOG_WARNING, "missing some arguments\n");
return -1;
}
if (!(mysql = find_identifier(connid, AST_MYSQL_ID_CONNID))) {
ast_log(LOG_WARNING, "Invalid connection identifier %s passed in aMYSQL_query\n", args.connid);
return -1;
}
if ((mysql_query_res = mysql_query(mysql, args.sql)) != 0) {
ast_log(LOG_WARNING, "aMYSQL_query: mysql_query failed. Error: %s\n", mysql_error(mysql));
return -1;
}
if ((mysqlres = mysql_store_result(mysql))) {
add_identifier_and_set_asterisk_int(chan, args.resultid, AST_MYSQL_ID_RESID, mysqlres);
return 0;
} else if (!mysql_field_count(mysql)) {
return 0;
} else
ast_log(LOG_WARNING, "mysql_store_result() failed on query %s\n", args.sql);
return -1;
}
static int aMYSQL_nextresult(struct ast_channel *chan, char *data)
{
MYSQL *mysql;
MYSQL_RES *mysqlres;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(nextresult);
AST_APP_ARG(resultid);
AST_APP_ARG(connid);
);
int connid = -1;
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
sscanf(args.connid, "%d", &connid);
if (args.argc != 3 || connid <= 0) {
ast_log(LOG_WARNING, "missing some arguments\n");
return -1;
}
if (!(mysql = find_identifier(connid, AST_MYSQL_ID_CONNID))) {
ast_log(LOG_WARNING, "Invalid connection identifier %d passed in aMYSQL_query\n", connid);
return -1;
}
if (mysql_more_results(mysql)) {
mysql_next_result(mysql);
if ((mysqlres = mysql_store_result(mysql))) {
add_identifier_and_set_asterisk_int(chan, args.resultid, AST_MYSQL_ID_RESID, mysqlres);
return 0;
} else if (!mysql_field_count(mysql)) {
return 0;
} else
ast_log(LOG_WARNING, "mysql_store_result() failed on storing next_result\n");
} else
ast_log(LOG_WARNING, "mysql_more_results() result set has no more results\n");
return 0;
}
static int aMYSQL_fetch(struct ast_channel *chan, char *data)
{
MYSQL_RES *mysqlres;
MYSQL_ROW mysqlrow;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(fetch);
AST_APP_ARG(resultvar);
AST_APP_ARG(fetchid);
AST_APP_ARG(vars);
);
char *s5, *parse;
int resultid = -1, numFields, j;
parse = ast_strdupa(data);
AST_NONSTANDARD_APP_ARGS(args, parse, ' ');
sscanf(args.fetchid, "%d", &resultid);
if (args.resultvar && (resultid >= 0) ) {
if ((mysqlres = find_identifier(resultid, AST_MYSQL_ID_RESID)) != NULL) {
/* Grab the next row */
if ((mysqlrow = mysql_fetch_row(mysqlres)) != NULL) {
numFields = mysql_num_fields(mysqlres);
for (j = 0; j < numFields; j++) {
s5 = strsep(&args.vars, " ");
if (s5 == NULL) {
ast_log(LOG_WARNING, "ast_MYSQL_fetch: More fields (%d) than variables (%d)\n", numFields, j);
break;
}
pbx_builtin_setvar_helper(chan, s5, mysqlrow[j] ? mysqlrow[j] :
nullvalue == NULLSTRING ? "NULL" :
nullvalue == EMPTYSTRING ? "" :
NULL);
}
ast_debug(5, "ast_MYSQL_fetch: numFields=%d\n", numFields);
set_asterisk_int(chan, args.resultvar, 1); /* try more rows */
} else {
ast_debug(5, "ast_MYSQL_fetch : EOF\n");
set_asterisk_int(chan, args.resultvar, 0); /* no more rows */
}
return 0;
} else {
set_asterisk_int(chan, args.resultvar, 0);
ast_log(LOG_WARNING, "aMYSQL_fetch: Invalid result identifier %d passed\n", resultid);
}
} else {
ast_log(LOG_WARNING, "aMYSQL_fetch: missing some arguments\n");
}
return -1;
}
static int aMYSQL_clear(struct ast_channel *chan, char *data)
{
MYSQL_RES *mysqlres;
int id;
strsep(&data, " "); /* eat the first token, we already know it :P */
id = safe_scan_int(&data, " \n", -1);
if ((mysqlres = find_identifier(id, AST_MYSQL_ID_RESID)) == NULL) {
ast_log(LOG_WARNING, "Invalid result identifier %d passed in aMYSQL_clear\n", id);
} else {
mysql_free_result(mysqlres);
del_identifier(id, AST_MYSQL_ID_RESID);
}
return 0;
}
static int aMYSQL_disconnect(struct ast_channel *chan, char *data)
{
MYSQL *mysql;
int id;
strsep(&data, " "); /* eat the first token, we already know it :P */
id = safe_scan_int(&data, " \n", -1);
if ((mysql = find_identifier(id, AST_MYSQL_ID_CONNID)) == NULL) {
ast_log(LOG_WARNING, "Invalid connection identifier %d passed in aMYSQL_disconnect\n", id);
} else {
mysql_close(mysql);
del_identifier(id, AST_MYSQL_ID_CONNID);
}
return 0;
}
static int MYSQL_exec(struct ast_channel *chan, const char *data)
{
int result;
char sresult[10];
ast_debug(5, "MYSQL: data=%s\n", data);
if (!data) {
ast_log(LOG_WARNING, "MYSQL requires an argument (see manual)\n");
return -1;
}
result = 0;
if (autoclear) {
struct ast_datastore *mysql_store = ast_channel_datastore_find(chan, &mysql_ds_info, NULL);
if (!mysql_store) {
if (!(mysql_store = ast_datastore_alloc(&mysql_ds_info, NULL))) {
ast_log(LOG_WARNING, "Unable to allocate new datastore.\n");
} else {
mysql_store->data = chan;
ast_channel_datastore_add(chan, mysql_store);
}
}
}
ast_mutex_lock(&_mysql_mutex);
if (strncasecmp("connect", data, strlen("connect")) == 0) {
result = aMYSQL_connect(chan, ast_strdupa(data));
} else if (strncasecmp("query", data, strlen("query")) == 0) {
result = aMYSQL_query(chan, ast_strdupa(data));
} else if (strncasecmp("nextresult", data, strlen("nextresult")) == 0) {
result = aMYSQL_nextresult(chan, ast_strdupa(data));
} else if (strncasecmp("fetch", data, strlen("fetch")) == 0) {
result = aMYSQL_fetch(chan, ast_strdupa(data));
} else if (strncasecmp("clear", data, strlen("clear")) == 0) {
result = aMYSQL_clear(chan, ast_strdupa(data));
} else if (strncasecmp("disconnect", data, strlen("disconnect")) == 0) {
result = aMYSQL_disconnect(chan, ast_strdupa(data));
} else if (strncasecmp("set", data, 3) == 0) {
result = aMYSQL_set(chan, ast_strdupa(data));
} else {
ast_log(LOG_WARNING, "Unknown argument to MYSQL application : %s\n", data);
result = -1;
}
ast_mutex_unlock(&_mysql_mutex);
snprintf(sresult, sizeof(sresult), "%d", result);
pbx_builtin_setvar_helper(chan, "MYSQL_STATUS", sresult);
return 0;
}
static int unload_module(void)
{
return ast_unregister_application(app);
}
static int load_module(void)
{
struct MYSQLidshead *headp = &_mysql_ids_head;
struct ast_flags config_flags = { 0 };
struct ast_config *cfg = ast_config_load(MYSQL_CONFIG, config_flags);
const char *temp;
if (cfg) {
if ((temp = ast_variable_retrieve(cfg, "general", "nullvalue"))) {
if (!strcasecmp(temp, "nullstring")) {
nullvalue = NULLSTRING;
} else if (!strcasecmp(temp, "emptystring")) {
nullvalue = EMPTYSTRING;
} else if (!strcasecmp(temp, "null")) {
nullvalue = NULLVALUE;
} else {
ast_log(LOG_WARNING, "Illegal value for 'nullvalue': '%s' (must be 'nullstring', 'null', or 'emptystring')\n", temp);
}
}
if ((temp = ast_variable_retrieve(cfg, "general", "autoclear")) && ast_true(temp)) {
autoclear = 1;
}
ast_config_destroy(cfg);
}
AST_LIST_HEAD_INIT(headp);
return ast_register_application(app, MYSQL_exec, synopsis, descrip);
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Simple Mysql Interface");

136
addons/app_saycountpl.c Normal file
View File

@ -0,0 +1,136 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2004, Andy Powell & TAAN Softworks Corp.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief Say Polish counting words
* \author Andy Powell
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
***/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
/*** DOCUMENTATION
<application name="SayCountPL" language="en_US">
<synopsis>
Say Polish counting words.
</synopsis>
<syntax>
<parameter name="word1" required="true" />
<parameter name="word2" required="true" />
<parameter name="word5" required="true" />
<parameter name="number" required="true" />
</syntax>
<description>
<para>Polish grammar has some funny rules for counting words. for example 1 zloty,
2 zlote, 5 zlotych. This application will take the words for 1, 2-4 and 5 and
decide based on grammar rules which one to use with the number you pass to it.</para>
<para>Example: SayCountPL(zloty,zlote,zlotych,122) will give: zlote</para>
</description>
</application>
***/
static const char app[] = "SayCountPL";
static int saywords(struct ast_channel *chan, char *word1, char *word2, char *word5, int num)
{
/* Put this in a separate proc because it's bound to change */
int d = 0;
if (num > 0) {
if (num % 1000 == 1) {
ast_streamfile(chan, word1, chan->language);
d = ast_waitstream(chan,"");
} else if (((num % 10) >= 2) && ((num % 10) <= 4 ) && ((num % 100) < 10 || (num % 100) > 20)) {
ast_streamfile(chan, word2, chan->language);
d = ast_waitstream(chan, "");
} else {
ast_streamfile(chan, word5, chan->language);
d = ast_waitstream(chan, "");
}
}
return d;
}
static int sayword_exec(struct ast_channel *chan, const char *data)
{
int res = 0;
char *s;
int inum;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(word1);
AST_APP_ARG(word2);
AST_APP_ARG(word5);
AST_APP_ARG(num);
);
if (!data) {
ast_log(LOG_WARNING, "SayCountPL requires 4 arguments: word-1,word-2,word-5,number\n");
return -1;
}
s = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, s);
/* Check to see if params passed */
if (!args.word1 || !args.word2 || !args.word5 || !args.num) {
ast_log(LOG_WARNING, "SayCountPL requires 4 arguments: word-1,word-2,word-3,number\n");
return -1;
}
if (sscanf(args.num, "%d", &inum) != 1) {
ast_log(LOG_WARNING, "'%s' is not a valid number\n", args.num);
return -1;
}
/* do the saying part (after a bit of maths) */
res = saywords(chan, args.word1, args.word2, args.word5, inum);
return res;
}
static int unload_module(void)
{
return ast_unregister_application(app);
}
static int load_module(void)
{
int res;
res = ast_register_application_xml(app, sayword_exec);
return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Say polish counting words");

641
addons/cdr_addon_mysql.c Normal file
View File

@ -0,0 +1,641 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* James Sharp <jsharp@psychoses.org>
*
* Modified August 2003
* Tilghman Lesher <asterisk__cdr__cdr_mysql__200308@the-tilghman.com>
*
* Modified August 6, 2005
* Joseph Benden <joe@thrallingpenguin.com>
* Added mysql connection timeout parameter
* Added an automatic reconnect as to not lose a cdr record
* Cleaned up the original code to match the coding guidelines
*
* Modified Juli 2006
* Martin Portmann <map@infinitum.ch>
* Added mysql ssl support
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief MySQL CDR backend
* \ingroup cdr_drivers
*/
/*** MODULEINFO
<depend>mysqlclient</depend>
<defaultenabled>no</defaultenabled>
***/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <mysql/mysql.h>
#include <mysql/errmsg.h>
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/cli.h"
#include "asterisk/strings.h"
#include "asterisk/linkedlists.h"
#include "asterisk/threadstorage.h"
#define DATE_FORMAT "%Y-%m-%d %T"
AST_THREADSTORAGE(sql1_buf);
AST_THREADSTORAGE(sql2_buf);
AST_THREADSTORAGE(escape_buf);
static const char desc[] = "MySQL CDR Backend";
static const char name[] = "mysql";
static const char config[] = "cdr_mysql.conf";
static struct ast_str *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL, *dbcharset = NULL;
static struct ast_str *ssl_ca = NULL, *ssl_cert = NULL, *ssl_key = NULL;
static int dbport = 0;
static int connected = 0;
static time_t connect_time = 0;
static int records = 0;
static int totalrecords = 0;
static int timeout = 0;
static int calldate_compat = 0;
AST_MUTEX_DEFINE_STATIC(mysql_lock);
struct unload_string {
AST_LIST_ENTRY(unload_string) entry;
struct ast_str *str;
};
static AST_LIST_HEAD_STATIC(unload_strings, unload_string);
struct column {
char *name;
char *cdrname;
char *staticvalue;
char *type;
AST_LIST_ENTRY(column) list;
};
/* Protected with mysql_lock */
static AST_RWLIST_HEAD_STATIC(columns, column);
static MYSQL mysql = { { NULL }, };
static char *handle_cli_cdr_mysql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
e->command = "cdr mysql status";
e->usage =
"Usage: cdr mysql status\n"
" Shows current connection status for cdr_mysql\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != 3)
return CLI_SHOWUSAGE;
if (connected) {
char status[256], status2[100] = "";
int ctime = time(NULL) - connect_time;
if (dbport)
snprintf(status, 255, "Connected to %s@%s, port %d", ast_str_buffer(dbname), ast_str_buffer(hostname), dbport);
else if (dbsock)
snprintf(status, 255, "Connected to %s on socket file %s", ast_str_buffer(dbname), S_OR(ast_str_buffer(dbsock), "default"));
else
snprintf(status, 255, "Connected to %s@%s", ast_str_buffer(dbname), ast_str_buffer(hostname));
if (!ast_strlen_zero(ast_str_buffer(dbuser)))
snprintf(status2, 99, " with username %s", ast_str_buffer(dbuser));
if (ast_str_strlen(dbtable))
snprintf(status2, 99, " using table %s", ast_str_buffer(dbtable));
if (ctime > 31536000) {
ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 31536000, (ctime % 31536000) / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
} else if (ctime > 86400) {
ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
} else if (ctime > 3600) {
ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 3600, (ctime % 3600) / 60, ctime % 60);
} else if (ctime > 60) {
ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60, ctime % 60);
} else {
ast_cli(a->fd, "%s%s for %d seconds.\n", status, status2, ctime);
}
if (records == totalrecords)
ast_cli(a->fd, " Wrote %d records since last restart.\n", totalrecords);
else
ast_cli(a->fd, " Wrote %d records since last restart and %d records since last reconnect.\n", totalrecords, records);
} else {
ast_cli(a->fd, "Not currently connected to a MySQL server.\n");
}
return CLI_SUCCESS;
}
static struct ast_cli_entry cdr_mysql_status_cli[] = {
AST_CLI_DEFINE(handle_cli_cdr_mysql_status, "Show connection status of cdr_mysql"),
};
static int mysql_log(struct ast_cdr *cdr)
{
struct ast_str *sql1 = ast_str_thread_get(&sql1_buf, 1024), *sql2 = ast_str_thread_get(&sql2_buf, 1024);
int retries = 5;
#if MYSQL_VERSION_ID >= 50013
my_bool my_bool_true = 1;
#endif
if (!sql1 || !sql2) {
ast_log(LOG_ERROR, "Memory error\n");
return -1;
}
ast_mutex_lock(&mysql_lock);
db_reconnect:
if ((!connected) && (hostname || dbsock) && dbuser && password && dbname && dbtable ) {
/* Attempt to connect */
mysql_init(&mysql);
/* Add option to quickly timeout the connection */
if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout) != 0) {
ast_log(LOG_ERROR, "mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
}
#if MYSQL_VERSION_ID >= 50013
/* Add option for automatic reconnection */
if (mysql_options(&mysql, MYSQL_OPT_RECONNECT, &my_bool_true) != 0) {
ast_log(LOG_ERROR, "mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
}
#endif
if (ssl_ca || ssl_cert || ssl_key) {
mysql_ssl_set(&mysql, ssl_key ? ast_str_buffer(ssl_key) : NULL, ssl_cert ? ast_str_buffer(ssl_cert) : NULL, ssl_ca ? ast_str_buffer(ssl_ca) : NULL, NULL, NULL);
}
if (mysql_real_connect(&mysql, ast_str_buffer(hostname), ast_str_buffer(dbuser), ast_str_buffer(password), ast_str_buffer(dbname), dbport, dbsock && ast_str_strlen(dbsock) ? ast_str_buffer(dbsock) : NULL, ssl_ca ? CLIENT_SSL : 0)) {
connected = 1;
connect_time = time(NULL);
records = 0;
if (dbcharset) {
ast_str_set(&sql1, 0, "SET NAMES '%s'", ast_str_buffer(dbcharset));
mysql_real_query(&mysql, ast_str_buffer(sql1), ast_str_strlen(sql1));
ast_debug(1, "SQL command as follows: %s\n", ast_str_buffer(sql1));
}
} else {
ast_log(LOG_ERROR, "Cannot connect to database server %s: (%d) %s\n", ast_str_buffer(hostname), mysql_errno(&mysql), mysql_error(&mysql));
connected = 0;
}
} else {
/* Long connection - ping the server */
int error;
if ((error = mysql_ping(&mysql))) {
connected = 0;
records = 0;
switch (mysql_errno(&mysql)) {
case CR_SERVER_GONE_ERROR:
case CR_SERVER_LOST:
ast_log(LOG_ERROR, "Server has gone away. Attempting to reconnect.\n");
break;
default:
ast_log(LOG_ERROR, "Unknown connection error: (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
}
retries--;
if (retries) {
goto db_reconnect;
} else {
ast_log(LOG_ERROR, "Retried to connect five times, giving up.\n");
}
}
}
if (connected) {
int column_count = 0;
char *cdrname;
char workspace[2048], *value = NULL;
struct column *entry;
struct ast_str *escape = ast_str_thread_get(&escape_buf, 16);
ast_str_set(&sql1, 0, "INSERT INTO %s (", AS_OR(dbtable, "cdr"));
ast_str_set(&sql2, 0, ") VALUES (");
AST_RWLIST_RDLOCK(&columns);
AST_RWLIST_TRAVERSE(&columns, entry, list) {
if (!strcmp(entry->name, "calldate")) {
/*!\note
* For some dumb reason, "calldate" used to be formulated using
* the datetime the record was posted, rather than the start
* time of the call. If someone really wants the old compatible
* behavior, it's provided here.
*/
if (calldate_compat) {
struct timeval tv = ast_tvnow();
struct ast_tm tm;
char timestr[128];
ast_localtime(&tv, &tm, NULL);
ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %T", &tm);
ast_cdr_setvar(cdr, "calldate", timestr, 0);
cdrname = "calldate";
} else {
cdrname = "start";
}
} else {
cdrname = entry->cdrname;
}
/* Construct SQL */
/* Need the type and value to determine if we want the raw value or not */
if (entry->staticvalue) {
value = ast_strdupa(entry->staticvalue);
} else if ((!strcmp(cdrname, "start") ||
!strcmp(cdrname, "answer") ||
!strcmp(cdrname, "end") ||
!strcmp(cdrname, "disposition") ||
!strcmp(cdrname, "amaflags")) &&
(strstr(entry->type, "int") ||
strstr(entry->type, "dec") ||
strstr(entry->type, "float") ||
strstr(entry->type, "double") ||
strstr(entry->type, "real") ||
strstr(entry->type, "numeric") ||
strstr(entry->type, "fixed"))) {
ast_cdr_getvar(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 1);
} else {
ast_cdr_getvar(cdr, cdrname, &value, workspace, sizeof(workspace), 0, 0);
}
if (value) {
size_t valsz;
if (column_count++) {
ast_str_append(&sql1, 0, ",");
ast_str_append(&sql2, 0, ",");
}
ast_str_make_space(&escape, (valsz = strlen(value)) * 2 + 1);
mysql_real_escape_string(&mysql, ast_str_buffer(escape), value, valsz);
ast_str_append(&sql1, 0, "%s", entry->name);
ast_str_append(&sql2, 0, "'%s'", ast_str_buffer(escape));
}
}
AST_RWLIST_UNLOCK(&columns);
ast_debug(1, "Inserting a CDR record.\n");
ast_str_append(&sql1, 0, "%s)", ast_str_buffer(sql2));
ast_debug(1, "SQL command as follows: %s\n", ast_str_buffer(sql1));
if (mysql_real_query(&mysql, ast_str_buffer(sql1), ast_str_strlen(sql1))) {
ast_log(LOG_ERROR, "Failed to insert into database: (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
mysql_close(&mysql);
connected = 0;
} else {
records++;
totalrecords++;
}
}
ast_mutex_unlock(&mysql_lock);
return 0;
}
static int my_unload_module(int reload)
{
struct unload_string *us;
struct column *entry;
ast_cli_unregister_multiple(cdr_mysql_status_cli, sizeof(cdr_mysql_status_cli) / sizeof(struct ast_cli_entry));
if (connected) {
mysql_close(&mysql);
connected = 0;
records = 0;
}
AST_LIST_LOCK(&unload_strings);
while ((us = AST_LIST_REMOVE_HEAD(&unload_strings, entry))) {
ast_free(us->str);
ast_free(us);
}
AST_LIST_UNLOCK(&unload_strings);
if (!reload) {
AST_RWLIST_WRLOCK(&columns);
}
while ((entry = AST_RWLIST_REMOVE_HEAD(&columns, list))) {
ast_free(entry);
}
if (!reload) {
AST_RWLIST_UNLOCK(&columns);
}
dbport = 0;
ast_cdr_unregister(name);
return 0;
}
static int my_load_config_string(struct ast_config *cfg, const char *category, const char *variable, struct ast_str **field, const char *def)
{
struct unload_string *us;
const char *tmp;
if (!(us = ast_calloc(1, sizeof(*us))))
return -1;
if (!(*field = ast_str_create(16))) {
ast_free(us);
return -1;
}
us->str = *field;
AST_LIST_LOCK(&unload_strings);
AST_LIST_INSERT_HEAD(&unload_strings, us, entry);
AST_LIST_UNLOCK(&unload_strings);
tmp = ast_variable_retrieve(cfg, category, variable);
ast_str_set(field, 0, "%s", tmp ? tmp : def);
return 0;
}
static int my_load_config_number(struct ast_config *cfg, const char *category, const char *variable, int *field, int def)
{
const char *tmp;
tmp = ast_variable_retrieve(cfg, category, variable);
if (!tmp || sscanf(tmp, "%d", field) < 1)
*field = def;
return 0;
}
static int my_load_module(int reload)
{
int res;
struct ast_config *cfg;
struct ast_variable *var;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct column *entry;
char *temp;
struct ast_str *compat;
MYSQL_ROW row;
MYSQL_RES *result;
char sqldesc[128];
#if MYSQL_VERSION_ID >= 50013
my_bool my_bool_true = 1;
#endif
cfg = ast_config_load(config, config_flags);
if (!cfg) {
ast_log(LOG_WARNING, "Unable to load config for mysql CDR's: %s\n", config);
return AST_MODULE_LOAD_SUCCESS;
} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
return AST_MODULE_LOAD_SUCCESS;
if (reload) {
AST_RWLIST_WRLOCK(&columns);
my_unload_module(1);
}
var = ast_variable_browse(cfg, "global");
if (!var) {
/* nothing configured */
if (reload) {
AST_RWLIST_UNLOCK(&columns);
}
return AST_MODULE_LOAD_SUCCESS;
}
res = 0;
res |= my_load_config_string(cfg, "global", "hostname", &hostname, "localhost");
res |= my_load_config_string(cfg, "global", "dbname", &dbname, "astriskcdrdb");
res |= my_load_config_string(cfg, "global", "user", &dbuser, "root");
res |= my_load_config_string(cfg, "global", "sock", &dbsock, "");
res |= my_load_config_string(cfg, "global", "table", &dbtable, "cdr");
res |= my_load_config_string(cfg, "global", "password", &password, "");
res |= my_load_config_string(cfg, "global", "charset", &dbcharset, "");
res |= my_load_config_string(cfg, "global", "ssl_ca", &ssl_ca, "");
res |= my_load_config_string(cfg, "global", "ssl_cert", &ssl_cert, "");
res |= my_load_config_string(cfg, "global", "ssl_key", &ssl_key, "");
res |= my_load_config_number(cfg, "global", "port", &dbport, 0);
res |= my_load_config_number(cfg, "global", "timeout", &timeout, 0);
res |= my_load_config_string(cfg, "global", "compat", &compat, "no");
if (ast_true(ast_str_buffer(compat))) {
calldate_compat = 1;
} else {
calldate_compat = 0;
}
if (res < 0) {
if (reload) {
AST_RWLIST_UNLOCK(&columns);
}
return AST_MODULE_LOAD_FAILURE;
}
/* Check for any aliases */
if (!reload) {
/* Lock, if not already */
AST_RWLIST_WRLOCK(&columns);
}
while ((entry = AST_LIST_REMOVE_HEAD(&columns, list))) {
ast_free(entry);
}
ast_debug(1, "Got hostname of %s\n", ast_str_buffer(hostname));
ast_debug(1, "Got port of %d\n", dbport);
ast_debug(1, "Got a timeout of %d\n", timeout);
if (dbsock)
ast_debug(1, "Got sock file of %s\n", ast_str_buffer(dbsock));
ast_debug(1, "Got user of %s\n", ast_str_buffer(dbuser));
ast_debug(1, "Got dbname of %s\n", ast_str_buffer(dbname));
ast_debug(1, "Got password of %s\n", ast_str_buffer(password));
ast_debug(1, "%sunning in calldate compatibility mode\n", calldate_compat ? "R" : "Not r");
if (dbcharset) {
ast_debug(1, "Got DB charset of %s\n", ast_str_buffer(dbcharset));
}
mysql_init(&mysql);
if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout) != 0) {
ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
}
#if MYSQL_VERSION_ID >= 50013
/* Add option for automatic reconnection */
if (mysql_options(&mysql, MYSQL_OPT_RECONNECT, &my_bool_true) != 0) {
ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
}
#endif
if ((ssl_ca && ast_str_strlen(ssl_ca)) || (ssl_cert && ast_str_strlen(ssl_cert)) || (ssl_key && ast_str_strlen(ssl_key))) {
mysql_ssl_set(&mysql,
ssl_key ? ast_str_buffer(ssl_key) : NULL,
ssl_cert ? ast_str_buffer(ssl_cert) : NULL,
ssl_ca ? ast_str_buffer(ssl_ca) : NULL,
NULL, NULL);
}
temp = dbsock && ast_str_strlen(dbsock) ? ast_str_buffer(dbsock) : NULL;
if (!mysql_real_connect(&mysql, ast_str_buffer(hostname), ast_str_buffer(dbuser), ast_str_buffer(password), ast_str_buffer(dbname), dbport, temp, ssl_ca && ast_str_strlen(ssl_ca) ? CLIENT_SSL : 0)) {
ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", ast_str_buffer(dbname), ast_str_buffer(hostname));
connected = 0;
records = 0;
} else {
ast_debug(1, "Successfully connected to MySQL database.\n");
connected = 1;
records = 0;
connect_time = time(NULL);
if (dbcharset) {
snprintf(sqldesc, sizeof(sqldesc), "SET NAMES '%s'", ast_str_buffer(dbcharset));
mysql_real_query(&mysql, sqldesc, strlen(sqldesc));
ast_debug(1, "SQL command as follows: %s\n", sqldesc);
}
/* Get table description */
snprintf(sqldesc, sizeof(sqldesc), "DESC %s", dbtable ? ast_str_buffer(dbtable) : "cdr");
if (mysql_query(&mysql, sqldesc)) {
ast_log(LOG_ERROR, "Unable to query table description!! Logging disabled.\n");
mysql_close(&mysql);
connected = 0;
AST_RWLIST_UNLOCK(&columns);
ast_config_destroy(cfg);
return AST_MODULE_LOAD_SUCCESS;
}
if (!(result = mysql_store_result(&mysql))) {
ast_log(LOG_ERROR, "Unable to query table description!! Logging disabled.\n");
mysql_close(&mysql);
connected = 0;
AST_RWLIST_UNLOCK(&columns);
ast_config_destroy(cfg);
return AST_MODULE_LOAD_SUCCESS;
}
while ((row = mysql_fetch_row(result))) {
struct column *entry;
char *cdrvar = "", *staticvalue = "";
ast_debug(1, "Got a field '%s' of type '%s'\n", row[0], row[1]);
/* Check for an alias or a static value */
for (var = ast_variable_browse(cfg, "columns"); var; var = var->next) {
if (strncmp(var->name, "alias", 5) == 0 && strcasecmp(var->value, row[0]) == 0 ) {
char *alias = ast_strdupa(var->name + 5);
cdrvar = ast_strip(alias);
ast_verb(3, "Found alias %s for column %s\n", cdrvar, row[0]);
break;
} else if (strncmp(var->name, "static", 6) == 0 && strcasecmp(var->value, row[0]) == 0) {
char *item = ast_strdupa(var->name + 6);
item = ast_strip(item);
if (item[0] == '"' && item[strlen(item) - 1] == '"') {
/* Remove surrounding quotes */
item[strlen(item) - 1] = '\0';
item++;
}
staticvalue = item;
}
}
entry = ast_calloc(sizeof(char), sizeof(*entry) + strlen(row[0]) + 1 + strlen(cdrvar) + 1 + strlen(staticvalue) + 1 + strlen(row[1]) + 1);
if (!entry) {
ast_log(LOG_ERROR, "Out of memory creating entry for column '%s'\n", row[0]);
res = -1;
break;
}
entry->name = (char *)entry + sizeof(*entry);
strcpy(entry->name, row[0]);
if (!ast_strlen_zero(cdrvar)) {
entry->cdrname = entry->name + strlen(row[0]) + 1;
strcpy(entry->cdrname, cdrvar);
} else { /* Point to same place as the column name */
entry->cdrname = (char *)entry + sizeof(*entry);
}
if (!ast_strlen_zero(staticvalue)) {
entry->staticvalue = entry->cdrname + strlen(entry->cdrname) + 1;
strcpy(entry->staticvalue, staticvalue);
ast_debug(1, "staticvalue length: %d\n", (int) strlen(staticvalue) );
entry->type = entry->staticvalue + strlen(entry->staticvalue) + 1;
} else {
entry->type = entry->cdrname + strlen(entry->cdrname) + 1;
}
strcpy(entry->type, row[1]);
ast_debug(1, "Entry name '%s'\n", entry->name);
ast_debug(1, " cdrname '%s'\n", entry->cdrname);
ast_debug(1, " static '%s'\n", entry->staticvalue);
ast_debug(1, " type '%s'\n", entry->type);
AST_LIST_INSERT_TAIL(&columns, entry, list);
}
mysql_free_result(result);
}
AST_RWLIST_UNLOCK(&columns);
ast_config_destroy(cfg);
if (res < 0) {
return AST_MODULE_LOAD_FAILURE;
}
res = ast_cdr_register(name, desc, mysql_log);
if (res) {
ast_log(LOG_ERROR, "Unable to register MySQL CDR handling\n");
} else {
res = ast_cli_register_multiple(cdr_mysql_status_cli, sizeof(cdr_mysql_status_cli) / sizeof(struct ast_cli_entry));
}
return res;
}
static int load_module(void)
{
return my_load_module(0);
}
static int unload_module(void)
{
return my_unload_module(0);
}
static int reload(void)
{
int ret;
ast_mutex_lock(&mysql_lock);
ret = my_load_module(1);
ast_mutex_unlock(&mysql_lock);
return ret;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "MySQL CDR Backend",
.load = load_module,
.unload = unload_module,
.reload = reload,
);

4266
addons/chan_mobile.c Normal file

File diff suppressed because it is too large Load Diff

3162
addons/chan_ooh323.c Normal file

File diff suppressed because it is too large Load Diff

113
addons/chan_ooh323.h Normal file
View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#ifndef _OO_CHAN_H323_H_
#define _OO_CHAN_H323_H_
#include <asterisk.h>
#undef PACKAGE_NAME
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#undef PACKAGE_STRING
#undef PACKAGE_BUGREPORT
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
#include <asterisk/pbx.h>
#include <asterisk/utils.h>
#include <asterisk/options.h>
#include <asterisk/sched.h>
#include <asterisk/io.h>
#include <asterisk/causes.h>
#include <asterisk/rtp.h>
#include <asterisk/acl.h>
#include <asterisk/callerid.h>
#include <asterisk/file.h>
#include <asterisk/cli.h>
#include <asterisk/app.h>
#include <asterisk/musiconhold.h>
#include <asterisk/manager.h>
#include <asterisk/dsp.h>
#include <asterisk/stringfields.h>
#include "ootypes.h"
#include "ooCapability.h"
#include "oochannels.h"
#include "ooh323ep.h"
#include "ooh323cDriver.h"
#include "ooCalls.h"
#include "ooq931.h"
#include "ooStackCmds.h"
#include "ooCapability.h"
#include "ooGkClient.h"
struct ooh323_pvt;
struct ooh323_user;
struct ooh323_peer;
/* Helper functions */
struct ooh323_user *find_user(const char * name, const char *ip);
struct ooh323_peer *find_peer(const char * name, int port);
void ooh323_delete_peer(struct ooh323_peer *peer);
int delete_users(void);
int delete_peers(void);
int ooh323_destroy(struct ooh323_pvt *p);
int reload_config(int reload);
int restart_monitor(void);
int configure_local_rtp(struct ooh323_pvt *p, ooCallData* call);
void setup_rtp_connection(ooCallData *call, const char *remoteIp,
int remotePort);
void close_rtp_connection(ooCallData *call);
struct ast_frame *ooh323_rtp_read
(struct ast_channel *ast, struct ooh323_pvt *p);
void ooh323_set_write_format(ooCallData *call, int fmt);
void ooh323_set_read_format(ooCallData *call, int fmt);
int ooh323_update_capPrefsOrderForCall
(ooCallData *call, struct ast_codec_pref *prefs);
int ooh323_convertAsteriskCapToH323Cap(int cap);
int ooh323_convert_hangupcause_asteriskToH323(int cause);
int ooh323_convert_hangupcause_h323ToAsterisk(int cause);
int update_our_aliases(ooCallData *call, struct ooh323_pvt *p);
/* h323 msg callbacks */
int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg);
int ooh323_onReceivedDigit(OOH323CallData *call, const char* digit);
#endif

336
addons/format_mp3.c Normal file
View File

@ -0,0 +1,336 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Anthony Minessale <anthmct@yahoo.com>
*
* Derived from other asterisk sound formats by
* Mark Spencer <markster@linux-support.net>
*
* Thanks to mpglib from http://www.mpg123.org/
* and Chris Stenton [jacs@gnome.co.uk]
* for coding the ability to play stereo and non-8khz files
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief MP3 Format Handler
* \ingroup formats
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
***/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "mp3/mpg123.h"
#include "mp3/mpglib.h"
#include "asterisk/module.h"
#include "asterisk/mod_format.h"
#include "asterisk/logger.h"
#define MP3_BUFLEN 320
#define MP3_SCACHE 16384
#define MP3_DCACHE 8192
struct mp3_private {
char waste[AST_FRIENDLY_OFFSET]; /* Buffer for sending frames, etc */
char empty; /* Empty character */
int lasttimeout;
int maxlen;
struct timeval last;
struct mpstr mp;
char sbuf[MP3_SCACHE];
char dbuf[MP3_DCACHE];
int buflen;
int sbuflen;
int dbuflen;
int dbufoffset;
int sbufoffset;
int lastseek;
int offset;
long seek;
};
static const char name[] = "mp3";
#define BLOCKSIZE 160
#define OUTSCALE 4096
#define GAIN -4 /* 2^GAIN is the multiple to increase the volume by */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htoll(b) (b)
#define htols(b) (b)
#define ltohl(b) (b)
#define ltohs(b) (b)
#else
#if __BYTE_ORDER == __BIG_ENDIAN
#define htoll(b) \
(((((b) ) & 0xFF) << 24) | \
((((b) >> 8) & 0xFF) << 16) | \
((((b) >> 16) & 0xFF) << 8) | \
((((b) >> 24) & 0xFF) ))
#define htols(b) \
(((((b) ) & 0xFF) << 8) | \
((((b) >> 8) & 0xFF) ))
#define ltohl(b) htoll(b)
#define ltohs(b) htols(b)
#else
#error "Endianess not defined"
#endif
#endif
static int mp3_open(struct ast_filestream *s)
{
struct mp3_private *p = s->_private;
InitMP3(&p->mp, OUTSCALE);
p->dbuflen = 0;
s->fr.data.ptr = s->buf;
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
/* datalen will vary for each frame */
s->fr.src = name;
s->fr.mallocd = 0;
p->offset = 0;
return 0;
}
static void mp3_close(struct ast_filestream *s)
{
struct mp3_private *p = s->_private;
ExitMP3(&p->mp);
return;
}
static int mp3_squeue(struct ast_filestream *s)
{
struct mp3_private *p = s->_private;
int res=0;
p->lastseek = ftell(s->f);
p->sbuflen = fread(p->sbuf, 1, MP3_SCACHE, s->f);
if(p->sbuflen < 0) {
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", p->sbuflen, strerror(errno));
return -1;
}
res = decodeMP3(&p->mp,p->sbuf,p->sbuflen,p->dbuf,MP3_DCACHE,&p->dbuflen);
if(res != MP3_OK)
return -1;
p->sbuflen -= p->dbuflen;
p->dbufoffset = 0;
return 0;
}
static int mp3_dqueue(struct ast_filestream *s)
{
struct mp3_private *p = s->_private;
int res=0;
if((res = decodeMP3(&p->mp,NULL,0,p->dbuf,MP3_DCACHE,&p->dbuflen)) == MP3_OK) {
p->sbuflen -= p->dbuflen;
p->dbufoffset = 0;
}
return res;
}
static int mp3_queue(struct ast_filestream *s)
{
struct mp3_private *p = s->_private;
int res = 0, bytes = 0;
if(p->seek) {
ExitMP3(&p->mp);
InitMP3(&p->mp, OUTSCALE);
fseek(s->f, 0, SEEK_SET);
p->sbuflen = p->dbuflen = p->offset = 0;
while(p->offset < p->seek) {
if(mp3_squeue(s))
return -1;
while(p->offset < p->seek && ((res = mp3_dqueue(s))) == MP3_OK) {
for(bytes = 0 ; bytes < p->dbuflen ; bytes++) {
p->dbufoffset++;
p->offset++;
if(p->offset >= p->seek)
break;
}
}
if(res == MP3_ERR)
return -1;
}
p->seek = 0;
return 0;
}
if(p->dbuflen == 0) {
if(p->sbuflen) {
res = mp3_dqueue(s);
if(res == MP3_ERR)
return -1;
}
if(! p->sbuflen || res != MP3_OK) {
if(mp3_squeue(s))
return -1;
}
}
return 0;
}
static struct ast_frame *mp3_read(struct ast_filestream *s, int *whennext)
{
struct mp3_private *p = s->_private;
int delay =0;
int save=0;
/* Send a frame from the file to the appropriate channel */
if(mp3_queue(s))
return NULL;
if(p->dbuflen) {
for(p->buflen=0; p->buflen < MP3_BUFLEN && p->buflen < p->dbuflen; p->buflen++) {
s->buf[p->buflen] = p->dbuf[p->buflen+p->dbufoffset];
p->sbufoffset++;
}
p->dbufoffset += p->buflen;
p->dbuflen -= p->buflen;
if(p->buflen < MP3_BUFLEN) {
if(mp3_queue(s))
return NULL;
for(save = p->buflen; p->buflen < MP3_BUFLEN; p->buflen++) {
s->buf[p->buflen] = p->dbuf[(p->buflen-save)+p->dbufoffset];
p->sbufoffset++;
}
p->dbufoffset += (MP3_BUFLEN - save);
p->dbuflen -= (MP3_BUFLEN - save);
}
}
p->offset += p->buflen;
delay = p->buflen/2;
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.offset = AST_FRIENDLY_OFFSET;
s->fr.datalen = p->buflen;
s->fr.data.ptr = s->buf;
s->fr.mallocd = 0;
s->fr.samples = delay;
*whennext = delay;
return &s->fr;
}
static int mp3_write(struct ast_filestream *fs, struct ast_frame *f)
{
ast_log(LOG_ERROR,"I Can't write MP3 only read them.\n");
return -1;
}
static int mp3_seek(struct ast_filestream *s, off_t sample_offset, int whence)
{
struct mp3_private *p = s->_private;
off_t min,max,cur;
long offset=0,samples;
samples = sample_offset * 2;
min = 0;
fseek(s->f, 0, SEEK_END);
max = ftell(s->f) * 100;
cur = p->offset;
if (whence == SEEK_SET)
offset = samples + min;
else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
offset = samples + cur;
else if (whence == SEEK_END)
offset = max - samples;
if (whence != SEEK_FORCECUR) {
offset = (offset > max)?max:offset;
}
p->seek = offset;
return p->seek;
}
static int mp3_rewrite(struct ast_filestream *s, const char *comment)
{
ast_log(LOG_ERROR,"I Can't write MP3 only read them.\n");
return -1;
}
static int mp3_trunc(struct ast_filestream *s)
{
ast_log(LOG_ERROR,"I Can't write MP3 only read them.\n");
return -1;
}
static off_t mp3_tell(struct ast_filestream *s)
{
struct mp3_private *p = s->_private;
return p->offset/2;
}
static char *mp3_getcomment(struct ast_filestream *s)
{
return NULL;
}
static const struct ast_format mp3_f = {
.name = "mp3",
.exts = "mp3",
.format = AST_FORMAT_SLINEAR,
.open = mp3_open,
.write = mp3_write,
.rewrite = mp3_rewrite,
.seek = mp3_seek,
.trunc = mp3_trunc,
.tell = mp3_tell,
.read = mp3_read,
.close = mp3_close,
.getcomment = mp3_getcomment,
.buf_size = MP3_BUFLEN + AST_FRIENDLY_OFFSET,
.desc_size = sizeof(struct mp3_private),
};
static int load_module(void)
{
InitMP3Constants();
return ast_format_register(&mp3_f);
}
static int unload_module(void)
{
return ast_format_unregister(name);
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "MP3 format [Any rate but 8000hz mono is optimal]");

39
addons/mp3/MPGLIB_README Normal file
View File

@ -0,0 +1,39 @@
MP3 library
-----------
Version 0.2
This decoder is a 'light' version (thrown out all unnecessay parts)
from the mpg123 package. I made this for a company.
Currently only Layer3 is enabled to save some space. Layer1,2 isn't
tested at all. The interface will not change significantly.
A backport to the mpg123 package is planed.
comiled and tested only on Solaris 2.6
main.c contains a simple demo application for library.
COPYING: you may use this source under GPL terms!
PLEASE NOTE: This software may contain patented alogrithm (at least
patented in some countries). It may be not allowed to sell/use products
based on this source code in these countries. Check this out first!
COPYRIGHT of MP3 music:
Please note, that the duplicating of copyrighted music without explicit
permission violates the rights of the owner.
SENDING PATCHES:
Maybe I change the copyright policy (ie some kind of more free BSD licencse).
Please consider this when sending patches/changes.
I also want to have the freedom to sell the code to companies that
can not use the code under GPL. So, if you send me significant patches,
I need your explicit permission to do this. Of course, there will also
be the GPLed open source version of the 100% same code.
For the case you cannot accept this: the code is GPL, it's your freedom
to distribute your changes again under GPL.
FEEDBACK:
I'm interessted to here from you, when you use this package as part
of another project.

2
addons/mp3/MPGLIB_TODO Normal file
View File

@ -0,0 +1,2 @@
apply 'VBR' bugfix

24
addons/mp3/Makefile Normal file
View File

@ -0,0 +1,24 @@
MP3OBJS=common.o dct64_i386.o decode_ntom.o layer3.o tabinit.o interface.o
ifeq ($(OSARCH),FreeBSD)
OSVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
CFLAGS+=$(if $(OSVERSION)<500016,-D_THREAD_SAFE)
LIBS+=$(if $(OSVERSION)<502102,-lc_r,-pthread)
INCLUDE+=-I/usr/local/include
CFLAGS+=$(shell if [ -d /usr/local/include/spandsp ]; then echo "-I/usr/local/include/spandsp"; fi)
endif # FreeBSD
ifeq ($(OSARCH),NetBSD)
CFLAGS+=-pthread
INCLUDE+=-I/usr/local/include
endif
ifeq ($(OSARCH),OpenBSD)
CFLAGS+=-pthread
endif
all: $(MP3OBJS)
clean:
rm -f *.o *.so *~
rm -f .*.o.d

24
addons/mp3/README Normal file
View File

@ -0,0 +1,24 @@
This is a module for asterisk to play mp3 natively.
They *SHOULD* be already at 8khz and *SHOULD* be mono.
otherwise they will be consuming CPU alot more than need be.
Convert them to 8k mono like this:
lame -q -p --mp3input -a --preset 8 in.mp3 8kout.mp3
just run
# make clean install
to install
or
# make clean autoload
to install and autoload at the same time
Comments or improvements
Anthony Minessale <anthmct@yahoo.com>
Donations Welcomed at paypal:jillkm3@yahoo.com

267
addons/mp3/common.c Normal file
View File

@ -0,0 +1,267 @@
#include <asterisk.h>
#include <asterisk/logger.h>
#include <ctype.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "mpg123.h"
#include "mpglib.h"
struct parameter param = { 1 , 1 , 0 , 0 };
int tabsel_123[2][3][16] = {
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
{ {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
};
long freqs[9] = { 44100, 48000, 32000,
22050, 24000, 16000 ,
11025 , 12000 , 8000 };
#if 0
static void get_II_stuff(struct frame *fr)
{
static int translate[3][2][16] =
{ { { 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0 } ,
{ 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0 } } ,
{ { 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0 } ,
{ 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0 } } ,
{ { 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0 } ,
{ 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0 } } };
int table,sblim;
static struct al_table *tables[5] =
{ alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 };
static int sblims[5] = { 27 , 30 , 8, 12 , 30 };
if(fr->lsf)
table = 4;
else
table = translate[fr->sampling_frequency][2-fr->stereo][fr->bitrate_index];
sblim = sblims[table];
fr->alloc = tables[table];
fr->II_sblimit = sblim;
}
#endif
#define HDRCMPMASK 0xfffffd00
#if 0
int head_check(unsigned long head)
{
if( (head & 0xffe00000) != 0xffe00000)
return FALSE;
if(!((head>>17)&3))
return FALSE;
if( ((head>>12)&0xf) == 0xf)
return FALSE;
if( ((head>>10)&0x3) == 0x3 )
return FALSE;
return TRUE;
}
#endif
/*
* the code a header and write the information
* into the frame structure
*/
int decode_header(struct frame *fr,unsigned long newhead)
{
if( newhead & (1<<20) ) {
fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1;
fr->mpeg25 = 0;
}
else {
fr->lsf = 1;
fr->mpeg25 = 1;
}
fr->lay = 4-((newhead>>17)&3);
if( ((newhead>>10)&0x3) == 0x3) {
ast_log(LOG_WARNING,"Stream error\n");
return (0);
}
if(fr->mpeg25) {
fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
}
else
fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3);
fr->error_protection = ((newhead>>16)&0x1)^0x1;
if(fr->mpeg25) /* allow Bitrate change for 2.5 ... */
fr->bitrate_index = ((newhead>>12)&0xf);
fr->bitrate_index = ((newhead>>12)&0xf);
fr->padding = ((newhead>>9)&0x1);
fr->extension = ((newhead>>8)&0x1);
fr->mode = ((newhead>>6)&0x3);
fr->mode_ext = ((newhead>>4)&0x3);
fr->copyright = ((newhead>>3)&0x1);
fr->original = ((newhead>>2)&0x1);
fr->emphasis = newhead & 0x3;
fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
if(!fr->bitrate_index)
{
ast_log(LOG_WARNING,"Free format not supported.\n");
return (0);
}
switch(fr->lay)
{
case 1:
#if 0
fr->do_layer = do_layer1;
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
(fr->mode_ext<<2)+4 : 32;
fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
fr->framesize /= freqs[fr->sampling_frequency];
fr->framesize = ((fr->framesize+fr->padding)<<2)-4;
#else
ast_log(LOG_WARNING,"Layer 1 not supported!\n");
#endif
break;
case 2:
#if 0
fr->do_layer = do_layer2;
get_II_stuff(fr);
fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
(fr->mode_ext<<2)+4 : fr->II_sblimit;
fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
fr->framesize /= freqs[fr->sampling_frequency];
fr->framesize += fr->padding - 4;
#else
ast_log(LOG_WARNING,"Layer 2 not supported!\n");
#endif
break;
case 3:
#if 0
fr->do_layer = do_layer3;
if(fr->lsf)
ssize = (fr->stereo == 1) ? 9 : 17;
else
ssize = (fr->stereo == 1) ? 17 : 32;
#endif
#if 0
if(fr->error_protection)
ssize += 2;
#endif
fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
fr->framesize /= freqs[fr->sampling_frequency]<<(fr->lsf);
fr->framesize = fr->framesize + fr->padding - 4;
break;
default:
ast_log(LOG_WARNING,"Sorry, unknown layer type.\n");
return (0);
}
return 1;
}
#if 0
void print_header(struct frame *fr)
{
static char *modes[4] = { "Stereo", "Joint-Stereo", "Dual-Channel", "Single-Channel" };
static char *layers[4] = { "Unknown" , "I", "II", "III" };
ast_log(LOG_WARNING,"MPEG %s, Layer: %s, Freq: %ld, mode: %s, modext: %d, BPF : %d\n",
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
layers[fr->lay],freqs[fr->sampling_frequency],
modes[fr->mode],fr->mode_ext,fr->framesize+4);
ast_log(LOG_WARNING,"Channels: %d, copyright: %s, original: %s, CRC: %s, emphasis: %d.\n",
fr->stereo,fr->copyright?"Yes":"No",
fr->original?"Yes":"No",fr->error_protection?"Yes":"No",
fr->emphasis);
ast_log(LOG_WARNING,"Bitrate: %d Kbits/s, Extension value: %d\n",
tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index],fr->extension);
}
void print_header_compact(struct frame *fr)
{
static char *modes[4] = { "stereo", "joint-stereo", "dual-channel", "mono" };
static char *layers[4] = { "Unknown" , "I", "II", "III" };
ast_log(LOG_WARNING,"MPEG %s layer %s, %d kbit/s, %ld Hz %s\n",
fr->mpeg25 ? "2.5" : (fr->lsf ? "2.0" : "1.0"),
layers[fr->lay],
tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index],
freqs[fr->sampling_frequency], modes[fr->mode]);
}
#endif
unsigned int getbits(struct mpstr *mp, int number_of_bits)
{
unsigned long rval;
if(!number_of_bits)
return 0;
{
rval = (mp->worksample).wordpointer[0];
rval <<= 8;
rval |= (mp->worksample).wordpointer[1];
rval <<= 8;
rval |= (mp->worksample).wordpointer[2];
rval <<= (mp->worksample).bitindex;
rval &= 0xffffff;
(mp->worksample).bitindex += number_of_bits;
rval >>= (24-number_of_bits);
(mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
(mp->worksample).bitindex &= 7;
}
return rval;
}
unsigned int getbits_fast(struct mpstr *mp, int number_of_bits)
{
unsigned long rval;
{
rval = (mp->worksample).wordpointer[0];
rval <<= 8;
rval |= (mp->worksample).wordpointer[1];
rval <<= (mp->worksample).bitindex;
rval &= 0xffff;
(mp->worksample).bitindex += number_of_bits;
rval >>= (16-number_of_bits);
(mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
(mp->worksample).bitindex &= 7;
}
return rval;
}
unsigned int get1bit(struct mpstr *mp)
{
unsigned char rval;
rval = *((mp->worksample).wordpointer) << (mp->worksample).bitindex;
(mp->worksample).bitindex++;
(mp->worksample).wordpointer += ((mp->worksample).bitindex>>3);
(mp->worksample).bitindex &= 7;
return rval>>7;
}

335
addons/mp3/dct64_i386.c Normal file
View File

@ -0,0 +1,335 @@
/*
* Discrete Cosine Tansform (DCT) for subband synthesis
* optimized for machines with no auto-increment.
* The performance is highly compiler dependend. Maybe
* the dct64.c version for 'normal' processor may be faster
* even for Intel processors.
*/
#include "mpg123.h"
/*
* the call via dct64 is a trick to force GCC to use
* (new) registers for the b1,b2 pointer to the bufs[xx] field
*/
void dct64(real *a,real *b,real *c);
static void dct64_1(real *out0,real *out1,real *b1,real *b2,real *samples)
{
{
register real *costab = pnts[0];
b1[0x00] = samples[0x00] + samples[0x1F];
b1[0x01] = samples[0x01] + samples[0x1E];
b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
b1[0x02] = samples[0x02] + samples[0x1D];
b1[0x03] = samples[0x03] + samples[0x1C];
b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
b1[0x04] = samples[0x04] + samples[0x1B];
b1[0x05] = samples[0x05] + samples[0x1A];
b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
b1[0x06] = samples[0x06] + samples[0x19];
b1[0x07] = samples[0x07] + samples[0x18];
b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
b1[0x08] = samples[0x08] + samples[0x17];
b1[0x09] = samples[0x09] + samples[0x16];
b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
b1[0x0A] = samples[0x0A] + samples[0x15];
b1[0x0B] = samples[0x0B] + samples[0x14];
b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
b1[0x0C] = samples[0x0C] + samples[0x13];
b1[0x0D] = samples[0x0D] + samples[0x12];
b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
b1[0x0E] = samples[0x0E] + samples[0x11];
b1[0x0F] = samples[0x0F] + samples[0x10];
b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
}
{
register real *costab = pnts[1];
b2[0x00] = b1[0x00] + b1[0x0F];
b2[0x01] = b1[0x01] + b1[0x0E];
b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
b2[0x02] = b1[0x02] + b1[0x0D];
b2[0x03] = b1[0x03] + b1[0x0C];
b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
b2[0x04] = b1[0x04] + b1[0x0B];
b2[0x05] = b1[0x05] + b1[0x0A];
b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
b2[0x06] = b1[0x06] + b1[0x09];
b2[0x07] = b1[0x07] + b1[0x08];
b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
/* */
b2[0x10] = b1[0x10] + b1[0x1F];
b2[0x11] = b1[0x11] + b1[0x1E];
b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
b2[0x12] = b1[0x12] + b1[0x1D];
b2[0x13] = b1[0x13] + b1[0x1C];
b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
b2[0x14] = b1[0x14] + b1[0x1B];
b2[0x15] = b1[0x15] + b1[0x1A];
b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
b2[0x16] = b1[0x16] + b1[0x19];
b2[0x17] = b1[0x17] + b1[0x18];
b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
}
{
register real *costab = pnts[2];
b1[0x00] = b2[0x00] + b2[0x07];
b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
b1[0x01] = b2[0x01] + b2[0x06];
b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
b1[0x02] = b2[0x02] + b2[0x05];
b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
b1[0x03] = b2[0x03] + b2[0x04];
b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
b1[0x08] = b2[0x08] + b2[0x0F];
b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
b1[0x09] = b2[0x09] + b2[0x0E];
b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
b1[0x0A] = b2[0x0A] + b2[0x0D];
b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
b1[0x0B] = b2[0x0B] + b2[0x0C];
b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
b1[0x10] = b2[0x10] + b2[0x17];
b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
b1[0x11] = b2[0x11] + b2[0x16];
b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
b1[0x12] = b2[0x12] + b2[0x15];
b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
b1[0x13] = b2[0x13] + b2[0x14];
b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
b1[0x18] = b2[0x18] + b2[0x1F];
b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
b1[0x19] = b2[0x19] + b2[0x1E];
b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
b1[0x1A] = b2[0x1A] + b2[0x1D];
b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
b1[0x1B] = b2[0x1B] + b2[0x1C];
b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
}
{
register real const cos0 = pnts[3][0];
register real const cos1 = pnts[3][1];
b2[0x00] = b1[0x00] + b1[0x03];
b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
b2[0x01] = b1[0x01] + b1[0x02];
b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
b2[0x04] = b1[0x04] + b1[0x07];
b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
b2[0x05] = b1[0x05] + b1[0x06];
b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
b2[0x08] = b1[0x08] + b1[0x0B];
b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
b2[0x09] = b1[0x09] + b1[0x0A];
b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
b2[0x0C] = b1[0x0C] + b1[0x0F];
b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
b2[0x0D] = b1[0x0D] + b1[0x0E];
b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
b2[0x10] = b1[0x10] + b1[0x13];
b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
b2[0x11] = b1[0x11] + b1[0x12];
b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
b2[0x14] = b1[0x14] + b1[0x17];
b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
b2[0x15] = b1[0x15] + b1[0x16];
b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
b2[0x18] = b1[0x18] + b1[0x1B];
b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
b2[0x19] = b1[0x19] + b1[0x1A];
b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
b2[0x1C] = b1[0x1C] + b1[0x1F];
b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
b2[0x1D] = b1[0x1D] + b1[0x1E];
b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
}
{
register real const cos0 = pnts[4][0];
b1[0x00] = b2[0x00] + b2[0x01];
b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
b1[0x02] = b2[0x02] + b2[0x03];
b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
b1[0x02] += b1[0x03];
b1[0x04] = b2[0x04] + b2[0x05];
b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
b1[0x06] = b2[0x06] + b2[0x07];
b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
b1[0x06] += b1[0x07];
b1[0x04] += b1[0x06];
b1[0x06] += b1[0x05];
b1[0x05] += b1[0x07];
b1[0x08] = b2[0x08] + b2[0x09];
b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
b1[0x0A] = b2[0x0A] + b2[0x0B];
b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
b1[0x0A] += b1[0x0B];
b1[0x0C] = b2[0x0C] + b2[0x0D];
b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
b1[0x0E] = b2[0x0E] + b2[0x0F];
b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
b1[0x0E] += b1[0x0F];
b1[0x0C] += b1[0x0E];
b1[0x0E] += b1[0x0D];
b1[0x0D] += b1[0x0F];
b1[0x10] = b2[0x10] + b2[0x11];
b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
b1[0x12] = b2[0x12] + b2[0x13];
b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
b1[0x12] += b1[0x13];
b1[0x14] = b2[0x14] + b2[0x15];
b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
b1[0x16] = b2[0x16] + b2[0x17];
b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
b1[0x16] += b1[0x17];
b1[0x14] += b1[0x16];
b1[0x16] += b1[0x15];
b1[0x15] += b1[0x17];
b1[0x18] = b2[0x18] + b2[0x19];
b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
b1[0x1A] = b2[0x1A] + b2[0x1B];
b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
b1[0x1A] += b1[0x1B];
b1[0x1C] = b2[0x1C] + b2[0x1D];
b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
b1[0x1E] = b2[0x1E] + b2[0x1F];
b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
b1[0x1E] += b1[0x1F];
b1[0x1C] += b1[0x1E];
b1[0x1E] += b1[0x1D];
b1[0x1D] += b1[0x1F];
}
out0[0x10*16] = b1[0x00];
out0[0x10*12] = b1[0x04];
out0[0x10* 8] = b1[0x02];
out0[0x10* 4] = b1[0x06];
out0[0x10* 0] = b1[0x01];
out1[0x10* 0] = b1[0x01];
out1[0x10* 4] = b1[0x05];
out1[0x10* 8] = b1[0x03];
out1[0x10*12] = b1[0x07];
#if 1
out0[0x10*14] = b1[0x08] + b1[0x0C];
out0[0x10*10] = b1[0x0C] + b1[0x0a];
out0[0x10* 6] = b1[0x0A] + b1[0x0E];
out0[0x10* 2] = b1[0x0E] + b1[0x09];
out1[0x10* 2] = b1[0x09] + b1[0x0D];
out1[0x10* 6] = b1[0x0D] + b1[0x0B];
out1[0x10*10] = b1[0x0B] + b1[0x0F];
out1[0x10*14] = b1[0x0F];
#else
b1[0x08] += b1[0x0C];
out0[0x10*14] = b1[0x08];
b1[0x0C] += b1[0x0a];
out0[0x10*10] = b1[0x0C];
b1[0x0A] += b1[0x0E];
out0[0x10* 6] = b1[0x0A];
b1[0x0E] += b1[0x09];
out0[0x10* 2] = b1[0x0E];
b1[0x09] += b1[0x0D];
out1[0x10* 2] = b1[0x09];
b1[0x0D] += b1[0x0B];
out1[0x10* 6] = b1[0x0D];
b1[0x0B] += b1[0x0F];
out1[0x10*10] = b1[0x0B];
out1[0x10*14] = b1[0x0F];
#endif
{
real tmp;
tmp = b1[0x18] + b1[0x1C];
out0[0x10*15] = tmp + b1[0x10];
out0[0x10*13] = tmp + b1[0x14];
tmp = b1[0x1C] + b1[0x1A];
out0[0x10*11] = tmp + b1[0x14];
out0[0x10* 9] = tmp + b1[0x12];
tmp = b1[0x1A] + b1[0x1E];
out0[0x10* 7] = tmp + b1[0x12];
out0[0x10* 5] = tmp + b1[0x16];
tmp = b1[0x1E] + b1[0x19];
out0[0x10* 3] = tmp + b1[0x16];
out0[0x10* 1] = tmp + b1[0x11];
tmp = b1[0x19] + b1[0x1D];
out1[0x10* 1] = tmp + b1[0x11];
out1[0x10* 3] = tmp + b1[0x15];
tmp = b1[0x1D] + b1[0x1B];
out1[0x10* 5] = tmp + b1[0x15];
out1[0x10* 7] = tmp + b1[0x13];
tmp = b1[0x1B] + b1[0x1F];
out1[0x10* 9] = tmp + b1[0x13];
out1[0x10*11] = tmp + b1[0x17];
out1[0x10*13] = b1[0x17] + b1[0x1F];
out1[0x10*15] = b1[0x1F];
}
}
/*
* the call via dct64 is a trick to force GCC to use
* (new) registers for the b1,b2 pointer to the bufs[xx] field
*/
void dct64(real *a,real *b,real *c)
{
real bufs[0x40];
dct64_1(a,b,bufs,bufs+0x20,c);
}

153
addons/mp3/decode_i386.c Normal file
View File

@ -0,0 +1,153 @@
/*
* Mpeg Layer-1,2,3 audio decoder
* ------------------------------
* copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
* See also 'README'
*
* slighlty optimized for machines without autoincrement/decrement.
* The performance is highly compiler dependend. Maybe
* the decode.c version for 'normal' processor may be faster
* even for Intel processors.
*/
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "mpglib.h"
/* old WRITE_SAMPLE */
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = sum; }
int synth_1to1_mono(struct mpstr *mp,real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_1to1(mp,bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<32;i++) {
*( (short *) samples) = *tmp1;
samples += 2;
tmp1 += 2;
}
*pnt += 64;
return ret;
}
int synth_1to1(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static const int step = 2;
int bo;
short *samples = (short *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
bo = mp->synth_bo;
if(!channel) {
bo--;
bo &= 0xf;
buf = mp->synth_buffs[0];
}
else {
samples++;
buf = mp->synth_buffs[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
mp->synth_bo = bo;
{
register int j;
real *window = decwin + 16 - bo1;
for (j=16;j;j--,b0+=0x10,window+=0x20,samples+=step)
{
real sum;
sum = window[0x0] * b0[0x0];
sum -= window[0x1] * b0[0x1];
sum += window[0x2] * b0[0x2];
sum -= window[0x3] * b0[0x3];
sum += window[0x4] * b0[0x4];
sum -= window[0x5] * b0[0x5];
sum += window[0x6] * b0[0x6];
sum -= window[0x7] * b0[0x7];
sum += window[0x8] * b0[0x8];
sum -= window[0x9] * b0[0x9];
sum += window[0xA] * b0[0xA];
sum -= window[0xB] * b0[0xB];
sum += window[0xC] * b0[0xC];
sum -= window[0xD] * b0[0xD];
sum += window[0xE] * b0[0xE];
sum -= window[0xF] * b0[0xF];
WRITE_SAMPLE(samples,sum,clip);
}
{
real sum;
sum = window[0x0] * b0[0x0];
sum += window[0x2] * b0[0x2];
sum += window[0x4] * b0[0x4];
sum += window[0x6] * b0[0x6];
sum += window[0x8] * b0[0x8];
sum += window[0xA] * b0[0xA];
sum += window[0xC] * b0[0xC];
sum += window[0xE] * b0[0xE];
WRITE_SAMPLE(samples,sum,clip);
b0-=0x10,window-=0x20,samples+=step;
}
window += bo1<<1;
for (j=15;j;j--,b0-=0x10,window-=0x20,samples+=step)
{
real sum;
sum = -window[-0x1] * b0[0x0];
sum -= window[-0x2] * b0[0x1];
sum -= window[-0x3] * b0[0x2];
sum -= window[-0x4] * b0[0x3];
sum -= window[-0x5] * b0[0x4];
sum -= window[-0x6] * b0[0x5];
sum -= window[-0x7] * b0[0x6];
sum -= window[-0x8] * b0[0x7];
sum -= window[-0x9] * b0[0x8];
sum -= window[-0xA] * b0[0x9];
sum -= window[-0xB] * b0[0xA];
sum -= window[-0xC] * b0[0xB];
sum -= window[-0xD] * b0[0xC];
sum -= window[-0xE] * b0[0xD];
sum -= window[-0xF] * b0[0xE];
sum -= window[-0x0] * b0[0xF];
WRITE_SAMPLE(samples,sum,clip);
}
}
*pnt += 128;
return clip;
}

219
addons/mp3/decode_ntom.c Normal file
View File

@ -0,0 +1,219 @@
/*
* Mpeg Layer-1,2,3 audio decoder
* ------------------------------
* copyright (c) 1995,1996,1997 by Michael Hipp, All rights reserved.
* See also 'README'
*
* N->M down/up sampling. Not optimized for speed.
*/
#include <asterisk.h>
#include <asterisk/logger.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "mpg123.h"
#include "mpglib.h"
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = sum; }
#define NTOM_MUL (32768)
static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 };
static unsigned long ntom_step = NTOM_MUL;
int synth_ntom_set_step(long m,long n)
{
if(param.verbose > 1)
ast_log(LOG_WARNING,"Init rate converter: %ld->%ld\n",m,n);
if(n >= 96000 || m >= 96000 || m == 0 || n == 0) {
ast_log(LOG_WARNING,"NtoM converter: illegal rates\n");
return (1);
}
n *= NTOM_MUL;
ntom_step = n / m;
if(ntom_step > 8*NTOM_MUL) {
ast_log(LOG_WARNING,"max. 1:8 conversion allowed!\n");
return (1);
}
ntom_val[0] = ntom_val[1] = NTOM_MUL>>1;
return (0);
}
int synth_ntom_mono (struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[8*64];
short *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
ret = synth_ntom(mp, bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
*( (short *)samples) = *tmp1;
samples += 2;
tmp1 += 2;
}
*pnt += pnt1 >> 1;
return ret;
}
int synth_ntom(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt)
{
static const int step = 2;
int bo;
short *samples = (short *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
int bo1;
int ntom;
bo = mp->synth_bo;
if(!channel) {
bo--;
bo &= 0xf;
buf = mp->synth_buffs[0];
ntom = ntom_val[1] = ntom_val[0];
}
else {
samples++;
out += 2; /* to compute the right *pnt value */
buf = mp->synth_buffs[1];
ntom = ntom_val[1];
}
if(bo & 0x1) {
b0 = buf[0];
bo1 = bo;
dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
}
else {
b0 = buf[1];
bo1 = bo+1;
dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
}
mp->synth_bo = bo;
{
register int j;
real *window = (mp->decwin) + 16 - bo1;
for (j=16;j;j--,window+=0x10)
{
real sum;
ntom += ntom_step;
if(ntom < NTOM_MUL) {
window += 16;
b0 += 16;
continue;
}
sum = *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
sum += *window++ * *b0++;
sum -= *window++ * *b0++;
while(ntom >= NTOM_MUL) {
WRITE_SAMPLE(samples,sum,clip);
samples += step;
ntom -= NTOM_MUL;
}
}
ntom += ntom_step;
if(ntom >= NTOM_MUL)
{
real sum;
sum = window[0x0] * b0[0x0];
sum += window[0x2] * b0[0x2];
sum += window[0x4] * b0[0x4];
sum += window[0x6] * b0[0x6];
sum += window[0x8] * b0[0x8];
sum += window[0xA] * b0[0xA];
sum += window[0xC] * b0[0xC];
sum += window[0xE] * b0[0xE];
while(ntom >= NTOM_MUL) {
WRITE_SAMPLE(samples,sum,clip);
samples += step;
ntom -= NTOM_MUL;
}
}
b0-=0x10,window-=0x20;
window += bo1<<1;
for (j=15;j;j--,b0-=0x20,window-=0x10)
{
real sum;
ntom += ntom_step;
if(ntom < NTOM_MUL) {
window -= 16;
b0 += 16;
continue;
}
sum = -*(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
sum -= *(--window) * *b0++;
while(ntom >= NTOM_MUL) {
WRITE_SAMPLE(samples,sum,clip);
samples += step;
ntom -= NTOM_MUL;
}
}
}
ntom_val[channel] = ntom;
*pnt = ((unsigned char *) samples - out);
return clip;
}

332
addons/mp3/huffman.h Normal file
View File

@ -0,0 +1,332 @@
/*
* huffman tables ... recalcualted to work with my optimzed
* decoder scheme (MH)
*
* probably we could save a few bytes of memory, because the
* smaller tables are often the part of a bigger table
*/
struct newhuff
{
unsigned int linbits;
short *table;
};
static short tab0[] =
{
0
};
static short tab1[] =
{
-5, -3, -1, 17, 1, 16, 0
};
static short tab2[] =
{
-15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1,
16, 0
};
static short tab3[] =
{
-13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
1, 0
};
static short tab5[] =
{
-29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19,
3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16,
0
};
static short tab6[] =
{
-25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19,
49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16,
0
};
static short tab7[] =
{
-69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83,
-1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1,
80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7,
-3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18,
-5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0
};
static short tab8[] =
{
-65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83,
-3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52,
67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4,
64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1,
2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0
};
static short tab9[] =
{
-63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1,
84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67,
-1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5,
-3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2,
18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0
};
static short tab10[] =
{
-125,-121,-111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118,
87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3,
-1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1,
100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23,
-17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81,
-1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7,
-3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1,
50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1,
2, 32, 17, -1, 1, 16, 0
};
static short tab11[] =
{
-121,-113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117,
-3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55,
-1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114,
-1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96,
-1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38,
6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1,
36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50,
-1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2,
32, 17, -3, -1, 1, 16, 0
};
static short tab12[] =
{
-115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87,
117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115,
85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7,
112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5,
-1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37,
82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4,
36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3,
-1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1,
2, 32, 0, 17, -1, 1, 16
};
static short tab13[] =
{
-509,-503,-475,-405,-333,-265,-205,-153,-115, -83, -53, -35, -21, -13, -9,
-7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238,
207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1,
236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249,
234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158,
-5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1,
203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245,
231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1,
63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15,
-5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1,
200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1,
240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1,
46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3,
-1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1,
198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5,
-1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167,
151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76,
196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137,
28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106,
-5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43,
-1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178,
-11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1,
58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161,
-3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88,
-1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1,
131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25,
145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100,
40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113,
-1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38,
-1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6,
96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81,
-7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11,
-5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3,
-1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
0
};
static short tab15[] =
{
-495,-445,-355,-263,-183,-115, -77, -43, -27, -13, -7, -3, -1, 255, 239,
-1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237,
191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3,
-1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219,
-3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173,
-3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246,
-3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9,
-3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243,
216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1,
31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1,
125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3,
-1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5,
-1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124,
199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1,
198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183,
-5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76,
-1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1,
122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15,
-7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106,
-5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5,
-1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74,
-1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1,
42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134,
73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29,
-13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7,
-3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7,
-3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86,
-3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100,
23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69,
-1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9,
-5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1,
5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20,
4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48,
34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16,
0
};
static short tab16[] =
{
-509,-503,-461,-323,-103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223,
253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3,
-1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5,
-3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19,
-13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1,
238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5,
-1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125,
94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13,
-5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3,
-1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186,
-1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1,
214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169,
-5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213,
-3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154,
108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1,
153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1,
192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45,
-1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107,
-1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12,
-1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1,
178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74,
164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33,
-19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3,
-1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147,
-1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1,
145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3,
-1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1,
8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3,
-1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1,
99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9,
-5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33,
-23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20,
-5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1,
3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
0
};
static short tab24[] =
{
-451,-117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1,
207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9,
-5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79,
244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31,
240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1,
236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3,
-1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3,
-1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255,-235,
-143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3,
-1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9,
-5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1,
78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185,
170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199,
77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3,
-1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3,
-1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196,
-3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1,
167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1,
137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10,
26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9,
144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165,
27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135,
-1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104,
-1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3,
-1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3,
-1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7,
-3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86,
101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15,
-7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84,
-7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1,
83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5,
80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5,
-1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1,
3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16,
0
};
static short tab_c0[] =
{
-29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5,
9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8,
0
};
static short tab_c1[] =
{
-15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9,
8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1,
0
};
static struct newhuff ht[] =
{
{ /* 0 */ 0 , tab0 } ,
{ /* 2 */ 0 , tab1 } ,
{ /* 3 */ 0 , tab2 } ,
{ /* 3 */ 0 , tab3 } ,
{ /* 0 */ 0 , tab0 } ,
{ /* 4 */ 0 , tab5 } ,
{ /* 4 */ 0 , tab6 } ,
{ /* 6 */ 0 , tab7 } ,
{ /* 6 */ 0 , tab8 } ,
{ /* 6 */ 0 , tab9 } ,
{ /* 8 */ 0 , tab10 } ,
{ /* 8 */ 0 , tab11 } ,
{ /* 8 */ 0 , tab12 } ,
{ /* 16 */ 0 , tab13 } ,
{ /* 0 */ 0 , tab0 } ,
{ /* 16 */ 0 , tab15 } ,
{ /* 16 */ 1 , tab16 } ,
{ /* 16 */ 2 , tab16 } ,
{ /* 16 */ 3 , tab16 } ,
{ /* 16 */ 4 , tab16 } ,
{ /* 16 */ 6 , tab16 } ,
{ /* 16 */ 8 , tab16 } ,
{ /* 16 */ 10, tab16 } ,
{ /* 16 */ 13, tab16 } ,
{ /* 16 */ 4 , tab24 } ,
{ /* 16 */ 5 , tab24 } ,
{ /* 16 */ 6 , tab24 } ,
{ /* 16 */ 7 , tab24 } ,
{ /* 16 */ 8 , tab24 } ,
{ /* 16 */ 9 , tab24 } ,
{ /* 16 */ 11, tab24 } ,
{ /* 16 */ 13, tab24 }
};
static struct newhuff htc[] =
{
{ /* 1 , 1 , */ 0 , tab_c0 } ,
{ /* 1 , 1 , */ 0 , tab_c1 }
};

323
addons/mp3/interface.c Normal file
View File

@ -0,0 +1,323 @@
#include <asterisk.h>
#include <asterisk/logger.h>
#include <stdlib.h>
#include <stdio.h>
#include "mpg123.h"
#include "mpglib.h"
void InitMP3Constants(void)
{
init_layer3_const();
make_decode_tables_const();
}
BOOL InitMP3(struct mpstr *mp, long outscale)
{
/* quiet 4096 med 8192 */
memset(mp,0,sizeof(struct mpstr));
mp->framesize = 0;
mp->fsizeold = -1;
mp->bsize = 0;
mp->head = mp->tail = NULL;
mp->fr.single = 3; /* force mono */
mp->bsnum = 0;
mp->synth_bo = 1;
mp->outsamplerate = 8000;
make_decode_tables_scale(mp, outscale);
init_layer3_sample_limits(mp, SBLIMIT);
return !0;
}
void ExitMP3(struct mpstr *mp)
{
struct buf *b,*bn;
b = mp->tail;
while(b) {
free(b->pnt);
bn = b->next;
free(b);
b = bn;
}
}
static struct buf *addbuf(struct mpstr *mp,char *buf,int size)
{
struct buf *nbuf;
nbuf = malloc( sizeof(struct buf) );
if(!nbuf) {
ast_log(LOG_WARNING,"Out of memory!\n");
return NULL;
}
nbuf->pnt = malloc(size);
if(!nbuf->pnt) {
free(nbuf);
return NULL;
}
nbuf->size = size;
memcpy(nbuf->pnt,buf,size);
nbuf->next = NULL;
nbuf->prev = mp->head;
nbuf->pos = 0;
if(!mp->tail) {
mp->tail = nbuf;
}
else {
mp->head->next = nbuf;
}
mp->head = nbuf;
mp->bsize += size;
return nbuf;
}
static void remove_buf(struct mpstr *mp)
{
struct buf *buf = mp->tail;
mp->tail = buf->next;
if(mp->tail)
mp->tail->prev = NULL;
else {
mp->tail = mp->head = NULL;
}
free(buf->pnt);
free(buf);
}
static int read_buf_byte(int *error, struct mpstr *mp)
{
unsigned int b;int pos;
pos = mp->tail->pos;
while(pos >= mp->tail->size) {
remove_buf(mp);
pos = mp->tail->pos;
if(!mp->tail) {
/* We may pick up this error a few times*/
/* But things have gone pear shaped */
ast_log(LOG_WARNING,"Fatal Buffer error!\n");
*error = 1;
return (0);
}
}
b = mp->tail->pnt[pos];
mp->bsize--;
mp->tail->pos++;
return b;
}
static int read_head(struct mpstr *mp)
{
unsigned long head;
int error=0;
head = read_buf_byte(&error, mp);
head <<= 8;
head |= read_buf_byte(&error, mp);
head <<= 8;
head |= read_buf_byte(&error, mp);
head <<= 8;
head |= read_buf_byte(&error, mp);
mp->header = head;
if(error){
return (1);
}else
return (0);
}
static int head_check(unsigned long head)
{
if( (head & 0xffe00000) != 0xffe00000)
return FALSE;
if(!((head>>17)&3))
return FALSE;
if( ((head>>12)&0xf) == 0xf || ((head>>12)&0xf) == 0)
return FALSE;
if( ((head>>10)&0x3) == 0x3 )
return FALSE;
if ((head & 0xffff0000) == 0xfffe0000)
return FALSE;
return TRUE;
}
static int head_shift(struct mpstr *mp)
{
unsigned long head;
int error = 0;
head = mp->header;
head <<= 8;
head |= read_buf_byte(&error, mp);
mp->header = head;
if (error){
return (1);
}else
return (0);
}
int decodeMP3(struct mpstr *mp,char *in,int isize,char *out,
int osize,int *done)
{
int len;
long n,m;
int down_sample_sblimit;
if(osize < 4608) {
ast_log(LOG_WARNING,"To less out space\n");
return MP3_ERR;
}
if(in) {
if(addbuf(mp,in,isize) == NULL) {
return MP3_ERR;
}
}
/* First decode header */
if(mp->framesize == 0) {
if(mp->bsize < 4) {
return MP3_NEED_MORE;
}
if (read_head(mp))
return MP3_ERR;
if(!head_check(mp->header) ) {
int i;
ast_log(LOG_WARNING,"Junk at the beginning of frame %08lx\n",mp->header);
/* step in byte steps through next 64K */
for(i=0;i<65536;i++) {
if(!mp->bsize)
return MP3_NEED_MORE;
if(head_shift(mp))
return MP3_ERR;
if(head_check(mp->header))
break;
}
if(i == 65536) {
ast_log(LOG_WARNING,"Giving up searching valid MPEG header\n");
return MP3_ERR;
}
}
decode_header(&mp->fr,mp->header);
mp->framesize = mp->fr.framesize;
if (!mp->initmp3){
mp->initmp3 = 1;
n = freqs[mp->fr.sampling_frequency];
if (mp->outsamplerate) {
m = mp->outsamplerate;
}
else {
m =n;
}
if (synth_ntom_set_step(n,m))
return MP3_ERR;
if(n>m) {
down_sample_sblimit = SBLIMIT * m;
down_sample_sblimit /= n;
}
else {
down_sample_sblimit = SBLIMIT;
}
init_layer3_sample_limits(mp, down_sample_sblimit);
}
}
if(mp->fr.framesize > mp->bsize)
return MP3_NEED_MORE;
(mp->worksample).wordpointer = mp->bsspace[mp->bsnum] + 512;
mp->bsnum = (mp->bsnum + 1) & 0x1;
(mp->worksample).bitindex = 0;
len = 0;
while(len < mp->framesize) {
int nlen;
int blen = mp->tail->size - mp->tail->pos;
if( (mp->framesize - len) <= blen) {
nlen = mp->framesize-len;
}
else {
nlen = blen;
}
memcpy((mp->worksample).wordpointer+len,mp->tail->pnt+mp->tail->pos,nlen);
len += nlen;
mp->tail->pos += nlen;
mp->bsize -= nlen;
if(mp->tail->pos == mp->tail->size) {
remove_buf(mp);
}
}
*done = 0;
if(mp->fr.error_protection)
getbits(mp, 16);
if (do_layer3(mp,(unsigned char *) out,done))
return MP3_ERR;
mp->fsizeold = mp->framesize;
mp->framesize = 0;
return MP3_OK;
}
int set_pointer(struct mpstr *mp, long backstep)
{
unsigned char *bsbufold;
if(mp->fsizeold < 0 && backstep > 0) {
ast_log(LOG_WARNING,"Can't step back %ld!\n",backstep);
return MP3_ERR;
}
bsbufold = mp->bsspace[mp->bsnum] + 512;
(mp->worksample).wordpointer -= backstep;
if (backstep)
memcpy((mp->worksample).wordpointer,bsbufold+mp->fsizeold-backstep,backstep);
(mp->worksample).bitindex = 0;
return MP3_OK;
}

2029
addons/mp3/layer3.c Normal file

File diff suppressed because it is too large Load Diff

132
addons/mp3/mpg123.h Normal file
View File

@ -0,0 +1,132 @@
#include <stdio.h>
#include <string.h>
#include <signal.h>
#ifndef WIN32
#include <sys/signal.h>
#include <unistd.h>
#endif
#include <math.h>
#ifdef _WIN32
# undef WIN32
# define WIN32
# define M_PI 3.14159265358979323846
# define M_SQRT2 1.41421356237309504880
# define REAL_IS_FLOAT
# define NEW_DCT9
# define random rand
# define srandom srand
#endif
#ifdef REAL_IS_FLOAT
# define real float
#elif defined(REAL_IS_LONG_DOUBLE)
# define real long double
#else
# define real double
#endif
#ifdef __GNUC__
#define INLINE inline
#else
#define INLINE
#endif
/* AUDIOBUFSIZE = n*64 with n=1,2,3 ... */
#define AUDIOBUFSIZE 16384
#define FALSE 0
#define TRUE 1
#define SBLIMIT 32
#define SSLIMIT 18
#define MPG_MD_STEREO 0
#define MPG_MD_JOINT_STEREO 1
#define MPG_MD_DUAL_CHANNEL 2
#define MPG_MD_MONO 3
#define MAXFRAMESIZE 1792
/* Pre Shift fo 16 to 8 bit converter table */
#define AUSHIFT (3)
struct frame {
int stereo;
int jsbound;
int single;
int lsf;
int mpeg25;
int header_change;
int lay;
int error_protection;
int bitrate_index;
int sampling_frequency;
int padding;
int extension;
int mode;
int mode_ext;
int copyright;
int original;
int emphasis;
int framesize; /* computed framesize */
};
struct parameter {
int quiet; /* shut up! */
int tryresync; /* resync stream after error */
int verbose; /* verbose level */
int checkrange;
};
extern int decode_header(struct frame *fr,unsigned long newhead);
struct gr_info_s {
int scfsi;
unsigned part2_3_length;
unsigned big_values;
unsigned scalefac_compress;
unsigned block_type;
unsigned mixed_block_flag;
unsigned table_select[3];
unsigned subblock_gain[3];
unsigned maxband[3];
unsigned maxbandl;
unsigned maxb;
unsigned region1start;
unsigned region2start;
unsigned preflag;
unsigned scalefac_scale;
unsigned count1table_select;
real *full_gain[3];
real *pow2gain;
};
struct III_sideinfo
{
unsigned main_data_begin;
unsigned private_bits;
struct {
struct gr_info_s gr[2];
} ch[2];
};
struct pcm_workingsample
{
int bitindex;
unsigned char *wordpointer;
};
extern long freqs[9];
extern struct parameter param;
extern real *pnts[5];

75
addons/mp3/mpglib.h Normal file
View File

@ -0,0 +1,75 @@
struct buf {
unsigned char *pnt;
long size;
long pos;
struct buf *next;
struct buf *prev;
};
struct framebuf {
struct buf *buf;
long pos;
struct frame *next;
struct frame *prev;
};
struct mpstr {
struct buf *head,*tail;
int bsize;
int framesize;
int fsizeold;
struct frame fr;
unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */
real hybrid_block[2][2][SBLIMIT*SSLIMIT];
int hybrid_blc[2];
unsigned long header;
int bsnum;
real synth_buffs[2][2][0x110];
int synth_bo;
long outscale; /* volume control default value 32768 */
long outsamplerate; /* raw output rate default same as mp3 sample rate*/
struct pcm_workingsample worksample; /* keep the state of the working sample for threads */
int initmp3; /* flag for first initialisation */
int longLimit[9][23]; /*sample limits re setting volume */
int shortLimit[9][14];
real decwin[512+32]; /* scale table */
};
#define BOOL int
#define MP3_ERR -1
#define MP3_OK 0
#define MP3_NEED_MORE 1
void InitMP3Constants(void);
BOOL InitMP3(struct mpstr *mp, long outscale);
int decodeMP3(struct mpstr *mp,char *inmemory,int inmemsize,
char *outmemory,int outmemsize,int *done);
void ExitMP3(struct mpstr *mp);
extern int synth_ntom_set_step(long,long);
extern int synth_ntom(struct mpstr *mp, real *bandPtr,int channel,unsigned char *out,int *pnt);
extern int synth_ntom_mono (struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt);
extern int synth_ntom_8bit (real *,int,unsigned char *,int *);
extern int synth_ntom_mono2stereo (real *,unsigned char *,int *);
extern int synth_ntom_8bit_mono (real *,unsigned char *,int *);
extern int synth_ntom_8bit_mono2stereo (real *,unsigned char *,int *);
extern void init_layer3_sample_limits(struct mpstr *mp, int down_sample_sblimit);
extern void init_layer3_const(void);
extern int do_layer3(struct mpstr *mp,unsigned char *,int *);
extern void make_decode_tables_scale(struct mpstr *mp, long scaleval);
extern void make_decode_tables_const(void);
extern void make_conv16to8_table(int);
extern void dct64(real *,real *,real *);
extern unsigned int get1bit(struct mpstr *mp);
extern unsigned int getbits(struct mpstr *mp, int);
extern unsigned int getbits_fast(struct mpstr *mp, int);
extern int set_pointer(struct mpstr *mp, long backstep);

81
addons/mp3/tabinit.c Normal file
View File

@ -0,0 +1,81 @@
#include <stdlib.h>
#include "mpg123.h"
#include "mpglib.h"
static real cos64[16],cos32[8],cos16[4],cos8[2],cos4[1];
real *pnts[] = { cos64,cos32,cos16,cos8,cos4 };
static long intwinbase[] = {
0, -1, -1, -1, -1, -1, -1, -2, -2, -2,
-2, -3, -3, -4, -4, -5, -5, -6, -7, -7,
-8, -9, -10, -11, -13, -14, -16, -17, -19, -21,
-24, -26, -29, -31, -35, -38, -41, -45, -49, -53,
-58, -63, -68, -73, -79, -85, -91, -97, -104, -111,
-117, -125, -132, -139, -147, -154, -161, -169, -176, -183,
-190, -196, -202, -208, -213, -218, -222, -225, -227, -228,
-228, -227, -224, -221, -215, -208, -200, -189, -177, -163,
-146, -127, -106, -83, -57, -29, 2, 36, 72, 111,
153, 197, 244, 294, 347, 401, 459, 519, 581, 645,
711, 779, 848, 919, 991, 1064, 1137, 1210, 1283, 1356,
1428, 1498, 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962,
2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063, 2037, 2000,
1952, 1893, 1822, 1739, 1644, 1535, 1414, 1280, 1131, 970,
794, 605, 402, 185, -45, -288, -545, -814, -1095, -1388,
-1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
-5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209,
-8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959,
-9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092,
-7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082,
-70, 998, 2122, 3300, 4533, 5818, 7154, 8540, 9975, 11455,
12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289,
30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617,
48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684,
64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
73415, 73908, 74313, 74630, 74856, 74992, 75038 };
void make_decode_tables_const(void)
{
int i,k,kr,divv;
real *costab;
for(i=0;i<5;i++)
{
kr=0x10>>i; divv=0x40>>i;
costab = pnts[i];
for(k=0;k<kr;k++)
costab[k] = 1.0 / (2.0 * cos(M_PI * ((double) k * 2.0 + 1.0) / (double) divv));
}
}
void make_decode_tables_scale(struct mpstr *mp, long scaleval)
{
int i,j;
real *table;
table = mp->decwin;
scaleval = -scaleval;
for(i=0,j=0;i<256;i++,j++,table+=32)
{
if(table < (mp->decwin)+512+16)
table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
if(i % 32 == 31)
table -= 1023;
if(i % 64 == 63)
scaleval = - scaleval;
}
for( /* i=256 */ ;i<512;i++,j--,table+=32)
{
if(table < (mp->decwin)+512+16)
table[16] = table[0] = (double) intwinbase[j] / 65536.0 * (double) scaleval;
if(i % 32 == 31)
table -= 1023;
if(i % 64 == 63)
scaleval = - scaleval;
}
}

341
addons/ooh323c/COPYING Normal file
View File

@ -0,0 +1,341 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program 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.
This program is distributed in the hope that it will be useful,
but 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

95
addons/ooh323c/README Normal file
View File

@ -0,0 +1,95 @@
Copyright (C) 2004-2005 by Objective Systems, Inc.
Objective Open H.323 README
Introduction
Objective Open H.323 stack is a simple H.323 implementation in C. This
package contains the core stack code. For complete H.323 stack package with
examples or for more information visit www.obj-sys.com/open
The ASN.1 messaging code was developed using the Objective Systems ASN1C
compiler to implement the core H.323 specifications (H.225, H.235,
and H.245). Additional code was then developed which makes use of
the compiler generated code for presenting a comparatively high level
stack API.
Features
Features supported in this package include the following:
* H.225/Q.931 - the following message types are supported (including
support for FastStart and H.245 tunneling):
- Setup
- Connect
- Call Proceeding
- Alerting
- Facility
- ReleaseComplete
* H.225/RAS - the following message types are supported
- GateKeeperRequest / Response
- RegistrationRequest / Response
- AdmissionRequest / Response
- DisengageRequest / Response
* H.245 - the following message types are supported
- MasterSlaveDetermination
- MasterSlaveDeterminationAck
- MasterSlaveDeterminationReject
- MasterSlaveDeterminationRelease
- TerminalCapabilitySet
- TerminalCapabilitySetReject
- TerminalCapabilitySetRelease
- TerminalCapabilitySetAck
- OpenLogicalChannel
- OpenLogicalChannelAck
- OpenLogicalChannelReject
- CloseLogicalChannel
- CloseLogicalChannelAck
- RequestChannelClose
- RequestChannelCloseAck
- RequestChannelCloseReject
- RequestChannelCloseRelease
To run the stack test application chansetup
chansetup - This is a sample program developed for testing multiple calls.
This program allows stack testing by placing multiple calls. The number of
calls, duration of each call and interval between successive calls are
configurable.
1. Two instances of this program have to be run. Can be run on same machine or
different machines.
2. First change to chansetup directory.
cd tests/chansetup
2. For running listener instance,
./h323peer [--use-ip ip] [--use-port port]
where local ip address and port can be specified for listening to incoming
calls. By default, application determines ip address and uses default H323
port number 1720.
3. For running calling instance
./h323peer [--use-ip ip] -n <number of calls> -duration <call duration>
-interval <inetrval between successive calls> destination
where all times are in seconds. Interval of 0 means next call will be placed
after current call finishes. "destination" is the dotted ip address of the
endpoint running listener instance.
NOTE: More sample programs are available in the original ooh323c package
which can be downloaded from www.obj-sys.com/open
Reporting Problems:
Report problems you encounter by sending E-mail to support@obj-sys.com.
If you have any further questions or comments on what you would like to
see in the product or what is difficult to use or understand, please
communicate them to us. Your feedback is important to us. Please let us
know how it works out for you - either good or bad.

View File

@ -0,0 +1,564 @@
# Makefile.in generated by automake 1.6.3 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@
AMTAR = @AMTAR@
AS = @AS@
AWK = @AWK@
CC = @CC@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
INSTALLPREFIX = @INSTALLPREFIX@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
OBJDUMP = @OBJDUMP@
OOH323CDRIVERDIR = @OOH323CDRIVERDIR@
OOH323CFLAGS = @OOH323CFLAGS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
STRIP = @STRIP@
VERSION = @VERSION@
am__include = @am__include@
am__quote = @am__quote@
install_sh = @install_sh@
AUTOMAKE_OPTIONS = gnu
CFLAGS = @OOH323CFLAGS@
noinst_LIBRARIES = libooh323c.a
libooh323c_a_SOURCES = ooLogChan.h ooLogChan.c ooUtils.c ooUtils.h ooGkClient.h ooGkClient.c context.c ooCommon.h ooDateTime.h ooDateTime.c decode.c dlist.c encode.c errmgmt.c memheap.c memheap.h ooasn1.h ootrace.h ootrace.c oochannels.c oochannels.h ooh245.c ooh245.h oohdr.h ooper.h ooports.c ooports.h ooq931.c ooq931.h ooCapability.c ooCapability.h ooSocket.c ooSocket.h ootypes.h perutil.c eventHandler.c eventHandler.h ooCalls.c ooCalls.h ooStackCmds.c ooStackCmds.h ooh323.c ooh323.h ooh323ep.c ooh323ep.h printHandler.c printHandler.h rtctype.c rtctype.h ooTimer.c ooTimer.h h323/H235-SECURITY-MESSAGESDec.c h323/H235-SECURITY-MESSAGESEnc.c h323/H235-SECURITY-MESSAGES.h h323/H323-MESSAGES.c h323/H323-MESSAGESDec.c h323/H323-MESSAGESEnc.c h323/H323-MESSAGES.h h323/MULTIMEDIA-SYSTEM-CONTROL.c h323/MULTIMEDIA-SYSTEM-CONTROLDec.c h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c h323/MULTIMEDIA-SYSTEM-CONTROL.h
INCLUDES = -Ih323
#include_HEADERS = ooUtils.h memheap.h ooCommon.h ooDateTime.h ooGkClient.h ooasn1.h oochannels.h ootrace.h ooh245.h ooports.h ooq931.h oohdr.h ooper.h ooSocket.h ooTimer.h ootypes.h eventHandler.h ooCapability.h ooCalls.h ooStackCmds.h ooh323.h ooh323ep.h printHandler.h rtctype.h h323/H235-SECURITY-MESSAGES.h h323/H323-MESSAGES.h h323/MULTIMEDIA-SYSTEM-CONTROL.h
EXTRA_DIST = oostk.dsp
subdir = ooh323c/src
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
libooh323c_a_AR = $(AR) cru
libooh323c_a_LIBADD =
am_libooh323c_a_OBJECTS = ooLogChan.$(OBJEXT) ooUtils.$(OBJEXT) \
ooGkClient.$(OBJEXT) context.$(OBJEXT) ooDateTime.$(OBJEXT) \
decode.$(OBJEXT) dlist.$(OBJEXT) encode.$(OBJEXT) \
errmgmt.$(OBJEXT) memheap.$(OBJEXT) ootrace.$(OBJEXT) \
oochannels.$(OBJEXT) ooh245.$(OBJEXT) ooports.$(OBJEXT) \
ooq931.$(OBJEXT) ooCapability.$(OBJEXT) ooSocket.$(OBJEXT) \
perutil.$(OBJEXT) eventHandler.$(OBJEXT) ooCalls.$(OBJEXT) \
ooStackCmds.$(OBJEXT) ooh323.$(OBJEXT) ooh323ep.$(OBJEXT) \
printHandler.$(OBJEXT) rtctype.$(OBJEXT) ooTimer.$(OBJEXT) \
H235-SECURITY-MESSAGESDec.$(OBJEXT) \
H235-SECURITY-MESSAGESEnc.$(OBJEXT) H323-MESSAGES.$(OBJEXT) \
H323-MESSAGESDec.$(OBJEXT) H323-MESSAGESEnc.$(OBJEXT) \
MULTIMEDIA-SYSTEM-CONTROL.$(OBJEXT) \
MULTIMEDIA-SYSTEM-CONTROLDec.$(OBJEXT) \
MULTIMEDIA-SYSTEM-CONTROLEnc.$(OBJEXT)
libooh323c_a_OBJECTS = $(am_libooh323c_a_OBJECTS)
DEFS = @DEFS@
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/H235-SECURITY-MESSAGESDec.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/H235-SECURITY-MESSAGESEnc.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/H323-MESSAGES.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/H323-MESSAGESDec.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/H323-MESSAGESEnc.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/context.Po ./$(DEPDIR)/decode.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/dlist.Po ./$(DEPDIR)/encode.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/errmgmt.Po ./$(DEPDIR)/eventHandler.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/memheap.Po ./$(DEPDIR)/ooCalls.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooCapability.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooDateTime.Po ./$(DEPDIR)/ooGkClient.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooLogChan.Po ./$(DEPDIR)/ooSocket.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooStackCmds.Po ./$(DEPDIR)/ooTimer.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooUtils.Po ./$(DEPDIR)/oochannels.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooh245.Po ./$(DEPDIR)/ooh323.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooh323ep.Po ./$(DEPDIR)/ooports.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/ooq931.Po ./$(DEPDIR)/ootrace.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/perutil.Po ./$(DEPDIR)/printHandler.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/rtctype.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(libooh323c_a_SOURCES)
DIST_COMMON = Makefile.am Makefile.in
SOURCES = $(libooh323c_a_SOURCES)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu ooh323c/src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
AR = ar
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
H235-SECURITY-MESSAGESDec.$(OBJEXT): h323/H235-SECURITY-MESSAGESDec.c
H235-SECURITY-MESSAGESEnc.$(OBJEXT): h323/H235-SECURITY-MESSAGESEnc.c
H323-MESSAGES.$(OBJEXT): h323/H323-MESSAGES.c
H323-MESSAGESDec.$(OBJEXT): h323/H323-MESSAGESDec.c
H323-MESSAGESEnc.$(OBJEXT): h323/H323-MESSAGESEnc.c
MULTIMEDIA-SYSTEM-CONTROL.$(OBJEXT): h323/MULTIMEDIA-SYSTEM-CONTROL.c
MULTIMEDIA-SYSTEM-CONTROLDec.$(OBJEXT): \
h323/MULTIMEDIA-SYSTEM-CONTROLDec.c
MULTIMEDIA-SYSTEM-CONTROLEnc.$(OBJEXT): \
h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
libooh323c.a: $(libooh323c_a_OBJECTS) $(libooh323c_a_DEPENDENCIES)
-rm -f libooh323c.a
$(libooh323c_a_AR) libooh323c.a $(libooh323c_a_OBJECTS) $(libooh323c_a_LIBADD)
$(RANLIB) libooh323c.a
mostlyclean-compile:
-rm -f *.$(OBJEXT) core *.core
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H235-SECURITY-MESSAGESDec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H235-SECURITY-MESSAGESEnc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H323-MESSAGES.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H323-MESSAGESDec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H323-MESSAGESEnc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/context.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errmgmt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eventHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooCalls.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooCapability.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooDateTime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooGkClient.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooLogChan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooSocket.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooStackCmds.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooTimer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooUtils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oochannels.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooh245.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooh323.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooh323ep.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooports.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ooq931.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ootrace.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perutil.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtctype.Po@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.c.o:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
.c.obj:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `cygpath -w $<`
.c.lo:
@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
H235-SECURITY-MESSAGESDec.o: h323/H235-SECURITY-MESSAGESDec.c
@AMDEP_TRUE@ source='h323/H235-SECURITY-MESSAGESDec.c' object='H235-SECURITY-MESSAGESDec.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H235-SECURITY-MESSAGESDec.Po' tmpdepfile='$(DEPDIR)/H235-SECURITY-MESSAGESDec.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H235-SECURITY-MESSAGESDec.o `test -f 'h323/H235-SECURITY-MESSAGESDec.c' || echo '$(srcdir)/'`h323/H235-SECURITY-MESSAGESDec.c
H235-SECURITY-MESSAGESDec.obj: h323/H235-SECURITY-MESSAGESDec.c
@AMDEP_TRUE@ source='h323/H235-SECURITY-MESSAGESDec.c' object='H235-SECURITY-MESSAGESDec.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H235-SECURITY-MESSAGESDec.Po' tmpdepfile='$(DEPDIR)/H235-SECURITY-MESSAGESDec.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H235-SECURITY-MESSAGESDec.obj `cygpath -w h323/H235-SECURITY-MESSAGESDec.c`
H235-SECURITY-MESSAGESDec.lo: h323/H235-SECURITY-MESSAGESDec.c
@AMDEP_TRUE@ source='h323/H235-SECURITY-MESSAGESDec.c' object='H235-SECURITY-MESSAGESDec.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H235-SECURITY-MESSAGESDec.Plo' tmpdepfile='$(DEPDIR)/H235-SECURITY-MESSAGESDec.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H235-SECURITY-MESSAGESDec.lo `test -f 'h323/H235-SECURITY-MESSAGESDec.c' || echo '$(srcdir)/'`h323/H235-SECURITY-MESSAGESDec.c
H235-SECURITY-MESSAGESEnc.o: h323/H235-SECURITY-MESSAGESEnc.c
@AMDEP_TRUE@ source='h323/H235-SECURITY-MESSAGESEnc.c' object='H235-SECURITY-MESSAGESEnc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H235-SECURITY-MESSAGESEnc.Po' tmpdepfile='$(DEPDIR)/H235-SECURITY-MESSAGESEnc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H235-SECURITY-MESSAGESEnc.o `test -f 'h323/H235-SECURITY-MESSAGESEnc.c' || echo '$(srcdir)/'`h323/H235-SECURITY-MESSAGESEnc.c
H235-SECURITY-MESSAGESEnc.obj: h323/H235-SECURITY-MESSAGESEnc.c
@AMDEP_TRUE@ source='h323/H235-SECURITY-MESSAGESEnc.c' object='H235-SECURITY-MESSAGESEnc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H235-SECURITY-MESSAGESEnc.Po' tmpdepfile='$(DEPDIR)/H235-SECURITY-MESSAGESEnc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H235-SECURITY-MESSAGESEnc.obj `cygpath -w h323/H235-SECURITY-MESSAGESEnc.c`
H235-SECURITY-MESSAGESEnc.lo: h323/H235-SECURITY-MESSAGESEnc.c
@AMDEP_TRUE@ source='h323/H235-SECURITY-MESSAGESEnc.c' object='H235-SECURITY-MESSAGESEnc.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H235-SECURITY-MESSAGESEnc.Plo' tmpdepfile='$(DEPDIR)/H235-SECURITY-MESSAGESEnc.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H235-SECURITY-MESSAGESEnc.lo `test -f 'h323/H235-SECURITY-MESSAGESEnc.c' || echo '$(srcdir)/'`h323/H235-SECURITY-MESSAGESEnc.c
H323-MESSAGES.o: h323/H323-MESSAGES.c
@AMDEP_TRUE@ source='h323/H323-MESSAGES.c' object='H323-MESSAGES.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGES.Po' tmpdepfile='$(DEPDIR)/H323-MESSAGES.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGES.o `test -f 'h323/H323-MESSAGES.c' || echo '$(srcdir)/'`h323/H323-MESSAGES.c
H323-MESSAGES.obj: h323/H323-MESSAGES.c
@AMDEP_TRUE@ source='h323/H323-MESSAGES.c' object='H323-MESSAGES.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGES.Po' tmpdepfile='$(DEPDIR)/H323-MESSAGES.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGES.obj `cygpath -w h323/H323-MESSAGES.c`
H323-MESSAGES.lo: h323/H323-MESSAGES.c
@AMDEP_TRUE@ source='h323/H323-MESSAGES.c' object='H323-MESSAGES.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGES.Plo' tmpdepfile='$(DEPDIR)/H323-MESSAGES.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGES.lo `test -f 'h323/H323-MESSAGES.c' || echo '$(srcdir)/'`h323/H323-MESSAGES.c
H323-MESSAGESDec.o: h323/H323-MESSAGESDec.c
@AMDEP_TRUE@ source='h323/H323-MESSAGESDec.c' object='H323-MESSAGESDec.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGESDec.Po' tmpdepfile='$(DEPDIR)/H323-MESSAGESDec.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGESDec.o `test -f 'h323/H323-MESSAGESDec.c' || echo '$(srcdir)/'`h323/H323-MESSAGESDec.c
H323-MESSAGESDec.obj: h323/H323-MESSAGESDec.c
@AMDEP_TRUE@ source='h323/H323-MESSAGESDec.c' object='H323-MESSAGESDec.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGESDec.Po' tmpdepfile='$(DEPDIR)/H323-MESSAGESDec.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGESDec.obj `cygpath -w h323/H323-MESSAGESDec.c`
H323-MESSAGESDec.lo: h323/H323-MESSAGESDec.c
@AMDEP_TRUE@ source='h323/H323-MESSAGESDec.c' object='H323-MESSAGESDec.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGESDec.Plo' tmpdepfile='$(DEPDIR)/H323-MESSAGESDec.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGESDec.lo `test -f 'h323/H323-MESSAGESDec.c' || echo '$(srcdir)/'`h323/H323-MESSAGESDec.c
H323-MESSAGESEnc.o: h323/H323-MESSAGESEnc.c
@AMDEP_TRUE@ source='h323/H323-MESSAGESEnc.c' object='H323-MESSAGESEnc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGESEnc.Po' tmpdepfile='$(DEPDIR)/H323-MESSAGESEnc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGESEnc.o `test -f 'h323/H323-MESSAGESEnc.c' || echo '$(srcdir)/'`h323/H323-MESSAGESEnc.c
H323-MESSAGESEnc.obj: h323/H323-MESSAGESEnc.c
@AMDEP_TRUE@ source='h323/H323-MESSAGESEnc.c' object='H323-MESSAGESEnc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGESEnc.Po' tmpdepfile='$(DEPDIR)/H323-MESSAGESEnc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGESEnc.obj `cygpath -w h323/H323-MESSAGESEnc.c`
H323-MESSAGESEnc.lo: h323/H323-MESSAGESEnc.c
@AMDEP_TRUE@ source='h323/H323-MESSAGESEnc.c' object='H323-MESSAGESEnc.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/H323-MESSAGESEnc.Plo' tmpdepfile='$(DEPDIR)/H323-MESSAGESEnc.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o H323-MESSAGESEnc.lo `test -f 'h323/H323-MESSAGESEnc.c' || echo '$(srcdir)/'`h323/H323-MESSAGESEnc.c
MULTIMEDIA-SYSTEM-CONTROL.o: h323/MULTIMEDIA-SYSTEM-CONTROL.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROL.c' object='MULTIMEDIA-SYSTEM-CONTROL.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.Po' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROL.o `test -f 'h323/MULTIMEDIA-SYSTEM-CONTROL.c' || echo '$(srcdir)/'`h323/MULTIMEDIA-SYSTEM-CONTROL.c
MULTIMEDIA-SYSTEM-CONTROL.obj: h323/MULTIMEDIA-SYSTEM-CONTROL.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROL.c' object='MULTIMEDIA-SYSTEM-CONTROL.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.Po' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROL.obj `cygpath -w h323/MULTIMEDIA-SYSTEM-CONTROL.c`
MULTIMEDIA-SYSTEM-CONTROL.lo: h323/MULTIMEDIA-SYSTEM-CONTROL.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROL.c' object='MULTIMEDIA-SYSTEM-CONTROL.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.Plo' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROL.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROL.lo `test -f 'h323/MULTIMEDIA-SYSTEM-CONTROL.c' || echo '$(srcdir)/'`h323/MULTIMEDIA-SYSTEM-CONTROL.c
MULTIMEDIA-SYSTEM-CONTROLDec.o: h323/MULTIMEDIA-SYSTEM-CONTROLDec.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROLDec.c' object='MULTIMEDIA-SYSTEM-CONTROLDec.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.Po' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROLDec.o `test -f 'h323/MULTIMEDIA-SYSTEM-CONTROLDec.c' || echo '$(srcdir)/'`h323/MULTIMEDIA-SYSTEM-CONTROLDec.c
MULTIMEDIA-SYSTEM-CONTROLDec.obj: h323/MULTIMEDIA-SYSTEM-CONTROLDec.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROLDec.c' object='MULTIMEDIA-SYSTEM-CONTROLDec.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.Po' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROLDec.obj `cygpath -w h323/MULTIMEDIA-SYSTEM-CONTROLDec.c`
MULTIMEDIA-SYSTEM-CONTROLDec.lo: h323/MULTIMEDIA-SYSTEM-CONTROLDec.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROLDec.c' object='MULTIMEDIA-SYSTEM-CONTROLDec.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.Plo' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLDec.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROLDec.lo `test -f 'h323/MULTIMEDIA-SYSTEM-CONTROLDec.c' || echo '$(srcdir)/'`h323/MULTIMEDIA-SYSTEM-CONTROLDec.c
MULTIMEDIA-SYSTEM-CONTROLEnc.o: h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c' object='MULTIMEDIA-SYSTEM-CONTROLEnc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.Po' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROLEnc.o `test -f 'h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c' || echo '$(srcdir)/'`h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
MULTIMEDIA-SYSTEM-CONTROLEnc.obj: h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c' object='MULTIMEDIA-SYSTEM-CONTROLEnc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.Po' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROLEnc.obj `cygpath -w h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c`
MULTIMEDIA-SYSTEM-CONTROLEnc.lo: h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
@AMDEP_TRUE@ source='h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c' object='MULTIMEDIA-SYSTEM-CONTROLEnc.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.Plo' tmpdepfile='$(DEPDIR)/MULTIMEDIA-SYSTEM-CONTROLEnc.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o MULTIMEDIA-SYSTEM-CONTROLEnc.lo `test -f 'h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c' || echo '$(srcdir)/'`h323/MULTIMEDIA-SYSTEM-CONTROLEnc.c
CCDEPMODE = @CCDEPMODE@
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ETAGS = etags
ETAGSFLAGS =
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ../..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@list='$(DISTFILES)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
mostlyclean-am
distclean: distclean-am
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
uninstall-am: uninstall-info-am
.PHONY: GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLIBRARIES distclean distclean-compile \
distclean-depend distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
tags uninstall uninstall-am uninstall-info-am
opt:
$(MAKE) "CFLAGS = -DGNU -D_GNU_SOURCE -D_REENTRANT -O2 -D_COMPACT" all
debug:
$(MAKE) "CFLAGS = -g -DGNU -D_GNU_SOURCE -D_REENTRANT" all
profile:
$(MAKE) "CFLAGS = -g -pg -DGNU -D_GNU_SOURCE -D_REENTRANT" all
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,140 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooasn1.h"
#include <stdlib.h>
int initContext (OOCTXT* pctxt)
{
memset (pctxt, 0, sizeof(OOCTXT));
memHeapCreate (&pctxt->pTypeMemHeap);
pctxt->pMsgMemHeap = pctxt->pTypeMemHeap;
memHeapAddRef (&pctxt->pMsgMemHeap);
return ASN_OK;
}
int initContextBuffer
(OOCTXT* pctxt, const ASN1OCTET* bufaddr, ASN1UINT bufsiz)
{
if (bufaddr == 0) {
/* dynamic buffer */
if (bufsiz == 0) bufsiz = ASN_K_ENCBUFSIZ;
pctxt->buffer.data = (ASN1OCTET*)
memHeapAlloc (&pctxt->pMsgMemHeap, bufsiz);
if (!pctxt->buffer.data) return ASN_E_NOMEM;
pctxt->buffer.size = bufsiz;
pctxt->buffer.dynamic = TRUE;
}
else {
/* static buffer */
pctxt->buffer.data = (ASN1OCTET*) bufaddr;
pctxt->buffer.size = bufsiz;
pctxt->buffer.dynamic = FALSE;
}
pctxt->buffer.byteIndex = 0;
pctxt->buffer.bitOffset = 8;
return ASN_OK;
}
int initSubContext (OOCTXT* pctxt, OOCTXT* psrc)
{
int stat = ASN_OK;
memset (pctxt, 0, sizeof(OOCTXT));
pctxt->pTypeMemHeap = psrc->pTypeMemHeap;
memHeapAddRef (&pctxt->pTypeMemHeap);
pctxt->pMsgMemHeap = psrc->pMsgMemHeap;
memHeapAddRef (&pctxt->pMsgMemHeap);
pctxt->flags = psrc->flags;
pctxt->buffer.dynamic = TRUE;
pctxt->buffer.byteIndex = 0;
pctxt->buffer.bitOffset = 8;
return stat;
}
void freeContext (OOCTXT* pctxt)
{
ASN1BOOL saveBuf = (pctxt->flags & ASN1SAVEBUF) != 0;
if (pctxt->buffer.dynamic && pctxt->buffer.data) {
if (saveBuf) {
memHeapMarkSaved (&pctxt->pMsgMemHeap, pctxt->buffer.data, TRUE);
}
else {
memHeapFreePtr (&pctxt->pMsgMemHeap, pctxt->buffer.data);
}
}
errFreeParms (&pctxt->errInfo);
memHeapRelease (&pctxt->pTypeMemHeap);
memHeapRelease (&pctxt->pMsgMemHeap);
}
void copyContext (OOCTXT* pdest, OOCTXT* psrc)
{
memcpy (&pdest->buffer, &psrc->buffer, sizeof(ASN1BUFFER));
pdest->flags = psrc->flags;
}
void setCtxtFlag (OOCTXT* pctxt, ASN1USINT mask)
{
pctxt->flags |= mask;
}
void clearCtxtFlag (OOCTXT* pctxt, ASN1USINT mask)
{
pctxt->flags &= ~mask;
}
int setPERBufferUsingCtxt (OOCTXT* pTarget, OOCTXT* pSource)
{
int stat = initContextBuffer
(pTarget, pSource->buffer.data, pSource->buffer.size);
if (ASN_OK == stat) {
pTarget->buffer.byteIndex = pSource->buffer.byteIndex;
pTarget->buffer.bitOffset = pSource->buffer.bitOffset;
}
return stat;
}
int setPERBuffer (OOCTXT* pctxt,
ASN1OCTET* bufaddr, ASN1UINT bufsiz, ASN1BOOL aligned)
{
int stat = initContextBuffer (pctxt, bufaddr, bufsiz);
if(stat != ASN_OK) return stat;
return ASN_OK;
}
OOCTXT* newContext ()
{
OOCTXT* pctxt = (OOCTXT*) ASN1CRTMALLOC0 (sizeof(OOCTXT));
if (pctxt) {
if (initContext(pctxt) != ASN_OK) {
ASN1CRTFREE0 (pctxt);
pctxt = 0;
}
pctxt->flags |= ASN1DYNCTXT;
}
return (pctxt);
}

1050
addons/ooh323c/src/decode.c Normal file

File diff suppressed because it is too large Load Diff

256
addons/ooh323c/src/dlist.c Normal file
View File

@ -0,0 +1,256 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooasn1.h"
void dListInit (DList* pList)
{
if (pList) {
pList->count = 0;
pList->head = (DListNode*) 0;
pList->tail = (DListNode*) 0;
}
}
DListNode* dListAppend (OOCTXT* pctxt, DList* pList, void* pData)
{
DListNode* pListNode = (DListNode*)
memAlloc (pctxt, sizeof(DListNode));
if (0 != pListNode) {
pListNode->data = pData;
pListNode->next = (DListNode*) 0;
if (0 != pList->tail) {
pList->tail->next = pListNode;
pListNode->prev = pList->tail;
}
if (0 == pList->head) {
pList->head = pListNode;
pListNode->prev = (DListNode*) 0;
}
pList->tail = pListNode;
pList->count++;
}
return pListNode;
}
DListNode* dListAppendNode (OOCTXT* pctxt, DList* pList, void* pData)
{
DListNode* pListNode =
(DListNode*) (((char*)pData) - sizeof(DListNode));
if (0 != pListNode) {
pListNode->data = pData;
pListNode->next = (DListNode*) 0;
if (0 != pList->tail) {
pList->tail->next = pListNode;
pListNode->prev = pList->tail;
}
if (0 == pList->head) {
pList->head = pListNode;
pListNode->prev = (DListNode*) 0;
}
pList->tail = pListNode;
pList->count++;
}
return pListNode;
}
/* Delete the head node from the list and return the data item stored */
/* in that node.. */
void* dListDeleteHead (OOCTXT* pctxt, DList* pList)
{
DListNode* pNode = (0 != pList) ? pList->head : 0;
if (0 != pNode) {
void* pdata = pNode->data;
dListRemove (pList, pNode);
memFreePtr (pctxt, pNode);
return pdata;
}
return 0;
}
/* Free all nodes, but not the data */
void dListFreeNodes (OOCTXT* pctxt, DList* pList)
{
DListNode* pNode, *pNextNode;
for (pNode = pList->head; pNode != 0; pNode = pNextNode) {
pNextNode = pNode->next;
memFreePtr (pctxt, pNode);
}
pList->count = 0;
pList->head = pList->tail = 0;
}
/* Free all nodes and their data */
void dListFreeAll (OOCTXT* pctxt, DList* pList)
{
DListNode* pNode, *pNextNode;
for (pNode = pList->head; pNode != 0; pNode = pNextNode) {
pNextNode = pNode->next;
memFreePtr (pctxt, pNode->data);
memFreePtr (pctxt, pNode);
}
pList->count = 0;
pList->head = pList->tail = 0;
}
/* Remove node from list. Node is not freed */
void dListRemove (DList* pList, DListNode* node)
{
if(node->next != 0) {
node->next->prev = node->prev;
}
else { /* tail */
pList->tail = node->prev;
}
if(node->prev != 0) {
node->prev->next = node->next;
}
else { /* head */
pList->head = node->next;
}
pList->count--;
}
void dListFindAndRemove(DList* pList, void *data)
{
DListNode *pNode, *pNextNode;
for(pNode = pList->head; pNode !=0; pNode = pNextNode){
pNextNode = pNode->next;
if(pNode->data == data) /* pointer comparison*/
break;
}
if(pNode)
dListRemove(pList, pNode);
}
DListNode* dListFindByIndex (DList* pList, int index)
{
DListNode* curNode;
int i;
if(index >= (int)pList->count) return 0;
for(i = 0, curNode = pList->head; i < index && curNode != 0; i++) {
curNode = curNode->next;
}
return curNode;
}
/* Insert item before given node */
DListNode* dListInsertBefore
(OOCTXT* pctxt, DList* pList, DListNode* node, const void* pData)
{
DListNode* pListNode = (DListNode*) memAlloc (pctxt, sizeof(DListNode));
if (0 != pListNode) {
pListNode->data = (void*)pData;
if (node == 0) { /* insert before end (as last element) */
pListNode->next = (DListNode*) 0;
if (0 != pList->tail) {
pList->tail->next = pListNode;
pListNode->prev = pList->tail;
}
if (0 == pList->head) {
pList->head = pListNode;
pListNode->prev = (DListNode*) 0;
}
pList->tail = pListNode;
}
else if (node == pList->head) { /* insert as head (head case) */
pListNode->next = pList->head;
pListNode->prev = (DListNode*) 0;
if(pList->head != 0) {
pList->head->prev = pListNode;
}
if(pList->tail == 0) {
pList->tail = pListNode;
}
pList->head = pListNode;
}
else { /* other cases */
pListNode->next = node;
pListNode->prev = node->prev;
node->prev = pListNode;
/* here, pListNode->prev always should be non-zero,
* because if pListNode->prev is zero - it is head case (see above).
*/
pListNode->prev->next = pListNode;
}
pList->count++;
}
return pListNode;
}
/* Insert item after given node */
DListNode* dListInsertAfter
(OOCTXT* pctxt, DList* pList, DListNode* node, const void* pData)
{
DListNode* pListNode = (DListNode*) memAlloc (pctxt, sizeof(DListNode));
if (0 != pListNode) {
pListNode->data = (void*)pData;
if (node == 0) { /* insert as head (as first element) */
pListNode->next = pList->head;
pListNode->prev = (DListNode*) 0;
if (pList->head != 0) {
pList->head->prev = pListNode;
}
if (pList->tail == 0) {
pList->tail = pListNode;
}
pList->head = pListNode;
}
else if (node == pList->tail) { /* insert as tail (as last element) */
pListNode->next = (DListNode*) 0;
if (0 != pList->tail) {
pList->tail->next = pListNode;
pListNode->prev = pList->tail;
}
if (0 == pList->head) {
pList->head = pListNode;
pListNode->prev = (DListNode*) 0;
}
pList->tail = pListNode;
}
else { /* other cases */
pListNode->next = node->next;
pListNode->prev = node;
node->next = pListNode;
/* here, pListNode->next always should be non-zero,
* because if pListNode->next is zero - it is tail case (see above).
*/
pListNode->next->prev = pListNode;
}
pList->count++;
}
return pListNode;
}

204
addons/ooh323c/src/dlist.h Normal file
View File

@ -0,0 +1,204 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file dlist.h
* Doubly-linked list structures and utility functions.
*/
#ifndef _OODLIST_H_
#define _OODLIST_H_
struct OOCTXT;
/**
* @defgroup llfuns Doubly-linked list structures and utility functions.
* @{
*/
typedef struct _DListNode {
void* data;
struct _DListNode* next;
struct _DListNode* prev;
} DListNode;
typedef struct _DList {
unsigned int count;
DListNode* head;
DListNode* tail;
} DList;
#define ALLOC_ASN1ELEMDNODE(pctxt,type) \
(type*) (((char*)memHeapAllocZ (&(pctxt)->pTypeMemHeap, sizeof(type) + \
sizeof(DListNode))) + sizeof(DListNode))
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#if defined (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#elif defined (USEASN1DLL)
#define EXTERN __declspec(dllimport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* This function appends an item to the linked list structure. The data item is
* passed into the function as a void pointer that can point to any object of
* any type. The memAlloc function is used to allocated the memory for the
* list node structure; therefore, all internal list memory will be released
* whenever memFree is called. The pointer to the data item itself is stored
* in the node structure - a copy is not made.
*
* @param pctxt A pointer to a context structure. This provides a
* storage area for the function to store all working
* variables that must be maintained between function
* calls.
* @param pList A pointer to a linked list structure onto which the data
* item is to be appended. A pointer to an updated linked
* list structure.
* @param pData A pointer to a data item to be appended to the list.
* @return A pointer to an allocated node structure used to link
* the given data value into the list.
*/
EXTERN DListNode* dListAppend
(struct OOCTXT* pctxt, DList* pList, void* pData);
EXTERN DListNode* dListAppendNode
(struct OOCTXT* pctxt, DList* pList, void* pData);
/**
* This function delete the head item from the list and returns a pointer
* the data item stored in that node. The memory for the node structure
* is released.
*
* @param pctxt A pointer to a context structure. This provides a
* storage area for the function to store all working
* variables that must be maintained between function
* calls.
* @param pList A pointer to the linked list structure from which
* the node will be deleted.
* @return A pointer to the data item stored in the deleted node.
*/
EXTERN void* dListDeleteHead (struct OOCTXT* pctxt, DList* pList);
EXTERN DListNode* dListFindByIndex (DList* pList, int index);
/**
* This function initializes a doubly linked list structure. It sets the number
* of elements to zero and sets all internal pointer values to NULL. A doubly
* linked-list structure is described by the DList type. Nodes of the list
* are of type DListNode.
*
* Memory for the structures is allocated using the memAlloc run-time
* function and is maintained within the context structure that is a required
* parameter to all dList functions. This memory is released when memFree
* is called or the Context is released. Unless otherwise noted, all data
* passed into the list functions is simply stored on the list by value (i.e. a
* deep-copy of the data is not done).
*
* @param pList A pointer to a linked list structure to be initialized.
*/
EXTERN void dListInit (DList* pList);
/**
* This function removes all nodes from the linked list and releases the memory
* that was allocated for storing the node structures (DListNode). The data
* will not be released.
*
* @param pctxt A pointer to a context structure. This provides a
* storage area for the function to store all working
* variables that must be maintained between function
* calls.
* @param pList A pointer to a linked list structure onto which the data
* item is to be appended. A pointer to an updated linked
* list structure.
*/
EXTERN void dListFreeNodes (struct OOCTXT* pctxt, DList* pList);
/**
* This function removes all nodes from the linked list structure and releases
* the memory that was allocated for storing the node structures
* (DListNode) and for data. The memory for data in each node must have
* been previously allocated with calls to memAlloc, memAllocZ, or
* memRealloc functions.
*
* @param pctxt Pointer to a context structure. This provides a
* storage area for the function to store all working
* variables that must be maintained between function
* calls.
* @param pList Pointer to a linked list structure.
*/
EXTERN void dListFreeAll (struct OOCTXT* pctxt, DList* pList);
/**
* This function inserts an item into the linked list structure before the
* specified element.
*
* @param pctxt Pointer to a context structure.
* @param pList A pointer to a linked list structure into which the
* data item is to be inserted.
* @param node The position in the list where the item is to be
* inserted. The item will be inserted before this
* node or appended to the list if node is null.
* @param pData A pointer to the data item to be inserted to the list.
* @return A pointer to an allocated node structure used to
* link the given data value into the list.
*/
EXTERN DListNode* dListInsertBefore
(struct OOCTXT* pctxt, DList* pList, DListNode* node, const void* pData);
/**
* This function inserts an item into the linked list structure after the
* specified element.
*
* @param pctxt Pointer to a context structure.
* @param pList A pointer to a linked list structure into which the
* data item is to be inserted.
* @param node The position in the list where the item is to be
* inserted. The item will be inserted after this
* node or added as the head element if node is null.
* @param pData A pointer to the data item to be inserted to the list.
* @return A pointer to an allocated node structure used to
* link the given data value into the list.
*/
EXTERN DListNode* dListInsertAfter
(struct OOCTXT* pctxt, DList* pList, DListNode* node, const void* pData);
/**
* This function removes a node from the linked list structure. The memAlloc
* function was used to allocate the memory for the list node structure,
* therefore, all internal list memory will be released whenever memFree or
* memFreePtr is called.
*
* @param pList A pointer to a linked list structure onto which the data
* item is to be removed. A pointer to an updated linked
* list structure.
* @param node A pointer to the node that is to be removed. It should
* already be in the linked list structure.
*/
EXTERN void dListRemove (DList* pList, DListNode* node);
void dListFindAndRemove(DList* pList, void* data);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

1103
addons/ooh323c/src/encode.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,261 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/* Error management functions */
#include <stdlib.h>
#include "ooasn1.h"
/* Error status text */
static const char* g_status_text[] = {
"Encode buffer overflow",
"Unexpected end of buffer on decode",
"Unexpected tag encountered: expected = %s, parsed = %s",
"Invalid object identifier",
"Invalid field length detected",
"Enumerated value %s not in defined set",
"Duplicate element in SET",
"Missing required element in SET",
"Element with tag %s not part of SET",
"Max elements defined for SEQUENCE field exceeded",
"Element with tag %s is an invalid option in choice",
"No dynamic memory available",
"Invalid string type",
"Invalid hex string",
"Invalid binary string",
"Invalid real value",
"Max items in sized BIT or OCTET STRING field exceeded",
"Invalid value specification",
"No definition found for referenced defined value",
"No definition found for referenced defined type",
"Invalid tag value",
"Nesting level too deep",
"Value constraint violation: field %s, value %s",
"Value range error: lower bound is greater than upper",
"Unexpected end of file detected",
"Invalid UTF-8 character at index %d",
"List error: concurrent modification attempt while iterating",
"List error: illegal state for attempted operation",
"Array index out of bounds",
"Invalid parameter passed to function or method",
"Invalid time string format",
"Context is not initialized",
"ASN.1 value will not fit in target variable",
"Character is not within the defined character set",
"Invalid XML state for attempted operation",
"Error condition returned from XML parser:\n%s",
"SEQUENCE elements not in correct order",
"Invalid index for table constraint identifier",
"Invalid value for relational table constraint fixed type field",
"File not found",
"File read error",
"File write error",
"Invalid Base64 string",
"Socket error",
"XML interface library not found",
"Invalid XML interface library"
} ;
#define ASN1_K_MAX_STAT (sizeof(g_status_text)/sizeof(char *))
/* Add an integer parameter to an error message */
int errAddIntParm (ASN1ErrInfo* pErrInfo, int errParm)
{
char lbuf[16];
sprintf (lbuf, "%d", errParm);
return errAddStrParm (pErrInfo, lbuf);
}
/* Add a character string parameter to an error message */
int errAddStrParm (ASN1ErrInfo* pErrInfo, const char* errprm_p)
{
#if defined(_NO_THREADS) || !defined(_NO_MALLOC)
if (pErrInfo->parmcnt < ASN_K_MAXERRP) {
char* tmpstr = (char*) ASN1CRTMALLOC0 (strlen(errprm_p)+1);
strcpy (tmpstr, errprm_p);
pErrInfo->parms[pErrInfo->parmcnt] = tmpstr;
pErrInfo->parmcnt++;
return TRUE;
}
else
#endif
return FALSE;
}
/* Add an unsigned integer parameter to an error message */
int errAddUIntParm (ASN1ErrInfo* pErrInfo, unsigned int errParm)
{
char lbuf[16];
sprintf (lbuf, "%u", errParm);
return errAddStrParm (pErrInfo, lbuf);
}
/* Free error parameter memory */
void errFreeParms (ASN1ErrInfo* pErrInfo)
{
#if defined(_NO_THREADS) || !defined(_NO_MALLOC)
int i;
for (i = 0; i < pErrInfo->parmcnt; i++)
ASN1CRTFREE0 ((char*)pErrInfo->parms[i]);
#endif
pErrInfo->parmcnt = 0;
pErrInfo->status = 0;
}
/* Reset error */
int errReset (ASN1ErrInfo* pErrInfo)
{
errFreeParms (pErrInfo);
pErrInfo->stkx = 0;
return ASN_OK;
}
/* Format error message */
char* errFmtMsg (ASN1ErrInfo* pErrInfo, char* bufp)
{
const char* tp;
int i, j, pcnt;
if (pErrInfo->status < 0)
{
i = abs (pErrInfo->status + 1);
if (i >= 0 && i < ASN1_K_MAX_STAT)
{
/* Substitute error parameters into error message */
j = pcnt = 0;
tp = g_status_text[i];
while (*tp)
{
if (*tp == '%' && *(tp+1) == 's')
{
/* Plug in error parameter */
if (pcnt < pErrInfo->parmcnt && pErrInfo->parms[pcnt])
{
strcpy (&bufp[j], pErrInfo->parms[pcnt]);
j += strlen (pErrInfo->parms[pcnt++]);
}
else
bufp[j++] = '?';
tp += 2;
}
else
bufp[j++] = *tp++;
}
bufp[j] = '\0'; /* null terminate string */
}
else
strcpy (bufp, "unrecognized completion status");
}
else strcpy (bufp, "normal completion status");
return (bufp);
}
/* Get error text in a dynamic memory buffer. This allocates memory */
/* using the 'memAlloc' function. This memory is automatically freed */
/* at the time the 'memFree' function is called. */
char* errGetText (OOCTXT* pctxt)
{
char lbuf[500];
char* pBuf = (char*) ASN1MALLOC (pctxt,
(sizeof(lbuf) + 100 * (2 + pctxt->errInfo.stkx)) * sizeof(char));
sprintf (pBuf, "ASN.1 ERROR: Status %d\n", pctxt->errInfo.status);
sprintf (lbuf, "%s\nStack trace:", errFmtMsg (&pctxt->errInfo, lbuf));
strcat(pBuf, lbuf);
while (pctxt->errInfo.stkx > 0) {
pctxt->errInfo.stkx--;
sprintf (lbuf, " Module: %s, Line %d\n",
pctxt->errInfo.stack[pctxt->errInfo.stkx].module,
pctxt->errInfo.stack[pctxt->errInfo.stkx].lineno);
strcat(pBuf, lbuf);
}
errFreeParms (&pctxt->errInfo);
return pBuf;
}
/* Print error information to the standard output */
void errPrint (ASN1ErrInfo* pErrInfo)
{
char lbuf[200];
printf ("ASN.1 ERROR: Status %d\n", pErrInfo->status);
printf ("%s\n", errFmtMsg (pErrInfo, lbuf));
printf ("Stack trace:");
while (pErrInfo->stkx > 0) {
pErrInfo->stkx--;
printf (" Module: %s, Line %d\n",
pErrInfo->stack[pErrInfo->stkx].module,
pErrInfo->stack[pErrInfo->stkx].lineno);
}
errFreeParms (pErrInfo);
}
/* Copy error data from one error structure to another */
int errCopyData (ASN1ErrInfo* pSrcErrInfo, ASN1ErrInfo* pDestErrInfo)
{
int i;
pDestErrInfo->status = pSrcErrInfo->status;
/* copy error parameters */
for (i = 0; i < pSrcErrInfo->parmcnt; i++) {
errAddStrParm (pDestErrInfo, pSrcErrInfo->parms[i]);
}
/* copy stack info */
for (i = 0; i < pSrcErrInfo->stkx; i++) {
if (pDestErrInfo->stkx < ASN_K_MAXERRSTK) {
pDestErrInfo->stack[pDestErrInfo->stkx].module =
pSrcErrInfo->stack[i].module;
pDestErrInfo->stack[pDestErrInfo->stkx++].lineno =
pSrcErrInfo->stack[i].lineno;
}
}
return (pSrcErrInfo->status);
}
int errSetData (ASN1ErrInfo* pErrInfo, int status,
const char* module, int lno)
{
if (pErrInfo->status == 0) {
pErrInfo->status = status;
}
ooLogAsn1Error(status, module, lno);
return status;
}

View File

@ -0,0 +1,122 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "eventHandler.h"
void setEventHandler (OOCTXT* pctxt, EventHandler* pHandler)
{
pctxt->pEventHandler = pHandler;
}
void removeEventHandler (OOCTXT* pctxt)
{
pctxt->pEventHandler = 0;
}
void invokeStartElement (OOCTXT* pctxt, const char* name, int index)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->startElement (name, index);
}
}
void invokeEndElement (OOCTXT* pctxt, const char* name, int index)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->endElement (name, index);
}
}
void invokeBoolValue (OOCTXT* pctxt, ASN1BOOL value)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->boolValue (value);
}
}
void invokeIntValue (OOCTXT* pctxt, ASN1INT value)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->intValue (value);
}
}
void invokeUIntValue (OOCTXT* pctxt, ASN1UINT value)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->uIntValue (value);
}
}
void invokeBitStrValue (OOCTXT* pctxt, ASN1UINT numbits,
const ASN1OCTET* data)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->bitStrValue (numbits, data);
}
}
void invokeOctStrValue (OOCTXT* pctxt, ASN1UINT numocts,
const ASN1OCTET* data)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->octStrValue (numocts, data);
}
}
void invokeCharStrValue (OOCTXT* pctxt, const char* value)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->charStrValue (value);
}
}
void invokeCharStr16BitValue (OOCTXT* pctxt, ASN1UINT nchars,
ASN116BITCHAR* data)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->charStr16BitValue (nchars, data);
}
}
void invokeNullValue (OOCTXT* pctxt)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->nullValue ();
}
}
void invokeOidValue (OOCTXT* pctxt, ASN1UINT numSubIds, ASN1UINT* pSubIds)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->oidValue (numSubIds, pSubIds);
}
}
void invokeEnumValue (OOCTXT* pctxt, ASN1UINT value)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->enumValue (value);
}
}
void invokeOpenTypeValue (OOCTXT* pctxt, ASN1UINT numocts,
const ASN1OCTET* data)
{
if (0 != pctxt->pEventHandler) {
pctxt->pEventHandler->openTypeValue (numocts, data);
}
}

View File

@ -0,0 +1,284 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file eventHandler.h
* C event handler structure. This structure holds event handler function
* callbacks for use by the generated code.
*/
/**
* @defgroup EventHandler event handler
* Event handler structures and callback function definitions.
* @{
*/
#ifndef _EVENTHANDLER_H_
#define _EVENTHANDLER_H_
#include <stdio.h>
#include "ooasn1.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#if define (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* This is a function pointer for a callback function which is invoked
* from within a decode function when an element of a SEQUENCE, SET,
* SEQUENCE OF, SET OF, or CHOICE construct is parsed.
*
* @param name For SEQUENCE, SET, or CHOICE, this is the name of the
* element as defined in the ASN.1 defination. For
* SEQUENCE OF or SET OF, this is set to the name
* "element".
* @param index For SEQUENCE, SET, or CHOICE, this is not used and is
* set to the value
* -1. For SEQUENCE OF or SET OF, this contains the
* zero-based index of the element in the conceptual
* array associated with the construct.
* @return - none
*/
typedef void (*StartElement) (const char* name, int index) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when parsing is complete on an element of a
* SEQUENCE, SET, SEQUENCE OF, SET OF, or CHOICE construct.
*
* @param name For SEQUENCE, SET, or CHOICE, this is the name of the
* element as defined in the ASN.1 defination. For
* SEQUENCE OF or SET OF, this is set to the name
* "element".
* @param index For SEQUENCE, SET, or CHOICE, this is not used and is
* set to the value
* -1. For SEQUENCE OF or SET OF, this contains the
* zero-based index of the element in the conceptual
* array associated with the construct.
* @return - none
*/
typedef void (*EndElement) (const char* name, int index) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of the BOOLEAN ASN.1 type is parsed.
*
* @param value Parsed value.
* @return - none
*/
typedef void (*BoolValue) (ASN1BOOL value);
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of the INTERGER ASN.1 type is parsed.
*
* @param value Parsed value.
* @return - none
*/
typedef void (*IntValue) (ASN1INT value);
/**
* This is a function pointer for a callback function which is invoked
* from within a decode function when a value of the INTEGER ASN.1 type
* is parsed. In this case, constraints on the integer value forced the
* use of unsigned integer C type to represent the value.
*
* @param value Parsed value.
* @return - none
*/
typedef void (*UIntValue) (ASN1UINT value);
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of the BIT STRING ASN.1 type is
* parsed.
*
* @param numbits - Number of bits in the parsed value.
* @param data - Pointer to a byte array that contains the bit
* string data.
* @return - none
*/
typedef void (*BitStrValue) (ASN1UINT numbits, const ASN1OCTET* data);
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of one of the OCTET STRING ASN.1 type
* is parsed.
*
* @param numocts Number of octets in the parsed value.
* @param data Pointer to byte array containing the octet string
* data.
* @return - none
*/
typedef void (*OctStrValue) (ASN1UINT numocts, const ASN1OCTET* data) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of one of the 8-bit ASN.1 character
* string types is parsed.
*
* @param value Null terminated character string value.
* @return - none
*/
typedef void (*CharStrValue) (const char* value) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of one of the 16-bit ASN.1 character
* string types is parsed.
*
* This is used for the ASN.1 BmpString type.
*
* @param nchars Number of characters in the parsed value.
* @param data Pointer to an array containing 16-bit values.
* These are represented using unsigned short integer
* values.
* @return - none
*/
typedef void (*CharStrValue16Bit) (ASN1UINT nchars, ASN116BITCHAR* data) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of the NULL ASN.1 type is parsed.
*
* @param - none
* @return - none
*/
typedef void (*NullValue) () ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function whn a value the OBJECT IDENTIFIER ASN.1 type is
* parsed.
*
* @param numSubIds Number of subidentifiers in the object identifier.
* @param pSubIds Pointer to array containing the subidentifier values.
* @return -none
*/
typedef void (*OidValue) (ASN1UINT numSubIds, ASN1UINT* pSubIds) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when a value of the ENUMERATED ASN.1 type is
* parsed.
*
* @param value - Parsed enumerated value
* @return - none
*/
typedef void (*EnumValue) (ASN1UINT value) ;
/**
* This is a function pointer for a callback function which is invoked from
* within a decode function when an ASN.1 open type is parsed.
*
* @param numocts Number of octets in the parsed value.
* @param data Pointer to byet array contain in tencoded ASN.1
* value.
* @return - none
*/
typedef void (*OpenTypeValue) (ASN1UINT numocts, const ASN1OCTET* data) ;
/**
* This is a basic C based event handler structure, which can be used
* to define user-defined event handlers.
*/
typedef struct EventHandler {
StartElement startElement;
EndElement endElement;
BoolValue boolValue;
IntValue intValue;
UIntValue uIntValue;
BitStrValue bitStrValue;
OctStrValue octStrValue;
CharStrValue charStrValue;
CharStrValue16Bit charStr16BitValue;
NullValue nullValue;
OidValue oidValue;
EnumValue enumValue;
OpenTypeValue openTypeValue;
} EventHandler;
/**
* This function sets the event handler object within the context. It
* will overwrite the definition of any handler that was set previously.
*
* @param pctxt Context to which event handler has to be added.
* @param pHandler Pointer to the event handler structure.
* @return none
*/
EXTERN void setEventHandler (OOCTXT* pctxt, EventHandler* pHandler);
/**
* This function is called to remove the event handler current defined
* in the context. This is done by setting the event handler object
* pointer to NULL.
*
* @param pctxt Context from which event handler has to be removed.
* @return none
*/
EXTERN void removeEventHandler (OOCTXT* pctxt);
/**
* The following functions are invoked from within the generated
* code to call the various user-defined event handler methods ..
*/
EXTERN void invokeStartElement (OOCTXT* pctxt, const char* name, int index);
EXTERN void invokeEndElement (OOCTXT* pctxt, const char* name, int index);
EXTERN void invokeBoolValue (OOCTXT* pctxt, ASN1BOOL value);
EXTERN void invokeIntValue (OOCTXT* pctxt, ASN1INT value);
EXTERN void invokeUIntValue (OOCTXT* pctxt, ASN1UINT value);
EXTERN void invokeBitStrValue
(OOCTXT* pctxt, ASN1UINT numbits, const ASN1OCTET* data);
EXTERN void invokeOctStrValue
(OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data);
EXTERN void invokeCharStrValue (OOCTXT* pctxt, const char* value);
EXTERN void invokeCharStr16BitValue
(OOCTXT* pctxt, ASN1UINT nchars, ASN116BITCHAR* data);
EXTERN void invokeNullValue (OOCTXT* pctxt);
EXTERN void invokeOidValue
(OOCTXT* pctxt, ASN1UINT numSubIds, ASN1UINT* pSubIds);
EXTERN void invokeEnumValue (OOCTXT* pctxt, ASN1UINT value);
EXTERN void invokeOpenTypeValue
(OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,690 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* This file was generated by the Objective Systems ASN1C Compiler
* (http://www.obj-sys.com). Version: 5.72, Date: 22-Mar-2005.
*/
#ifndef H235_SECURITY_MESSAGES_H
#define H235_SECURITY_MESSAGES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include "ooasn1.h"
/**************************************************************/
/* */
/* ChallengeString */
/* */
/**************************************************************/
typedef struct EXTERN H235ChallengeString {
ASN1UINT numocts;
ASN1OCTET data[128];
} H235ChallengeString;
EXTERN int asn1PE_H235ChallengeString (OOCTXT* pctxt, H235ChallengeString* pvalue);
EXTERN int asn1PD_H235ChallengeString (OOCTXT* pctxt, H235ChallengeString* pvalue);
/**************************************************************/
/* */
/* TimeStamp */
/* */
/**************************************************************/
typedef ASN1UINT H235TimeStamp;
EXTERN int asn1PE_H235TimeStamp (OOCTXT* pctxt, H235TimeStamp value);
EXTERN int asn1PD_H235TimeStamp (OOCTXT* pctxt, H235TimeStamp* pvalue);
/**************************************************************/
/* */
/* RandomVal */
/* */
/**************************************************************/
typedef ASN1INT H235RandomVal;
EXTERN int asn1PE_H235RandomVal (OOCTXT* pctxt, H235RandomVal value);
EXTERN int asn1PD_H235RandomVal (OOCTXT* pctxt, H235RandomVal* pvalue);
/**************************************************************/
/* */
/* Password */
/* */
/**************************************************************/
typedef ASN1BMPString H235Password;
EXTERN int asn1PE_H235Password (OOCTXT* pctxt, H235Password value);
EXTERN int asn1PD_H235Password (OOCTXT* pctxt, H235Password* pvalue);
/**************************************************************/
/* */
/* EncodedPwdCertToken */
/* */
/**************************************************************/
typedef ASN1OpenType H235EncodedPwdCertToken;
EXTERN int asn1PE_H235EncodedPwdCertToken (OOCTXT* pctxt, H235EncodedPwdCertToken value);
EXTERN int asn1PD_H235EncodedPwdCertToken (OOCTXT* pctxt, H235EncodedPwdCertToken* pvalue);
/**************************************************************/
/* */
/* NonStandardParameter */
/* */
/**************************************************************/
typedef struct EXTERN H235NonStandardParameter {
ASN1OBJID nonStandardIdentifier;
ASN1DynOctStr data;
} H235NonStandardParameter;
EXTERN int asn1PE_H235NonStandardParameter (OOCTXT* pctxt, H235NonStandardParameter* pvalue);
EXTERN int asn1PD_H235NonStandardParameter (OOCTXT* pctxt, H235NonStandardParameter* pvalue);
/**************************************************************/
/* */
/* AuthenticationBES */
/* */
/**************************************************************/
/* Choice tag constants */
#define T_H235AuthenticationBES_default_ 1
#define T_H235AuthenticationBES_radius 2
#define T_H235AuthenticationBES_extElem1 3
typedef struct EXTERN H235AuthenticationBES {
int t;
} H235AuthenticationBES;
EXTERN int asn1PE_H235AuthenticationBES (OOCTXT* pctxt, H235AuthenticationBES* pvalue);
EXTERN int asn1PD_H235AuthenticationBES (OOCTXT* pctxt, H235AuthenticationBES* pvalue);
/**************************************************************/
/* */
/* AuthenticationMechanism */
/* */
/**************************************************************/
/* Choice tag constants */
#define T_H235AuthenticationMechanism_dhExch 1
#define T_H235AuthenticationMechanism_pwdSymEnc 2
#define T_H235AuthenticationMechanism_pwdHash 3
#define T_H235AuthenticationMechanism_certSign 4
#define T_H235AuthenticationMechanism_ipsec 5
#define T_H235AuthenticationMechanism_tls 6
#define T_H235AuthenticationMechanism_nonStandard 7
#define T_H235AuthenticationMechanism_authenticationBES 8
#define T_H235AuthenticationMechanism_extElem1 9
typedef struct EXTERN H235AuthenticationMechanism {
int t;
union {
/* t = 1 */
/* t = 2 */
/* t = 3 */
/* t = 4 */
/* t = 5 */
/* t = 6 */
/* t = 7 */
H235NonStandardParameter *nonStandard;
/* t = 8 */
H235AuthenticationBES *authenticationBES;
/* t = 9 */
} u;
} H235AuthenticationMechanism;
EXTERN int asn1PE_H235AuthenticationMechanism (OOCTXT* pctxt, H235AuthenticationMechanism* pvalue);
EXTERN int asn1PD_H235AuthenticationMechanism (OOCTXT* pctxt, H235AuthenticationMechanism* pvalue);
/**************************************************************/
/* */
/* DHset_halfkey */
/* */
/**************************************************************/
typedef struct EXTERN H235DHset_halfkey {
ASN1UINT numbits;
ASN1OCTET data[256];
} H235DHset_halfkey;
EXTERN int asn1PE_H235DHset_halfkey (OOCTXT* pctxt, H235DHset_halfkey* pvalue);
EXTERN int asn1PD_H235DHset_halfkey (OOCTXT* pctxt, H235DHset_halfkey* pvalue);
/**************************************************************/
/* */
/* DHset_modSize */
/* */
/**************************************************************/
typedef struct EXTERN H235DHset_modSize {
ASN1UINT numbits;
ASN1OCTET data[256];
} H235DHset_modSize;
EXTERN int asn1PE_H235DHset_modSize (OOCTXT* pctxt, H235DHset_modSize* pvalue);
EXTERN int asn1PD_H235DHset_modSize (OOCTXT* pctxt, H235DHset_modSize* pvalue);
/**************************************************************/
/* */
/* DHset_generator */
/* */
/**************************************************************/
typedef struct EXTERN H235DHset_generator {
ASN1UINT numbits;
ASN1OCTET data[256];
} H235DHset_generator;
EXTERN int asn1PE_H235DHset_generator (OOCTXT* pctxt, H235DHset_generator* pvalue);
EXTERN int asn1PD_H235DHset_generator (OOCTXT* pctxt, H235DHset_generator* pvalue);
/**************************************************************/
/* */
/* DHset */
/* */
/**************************************************************/
typedef struct EXTERN H235DHset {
H235DHset_halfkey halfkey;
H235DHset_modSize modSize;
H235DHset_generator generator;
} H235DHset;
EXTERN int asn1PE_H235DHset (OOCTXT* pctxt, H235DHset* pvalue);
EXTERN int asn1PD_H235DHset (OOCTXT* pctxt, H235DHset* pvalue);
/**************************************************************/
/* */
/* TypedCertificate */
/* */
/**************************************************************/
typedef struct EXTERN H235TypedCertificate {
ASN1OBJID type;
ASN1DynOctStr certificate;
} H235TypedCertificate;
EXTERN int asn1PE_H235TypedCertificate (OOCTXT* pctxt, H235TypedCertificate* pvalue);
EXTERN int asn1PD_H235TypedCertificate (OOCTXT* pctxt, H235TypedCertificate* pvalue);
/**************************************************************/
/* */
/* Identifier */
/* */
/**************************************************************/
typedef ASN1BMPString H235Identifier;
EXTERN int asn1PE_H235Identifier (OOCTXT* pctxt, H235Identifier value);
EXTERN int asn1PD_H235Identifier (OOCTXT* pctxt, H235Identifier* pvalue);
/**************************************************************/
/* */
/* ECpoint_x */
/* */
/**************************************************************/
typedef struct EXTERN H235ECpoint_x {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECpoint_x;
EXTERN int asn1PE_H235ECpoint_x (OOCTXT* pctxt, H235ECpoint_x* pvalue);
EXTERN int asn1PD_H235ECpoint_x (OOCTXT* pctxt, H235ECpoint_x* pvalue);
/**************************************************************/
/* */
/* ECpoint_y */
/* */
/**************************************************************/
typedef struct EXTERN H235ECpoint_y {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECpoint_y;
EXTERN int asn1PE_H235ECpoint_y (OOCTXT* pctxt, H235ECpoint_y* pvalue);
EXTERN int asn1PD_H235ECpoint_y (OOCTXT* pctxt, H235ECpoint_y* pvalue);
/**************************************************************/
/* */
/* ECpoint */
/* */
/**************************************************************/
typedef struct EXTERN H235ECpoint {
struct {
unsigned xPresent : 1;
unsigned yPresent : 1;
} m;
H235ECpoint_x x;
H235ECpoint_y y;
} H235ECpoint;
EXTERN int asn1PE_H235ECpoint (OOCTXT* pctxt, H235ECpoint* pvalue);
EXTERN int asn1PD_H235ECpoint (OOCTXT* pctxt, H235ECpoint* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdhp_modulus */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdhp_modulus {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECKASDH_eckasdhp_modulus;
EXTERN int asn1PE_H235ECKASDH_eckasdhp_modulus (OOCTXT* pctxt, H235ECKASDH_eckasdhp_modulus* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdhp_modulus (OOCTXT* pctxt, H235ECKASDH_eckasdhp_modulus* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdhp_weierstrassA */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdhp_weierstrassA {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECKASDH_eckasdhp_weierstrassA;
EXTERN int asn1PE_H235ECKASDH_eckasdhp_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassA* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdhp_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassA* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdhp_weierstrassB */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdhp_weierstrassB {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECKASDH_eckasdhp_weierstrassB;
EXTERN int asn1PE_H235ECKASDH_eckasdhp_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassB* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdhp_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdhp_weierstrassB* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdhp */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdhp {
H235ECpoint public_key;
H235ECKASDH_eckasdhp_modulus modulus;
H235ECpoint base;
H235ECKASDH_eckasdhp_weierstrassA weierstrassA;
H235ECKASDH_eckasdhp_weierstrassB weierstrassB;
} H235ECKASDH_eckasdhp;
EXTERN int asn1PE_H235ECKASDH_eckasdhp (OOCTXT* pctxt, H235ECKASDH_eckasdhp* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdhp (OOCTXT* pctxt, H235ECKASDH_eckasdhp* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdh2_fieldSize */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdh2_fieldSize {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECKASDH_eckasdh2_fieldSize;
EXTERN int asn1PE_H235ECKASDH_eckasdh2_fieldSize (OOCTXT* pctxt, H235ECKASDH_eckasdh2_fieldSize* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdh2_fieldSize (OOCTXT* pctxt, H235ECKASDH_eckasdh2_fieldSize* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdh2_weierstrassA */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdh2_weierstrassA {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECKASDH_eckasdh2_weierstrassA;
EXTERN int asn1PE_H235ECKASDH_eckasdh2_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassA* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdh2_weierstrassA (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassA* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdh2_weierstrassB */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdh2_weierstrassB {
ASN1UINT numbits;
ASN1OCTET data[64];
} H235ECKASDH_eckasdh2_weierstrassB;
EXTERN int asn1PE_H235ECKASDH_eckasdh2_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassB* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdh2_weierstrassB (OOCTXT* pctxt, H235ECKASDH_eckasdh2_weierstrassB* pvalue);
/**************************************************************/
/* */
/* ECKASDH_eckasdh2 */
/* */
/**************************************************************/
typedef struct EXTERN H235ECKASDH_eckasdh2 {
H235ECpoint public_key;
H235ECKASDH_eckasdh2_fieldSize fieldSize;
H235ECpoint base;
H235ECKASDH_eckasdh2_weierstrassA weierstrassA;
H235ECKASDH_eckasdh2_weierstrassB weierstrassB;
} H235ECKASDH_eckasdh2;
EXTERN int asn1PE_H235ECKASDH_eckasdh2 (OOCTXT* pctxt, H235ECKASDH_eckasdh2* pvalue);
EXTERN int asn1PD_H235ECKASDH_eckasdh2 (OOCTXT* pctxt, H235ECKASDH_eckasdh2* pvalue);
/**************************************************************/
/* */
/* ECKASDH */
/* */
/**************************************************************/
/* Choice tag constants */
#define T_H235ECKASDH_eckasdhp 1
#define T_H235ECKASDH_eckasdh2 2
#define T_H235ECKASDH_extElem1 3
typedef struct EXTERN H235ECKASDH {
int t;
union {
/* t = 1 */
H235ECKASDH_eckasdhp *eckasdhp;
/* t = 2 */
H235ECKASDH_eckasdh2 *eckasdh2;
/* t = 3 */
} u;
} H235ECKASDH;
EXTERN int asn1PE_H235ECKASDH (OOCTXT* pctxt, H235ECKASDH* pvalue);
EXTERN int asn1PD_H235ECKASDH (OOCTXT* pctxt, H235ECKASDH* pvalue);
/**************************************************************/
/* */
/* ClearToken */
/* */
/**************************************************************/
typedef struct EXTERN H235ClearToken {
struct {
unsigned timeStampPresent : 1;
unsigned passwordPresent : 1;
unsigned dhkeyPresent : 1;
unsigned challengePresent : 1;
unsigned randomPresent : 1;
unsigned certificatePresent : 1;
unsigned generalIDPresent : 1;
unsigned nonStandardPresent : 1;
unsigned eckasdhkeyPresent : 1;
unsigned sendersIDPresent : 1;
} m;
ASN1OBJID tokenOID;
H235TimeStamp timeStamp;
H235Password password;
H235DHset dhkey;
H235ChallengeString challenge;
H235RandomVal random;
H235TypedCertificate certificate;
H235Identifier generalID;
H235NonStandardParameter nonStandard;
H235ECKASDH eckasdhkey;
H235Identifier sendersID;
} H235ClearToken;
EXTERN int asn1PE_H235ClearToken (OOCTXT* pctxt, H235ClearToken* pvalue);
EXTERN int asn1PD_H235ClearToken (OOCTXT* pctxt, H235ClearToken* pvalue);
/**************************************************************/
/* */
/* IV8 */
/* */
/**************************************************************/
typedef struct EXTERN H235IV8 {
ASN1UINT numocts;
ASN1OCTET data[8];
} H235IV8;
EXTERN int asn1PE_H235IV8 (OOCTXT* pctxt, H235IV8* pvalue);
EXTERN int asn1PD_H235IV8 (OOCTXT* pctxt, H235IV8* pvalue);
/**************************************************************/
/* */
/* IV16 */
/* */
/**************************************************************/
typedef struct EXTERN H235IV16 {
ASN1UINT numocts;
ASN1OCTET data[16];
} H235IV16;
EXTERN int asn1PE_H235IV16 (OOCTXT* pctxt, H235IV16* pvalue);
EXTERN int asn1PD_H235IV16 (OOCTXT* pctxt, H235IV16* pvalue);
/**************************************************************/
/* */
/* Params */
/* */
/**************************************************************/
typedef struct EXTERN H235Params {
struct {
unsigned ranIntPresent : 1;
unsigned iv8Present : 1;
unsigned iv16Present : 1;
} m;
ASN1INT ranInt;
H235IV8 iv8;
H235IV16 iv16;
} H235Params;
EXTERN int asn1PE_H235Params (OOCTXT* pctxt, H235Params* pvalue);
EXTERN int asn1PD_H235Params (OOCTXT* pctxt, H235Params* pvalue);
/**************************************************************/
/* */
/* ENCRYPTED */
/* */
/**************************************************************/
typedef struct EXTERN H235ENCRYPTED {
ASN1OBJID algorithmOID;
H235Params paramS;
ASN1DynOctStr encryptedData;
} H235ENCRYPTED;
EXTERN int asn1PE_H235ENCRYPTED (OOCTXT* pctxt, H235ENCRYPTED* pvalue);
EXTERN int asn1PD_H235ENCRYPTED (OOCTXT* pctxt, H235ENCRYPTED* pvalue);
/**************************************************************/
/* */
/* CryptoToken_cryptoEncryptedToken */
/* */
/**************************************************************/
typedef struct EXTERN H235CryptoToken_cryptoEncryptedToken {
ASN1OBJID tokenOID;
H235ENCRYPTED token;
} H235CryptoToken_cryptoEncryptedToken;
EXTERN int asn1PE_H235CryptoToken_cryptoEncryptedToken (OOCTXT* pctxt, H235CryptoToken_cryptoEncryptedToken* pvalue);
EXTERN int asn1PD_H235CryptoToken_cryptoEncryptedToken (OOCTXT* pctxt, H235CryptoToken_cryptoEncryptedToken* pvalue);
/**************************************************************/
/* */
/* EncodedGeneralToken */
/* */
/**************************************************************/
typedef ASN1OpenType H235EncodedGeneralToken;
EXTERN int asn1PE_H235EncodedGeneralToken (OOCTXT* pctxt, H235EncodedGeneralToken value);
EXTERN int asn1PD_H235EncodedGeneralToken (OOCTXT* pctxt, H235EncodedGeneralToken* pvalue);
/**************************************************************/
/* */
/* CryptoToken_cryptoSignedToken_token */
/* */
/**************************************************************/
typedef struct EXTERN H235CryptoToken_cryptoSignedToken_token {
H235EncodedGeneralToken toBeSigned;
ASN1OBJID algorithmOID;
H235Params paramS;
ASN1DynBitStr signature;
} H235CryptoToken_cryptoSignedToken_token;
EXTERN int asn1PE_H235CryptoToken_cryptoSignedToken_token (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken_token* pvalue);
EXTERN int asn1PD_H235CryptoToken_cryptoSignedToken_token (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken_token* pvalue);
/**************************************************************/
/* */
/* CryptoToken_cryptoSignedToken */
/* */
/**************************************************************/
typedef struct EXTERN H235CryptoToken_cryptoSignedToken {
ASN1OBJID tokenOID;
H235CryptoToken_cryptoSignedToken_token token;
} H235CryptoToken_cryptoSignedToken;
EXTERN int asn1PE_H235CryptoToken_cryptoSignedToken (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken* pvalue);
EXTERN int asn1PD_H235CryptoToken_cryptoSignedToken (OOCTXT* pctxt, H235CryptoToken_cryptoSignedToken* pvalue);
/**************************************************************/
/* */
/* HASHED */
/* */
/**************************************************************/
typedef struct EXTERN H235HASHED {
ASN1OBJID algorithmOID;
H235Params paramS;
ASN1DynBitStr hash;
} H235HASHED;
EXTERN int asn1PE_H235HASHED (OOCTXT* pctxt, H235HASHED* pvalue);
EXTERN int asn1PD_H235HASHED (OOCTXT* pctxt, H235HASHED* pvalue);
/**************************************************************/
/* */
/* CryptoToken_cryptoHashedToken */
/* */
/**************************************************************/
typedef struct EXTERN H235CryptoToken_cryptoHashedToken {
ASN1OBJID tokenOID;
H235ClearToken hashedVals;
H235HASHED token;
} H235CryptoToken_cryptoHashedToken;
EXTERN int asn1PE_H235CryptoToken_cryptoHashedToken (OOCTXT* pctxt, H235CryptoToken_cryptoHashedToken* pvalue);
EXTERN int asn1PD_H235CryptoToken_cryptoHashedToken (OOCTXT* pctxt, H235CryptoToken_cryptoHashedToken* pvalue);
/**************************************************************/
/* */
/* CryptoToken */
/* */
/**************************************************************/
/* Choice tag constants */
#define T_H235CryptoToken_cryptoEncryptedToken 1
#define T_H235CryptoToken_cryptoSignedToken 2
#define T_H235CryptoToken_cryptoHashedToken 3
#define T_H235CryptoToken_cryptoPwdEncr 4
#define T_H235CryptoToken_extElem1 5
typedef struct EXTERN H235CryptoToken {
int t;
union {
/* t = 1 */
H235CryptoToken_cryptoEncryptedToken *cryptoEncryptedToken;
/* t = 2 */
H235CryptoToken_cryptoSignedToken *cryptoSignedToken;
/* t = 3 */
H235CryptoToken_cryptoHashedToken *cryptoHashedToken;
/* t = 4 */
H235ENCRYPTED *cryptoPwdEncr;
/* t = 5 */
} u;
} H235CryptoToken;
EXTERN int asn1PE_H235CryptoToken (OOCTXT* pctxt, H235CryptoToken* pvalue);
EXTERN int asn1PD_H235CryptoToken (OOCTXT* pctxt, H235CryptoToken* pvalue);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,112 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* This file was generated by the Objective Systems ASN1C Compiler
* (http://www.obj-sys.com). Version: 5.72, Date: 22-Mar-2005.
*/
#include "ooasn1.h"
#include "H323-MESSAGES.h"
/**************************************************************/
/* */
/* NumberDigits */
/* */
/**************************************************************/
EXTERN const char* gs_H323_MESSAGES_NumberDigits_CharSet =
"#*,0123456789";
/**************************************************************/
/* */
/* TBCD_STRING */
/* */
/**************************************************************/
EXTERN const char* gs_H323_MESSAGES_TBCD_STRING_CharSet =
"#*0123456789abc";
/**************************************************************/
/* */
/* ANSI_41_UIM_system_id */
/* */
/**************************************************************/
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_system_id_sid_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_system_id_mid_CharSet =
"#*0123456789abc";
/**************************************************************/
/* */
/* ANSI_41_UIM */
/* */
/**************************************************************/
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_imsi_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_min_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_mdn_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_msisdn_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_esn_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_mscid_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_sesn_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_ANSI_41_UIM_soc_CharSet =
"#*0123456789abc";
/**************************************************************/
/* */
/* GSM_UIM */
/* */
/**************************************************************/
EXTERN const char* gs_H323_MESSAGES_GSM_UIM_imsi_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_GSM_UIM_msisdn_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_GSM_UIM_imei_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_GSM_UIM_hplmn_CharSet =
"#*0123456789abc";
EXTERN const char* gs_H323_MESSAGES_GSM_UIM_vplmn_CharSet =
"#*0123456789abc";
/**************************************************************/
/* */
/* AliasAddress */
/* */
/**************************************************************/
EXTERN const char* gs_H323_MESSAGES_AliasAddress_dialedDigits_CharSet =
"#*,0123456789";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* This file was generated by the Objective Systems ASN1C Compiler
* (http://www.obj-sys.com). Version: 5.72, Date: 22-Mar-2005.
*/
#include "ooasn1.h"
#include "MULTIMEDIA-SYSTEM-CONTROL.h"
/**************************************************************/
/* */
/* NetworkAccessParameters_networkAddress */
/* */
/**************************************************************/
EXTERN const char* gs_MULTIMEDIA_SYSTEM_CONTROL_NetworkAccessParameters_networkAddress_e164Address_CharSet =
"#*,0123456789";
/**************************************************************/
/* */
/* UserInputIndication_signal */
/* */
/**************************************************************/
EXTERN const char* gs_MULTIMEDIA_SYSTEM_CONTROL_UserInputIndication_signal_signalType_CharSet =
"!#*0123456789ABCD";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1331
addons/ooh323c/src/memheap.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#ifndef __RTMEMHEAP_HH__
#define __RTMEMHEAP_HH__
#include "ooasn1.h"
/* internal heap flags */
#define RT_MH_INTERNALMASK 0xF0000000u
#define RT_MH_FREEHEAPDESC 0x10000000u
typedef struct OSMemLink {
struct OSMemLink* pnext;
struct OSMemLink* pprev;
struct OSMemLink* pnextRaw; /* next RAW block */
void* pMemBlk;
ASN1OCTET blockType; /* 1 = standard, 2 = raw (see RTMEM* flags) */
} OSMemLink;
/* MemLink blockTypes */
#define RTMEMSTD 0x0001
#define RTMEMRAW 0x0002
#define RTMEMMALLOC 0x0004
#define RTMEMSAVED 0x0008
#define RTMEMLINK 0x0010 /* contains MemLink */
/* ASN.1 memory allocation structures */
typedef struct OSMemHeap {
OSMemLink* phead;
ASN1UINT usedUnits;
ASN1UINT usedBlocks;
ASN1UINT freeUnits;
ASN1UINT freeBlocks;
ASN1UINT keepFreeUnits;
ASN1UINT defBlkSize;
ASN1UINT refCnt;
ASN1UINT flags;
} OSMemHeap;
/* see rtMemDefs.c file */
extern ASN1UINT g_defBlkSize;
extern OSMallocFunc g_malloc_func;
extern OSReallocFunc g_realloc_func;
extern OSFreeFunc g_free_func;
#endif /* __RTMEMHEAP_HH__ */

View File

@ -0,0 +1,820 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ootrace.h"
#include "ootypes.h"
#include "ooCalls.h"
#include "ooUtils.h"
#include "ooports.h"
#include "oochannels.h"
#include "ooh245.h"
#include "ooCapability.h"
#include "ooGkClient.h"
#include "ooh323ep.h"
#include "ooCalls.h"
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
OOH323CallData* ooCreateCall(char* type, char*callToken)
{
OOH323CallData *call=NULL;
OOCTXT *pctxt=NULL;
pctxt = newContext();
if(!pctxt)
{
OOTRACEERR1("ERROR:Failed to create OOCTXT for new call\n");
return NULL;
}
call = (OOH323CallData*)memAlloc(pctxt, sizeof(OOH323CallData));
if(!call)
{
OOTRACEERR1("ERROR:Memory - ooCreateCall - call\n");
return NULL;
}
/* memset(call, 0, sizeof(OOH323CallData));*/
call->pctxt = pctxt;
call->callMode = gH323ep.callMode;
sprintf(call->callToken, "%s", callToken);
sprintf(call->callType, "%s", type);
call->callReference = 0;
if(gH323ep.callerid) {
strncpy(call->ourCallerId, gH323ep.callerid, sizeof(call->ourCallerId)-1);
call->ourCallerId[sizeof(call->ourCallerId)-1] = '\0';
}
else {
call->ourCallerId[0] = '\0';
}
memset(&call->callIdentifier, 0, sizeof(H225CallIdentifier));
memset(&call->confIdentifier, 0, sizeof(H225ConferenceIdentifier));
call->flags = 0;
if (OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING))
OO_SETFLAG (call->flags, OO_M_TUNNELING);
if(gH323ep.gkClient)
{
if(OO_TESTFLAG(gH323ep.flags, OO_M_GKROUTED))
{
OO_SETFLAG(call->flags, OO_M_GKROUTED);
}
}
if (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART))
OO_SETFLAG (call->flags, OO_M_FASTSTART);
if (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN))
OO_SETFLAG (call->flags, OO_M_MEDIAWAITFORCONN);
call->callState = OO_CALL_CREATED;
call->callEndReason = OO_REASON_UNKNOWN;
call->pCallFwdData = NULL;
if(!strcmp(call->callType, "incoming"))
{
call->callingPartyNumber = NULL;
}
else{
if(ooUtilsIsStrEmpty(gH323ep.callingPartyNumber))
{
call->callingPartyNumber = NULL;
}
else{
call->callingPartyNumber = (char*) memAlloc(call->pctxt,
strlen(gH323ep.callingPartyNumber)+1);
if(call->callingPartyNumber)
{
strcpy(call->callingPartyNumber, gH323ep.callingPartyNumber);
}
else{
OOTRACEERR3("Error:Memory - ooCreateCall - callingPartyNumber"
".(%s, %s)\n", call->callType, call->callToken);
freeContext(pctxt);
return NULL;
}
}
}
call->calledPartyNumber = NULL;
call->h245ConnectionAttempts = 0;
call->h245SessionState = OO_H245SESSION_IDLE;
call->dtmfmode = gH323ep.dtmfmode;
call->mediaInfo = NULL;
strcpy(call->localIP, gH323ep.signallingIP);
call->pH225Channel = NULL;
call->pH245Channel = NULL;
call->h245listener = NULL;
call->h245listenport = NULL;
call->remoteIP[0] = '\0';
call->remotePort = 0;
call->remoteH245Port = 0;
call->remoteDisplayName = NULL;
call->remoteAliases = NULL;
call->ourAliases = NULL;
call->masterSlaveState = OO_MasterSlave_Idle;
call->statusDeterminationNumber = 0;
call->localTermCapState = OO_LocalTermCapExchange_Idle;
call->remoteTermCapState = OO_RemoteTermCapExchange_Idle;
call->ourCaps = NULL;
call->remoteCaps = NULL;
call->jointCaps = NULL;
dListInit(&call->remoteFastStartOLCs);
call->remoteTermCapSeqNo =0;
call->localTermCapSeqNo = 0;
memcpy(&call->capPrefs, &gH323ep.capPrefs, sizeof(OOCapPrefs));
call->logicalChans = NULL;
call->noOfLogicalChannels = 0;
call->logicalChanNoBase = 1001;
call->logicalChanNoMax = 1100;
call->logicalChanNoCur = 1001;
call->nextSessionID = 4; /* 1,2,3 are reserved for audio, video and data */
dListInit(&call->timerList);
call->msdRetries = 0;
call->pFastStartRes = NULL;
call->usrData = NULL;
OOTRACEINFO3("Created a new call (%s, %s)\n", call->callType,
call->callToken);
/* Add new call to calllist */
ooAddCallToList (call);
if(gH323ep.h323Callbacks.onNewCallCreated)
gH323ep.h323Callbacks.onNewCallCreated(call);
return call;
}
int ooAddCallToList(OOH323CallData *call)
{
if(!gH323ep.callList)
{
gH323ep.callList = call;
call->next = NULL;
call->prev = NULL;
}
else{
call->next = gH323ep.callList;
call->prev = NULL;
gH323ep.callList->prev = call;
gH323ep.callList = call;
}
return OO_OK;
}
int ooEndCall(OOH323CallData *call)
{
OOTRACEDBGA4("In ooEndCall call state is - %s (%s, %s)\n",
ooGetCallStateText(call->callState), call->callType,
call->callToken);
if(call->callState == OO_CALL_CLEARED)
{
ooCleanCall(call);
return OO_OK;
}
if(call->logicalChans)
{
OOTRACEINFO3("Clearing all logical channels. (%s, %s)\n", call->callType,
call->callToken);
ooClearAllLogicalChannels(call);
}
if(!OO_TESTFLAG(call->flags, OO_M_ENDSESSION_BUILT))
{
if(call->h245SessionState == OO_H245SESSION_ACTIVE ||
call->h245SessionState == OO_H245SESSION_ENDRECVD)
{
ooSendEndSessionCommand(call);
OO_SETFLAG(call->flags, OO_M_ENDSESSION_BUILT);
}
}
if(!call->pH225Channel || call->pH225Channel->sock ==0)
{
call->callState = OO_CALL_CLEARED;
}
else{
if(!OO_TESTFLAG(call->flags, OO_M_RELEASE_BUILT))
{
if(call->callState == OO_CALL_CLEAR ||
call->callState == OO_CALL_CLEAR_RELEASERECVD)
{
ooSendReleaseComplete(call);
OO_SETFLAG(call->flags, OO_M_RELEASE_BUILT);
}
}
}
return OO_OK;
}
int ooRemoveCallFromList (OOH323CallData *call)
{
if(!call)
return OO_OK;
if(call == gH323ep.callList)
{
if(!call->next)
gH323ep.callList = NULL;
else{
call->next->prev = NULL;
gH323ep.callList = call->next;
}
}
else{
call->prev->next = call->next;
if(call->next)
call->next->prev = call->prev;
}
return OO_OK;
}
int ooCleanCall(OOH323CallData *call)
{
OOCTXT *pctxt;
OOTRACEWARN4 ("Cleaning Call (%s, %s)- reason:%s\n",
call->callType, call->callToken,
ooGetReasonCodeText (call->callEndReason));
/* First clean all the logical channels, if not already cleaned. */
if(call->logicalChans)
ooClearAllLogicalChannels(call);
/* Close H.245 connection, if not already closed */
if(call->h245SessionState != OO_H245SESSION_CLOSED)
ooCloseH245Connection(call);
else{
if(call->pH245Channel && call->pH245Channel->outQueue.count > 0)
{
dListFreeAll(call->pctxt, &(call->pH245Channel->outQueue));
memFreePtr(call->pctxt, call->pH245Channel);
}
}
/* Close H.245 listener, if not already closed */
if(call->h245listener)
{
ooCloseH245Listener(call);
}
/* Close H225 connection, if not already closed. */
if (0 != call->pH225Channel && 0 != call->pH225Channel->sock)
{
ooCloseH225Connection(call);
}
/* Clean timers */
if(call->timerList.count > 0)
{
dListFreeAll(call->pctxt, &(call->timerList));
}
if(gH323ep.gkClient && !OO_TESTFLAG(call->flags, OO_M_DISABLEGK))
{
ooGkClientCleanCall(gH323ep.gkClient, call);
}
ooRemoveCallFromList (call);
OOTRACEINFO3("Removed call (%s, %s) from list\n", call->callType,
call->callToken);
if(call->pCallFwdData && call->pCallFwdData->fwdedByRemote)
{
if(gH323ep.h323Callbacks.onCallForwarded)
gH323ep.h323Callbacks.onCallForwarded(call);
if(ooH323HandleCallFwdRequest(call)!= OO_OK)
{
OOTRACEERR3("Error:Failed to forward call (%s, %s)\n", call->callType,
call->callToken);
}
}
else {
if(gH323ep.h323Callbacks.onCallCleared)
gH323ep.h323Callbacks.onCallCleared(call);
}
pctxt = call->pctxt;
freeContext(pctxt);
ASN1CRTFREE0(pctxt);
return OO_OK;
}
int ooCallSetCallerId(OOH323CallData* call, const char* callerid)
{
if(!call || !callerid) return OO_FAILED;
strncpy(call->ourCallerId, callerid, sizeof(call->ourCallerId)-1);
call->ourCallerId[sizeof(call->ourCallerId)-1]='\0';
return OO_OK;
}
int ooCallSetCallingPartyNumber(OOH323CallData *call, const char *number)
{
if(call->callingPartyNumber)
memFreePtr(call->pctxt, call->callingPartyNumber);
call->callingPartyNumber = (char*) memAlloc(call->pctxt, strlen(number)+1);
if(call->callingPartyNumber)
{
strcpy(call->callingPartyNumber, number);
}
else{
OOTRACEERR3("Error:Memory - ooCallSetCallingPartyNumber - "
"callingPartyNumber.(%s, %s)\n", call->callType,
call->callToken);
return OO_FAILED;
}
/* Set dialed digits alias */
/* if(!strcmp(call->callType, "outgoing"))
{
ooCallAddAliasDialedDigits(call, number);
}*/
return OO_OK;
}
int ooCallGetCallingPartyNumber(OOH323CallData *call, char *buffer, int len)
{
if(call->callingPartyNumber)
{
if(len>(int)strlen(call->callingPartyNumber))
{
strcpy(buffer, call->callingPartyNumber);
return OO_OK;
}
}
return OO_FAILED;
}
int ooCallSetCalledPartyNumber(OOH323CallData *call, const char *number)
{
if(call->calledPartyNumber)
memFreePtr(call->pctxt, call->calledPartyNumber);
call->calledPartyNumber = (char*) memAlloc(call->pctxt, strlen(number)+1);
if(call->calledPartyNumber)
{
strcpy(call->calledPartyNumber, number);
}
else{
OOTRACEERR3("Error:Memory - ooCallSetCalledPartyNumber - "
"calledPartyNumber.(%s, %s)\n", call->callType,
call->callToken);
return OO_FAILED;
}
return OO_OK;
}
int ooCallGetCalledPartyNumber(OOH323CallData *call, char *buffer, int len)
{
if(call->calledPartyNumber)
{
if(len>(int)strlen(call->calledPartyNumber))
{
strcpy(buffer, call->calledPartyNumber);
return OO_OK;
}
}
return OO_FAILED;
}
int ooCallClearAliases(OOH323CallData *call)
{
if(call->ourAliases)
memFreePtr(call->pctxt, call->ourAliases);
call->ourAliases = NULL;
return OO_OK;
}
int ooCallAddAlias
(OOH323CallData *call, int aliasType, const char *value, OOBOOL local)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(call->pctxt, sizeof(ooAliases));
if(!psNewAlias)
{
OOTRACEERR3("Error:Memory - ooCallAddAlias - psNewAlias"
"(%s, %s)\n", call->callType, call->callToken);
return OO_FAILED;
}
psNewAlias->type = aliasType;
psNewAlias->value = (char*) memAlloc(call->pctxt, strlen(value)+1);
if(!psNewAlias->value)
{
OOTRACEERR3("Error:Memory - ooCallAddAlias - psNewAlias->value"
" (%s, %s)\n", call->callType, call->callToken);
memFreePtr(call->pctxt, psNewAlias);
return OO_FAILED;
}
strcpy(psNewAlias->value, value);
if(local)
{
psNewAlias->next = call->ourAliases;
call->ourAliases = psNewAlias;
}
else {
psNewAlias->next = call->remoteAliases;
call->remoteAliases = psNewAlias;
}
OOTRACEDBGC5("Added %s alias %s to call. (%s, %s)\n",
local?"local":"remote", value, call->callType, call->callToken);
return OO_OK;
}
int ooCallAddAliasH323ID(OOH323CallData *call, const char* h323id)
{
return ooCallAddAlias(call, T_H225AliasAddress_h323_ID, h323id, TRUE);
}
int ooCallAddAliasDialedDigits(OOH323CallData *call, const char* dialedDigits)
{
return ooCallAddAlias
(call, T_H225AliasAddress_dialedDigits, dialedDigits, TRUE);
}
int ooCallAddAliasEmailID(OOH323CallData *call, const char* email)
{
return ooCallAddAlias(call, T_H225AliasAddress_email_ID, email, TRUE);
}
int ooCallAddAliasURLID(OOH323CallData *call, const char* url)
{
return ooCallAddAlias(call, T_H225AliasAddress_url_ID, url, TRUE);
}
int ooCallAddRemoteAliasH323ID(OOH323CallData *call, const char* h323id)
{
return ooCallAddAlias(call, T_H225AliasAddress_h323_ID, h323id, FALSE);
}
int ooCallAddRemoteAliasDialedDigits
(OOH323CallData *call, const char* dialedDigits)
{
return ooCallAddAlias
(call, T_H225AliasAddress_dialedDigits, dialedDigits, FALSE);
}
/* Used to override global end point capabilities and add call specific
capabilities */
int ooCallAddG7231Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, OOBOOL silenceSuppression, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(call, cap, txframes, rxframes,
silenceSuppression, dir, startReceiveChannel,
startTransmitChannel, stopReceiveChannel,
stopTransmitChannel, FALSE);
}
int ooCallAddG729Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(call, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
/*
int ooCallAddG726Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(call, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
*/
int ooCallAddG728Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(call, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
int ooCallAddG711Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(call, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
int ooCallAddGSMCapability
(OOH323CallData* call, int cap, ASN1USINT framesPerPkt,
OOBOOL comfortNoise, OOBOOL scrambled, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddGSMCapability(call, cap, framesPerPkt, comfortNoise,
scrambled, dir, startReceiveChannel,
startTransmitChannel, stopReceiveChannel,
stopTransmitChannel, FALSE);
}
int ooCallAddH263VideoCapability
(OOH323CallData *call, int cap, unsigned sqcifMPI, unsigned qcifMPI,
unsigned cifMPI, unsigned cif4MPI, unsigned cif16MPI, unsigned maxBitRate,
int dir, cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddH263VideoCapability(call, sqcifMPI, qcifMPI, cifMPI,
cif4MPI, cif16MPI, maxBitRate,dir,
startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel,
FALSE);
}
int ooCallEnableDTMFRFC2833(OOH323CallData *call, int dynamicRTPPayloadType)
{
return ooCapabilityEnableDTMFRFC2833(call, dynamicRTPPayloadType);
}
int ooCallDisableDTMFRFC2833(OOH323CallData *call)
{
return ooCapabilityDisableDTMFRFC2833(call);
}
int ooCallEnableDTMFH245Alphanumeric(OOH323CallData *call)
{
return ooCapabilityEnableDTMFH245Alphanumeric(call);
}
int ooCallDisableDTMFH245Alphanumeric(OOH323CallData *call)
{
return ooCapabilityDisableDTMFH245Alphanumeric(call);
}
int ooCallEnableDTMFH245Signal(OOH323CallData *call)
{
return ooCapabilityEnableDTMFH245Signal(call);
}
int ooCallDisableDTMFH245Signal(OOH323CallData *call)
{
return ooCapabilityDisableDTMFH245Signal(call);
}
int ooCallEnableDTMFQ931Keypad(OOH323CallData *call)
{
return ooCapabilityEnableDTMFQ931Keypad(call);
}
int ooCallDisableDTMFQ931Keypad(OOH323CallData *call)
{
return ooCapabilityDisableDTMFQ931Keypad(call);
}
OOH323CallData* ooFindCallByToken(char *callToken)
{
OOH323CallData *call;
if(!callToken)
{
OOTRACEERR1("ERROR:Invalid call token passed - ooFindCallByToken\n");
return NULL;
}
if(!gH323ep.callList)
{
OOTRACEERR1("ERROR: Empty calllist - ooFindCallByToken failed\n");
return NULL;
}
call = gH323ep.callList;
while(call)
{
if(!strcmp(call->callToken, callToken))
break;
else
call = call->next;
}
if(!call)
{
OOTRACEERR2("ERROR:Call with token %s not found\n", callToken);
return NULL;
}
return call;
}
/* Checks whether session with suplied ID and direction is already active*/
ASN1BOOL ooIsSessionEstablished(OOH323CallData *call, int sessionID, char* dir)
{
OOLogicalChannel * temp = NULL;
temp = call->logicalChans;
while(temp)
{
if(temp->sessionID == sessionID &&
temp->state == OO_LOGICALCHAN_ESTABLISHED &&
!strcmp(temp->dir, dir) )
return TRUE;
temp = temp->next;
}
return FALSE;
}
int ooAddMediaInfo(OOH323CallData *call, OOMediaInfo mediaInfo)
{
OOMediaInfo *newMediaInfo=NULL;
if(!call)
{
OOTRACEERR3("Error:Invalid 'call' param for ooAddMediaInfo.(%s, %s)\n",
call->callType, call->callToken);
return OO_FAILED;
}
newMediaInfo = (OOMediaInfo*) memAlloc(call->pctxt, sizeof(OOMediaInfo));
if(!newMediaInfo)
{
OOTRACEERR3("Error:Memory - ooAddMediaInfo - newMediaInfo. "
"(%s, %s)\n", call->callType, call->callToken);
return OO_FAILED;
}
memcpy (newMediaInfo, &mediaInfo, sizeof(OOMediaInfo));
OOTRACEDBGC4("Configured mediainfo for cap %s (%s, %s)\n",
ooGetCapTypeText(mediaInfo.cap),
call->callType, call->callToken);
if(!call->mediaInfo) {
newMediaInfo->next = NULL;
call->mediaInfo = newMediaInfo;
}
else {
newMediaInfo->next = call->mediaInfo;
call->mediaInfo = newMediaInfo;
}
return OO_OK;
}
unsigned ooCallGenerateSessionID
(OOH323CallData *call, OOCapType type, char *dir)
{
unsigned sessionID=0;
if(type == OO_CAP_TYPE_AUDIO)
{
if(!ooGetLogicalChannel(call, 1, dir))
{
sessionID = 1;
}
else{
if(call->masterSlaveState == OO_MasterSlave_Master)
sessionID = call->nextSessionID++;
else{
OOTRACEDBGC4("Session id for %s channel of type audio has to be "
"provided by remote.(%s, %s)\n", dir, call->callType,
call->callToken);
sessionID = 0; /* Will be assigned by remote */
}
}
}
if(type == OO_CAP_TYPE_VIDEO)
{
if(!ooGetLogicalChannel(call, 2, dir))
{
sessionID = 2;
}
else{
if(call->masterSlaveState == OO_MasterSlave_Master)
sessionID = call->nextSessionID++;
else{
sessionID = 0; /* Will be assigned by remote */
OOTRACEDBGC4("Session id for %s channel of type video has to be "
"provided by remote.(%s, %s)\n", dir, call->callType,
call->callToken);
}
}
}
return sessionID;
}
int ooCallH245ConnectionRetryTimerExpired(void *data)
{
ooTimerCallback *cbData = (ooTimerCallback*) data;
OOH323CallData *call = cbData->call;
OOTRACEINFO3("H245 connection retry timer expired. (%s, %s)\n",
call->callType, call->callToken);
memFreePtr(call->pctxt, cbData);
call->h245ConnectionAttempts++;
ooCreateH245Connection(call);
return OO_OK;
}
const char* ooGetReasonCodeText (OOUINT32 code)
{
static const char* reasonCodeText[] = {
"OO_REASON_UNKNOWN",
"OO_REASON_INVALIDMESSAGE",
"OO_REASON_TRANSPORTFAILURE",
"OO_REASON_NOROUTE",
"OO_REASON_NOUSER",
"OO_REASON_NOBW",
"OO_REASON_GK_NOCALLEDUSER",
"OO_REASON_GK_NOCALLERUSER",
"OO_REASON_GK_NORESOURCES",
"OO_REASON_GK_UNREACHABLE",
"OO_REASON_GK_CLEARED",
"OO_REASON_NOCOMMON_CAPABILITIES",
"OO_REASON_REMOTE_FWDED",
"OO_REASON_LOCAL_FWDED",
"OO_REASON_REMOTE_CLEARED",
"OO_REASON_LOCAL_CLEARED",
"OO_REASON_REMOTE_BUSY",
"OO_REASON_LOCAL_BUSY",
"OO_REASON_REMOTE_NOANSWER",
"OO_REASON_LOCAL_NOTANSWERED",
"OO_REASON_REMOTE_REJECTED",
"OO_REASON_LOCAL_REJECTED",
"OO_REASON_REMOTE_CONGESTED",
"OO_REASON_LOCAL_CONGESTED"
};
return ooUtilsGetText (code, reasonCodeText, OONUMBEROF(reasonCodeText));
}
const char* ooGetCallStateText (OOCallState callState)
{
static const char* callStateText[] = {
"OO_CALL_CREATED",
"OO_CALL_WAITING_ADMISSION",
"OO_CALL_CONNECTING",
"OO_CALL_CONNECTED",
"OO_CALL_PAUSED",
"OO_CALL_CLEAR",
"OO_CALL_CLEAR_RELEASERECVD",
"OO_CALL_CLEAR_RELEASESENT",
"OO_CALL_CLEARED"
};
return ooUtilsGetText (callState, callStateText, OONUMBEROF(callStateText));
}

View File

@ -0,0 +1,822 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooCalls.h
* This file contains call management functions.
*/
#ifndef _OOCALLS_H_
#define _OOCALLS_H_
#include "ooLogChan.h"
#include "ooCapability.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup callmgmt Call Management
* @{
*/
/* Flag mask values */
/* DISABLEGK is used to selectively disable gatekeeper use. For incoming calls
DISABLEGK can be set in onReceivedSetup callback by application.
Very useful in pbx applications where gk is used only when call is
to or from outside pbx domian. For outgoing calls, ooMakeCallNoGk
disables use of gk for specific call.
*/
#define OO_M_ENDSESSION_BUILT ASN1UINTCNT(0x00800000)
#define OO_M_RELEASE_BUILT ASN1UINTCNT(0x00400000)
#define OO_M_FASTSTARTANSWERED ASN1UINTCNT(0x04000000)
#define OO_M_ENDPOINTCREATED ASN1UINTCNT(0x00010000)
#define OO_M_GKROUTED ASN1UINTCNT(0x00200000)
#define OO_M_AUTOANSWER ASN1UINTCNT(0x00100000)
#define OO_M_TUNNELING ASN1UINTCNT(0x08000000)
#define OO_M_MEDIAWAITFORCONN ASN1UINTCNT(0x20000000)
#define OO_M_FASTSTART ASN1UINTCNT(0x02000000)
#define OO_M_DISABLEGK ASN1UINTCNT(0x01000000)
#define OO_M_MANUALRINGBACK ASN1UINTCNT(0x10000000)
/**
* Call states.
*/
typedef enum {
OO_CALL_CREATED, /*!< Call created. */
OO_CALL_WAITING_ADMISSION, /*!< Call waiting for admission by GK */
OO_CALL_CONNECTING, /*!< Call in process of connecting */
OO_CALL_CONNECTED, /*!< Call currently connected. */
OO_CALL_PAUSED, /*!< Call Paused for hold/transfer. */
OO_CALL_CLEAR, /*!< Call marked for clearing */
OO_CALL_CLEAR_RELEASERECVD, /*!< Release command received. */
OO_CALL_CLEAR_RELEASESENT, /*!< Release sent */
OO_CALL_CLEARED /*!< Call cleared */
} OOCallState;
/**
* H.245 session states.
*/
typedef enum {
OO_H245SESSION_IDLE,
OO_H245SESSION_PAUSED,
OO_H245SESSION_ACTIVE,
OO_H245SESSION_ENDSENT,
OO_H245SESSION_ENDRECVD,
OO_H245SESSION_CLOSED
} OOH245SessionState;
/**
* Structure to store local and remote media endpoint info for a
* given media type.
*/
typedef struct OOMediaInfo{
char dir[15]; /* transmit/receive*/
int cap;
int lMediaPort;
int lMediaCntrlPort;
char lMediaIP[20];
struct OOMediaInfo *next;
} OOMediaInfo;
#define ooMediaInfo OOMediaInfo
struct OOAliases;
/**
* Structure to hold information on a forwarded call.
*/
typedef struct OOCallFwdData {
char ip[20];
int port;
struct OOAliases *aliases;
OOBOOL fwdedByRemote; /*Set when we are being fwded by remote*/
} OOCallFwdData;
/**
* Structure to store information on an H.323 channel (H.225 or H.245) for
* a particular call.
*/
typedef struct OOH323Channel {
OOSOCKET sock; /*!< Socket connection for the channel */
int port; /*!< Port assigned to the channel */
DList outQueue; /*!< Output message queue */
} OOH323Channel;
/**
* Structure to store information on fast start response (H.225) to
* reply same answer in CALL PROCEEDING, ALERTING & CONNECT.
*/
typedef struct EXTERN FastStartResponse {
ASN1UINT n;
ASN1DynOctStr *elem;
} FastStartResponse;
/**
* This structure is used to maintain all information on an active call.
* A list of these structures is maintained within the global endpoint
* structure.
*/
typedef struct OOH323CallData {
OOCTXT *pctxt;
char callToken[20]; /* ex: ooh323c_call_1 */
char callType[10]; /* incoming/outgoing */
OOCallMode callMode;
ASN1USINT callReference;
char ourCallerId[256];
H225CallIdentifier callIdentifier;/* The call identifier for the active
call. */
char *callingPartyNumber;
char *calledPartyNumber;
H225ConferenceIdentifier confIdentifier;
ASN1UINT flags;
OOCallState callState;
OOCallClearReason callEndReason;
unsigned h245ConnectionAttempts;
OOH245SessionState h245SessionState;
int dtmfmode;
OOMediaInfo *mediaInfo;
OOCallFwdData *pCallFwdData;
char localIP[20];/* Local IP address */
OOH323Channel* pH225Channel;
OOH323Channel* pH245Channel;
OOSOCKET *h245listener;
int *h245listenport;
char remoteIP[20];/* Remote IP address */
int remotePort;
int remoteH245Port;
char *remoteDisplayName;
struct OOAliases *remoteAliases;
struct OOAliases *ourAliases; /*aliases used in the call for us */
OOMasterSlaveState masterSlaveState; /*!< Master-Slave state */
ASN1UINT statusDeterminationNumber;
OOCapExchangeState localTermCapState;
OOCapExchangeState remoteTermCapState;
struct ooH323EpCapability* ourCaps;
struct ooH323EpCapability* remoteCaps; /* TODO: once we start using jointCaps, get rid of remoteCaps*/
struct ooH323EpCapability* jointCaps;
int jointDtmfMode;
DList remoteFastStartOLCs;
ASN1UINT8 remoteTermCapSeqNo;
ASN1UINT8 localTermCapSeqNo;
OOCapPrefs capPrefs;
OOLogicalChannel* logicalChans;
int noOfLogicalChannels;
int logicalChanNoBase;
int logicalChanNoMax;
int logicalChanNoCur;
unsigned nextSessionID; /* Note by default 1 is audio session, 2 is video and 3 is data, from 3 onwards master decides*/
DList timerList;
ASN1UINT msdRetries;
FastStartResponse *pFastStartRes; /* fast start response */
void *usrData; /*!<User can set this to user specific data*/
struct OOH323CallData* next;
struct OOH323CallData* prev;
} OOH323CallData;
#define ooCallData OOH323CallData
/**
* This callback function is triggered when a new call structure is
* created inside the stack for an incoming or outgoing call.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OnNewCallCreated)(OOH323CallData* call);
/**
* This callback function is triggered when a Q.931 alerting message is
* received for an outgoing call or when a Q.931 alerting message is sent
* for an incoming call.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OnAlerting)(OOH323CallData * call);
/**
* This callback function is triggered when there is an incoming call.
* In the case where a gatekeeper is in use, the call must first be
* admitted by the gatekeeper before this callback is triggered.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OnIncomingCall)(OOH323CallData* call );
/**
* This callback function is triggered after a Q.931 setup message
* is sent for an outgoing call.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OnOutgoingCall)(OOH323CallData* call );
/**
* This callback function is triggered when a Q.931 connect message is
* sent in case of incoming call. In case of outgoing call, this is invoked
* when a Q.931 connect message is received. It is not invoked until after
* fast start and H.245 tunneling messages within the connect message are
* processed.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OnCallEstablished)(struct OOH323CallData* call);
/**
* This callback function is triggered when a call is cleared.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OnCallCleared)(struct OOH323CallData* call);
/**
* This callback function is triggered when master-slave determination
* and capabilities negotiation procedures are successfully completed
* for a call.
*
* @param call H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure.
*/
typedef int (*cb_OpenLogicalChannels)(struct OOH323CallData* call);
/**
* This callback function is triggered when a call is forwarded by
* a remote endpoint to another remote destination.
* @param call Associated H.323 call data structure
* @return 0 if callback was successful, non-zero error code if failure
*/
typedef int (*cb_OnCallForwarded)(struct OOH323CallData* call);
/**
* This callback function is triggered when dtmf is received over Q.931(keypad)
* or H.245(alphanumeric) or H.245(signal). This is not triggered when rfc
* 2833 based dtmf is received.
*/
typedef int (*cb_OnReceivedDTMF)
(struct OOH323CallData *call, const char *dtmf);
/**
* This structure holds all of the H.323 signaling callback function
* addresses.
* @see ooH323EpSetH323Callbacks
*/
typedef struct OOH323CALLBACKS {
cb_OnAlerting onNewCallCreated;
cb_OnAlerting onAlerting;
cb_OnIncomingCall onIncomingCall;
cb_OnOutgoingCall onOutgoingCall;
cb_OnCallEstablished onCallEstablished;
cb_OnCallForwarded onCallForwarded;
cb_OnCallCleared onCallCleared;
cb_OpenLogicalChannels openLogicalChannels;
cb_OnReceivedDTMF onReceivedDTMF;
} OOH323CALLBACKS;
/**
* This function is used to create a new call entry.
* @param type Type of the call (incoming/outgoing)
* @param callToken Call Token, an uniques identifier for the call
*
* @return Pointer to a newly created call
*/
EXTERN OOH323CallData* ooCreateCall(char *type, char *callToken);
/**
* This function is used to add a call to the list of existing calls.
* @param call Pointer to the call to be added.
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooAddCallToList (OOH323CallData *call);
/**
* This function is used to set the caller ID for a call.
*
* @param call Handle to the call
* @param callerid caller ID value
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooCallSetCallerId
(OOH323CallData* call, const char* callerid);
/**
* This function is used to set calling party number for a particular call.
* @param call Handle to the call.
* @param number Calling Party number value.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallSetCallingPartyNumber
(OOH323CallData *call, const char *number);
/**
* This function is used to retrieve calling party number of a particular call.
* @param call Handle to the call.
* @param buffer Handle to the buffer in which value will be returned.
* @param len Length of the supplied buffer.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallGetCallingPartyNumber
(OOH323CallData *call, char *buffer, int len);
/**
* This function is used to retrieve called party number of a particular call.
* @param call Handle to the call.
* @param buffer Handle to the buffer in which value will be returned.
* @param len Length of the supplied buffer.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallGetCalledPartyNumber
(OOH323CallData *call, char *buffer, int len);
/**
* This function is used to set called party number for a particular call.
* @param call Handle to the call.
* @param number Called Party number value.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallSetCalledPartyNumber
(OOH323CallData *call, const char *number);
/**
* This function is used to clear the local aliases used by this call.
* @param call Handle to the call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallClearAliases(OOH323CallData *call);
/**
* This function is used to add an H323ID alias to be used by local endpoint
* for a particular call.
* @param call Handle to the call
* @param h323id H323ID to add for the local endpoint for the call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddAliasH323ID(OOH323CallData *call, const char* h323id);
/**
* This function is used to add an dialedDigits alias to be used by local
* endpoint for a particular call.
* @param call Handle to the call
* @param dialedDigits DialedDigits to add for the local endpoint for call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddAliasDialedDigits
(OOH323CallData *call, const char* dialedDigits);
/**
* This function is used to add an email-id alias to be used by local
* endpoint for a particular call.
* @param call Handle to the call
* @param email Email-id to add for the local endpoint for call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddAliasEmailID(OOH323CallData *call, const char* email);
/**
* This function is used to add an email-id alias to be used by local
* endpoint for a particular call.
* @param call Handle to the call
* @param url URL-id to add for the local endpoint for call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddAliasURLID(OOH323CallData *call, const char* url);
/**
* This is a helper function used by other call related add aliases functions
* to add a particular alias. This function is not supposed to be called
* directly.
* @param call Handle to the call
* @param aliasType Type of alias being added
* @param value Alias value
* @param local Whether alias is for local party or remote party
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooCallAddAlias
(OOH323CallData *call, int aliasType, const char *value, OOBOOL local);
/**
* This function is used to add an dialed digits alias for the remote endpoint
* involved in a particular call.
* @param call Handle to the call
* @param dialedDigits dialedDigits alias to add for the remote endpoint.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddRemoteAliasDialedDigits
(OOH323CallData *call, const char* dialedDigits);
/**
* This function is used to add an H323ID alias for the remote endpoint
* involved in a particular call.
* @param call Handle to the call
* @param h323id H323ID to add for the remote endpoint.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddRemoteAliasH323ID(OOH323CallData *call, const char* h323id);
/**
* This function is used to add G7231 capability for the call. The
* "ooCallAdd...Capability" functions allow to override the global endpoint
* capabilities and use specific capabilities for specific calls.
* @param call Call for which capability has to be added.
* @param cap Capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param silenceSuppression Indicates support for silenceSuppression.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddG7231Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, OOBOOL silenceSuppression, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add G728 capability for the call. The
* "ooCallAdd...Capability" functions allow to override the global endpoint
* capabilities and use specific capabilities for specific calls.
* @param call Call for which capability has to be added.
* @param cap Capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddG728Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add G729 capability for the call. The
* "ooCallAdd...Capability" functions allow to override the global endpoint
* capabilities and use specific capabilities for specific calls.
* @param call Call for which capability has to be added.
* @param cap Capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddG729Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add G711 capability for the call. The
* "ooCallAdd...Capability" functions allow to override the global endpoint
* capabilities and use specific capabilities for specific calls.
* @param call Call for which capability has to be added.
* @param cap Capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddG711Capability(OOH323CallData *call, int cap, int txframes,
int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add GSM capability for the call. The
* "ooCallAdd...Capability" functions allow to override the global endpoint
* capabilities and use specific capabilities for specific calls.
* @param call Call for which capability has to be added.
* @param cap Type of GSM capability to be added.
* @param framesPerPkt Number of GSM frames pre packet.
* @param comfortNoise Comfort noise spec for the capability.
* @param scrambled Scrambled enabled/disabled for the capability.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddGSMCapability(OOH323CallData* call, int cap,
ASN1USINT framesPerPkt, OOBOOL comfortNoise,
OOBOOL scrambled, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add H263 video capability for the call. The
* "ooCallAdd...Capability" functions allow to override the global endpoint
* capabilities and use specific capabilities for specific calls.
* @param call Call for which capability has to be added.
* @param cap Capability type - OO_H263VIDEO
* @param sqcifMPI Minimum picture interval for encoding/decoding
* of SQCIF pictures.
* @param qcifMPI Minimum picture interval for encoding/decoding
* of QCIF pictures.
* @param cifMPI Minimum picture interval for encoding/decoding
* of CIF pictures.
* @param cif4MPI Minimum picture interval for encoding/decoding
* of CIF4 pictures.
* @param cif16MPI Minimum picture interval for encoding/decoding
* of CIF16 pictures.
* @param maxBitRate Maximum bit rate in units of 100 bits/s at
* which a transmitter can transmit video or a
* receiver can receive video.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCallAddH263VideoCapability(OOH323CallData *call, int cap,
unsigned sqcifMPI, unsigned qcifMPI,
unsigned cifMPI, unsigned cif4MPI,
unsigned cif16MPI, unsigned maxBitRate,
int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to enable rfc 2833 capability for the call. By default
* the stack uses the dtmf settings for the endpoint. But if you want to
* enable/disable dtmf for a specific call, then you can override end-point
* settings using this function
* @param call Call for which rfc2833 has to be enabled.
* @param dynamicRTPPayloadType dynamicRTPPayloadType to be used.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallEnableDTMFRFC2833
(OOH323CallData *call, int dynamicRTPPayloadType);
/**
* This function is used to disable rfc 2833 capability for the call.
* By default the stack uses the dtmf settings for the endpoint. But if you
* want to enable/disable dtmf for a specific call, then you can override
* end-point settings using this function
* @param call Call for which rfc2833 has to be disabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallDisableDTMFRFC2833(OOH323CallData *call);
/**
* This function is used to enable H.245(alphanumeric) dtmf support for the
* call. By default the stack uses the dtmf settings for the endpoint. But if
* you want to enable H.245(alphanumeric) dtmf for a specific call, then you
* can override end-point settings using this function
* @param call Call for which H.245(alphanumeric) dtmf support
* has to be enabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallEnableDTMFH245Alphanumeric(OOH323CallData *call);
/**
* This function is used to disable H.245(alphanumeric) dtmf support for the
* call. By default the stack uses the dtmf settings for the endpoint. But if
* you want to disable H.245(alphanumeric) dtmf for a specific call, then you
* can override end-point settings using this function
* @param call Call for which H.245(alphanumeric) dtmf support
* has to be disabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallDisableDTMFH245Alphanumeric(OOH323CallData *call);
/**
* This function is used to enable H.245(signal) dtmf support for the call.
* By default the stack uses the dtmf settings for the endpoint. But if you
* want to enable H.245(signal) dtmf for a specific call, then you can override
* end-point settings using this function
* @param call Call for which H.245(signal) dtmf support
* has to be enabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallEnableDTMFH245Signal(OOH323CallData *call);
/**
* This function is used to disable H.245(signal) dtmf support for the call.
* By default the stack uses the dtmf settings for the endpoint. But if you
* want to disable H.245(signal) dtmf for a specific call, then you can
* override end-point settings using this function
* @param call Call for which H.245(signal) dtmf support
* has to be disabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallDisableDTMFH245Signal(OOH323CallData *call);
/**
* This function is used to enable Q.931(keypad) dtmf support for the call.
* By default the stack uses the dtmf settings for the endpoint. But if you
* want to enable Q.931(keypad) dtmf support for a specific call, then you can
* override end-point settings using this function
* @param call Call for which Q.931(keypad) dtmf support
* has to be enabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallEnableDTMFQ931Keypad(OOH323CallData *call);
/**
* This function is used to disable Q.931(keypad) dtmf support for the call.
* By default the stack uses the dtmf settings for the endpoint. But if you
* want to disable Q.931(keypad) dtmf support for a specific call, then you can
* override end-point settings using this function
* @param call Call for which Q.931(keypad) dtmf support
* has to be disabled.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallDisableDTMFQ931Keypad(OOH323CallData *call);
/**
* This function is used to find a call by using the unique token for the call.
* @param callToken The unique token for the call.
*
* @return Pointer to the call if found, NULL otherwise.
*/
EXTERN OOH323CallData* ooFindCallByToken(char *callToken);
/**
* This function is used to end a call. Based on what stage of clearance the
* call is it takes appropriate action.
*
* @param call Handle to the call which has to be cleared.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooEndCall(OOH323CallData *call);
/**
* This function is used to remove a call from the list of existing calls.
*
* @param call Pointer to the call to be removed.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooRemoveCallFromList (OOH323CallData *call);
/**
* This function is used to clean up a call. It closes all associated sockets,
* removes the call from the global list and frees up associated memory.
*
* @param call Pointer to the call to be cleared.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCleanCall(OOH323CallData *call);
/**
* This function is used to check whether a specified session in specified
* direction is active for the call.
* @param call Handle to call for which session has to be queried.
* @param sessionID Session id to identify the type of session(1 for audio,
* 2 for voice and 3 for data)
* @param dir Direction of the session(transmit/receive)
*
* @return 1, if session active. 0, otherwise.
*/
EXTERN ASN1BOOL ooIsSessionEstablished
(OOH323CallData *call, int sessionID, char* dir);
/**
* This function can be used by an application to specify media endpoint
* information for different types of media. The stack by default uses local IP
* and port for media. An application can provide mediainfo if it wants to
* override default.
* @param call Handle to the call
* @param mediaInfo Structure which defines the media endpoint to be
* used.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooAddMediaInfo(OOH323CallData *call, OOMediaInfo mediaInfo);
/**
* This function is used to generate a media session id for the new media
* session for the call.
* @param call Handle to the call.
* @param type Type of media session.
* @param dir Direction of session
*
* @return Generated session id.
*/
EXTERN unsigned ooCallGenerateSessionID
(OOH323CallData *call, OOCapType type, char *dir);
/**
* This is an handler for H245 connection retry timer. When remote end is not
* yet listening for H245 connections, this timer provides a wait and retry
* mechanism to establish H245 connection.
* @param data Timer callback data.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooCallH245ConnectionRetryTimerExpired(void *data);
/**
* This function is used to retrieve the description text for a reason
* code.
*
* @param code Reason code.
* @return The text description string.
*/
EXTERN const char* ooGetReasonCodeText (OOUINT32 code);
/**
* This function is used to retrieve the description text for a call
* state.
*
* @param callState Call state.
* @return The text description string.
*/
EXTERN const char* ooGetCallStateText (OOCallState callState);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,726 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooCapability.h
* This file contains Capability management functions.
*/
#ifndef OO_CAPABILITY_H_
#define OO_CAPABILITY_H_
#include "ootypes.h"
#include "ooasn1.h"
#define OO_GSMFRAMESIZE 33 /* standard frame size for gsm is 33 bytes */
#define OORX (1<<0)
#define OOTX (1<<1)
#define OORXANDTX (1<<2)
#define OORXTX (1<<3) /* For symmetric capabilities */
/* Various types of caps. Note that not all
supported */
typedef enum OOCapabilities{
OO_CAP_AUDIO_BASE = 0,
OO_G711ALAW64K = 2,
OO_G711ALAW56K = 3,
OO_G711ULAW64K = 4,
OO_G711ULAW56K = 5,
OO_G722_64k = 6,
OO_G722_56k = 7,
OO_G722_48k = 8,
OO_G7231 = 9,
OO_G728 = 10,
OO_G729 = 11,
OO_G729A = 12,
OO_IS11172_AUDIO = 13,
OO_IS13818_AUDIO = 14,
OO_G729B = 15,
OO_G729AB = 16,
OO_G7231C = 17,
OO_GSMFULLRATE = 18,
OO_GSMHALFRATE = 19,
OO_GSMENHANCEDFULLRATE = 20,
OO_GENERICAUDIO = 21,
OO_G729EXT = 22,
OO_AUDIO_VBD = 23,
OO_AUDIOTELEPHONYEVENT = 24,
OO_AUDIO_TONE = 25,
OO_EXTELEM1 = 26,
OO_CAP_VIDEO_BASE = 27,
OO_NONSTDVIDEO = 28,
OO_H261VIDEO = 29,
OO_H262VIDEO = 30,
OO_H263VIDEO = 31,
OO_IS11172VIDEO = 32, /* mpeg */
OO_GENERICVIDEO = 33,
OO_EXTELEMVIDEO = 34
} OOCapabilities;
/*DTMF capabilities*/
#define OO_CAP_DTMF_RFC2833 (1<<0)
#define OO_CAP_DTMF_Q931 (1<<1)
#define OO_CAP_DTMF_H245_alphanumeric (1<<2)
#define OO_CAP_DTMF_H245_signal (1<<3)
/**
* This structure defines the preference order for capabilities.
*
*/
typedef struct OOCapPrefs {
int order[20];
int index;
}OOCapPrefs;
typedef struct OOCapParams {
int txframes; /*!< Number of frames per packet for transmission */
int rxframes; /*!< Number of frames per packet for reception */
OOBOOL silenceSuppression;
} OOCapParams;
typedef struct OOGSMCapParams {
unsigned txframes;
unsigned rxframes;
OOBOOL scrambled;
OOBOOL comfortNoise;
} OOGSMCapParams;
typedef enum OOPictureFormat{
OO_PICFORMAT_SQCIF,
OO_PICFORMAT_QCIF,
OO_PICFORMAT_CIF,
OO_PICFORMAT_CIF4,
OO_PICFORMAT_CIF16
}OOPictureFormat;
typedef struct OOH263CapParams {
enum OOPictureFormat picFormat; /* !< One of sqcif, qcif, cif, cif4, cif16*/
unsigned MPI; /* !< Minimum Picture Interval */
unsigned maxBitRate; /* !< Maximum bit rate for transmission/reception in units of 100 bits/sec */
} OOH263CapParams;
struct OOH323CallData;
struct OOLogicalChannel;
#ifdef __cplusplus
extern "C" {
#endif
/**
* This callback is used for starting media receive channel. This callback
* function is triggered when receive media channel has to be started.
* @param call Call for which receive media channel has to be started.
* @param pChannel Channel details. This structure has important information
* such as rtp ip:port and capability describing media type
* to be received.
* @return OO_OK, on success. OO_FAILED, on failure
*/
typedef int (*cb_StartReceiveChannel)
(struct OOH323CallData *call, struct OOLogicalChannel *pChannel);
/**
* This callback is used for starting media transmit channel. This callback
* function is triggered when transmit media channel has to be started.
* @param call Call for which transmit media channel has to be started.
* @param pChannel Channel details. This structure has important information
* such as rtp ip:port and capability describing media type
* to be transmitted.
* @return OO_OK, on success. OO_FAILED, on failure
*/
typedef int (*cb_StartTransmitChannel)
(struct OOH323CallData *call, struct OOLogicalChannel *pChannel);
/**
* This callback is used for stopping media receive channel. This callback
* function is triggered when receive media channel has to be stopped.
* @param call Call for which receive media channel has to be stopped.
* @param pChannel Channel details. This structure has important information
* such as rtp ip:port and capability describing media type
* being received.
* @return OO_OK, on success. OO_FAILED, on failure
*/
typedef int (*cb_StopReceiveChannel)
(struct OOH323CallData *call, struct OOLogicalChannel *pChannel);
/**
* This callback is used for stopping media transmit channel. This callback
* function is triggered when transmit media channel has to be stopped.
* @param call Call for which transmit media channel has to be stopped.
* @param pChannel Channel details. This structure has important information
* such as rtp ip:port and capability describing media type
* being transmitted.
* @return OO_OK, on success. OO_FAILED, on failure
*/
typedef int (*cb_StopTransmitChannel)
(struct OOH323CallData *call, struct OOLogicalChannel *pChannel);
typedef enum OOCapType {
OO_CAP_TYPE_AUDIO,
OO_CAP_TYPE_VIDEO,
OO_CAP_TYPE_DATA
} OOCapType;
/**
* Structure to store information related to end point
* capability
*/
typedef struct ooH323EpCapability {
int dir;
int cap;
OOCapType capType;
void *params;
cb_StartReceiveChannel startReceiveChannel;
cb_StartTransmitChannel startTransmitChannel;
cb_StopReceiveChannel stopReceiveChannel;
cb_StopTransmitChannel stopTransmitChannel;
struct ooH323EpCapability *next;
} ooH323EpCapability;
#ifndef EXTERN
#if defined (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* @defgroup capmgmt Capability Management
* @{
*/
/**
* This function is used to add rfc2833 based dtmf detection capability
* @param call Call if enabling for call, else null for
* endpoint.
* @param dynamicRTPPayloadType dynamicRTPPayloadType to be used.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityEnableDTMFRFC2833
(struct OOH323CallData *call, int dynamicRTPPayloadType);
/**
* This function is used to remove rfc2833 dtmf detection capability.
* @param call Handle to call, if disabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityDisableDTMFRFC2833(struct OOH323CallData *call);
/**
* This function is used to enable support for H.245 based alphanumeric dtmf
* capability.
* @param call Handle to call, if enabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityEnableDTMFH245Alphanumeric(struct OOH323CallData *call);
/**
* This function is used to disable support for H.245 based alphanumeric dtmf
* capability.
* @param call Handle to call, if disabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityDisableDTMFH245Alphanumeric
(struct OOH323CallData *call);
/**
* This function is used to enable support for H.245 based signal dtmf
* capability.
* @param call Handle to call, if enabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityEnableDTMFH245Signal(struct OOH323CallData *call);
/**
* This function is used to disable support for H.245 based signal dtmf
* capability.
* @param call Handle to call, if disabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityDisableDTMFH245Signal(struct OOH323CallData *call);
/**
* This function is used to enable support for dtmf using Q.931 Keypad IE.
* @param call Handle to call, if enabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityEnableDTMFQ931Keypad(struct OOH323CallData *call);
/**
* This function is used to disable support for dtmf using Q.931 Keypad IE.
* @param call Handle to call, if disabling for the call, else NULL
* for end-point.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityDisableDTMFQ931Keypad(struct OOH323CallData *call);
/**
* This function is used to add simple capabilities which have only rxframes
* and txframes parameters to the endpoint or call.(ex. G711, G728, G723.1,
* G729)
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability list, else it is added to local H323
* endpoint list.
* @param cap Type of G711 capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param silenceSuppression Indicates support for silence suppression.
* Used only in case of g7231, otherwise ignored.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
* @param remote TRUE, if adding call's remote capability.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityAddSimpleCapability
(struct OOH323CallData *call, int cap, int txframes, int rxframes,
OOBOOL silenceSuppression, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote);
/**
* This is an internal helper function which is used to add a GSM capability
* to local endpoints capability list or to remote endpoints capability list or
* to a call's capability list.
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability list, else it is added to local H323
* endpoint list.
* @param cap Type of GSM capability to be added.
* @param framesPerPkt Number of GSM frames per packet.
* @param comfortNoise Comfort noise spec for the capability.
* @param scrambled Scrambled enabled/disabled for the capability.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
* @param remote TRUE, if adding call's remote capabilities.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooCapabilityAddGSMCapability(struct OOH323CallData *call, int cap,
unsigned framesPerPkt, OOBOOL comfortNoise,
OOBOOL scrambled, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote);
/**
* This function is used to add H263 video capability to local endpoints
* capability list or to remote endpoints capability list or to a call's
* capability list.
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability list, else it is added to local H323
* endpoint list.
* @param sqcifMPI Minimum picture interval for encoding/decoding
* of SQCIF pictures.
* @param qcifMPI Minimum picture interval for encoding/decoding
* of QCIF pictures.
* @param cifMPI Minimum picture interval for encoding/decoding
* of CIF pictures.
* @param cif4MPI Minimum picture interval for encoding/decoding
* of CIF4 pictures.
* @param cif16MPI Minimum picture interval for encoding/decoding
* of CIF16 pictures.
* @param maxBitRate Maximum bit rate in units of 100 bits/s at
* which a transmitter can transmit video or a
* receiver can receive video.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
* @param remote TRUE, if adding call's remote capabilities.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCapabilityAddH263VideoCapability(struct OOH323CallData *call,
unsigned sqcifMPI, unsigned qcifMPI,
unsigned cifMPI, unsigned cif4MPI,
unsigned cif16MPI, unsigned maxBitRate, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote);
/**
* This function is an helper function to ooCapabilityAddH263VideoCapability.
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability list, else it is added to local H323
* endpoint list.
* @param sqcifMPI Minimum picture interval for encoding/decoding
* of SQCIF pictures.
* @param qcifMPI Minimum picture interval for encoding/decoding
* of QCIF pictures.
* @param cifMPI Minimum picture interval for encoding/decoding
* of CIF pictures.
* @param cif4MPI Minimum picture interval for encoding/decoding
* of CIF4 pictures.
* @param cif16MPI Minimum picture interval for encoding/decoding
* of CIF16 pictures.
* @param maxBitRate Maximum bit rate in units of 100 bits/s at
* which a transmitter can transmit video or a
* receiver can receive video.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
* @param remote TRUE, if adding call's remote capabilities.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooCapabilityAddH263VideoCapability_helper(struct OOH323CallData *call,
unsigned sqcifMPI, unsigned qcifMPI,
unsigned cifMPI, unsigned cif4MPI,
unsigned cif16MPI, unsigned maxBitRate, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel,
OOBOOL remote);
/**
* This function is used to add a audio capability to calls remote
* capability list.
* @param call Handle to the call.
* @param audioCap Handle to the remote endpoint's audio capability.
* @param dir Direction in which capability is supported by
* remote endpoint.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooAddRemoteAudioCapability(struct OOH323CallData *call,
H245AudioCapability *audioCap, int dir);
/**
* This function is used to add a capability to call's remote capability list.
* The capabilities to be added are extracted from received TCS message.
* @param call Handle to the call.
* @param cap Handle to the remote endpoint's H245 capability.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooAddRemoteCapability(struct OOH323CallData *call, H245Capability *cap);
/**
* This function is used to update joint capabilities for call. It checks
* whether remote capability can be supported by local capabilities for the
* call and if supported makes entry into the joint capability list for the
* call.
* @param call Handle to the call
* @param cap Remote cap which will be tested for compatibility.
*
* @return returns OO_OK, if updated else OO_FAILED;
*/
EXTERN int ooCapabilityUpdateJointCapabilities
(struct OOH323CallData* call, H245Capability *cap);
/**
* This function is used to update joint video capabilities for call. It checks
* whether remote capability can be supported by local capabilities for the
* call and if supported makes entry into the joint capability list for the
* call.
* @param call Handle to the call
* @param videoCap Remote video capability which will be tested for
* compatibility.
* @param dir Direction of the capability
*
* @return returns OO_OK, if updated else OO_FAILED;
*/
EXTERN int ooCapabilityUpdateJointCapabilitiesVideo
(struct OOH323CallData *call, H245VideoCapability *videoCap, int dir);
/**
* This function is used to update joint video H263 capabilities for call. It
* checks whether remote capability can be supported by local capabilities for
* the call and if supported makes entry into the joint capability list for the
* call.
* @param call Handle to the call
* @param pH263Cap Remote H263 video capability which will be tested for
* compatibility.
* @param dir Direction of the H263 capability
*
* @return returns OO_OK, if updated else OO_FAILED;
*/
EXTERN int ooCapabilityUpdateJointCapabilitiesVideoH263
(struct OOH323CallData *call, H245H263VideoCapability *pH263Cap, int dir);
/**
* This function is used to test whether the endpoint capability in the
* specified direction can be supported by the audio capability.
* @param call Handle to the call.
* @param epCap Endpoint capability.
* @param dataType Data type with which compatibility has to
* be tested.
* @param dir Direction indicating whether endpoint capability
* will be used for transmission or reception.
*
* @return TRUE, if compatible. FALSE, otherwise.
*/
ASN1BOOL ooCapabilityCheckCompatibility(struct OOH323CallData *call,
ooH323EpCapability *epCap,
H245DataType *dataType, int dir);
/**
* This function is used to create a audio capability structure using the
* capability type.
* @param epCap Capability.
* @param pctxt Handle to OOCTXT which will be used to allocate memory
* for new audio capability.
* @param dir Direction in which the newly created capability will be
* used.
*
* @return Newly created audio capability on success, NULL on
* failure.
*/
struct H245AudioCapability* ooCapabilityCreateAudioCapability
(ooH323EpCapability* epCap, OOCTXT *pctxt, int dir);
/**
* This function is used to create a video capability structure using the
* capability type.
* @param epCap Capability.
* @param pctxt Handle to OOCTXT which will be used to allocate memory
* for new video capability.
* @param dir Direction in which the newly created capability will be
* used.
*
* @return Newly created video capability on success, NULL on
* failure.
*/
struct H245VideoCapability* ooCapabilityCreateVideoCapability
(ooH323EpCapability *epCap, OOCTXT *pctxt, int dir);
/**
* This function is used to create a dtmf capability which can be added to
* a TCS message.
* @param cap Type of dtmf capability to be created.
* @param pctxt Pointer to OOCTXT structure to be used for memory
* allocation.
*
* @return Pointer to the created DTMF capability, NULL in case of
* failure.
*/
void * ooCapabilityCreateDTMFCapability(int cap, OOCTXT *pctxt);
/**
* This function is used to create a GSM Full Rate capability structure.
* @param epCap Handle to the endpoint capability.
* @param pctxt Handle to OOCTXT which will be used to allocate memory
* for new audio capability.
* @param dir Direction for the newly created capability.
*
* @return Newly created audio capability on success, NULL on
* failure.
*/
struct H245AudioCapability* ooCapabilityCreateGSMFullRateCapability
(ooH323EpCapability *epCap, OOCTXT* pctxt, int dir);
/**
* This function is used to create a simple(g711, g728, g723.1, g729) audio
* capability structure.
*
* @param epCap Handle to the endpoint capability
* @param pctxt Handle to OOCTXT which will be used to allocate memory
* for new audio capability.
* @param dir Direction in which the newly created capability will be
* used.
*
* @return Newly created audio capability on success, NULL on
* failure.
*/
struct H245AudioCapability* ooCapabilityCreateSimpleCapability
(ooH323EpCapability *epCap, OOCTXT* pctxt, int dir);
/**
* This function is used to create a H263 video capability
* structure.
* @param epCap Handle to the endpoint capability
* @param pctxt Handle to OOCTXT which will be used to allocate memory
* for new video capability.
* @param dir Direction in which the newly created capability will be
* used.
*
* @return Newly created video capability on success, NULL on
* failure.
*/
struct H245VideoCapability* ooCapabilityCreateH263VideoCapability
(ooH323EpCapability *epCap, OOCTXT* pctxt, int dir);
/**
* This function is used to determine whether a particular capability
* can be supported by the endpoint.
* @param call Handle to the call.
* @param audioCap Handle to the audio capability.
* @param dir Direction in which support is desired.
*
* @return Handle to the copyof capability which supports audioCap,
* Null if none found
*/
ooH323EpCapability* ooIsAudioDataTypeSupported
(struct OOH323CallData *call, H245AudioCapability* audioCap, int dir);
/**
* This function is used to determine whether a particular video capability
* can be supported by the endpoint.
* @param call Handle to the call.
* @param pVideoCap Handle to the video capability.
* @param dir Direction in which support is desired.
*
* @return Handle to the copy of capability which supports video
* capability, Null if none found
*/
ooH323EpCapability* ooIsVideoDataTypeSupported
(struct OOH323CallData *call, H245VideoCapability* pVideoCap, int dir);
/**
* This function is used to determine whether a particular H263 capability
* can be supported by the endpoint.
* @param call Handle to the call.
* @param pH263Cap Handle to the H263 video capability.
* @param dir Direction in which support is desired.
* @param picFormat Picture type(cif, qcif etc.)
*
* @return Handle to the copy of capability which supports H263
* capability, Null if none found
*/
ooH323EpCapability* ooIsVideoDataTypeH263Supported
(struct OOH323CallData *call, H245H263VideoCapability* pH263Cap, int dir,
OOPictureFormat picFormat);
/**
* This function is used to determine whether a particular capability type
* can be supported by the endpoint.
* @param call Handle to the call.
* @param data Handle to the capability type.
* @param dir Direction in which support is desired.
*
* @return Handle to the copy of capability which supports specified
* capability type, Null if none found
*/
ooH323EpCapability* ooIsDataTypeSupported
(struct OOH323CallData *call, H245DataType *data, int dir);
/**
* This function is used to clear the capability preference order.
* @param call Handle to call, if capability preference order for call
* has to be cleared, NULL for endpoint.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooResetCapPrefs(struct OOH323CallData *call);
/**
* This function is used to remove a particular capability from preference
* list.
* @param call Handle to call, if call's preference list has to be modified
* else NULL, to modify endpoint's preference list.
* @param cap Capability to be removed
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooRemoveCapFromCapPrefs(struct OOH323CallData *call, int cap);
/**
* This function is used to append a particular capability to preference
* list.
* @param call Handle to call, if call's preference list has to be modified
* else NULL, to modify endpoint's preference list.
* @param cap Capability to be appended.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooAppendCapToCapPrefs(struct OOH323CallData *call, int cap);
/**
* This function is used to change preference order of a particular capability
* in the preference list.
* @param call Handle to call, if call's preference list has to be modified
* else NULL, to modify endpoint's preference list.
* @param cap Capability concerned
* @param pos New position in the preference order
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooChangeCapPrefOrder(struct OOH323CallData *call, int cap, int pos);
/**
* This function is used to preppend a particular capability to preference
* list.
* @param call Handle to call, if call's preference list has to be modified
* else NULL, to modify endpoint's preference list.
* @param cap Capability to be preppended.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooPreppendCapToCapPrefs(struct OOH323CallData *call, int cap);
/**
* This function is used to retrieve the text description for a capability
* type.
* @param cap Capability
* @return The text description string.
*/
EXTERN const char* ooGetCapTypeText (OOCapabilities cap);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,193 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooStackCmds.h"
#include "ootrace.h"
#include "ooq931.h"
#include "ooh245.h"
#include "ooh323ep.h"
#include "oochannels.h"
#include "ooCalls.h"
#include "ooCmdChannel.h"
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
OOSOCKET gCmdChan = 0;
pthread_mutex_t gCmdChanLock;
int ooCreateCmdConnection()
{
int ret = 0;
int thePipe[2];
if ((ret = pipe(thePipe)) == -1) {
return OO_FAILED;
}
pthread_mutex_init(&gCmdChanLock, NULL);
gH323ep.cmdSock = dup(thePipe[0]);
close(thePipe[0]);
gCmdChan = dup(thePipe[1]);
close(thePipe[1]);
return OO_OK;
}
int ooCloseCmdConnection()
{
close(gH323ep.cmdSock);
gH323ep.cmdSock = 0;
close(gCmdChan);
gCmdChan = 0;
pthread_mutex_destroy(&gCmdChanLock);
return OO_OK;
}
int ooWriteStackCommand(OOStackCommand *cmd)
{
pthread_mutex_lock(&gCmdChanLock);
if (write(gCmdChan, (char*)cmd, sizeof(OOStackCommand)) == -1) {
pthread_mutex_unlock(&gCmdChanLock);
return OO_FAILED;
}
pthread_mutex_unlock(&gCmdChanLock);
return OO_OK;
}
int ooReadAndProcessStackCommand()
{
OOH323CallData *pCall = NULL;
unsigned char buffer[MAXMSGLEN];
int i, recvLen = 0;
OOStackCommand cmd;
memset(&cmd, 0, sizeof(OOStackCommand));
recvLen = read(gH323ep.cmdSock, buffer, MAXMSGLEN);
if(recvLen <= 0)
{
OOTRACEERR1("Error:Failed to read CMD message\n");
return OO_FAILED;
}
for(i=0; (int)(i+sizeof(OOStackCommand)) <= recvLen; i += sizeof(OOStackCommand))
{
memcpy(&cmd, buffer+i, sizeof(OOStackCommand));
if(cmd.type == OO_CMD_NOOP)
continue;
if(gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered)
{
OOTRACEINFO1("Ignoring stack command as Gk Client is not registered"
" yet\n");
}
else {
switch(cmd.type) {
case OO_CMD_MAKECALL:
OOTRACEINFO2("Processing MakeCall command %s\n",
(char*)cmd.param2);
ooH323MakeCall ((char*)cmd.param1, (char*)cmd.param2,
(ooCallOptions*)cmd.param3);
break;
case OO_CMD_MANUALRINGBACK:
if(OO_TESTFLAG(gH323ep.flags, OO_M_MANUALRINGBACK))
{
pCall = ooFindCallByToken((char*)cmd.param1);
if(!pCall) {
OOTRACEINFO2("Call \"%s\" does not exist\n",
(char*)cmd.param1);
OOTRACEINFO1("Call migth be cleared/closed\n");
}
else {
ooSendAlerting(ooFindCallByToken((char*)cmd.param1));
if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER)) {
ooSendConnect(ooFindCallByToken((char*)cmd.param1));
}
}
}
break;
case OO_CMD_ANSCALL:
pCall = ooFindCallByToken((char*)cmd.param1);
if(!pCall) {
OOTRACEINFO2("Call \"%s\" does not exist\n",
(char*)cmd.param1);
OOTRACEINFO1("Call might be cleared/closed\n");
}
else {
OOTRACEINFO2("Processing Answer Call command for %s\n",
(char*)cmd.param1);
ooSendConnect(pCall);
}
break;
case OO_CMD_FWDCALL:
OOTRACEINFO3("Forwarding call %s to %s\n", (char*)cmd.param1,
(char*)cmd.param2);
ooH323ForwardCall((char*)cmd.param1, (char*)cmd.param2);
break;
case OO_CMD_HANGCALL:
OOTRACEINFO2("Processing Hang call command %s\n",
(char*)cmd.param1);
ooH323HangCall((char*)cmd.param1,
*(OOCallClearReason*)cmd.param2);
break;
case OO_CMD_SENDDIGIT:
pCall = ooFindCallByToken((char*)cmd.param1);
if(!pCall) {
OOTRACEERR2("ERROR:Invalid calltoken %s\n",
(char*)cmd.param1);
break;
}
if(pCall->jointDtmfMode & OO_CAP_DTMF_H245_alphanumeric) {
ooSendH245UserInputIndication_alphanumeric(
pCall, (const char*)cmd.param2);
}
else if(pCall->jointDtmfMode & OO_CAP_DTMF_H245_signal) {
ooSendH245UserInputIndication_signal(
pCall, (const char*)cmd.param2);
}
else {
ooQ931SendDTMFAsKeyPadIE(pCall, (const char*)cmd.param2);
}
break;
case OO_CMD_STOPMONITOR:
OOTRACEINFO1("Processing StopMonitor command\n");
ooStopMonitorCalls();
break;
default: OOTRACEERR1("ERROR:Unknown command\n");
}
}
if(cmd.param1) free(cmd.param1);
if(cmd.param2) free(cmd.param2);
if(cmd.param3) free(cmd.param3);
}
return OO_OK;
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooCmdChannel.h
* This file contains stack commands which an user application can use to make
* call, hang call etc.
*/
#ifndef OO_CMDCHANNEL_H
#define OO_CMDCHANNEL_H
#include "ootypes.h"
#include "ooStackCmds.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#if defined (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
#define OO_DEFAULT_CMDLISTENER_PORT 7575
/**
* @addtogroup channels
* @{
*/
/**
* This function is used to setup a command connection with the main stack
* thread. The application commands are sent over this connection to stack
* thread.
*
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooCreateCmdConnection();
/**
* This function is used to close a command channel setup with the stack
* thread.
*
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooCloseCmdConnection();
/**
* This function is used by stack api to write stack commands to command
* channel.
*
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooWriteStackCommand(OOStackCommand *cmd);
/**
* This function is used by stack thread to read and process stack commands
* received over command channel.
*
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooReadAndProcessStackCommand();
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,124 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the LICENSE.txt file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooCommon.h
* Common runtime constant and type definitions.
*/
#ifndef _OOCOMMON_H_
#define _OOCOMMON_H_
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef _WIN32_WCE
#include <winsock.h>
#elif defined(_WIN32) || defined(_WIN64)
#include <sys/types.h>
#define INCL_WINSOCK_API_TYPEDEFS 1
#define INCL_WINSOCK_API_PROTOTYPES 0
#include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#endif
/**
* @ingroup cruntime C Runtime Common Constant and Type Definitions.
* @{
*/
/* Basic type definitions */
typedef char OOCHAR;
typedef unsigned char OOUCHAR;
typedef signed char OOINT8;
typedef unsigned char OOUINT8;
typedef short OOINT16;
typedef unsigned short OOUINT16;
typedef int OOINT32;
typedef unsigned int OOUINT32;
typedef OOUINT8 OOBOOL;
#define OOUINT32_MAX 4294967295U
#define OOINT32_MAX ((OOINT32)2147483647L)
#define OOINT32_MIN ((OOINT32)(-OOINT32_MAX-1))
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
/* Common error codes */
#define OOERRINVPARAM (-50) /* Invalid parameter */
#define OOERRBUFOVFLW (-51) /* Buffer overflow */
#define OOERRNOMEM (-52) /* No dynamic memory available */
/* Message buffer: this is used for asynchronous transfers */
typedef struct _OOMsgBuf {
OOUINT8* pdata; /* Pointer to binary or text data */
OOUINT32 bufsiz; /* Size of the buffer in bytes */
OOUINT32 length; /* # bytes to send (write) or # received (read) */
OOUINT32 offset; /* Offset into buffer of first byte to send */
OOBOOL dynamic; /* pdata is dynamic (allocated with OOMEMALLOC) */
} OOMsgBuf;
/* Memory allocation and free function definitions. These definitions */
/* can be changed if a non-standard allocation/free function is to be */
/* used.. */
#define OOMEMALLOC malloc
#define OOMEMFREE free
/* Min/max macros */
#ifndef OOMAX
#define OOMAX(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef OOMIN
#define OOMIN(a,b) (((a)<(b))?(a):(b))
#endif
/* Get count of number of items in an array */
#define OONUMBEROF(items) (sizeof(items)/sizeof(items[0]))
/* This is used for creating a Windows DLL. Specify -DMAKE_DLL to */
/* compile code for inclusion in a DLL. */
#ifndef EXTERN
#if defined (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#elif defined (USE_DLL)
#define EXTERN __declspec(dllimport)
#else
#define EXTERN
#endif /* _DLL */
#endif /* EXTERN */
/**
* @}
*/
#endif /* _OOCOMMON_H_ */

View File

@ -0,0 +1,175 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the LICENSE.txt file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooCommon.h"
#if defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
#ifndef __MINGW32__
#include <SYS\TIMEB.H>
int gettimeofday (struct timeval *tv, struct timezone *tz)
{
struct _timeb currSysTime;
_ftime(&currSysTime);
tv->tv_sec = currSysTime.time;
tv->tv_usec = currSysTime.millitm * 1000;
return 0;
}
#else
/* Mingw specific logic..probably works with regular winders
* too, but cannot test. --Ben
*/
#define uint64 unsigned long long
#define uint32 unsigned long
static uint64 calcEpocOffset() {
SYSTEMTIME st;
FILETIME ft;
memset(&st, 0, sizeof(st));
memset(&ft, 0, sizeof(ft));
st.wYear = 1970;
st.wMonth = 1;
st.wDayOfWeek = 0;
st.wDay = 1;
st.wHour = 0;
st.wMinute = 0;
st.wSecond = 0;
st.wMilliseconds = 0;
if (!SystemTimeToFileTime(&st, &ft)) {
//cout << "ERROR: SystemTimeToFileTime failed, err: "
// << GetLastError() << endl;
}
uint64 t = ft.dwHighDateTime;
t = t << 32;
t |= ft.dwLowDateTime;
return t;
}
// Gets high resolution by spinning up to 15ms. Don't call this often!!!
static uint64 getRawCurMsSpin() {
FILETIME tm;
uint64 t_now;
static uint64 epocOffset = 0;
static int do_once = 1;
if (do_once) {
epocOffset = calcEpocOffset();
do_once = 0;
}
GetSystemTimeAsFileTime(&tm);
uint64 t_start = tm.dwHighDateTime;
t_start = t_start << 32;
t_start |= tm.dwLowDateTime;
while (1) {
GetSystemTimeAsFileTime(&tm);
t_now = tm.dwHighDateTime;
t_now = t_now << 32;
t_now |= tm.dwLowDateTime;
if (t_now != t_start) {
// Hit a boundary...as accurate as we are going to get.
break;
}
}
t_now -= epocOffset;
// t is in 100ns units, convert to usecs
t_now = t_now / 10000; //msecs
return t_now;
}
static uint64 baselineMs = 0;
static uint32 tickBaseline = 0;
int gettimeofday(struct timeval* tv, void* null) {
// Get baseline time, in seconds.
if (baselineMs == 0) {
baselineMs = getRawCurMsSpin();
tickBaseline = timeGetTime();
}
uint32 curTicks = timeGetTime();
if (curTicks < tickBaseline) {
// Wrap!
baselineMs = getRawCurMsSpin();
tickBaseline = timeGetTime();
}
uint64 now_ms = (baselineMs + (curTicks - tickBaseline));
*tv = oo_ms_to_tv(now_ms);
return 0;
};
/* Correctly synched with the 'real' time/date clock, but only exact to
* about 15ms. Set foo to non NULL if you want to recalculate the
*/
uint64 getCurMsFromClock() {
// This has resolution of only about 15ms
FILETIME tm;
// The Windows epoc is January 1, 1601 (UTC).
static uint64 offset = 0;
static int do_once = 1;
if (do_once) {
offset = calcEpocOffset();
do_once = 0;
}
GetSystemTimeAsFileTime(&tm);
uint64 t = tm.dwHighDateTime;
t = t << 32;
t |= tm.dwLowDateTime;
/*cout << "file-time: " << t << " offset: " << offset
<< " normalized: " << (t - offset) << " hi: "
<< tm.dwHighDateTime << " lo: " << tm.dwLowDateTime
<< " calc-offset:\n" << calcEpocOffset() << "\n\n";
*/
t -= offset;
// t is in 100ns units, convert to ms
t = t / 10000;
return t;
}
#endif
#endif
int ooGetTimeOfDay (struct timeval *tv, struct timezone *tz)
{
return gettimeofday (tv, tz);
}
long ooGetTimeDiff(struct timeval *tv1, struct timeval *tv2)
{
return ( ((tv2->tv_sec-tv1->tv_sec)*1000) +
((tv2->tv_usec-tv1->tv_usec)/1000) );
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the LICENSE.txt file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooDateTime.h
* Time functions that reconcile differences between Windows and UNIX.
*/
#ifndef _OOTIME_H_
#define _OOTIME_H_
#include "ooCommon.h"
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* This function provides an abstraction for the UNIX 'gettimeofday'
* function which is not available on Windows.
*
* @param tv Pointer to time value structure to receive
* current time value.
* @param tz Point to time zone information.
* @return Completion status of operation: 0 = success,
* negative return value is error.
*/
EXTERN int ooGetTimeOfDay (struct timeval *tv, struct timezone *tz);
/**
* This function subtracts first timeval parameter from second and provides
* the difference in milliseconds.
* @param tv1 Pointer to timeval value.
* @param tv2 Pointer to timeval value.
*
* @return Difference between two timevals in milliseconds.
*/
EXTERN long ooGetTimeDiff(struct timeval *tv1, struct timeval *tv2);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,560 @@
/*
* Copyright (C) 2005 by Page Iberica, S.A.
* Copyright (C) 2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooGkClient.h
* This file contains functions to support RAS protocol.
*
*
*/
#ifndef _OOGKCLIENT_H_
#define _OOGKCLIENT_H_
#include "ooasn1.h"
#include "ootypes.h"
#include "H323-MESSAGES.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* _WIN32 */
#endif /* EXTERN */
/*-------------------------------------------------------------------*/
/* Public definitions */
/*-------------------------------------------------------------------*/
#define MAX_IP_LEN 15
#define DEFAULT_GKPORT 1719
#define MULTICAST_GKADDRESS "224.0.1.41"
#define MULTICAST_GKPORT 1718
#define DEFAULT_BW_REQUEST 100000
/* Various timeouts in seconds */
#define DEFAULT_REG_TTL 300
#define DEFAULT_TTL_OFFSET 20
#define DEFAULT_ARQ_TIMEOUT 5
#define DEFAULT_DRQ_TIMEOUT 5
#define DEFAULT_GRQ_TIMEOUT 15
#define DEFAULT_RRQ_TIMEOUT 10
/* Number of retries before giving up */
#define OO_MAX_GRQ_RETRIES 3
#define OO_MAX_RRQ_RETRIES 3
#define OO_MAX_ARQ_RETRIES 3
/* Gk Client timers */
#define OO_GRQ_TIMER (1<<0)
#define OO_RRQ_TIMER (1<<1)
#define OO_REG_TIMER (1<<2)
#define OO_ARQ_TIMER (1<<3)
#define OO_DRQ_TIMER (1<<4)
/**
* @defgroup gkclient Gatekeeper client
* @{
*/
struct OOH323CallData;
struct ooGkClient;
struct RasCallAdmissionInfo;
typedef struct ooGkClientTimerCb{
int timerType;
struct ooGkClient *pGkClient;
struct RasCallAdmissionInfo *pAdmInfo;
}ooGkClientTimerCb;
enum RasGatekeeperMode {
RasNoGatekeeper = 0,
RasDiscoverGatekeeper = 1,
RasUseSpecificGatekeeper = 2,
};
enum RasCallType{
RasPointToPoint =0,
RasOneToN,
RasnToOne,
RasnToN,
};
enum OOGkClientState {
GkClientIdle = 0,
GkClientDiscovered, /* Gk Discovery is complete */
GkClientRegistered, /* registered with gk */
GkClientUnregistered,
GkClientGkErr,/*Gk is not responding, in discover mode can look for new GK*/
GkClientFailed
};
typedef struct RasGatekeeperInfo
{
ASN1BOOL willRespondToIRR;
H225UUIEsRequested uuiesRequested;
H225BandWidth bw;
H225RegistrationConfirm_preGrantedARQ preGrantedARQ;
}RasGatekeeperInfo;
/**
* Call Admission Information
*/
typedef struct RasCallAdmissionInfo
{
struct OOH323CallData *call;
unsigned int retries;
unsigned short requestSeqNum;
ASN1USINT irrFrequency;
} RasCallAdmissionInfo;
struct OOAliases;
/**
* NOTE- This functionality is not yet fully completed.
* This is a callback function which is triggered when registration confirm
* message is received from the gatekeeper. The first parameter is the message
* received. The second parameter provides updated list of aliases after the
* message was processed by the stack.
* @param rcf Handle to the received registration confirm message
*/
typedef int (*cb_OnReceivedRegistrationConfirm)
(H225RegistrationConfirm *rcf, struct OOAliases *aliases);
/**
* NOTE- This functionality is not yet fully completed.
* This is a callback function which is triggered when unregistration confirm
* message is received. The first parameter is the message received. The second
* parameter provides updated list of aliases after the message was processed
* by the stack.
*/
typedef int (*cb_OnReceivedUnregistrationConfirm)
(H225UnregistrationConfirm *ucf, struct OOAliases *aliases);
/**
* NOTE- This functionality is not yet fully completed.
* This is a callback function which is triggered when unregistration request
* message is received. The first parameter is the message received. The second
* parameter provides the list of aliases requested to be unregistered.
*/
typedef int (*cb_OnReceivedUnregistrationRequest)
(H225UnregistrationRequest *urq, struct OOAliases *aliases);
typedef struct OOGKCLIENTCALLBACKS{
cb_OnReceivedRegistrationConfirm onReceivedRegistrationConfirm;
cb_OnReceivedUnregistrationConfirm onReceivedUnregistrationConfirm;
cb_OnReceivedUnregistrationRequest onReceivedUnregistrationRequest;
}OOGKCLIENTCALLBACKS;
/**
* Structure to store all the configuration information for the gatekeeper
* client. Gatekeeper client is responsible for all the communication with
* a gatekeeper.
*/
typedef struct ooGkClient{
ASN1BOOL discoveryComplete;
OOCTXT ctxt;
OOCTXT msgCtxt;
OOSOCKET rasSocket;
int localRASPort;
char localRASIP[20];
char gkRasIP[20];
char gkCallSignallingIP[20];
RasGatekeeperInfo gkInfo;
int gkRasPort;
int gkCallSignallingPort;
unsigned short requestSeqNum;
enum RasGatekeeperMode gkMode; /* Current Gk mode */
struct timeval registrationTime;
H225GatekeeperIdentifier gkId;
H225EndpointIdentifier endpointId;
DList callsPendingList;
DList callsAdmittedList;
DList timerList;
OOGKCLIENTCALLBACKS callbacks;
ASN1UINT grqRetries;
ASN1UINT rrqRetries;
ASN1UINT grqTimeout;
ASN1UINT rrqTimeout;
ASN1UINT regTimeout;
ASN1UINT arqTimeout;
ASN1UINT drqTimeout;
enum OOGkClientState state;
} ooGkClient;
struct OOAliases;
struct OOH323CallData;
/**
* This function is used to initialize the Gatekeeper client.If an application
* wants to use gatekeeper services, it should call this function immediately
* after initializing the H323 EndPoint.
* @param eGkMode Gatekeeper mode.
* @param szGkAddr Dotted gk ip address, if gk has to be specified.
* @param iGkPort Gk port.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*
*/
EXTERN int ooGkClientInit
(enum RasGatekeeperMode eGkMode, char *szGkAddr, int iGkPort );
/**
* This function is used to print the gatekeeper client configuration
* information to log.
* @param pGkClient Handle to gatekeeper client.
*/
EXTERN void ooGkClientPrintConfig(ooGkClient *pGkClient);
/**
* This function is used to destroy Gatekeeper client. It releases all the
* associated memory.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientDestroy(void);
/**
* This function is used to start the Gatekeeper client functionality.
* @param pGkClient Pointer to the Gatekeeper Client.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientStart(ooGkClient *pGkClient);
/**
* This function is invoked to set a gatekeeper mode.
* @param pGkClient Handle to gatekeeper client.
* @param eGkMode Gatekeeper mode selected. One of the following:
* - RasNoGatekeeper (DEFAULT), No Gatekeeper.
* - RasDiscoverGatekeeper, to discover a gatekeeper
* automatically.
* - RasUseSpecificGatekeeper, to use a specific gatekeeper.
* @param szGkAddr Gatekeeper address (only when using specific gatekeeper).
* @param iGkPort Gatekeeper RAS port
*
* @return Completion status - OO_OK on success, OO_FAILED on failure
*/
EXTERN int ooGkClientSetGkMode(ooGkClient *pGkClient,
enum RasGatekeeperMode eGkMode, char *szGkAddr,
int iGkPort );
/**
* This function is used to create a RAS channel for the gatekeeper.
* @param pGkClient Pointer to the Gatekeeper client for which RAS channel
* has to be created.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientCreateChannel(ooGkClient *pGkClient);
/**
* This function is used to close a RAS channel of the gatekeeper client.
* @param pGkClient Pointer to the gatekeeper client.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientCloseChannel(ooGkClient *pGkClient);
/**
* This function is used to fill endpoint's vendor information into vendor
* identifier.
* @param pGkClient Pointer to gatekeeper client.
* @param psVendor Pointer to vendor identifier to be filled.
*
*/
EXTERN void ooGkClientRasFillVendor
(ooGkClient *pGkClient, H225VendorIdentifier *psVendor);
/**
* This function is invoked to receive data on Gatekeeper client's RAS channel.
* @param pGkClient Handle to Gatekeeper client for which message has to be
* received.
*
* @return Completion status - OO_OK on success, OO_FAILED on
* failure
*/
EXTERN int ooGkClientReceive(ooGkClient *pGkClient);
/**
* This function is used to handle a received RAS message by a gatekeeper
* client.
* @param pGkClient Handle to gatekeeper client.
* @param pRasMsg Handle to received Ras message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientHandleRASMessage
(ooGkClient *pGkClient, H225RasMessage *pRasMsg);
/**
* This function is used to send a message on Gatekeeper clien't RAS channel.
* @param pGkClient Handle to the gatekeeper client.
* @param pRasMsg Handle to Ras message to be sent.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientSendMsg(ooGkClient *pGkClient, H225RasMessage *pRasMsg);
/**
* This function is used to send Gatekeeper request message.
* @param pGkClient Handle to gatekeeper client for which GRQ message has to
* be sent.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientSendGRQ(ooGkClient *pGkClient);
/**
* This function is used to handle a received gatekeeper reject message.
* @param pGkClient Handle to gatekeeper client.
* @param pGatekeeperReject Handle to received reject message.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleGatekeeperReject
(ooGkClient *pGkClient, H225GatekeeperReject *pGatekeeperReject);
/**
* This function is used to handle a received gatekeeper confirm message.
* @param pGkClient Handle to gatekeeper client.
* @param pGatekeeperConfirm Handle to received confirmed message.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleGatekeeperConfirm
(ooGkClient *pGkClient, H225GatekeeperConfirm *pGatekeeperConfirm);
/**
* This function is used to send Registration request message.
* @param pGkClient Handle to gatekeeper client for which RRQ message has to
* be sent.
* @param keepAlive Indicates whether keepalive lightweight registration has
* to be sent.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientSendRRQ(ooGkClient *pGkClient, ASN1BOOL keepAlive);
/**
* This function is used to handle a received registration confirm message.
* @param pGkClient Handle to gatekeeper client.
* @param pRegistrationConfirm Handle to received confirmed message.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleRegistrationConfirm
(ooGkClient *pGkClient, H225RegistrationConfirm *pRegistrationConfirm);
/**
* This function is used to handle a received registration reject message.
* @param pGkClient Handle to gatekeeper client.
* @param pRegistrationReject Handle to received reject message.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleRegistrationReject
(ooGkClient *pGkClient, H225RegistrationReject *pRegistrationReject);
/**
* This function is used to send UnRegistration request message.
* @param pGkClient Handle to gatekeeper client for which URQ message has to
* be sent.
* @param aliases List of aliases to be unregistered. NULL, if all the
* aliases have to be unregistered.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientSendURQ(ooGkClient *pGkClient, struct OOAliases *aliases);
/**
* This function is used to handle a received Unregistration request message.
* @param pGkClient Handle to gatekeeper client.
* @param punregistrationRequest Handle to received unregistration request.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleUnregistrationRequest
(ooGkClient *pGkClient, H225UnregistrationRequest *punregistrationRequest);
/**
* This function is used to send an unregistration confirm messsage to
* gatekeeper.
* @param pGkClient Handle to gatekeeper client.
* @param reqNo Request Sequence number for the confirm message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientSendUnregistrationConfirm(ooGkClient *pGkClient,
unsigned reqNo);
/**
* This function is invoked to request bandwith admission for a call.
* @param pGkClient Gatekeeper client to be used
* @param call Handle to the call.
* @param retransmit Indicates whether new call or retransmitting for
* existing call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientSendAdmissionRequest
(ooGkClient *pGkClient, struct OOH323CallData *call, ASN1BOOL retransmit);
/**
* This function is used to handle a received Admission confirm message.
* @param pGkClient Handle to gatekeeper client.
* @param pAdmissionConfirm Handle to received confirmed message.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleAdmissionConfirm
(ooGkClient *pGkClient, H225AdmissionConfirm *pAdmissionConfirm);
/**
* This function is used to handle a received Admission Reject message. It
* finds the associated call and marks it for cleaning with appropriate
* call end reason code.
* @param pGkClient Handle to Gatekeeper client.
* @param pAdmissionReject Handle to received admission reject message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientHandleAdmissionReject
(ooGkClient *pGkClient, H225AdmissionReject *pAdmissionReject);
/**
* This function is invoked to request call disengage to gatekeeper.
* @param pGkClient Gatekeeper client to be used.
* @param call Call Handle
*
* @return Completion status - OO_OK on success, OO_FAILED on failure
*/
EXTERN int ooGkClientSendDisengageRequest
(ooGkClient *pGkClient, struct OOH323CallData *call);
/**
* This function is used to handle a received disengage confirm message.
* @param pGkClient Handle to gatekeeper client.
* @param pDCF Handle to received confirmed message.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooGkClientHandleDisengageConfirm
(ooGkClient *pGkClient, H225DisengageConfirm *pDCF);
/**
* This function is used to handle an expired registration request timer.
* @param pdata Handle to callback data
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientRRQTimerExpired(void*pdata);
/**
* This function is used to handle an expired gatekeeper request timer.
* @param pdata Handle to callback data
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientGRQTimerExpired(void* pdata);
/**
* This function is used to handle an expired registration time-to-live timer.
* @param pdata Handle to callback data
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientREGTimerExpired(void *pdata);
/**
* This function is used to handle an expired admission request timer.
* @param pdata Handle to callback data
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientARQTimerExpired(void* pdata);
/**
* This function is used to clean call related data from gatekeeper client.
* @param pGkClient Handle to the gatekeeper client.
* @param call Handle to the call to be cleaned.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientCleanCall(ooGkClient *pGkClient, struct OOH323CallData *call);
/**
* This function is used to handle gatekeeper client failure or gatekeeper
* failure which can be detected by unresponsiveness of gk.
* @param pGkClient Handle to gatekeeper client.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientHandleClientOrGkFailure(ooGkClient *pGkClient);
/**
* This function is used to update the registration status of aliases.
* @param pGkClient Handle to the GK client.
* @param pAddresses List of newly registered addresses. NULL means all
* aliases have been successfully registered.
* @param registered Indicates whether aliases are registered or unregistered.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGkClientUpdateRegisteredAliases
(ooGkClient *pGkClient, H225_SeqOfH225AliasAddress *pAddresses,
OOBOOL registered);
/**
* This function is used internally to set Gatekeeper Clients callbacks.
* Note: This functionality is not yet fully supported
* @param pGkClient Handle to the GK client.
* @param callbacks Callback structure contatining various gatekeeper client
* callbacks.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooGkClientSetCallbacks
(ooGkClient *pGkClient, OOGKCLIENTCALLBACKS callbacks);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __GKCLIENT_H */

View File

@ -0,0 +1,372 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooCalls.h"
#include "ooh323ep.h"
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
OOLogicalChannel* ooAddNewLogicalChannel(OOH323CallData *call, int channelNo,
int sessionID, char *dir,
ooH323EpCapability *epCap)
{
OOLogicalChannel *pNewChannel=NULL, *pChannel=NULL;
OOMediaInfo *pMediaInfo = NULL;
OOTRACEDBGC5("Adding new media channel for cap %d dir %s (%s, %s)\n",
epCap->cap, dir, call->callType, call->callToken);
/* Create a new logical channel entry */
pNewChannel = (OOLogicalChannel*)memAlloc(call->pctxt,
sizeof(OOLogicalChannel));
if(!pNewChannel)
{
OOTRACEERR3("ERROR:Memory - ooAddNewLogicalChannel - pNewChannel "
"(%s, %s)\n", call->callType, call->callToken);
return NULL;
}
memset(pNewChannel, 0, sizeof(OOLogicalChannel));
pNewChannel->channelNo = channelNo;
pNewChannel->sessionID = sessionID;
pNewChannel->state = OO_LOGICALCHAN_IDLE;
pNewChannel->type = epCap->capType;
/* strcpy(pNewChannel->type, type);*/
strcpy(pNewChannel->dir, dir);
pNewChannel->chanCap = epCap;
OOTRACEDBGC4("Adding new channel with cap %d (%s, %s)\n", epCap->cap,
call->callType, call->callToken);
/* As per standards, media control port should be same for all
proposed channels with same session ID. However, most applications
use same media port for transmit and receive of audio streams. Infact,
testing of OpenH323 based asterisk assumed that same ports are used.
Hence we first search for existing media ports for same session and use
them. This should take care of all cases.
*/
if(call->mediaInfo)
{
pMediaInfo = call->mediaInfo;
while(pMediaInfo)
{
if(!strcmp(pMediaInfo->dir, dir) &&
(pMediaInfo->cap == epCap->cap))
{
break;
}
pMediaInfo = pMediaInfo->next;
}
}
if(pMediaInfo)
{
OOTRACEDBGC3("Using configured media info (%s, %s)\n", call->callType,
call->callToken);
pNewChannel->localRtpPort = pMediaInfo->lMediaPort;
pNewChannel->localRtcpPort = pMediaInfo->lMediaCntrlPort;
/* If user application has not specified a specific ip and is using
multihomed mode, substitute appropriate ip.
*/
if(!strcmp(pMediaInfo->lMediaIP, "0.0.0.0"))
strcpy(pNewChannel->localIP, call->localIP);
else
strcpy(pNewChannel->localIP, pMediaInfo->lMediaIP);
}
else{
OOTRACEDBGC3("Using default media info (%s, %s)\n", call->callType,
call->callToken);
pNewChannel->localRtpPort = ooGetNextPort (OORTP);
/* Ensures that RTP port is an even one */
if((pNewChannel->localRtpPort & 1) == 1)
pNewChannel->localRtpPort = ooGetNextPort (OORTP);
pNewChannel->localRtcpPort = ooGetNextPort (OORTP);
strcpy(pNewChannel->localIP, call->localIP);
}
/* Add new channel to the list */
pNewChannel->next = NULL;
if(!call->logicalChans) {
call->logicalChans = pNewChannel;
}
else{
pChannel = call->logicalChans;
while(pChannel->next) pChannel = pChannel->next;
pChannel->next = pNewChannel;
}
/* increment logical channels */
call->noOfLogicalChannels++;
OOTRACEINFO3("Created new logical channel entry (%s, %s)\n", call->callType,
call->callToken);
return pNewChannel;
}
OOLogicalChannel* ooFindLogicalChannelByLogicalChannelNo(OOH323CallData *call,
int ChannelNo)
{
OOLogicalChannel *pLogicalChannel=NULL;
if(!call->logicalChans)
{
OOTRACEERR3("ERROR: No Open LogicalChannels - Failed "
"FindLogicalChannelByChannelNo (%s, %s\n", call->callType,
call->callToken);
return NULL;
}
pLogicalChannel = call->logicalChans;
while(pLogicalChannel)
{
if(pLogicalChannel->channelNo == ChannelNo)
break;
else
pLogicalChannel = pLogicalChannel->next;
}
return pLogicalChannel;
}
OOLogicalChannel * ooFindLogicalChannelByOLC(OOH323CallData *call,
H245OpenLogicalChannel *olc)
{
H245DataType * psDataType=NULL;
H245H2250LogicalChannelParameters * pslcp=NULL;
OOTRACEDBGC4("ooFindLogicalChannel by olc %d (%s, %s)\n",
olc->forwardLogicalChannelNumber, call->callType, call->callToken);
if(olc->m.reverseLogicalChannelParametersPresent)
{
OOTRACEDBGC3("Finding receive channel (%s,%s)\n", call->callType,
call->callToken);
psDataType = &olc->reverseLogicalChannelParameters.dataType;
/* Only H2250LogicalChannelParameters are supported */
if(olc->reverseLogicalChannelParameters.multiplexParameters.t !=
T_H245OpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters){
OOTRACEERR4("Error:Invalid olc %d received (%s, %s)\n",
olc->forwardLogicalChannelNumber, call->callType, call->callToken);
return NULL;
}
pslcp = olc->reverseLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
return ooFindLogicalChannel(call, pslcp->sessionID, "receive", psDataType);
}
else{
OOTRACEDBGC3("Finding transmit channel (%s, %s)\n", call->callType,
call->callToken);
psDataType = &olc->forwardLogicalChannelParameters.dataType;
/* Only H2250LogicalChannelParameters are supported */
if(olc->forwardLogicalChannelParameters.multiplexParameters.t !=
T_H245OpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
{
OOTRACEERR4("Error:Invalid olc %d received (%s, %s)\n",
olc->forwardLogicalChannelNumber, call->callType, call->callToken);
return NULL;
}
pslcp = olc->forwardLogicalChannelParameters.multiplexParameters.u.h2250LogicalChannelParameters;
return ooFindLogicalChannel(call, pslcp->sessionID, "transmit", psDataType);
}
}
OOLogicalChannel * ooFindLogicalChannel(OOH323CallData *call, int sessionID,
char *dir, H245DataType * dataType)
{
OOLogicalChannel * pChannel = NULL;
pChannel = call->logicalChans;
while(pChannel)
{
OOTRACEDBGC3("ooFindLogicalChannel, checking channel: %d:%s\n",
pChannel->sessionID, pChannel->dir);
if(pChannel->sessionID == sessionID)
{
if(!strcmp(pChannel->dir, dir))
{
OOTRACEDBGC3("ooFindLogicalChannel, comparing channel: %d:%s\n",
pChannel->channelNo, pChannel->dir);
if(!strcmp(dir, "receive"))
{
if(ooCapabilityCheckCompatibility(call, pChannel->chanCap,
dataType, OORX)) {
return pChannel;
}
}
else if(!strcmp(dir, "transmit"))
{
if(ooCapabilityCheckCompatibility(call, pChannel->chanCap,
dataType, OOTX)) {
return pChannel;
}
}
}
}
pChannel = pChannel->next;
}
return NULL;
}
/* This function is used to get a logical channel with a particular session ID */
OOLogicalChannel* ooGetLogicalChannel
(OOH323CallData *call, int sessionID, char *dir)
{
OOLogicalChannel * pChannel = NULL;
pChannel = call->logicalChans;
while(pChannel)
{
if(pChannel->sessionID == sessionID && !strcmp(pChannel->dir, dir))
return pChannel;
else
pChannel = pChannel->next;
}
return NULL;
}
int ooClearAllLogicalChannels(OOH323CallData *call)
{
OOLogicalChannel * temp = NULL, *prev = NULL;
OOTRACEINFO3("Clearing all logical channels (%s, %s)\n", call->callType,
call->callToken);
temp = call->logicalChans;
while(temp)
{
prev = temp;
temp = temp->next;
ooClearLogicalChannel(call, prev->channelNo);/* TODO: efficiency - This causes re-search
of of logical channel in the list. Can be
easily improved.*/
}
call->logicalChans = NULL;
return OO_OK;
}
int ooClearLogicalChannel(OOH323CallData *call, int channelNo)
{
OOLogicalChannel *pLogicalChannel = NULL;
ooH323EpCapability *epCap=NULL;
OOTRACEDBGC4("Clearing logical channel number %d. (%s, %s)\n", channelNo,
call->callType, call->callToken);
pLogicalChannel = ooFindLogicalChannelByLogicalChannelNo(call,channelNo);
if(!pLogicalChannel)
{
OOTRACEWARN4("Logical Channel %d doesn't exist, in clearLogicalChannel."
" (%s, %s)\n",
channelNo, call->callType, call->callToken);
return OO_OK;
}
epCap = (ooH323EpCapability*) pLogicalChannel->chanCap;
if(!strcmp(pLogicalChannel->dir, "receive"))
{
if(epCap->stopReceiveChannel)
{
epCap->stopReceiveChannel(call, pLogicalChannel);
OOTRACEINFO4("Stopped Receive channel %d (%s, %s)\n",
channelNo, call->callType, call->callToken);
}
else{
OOTRACEERR4("ERROR:No callback registered for stopReceiveChannel %d "
"(%s, %s)\n", channelNo, call->callType, call->callToken);
}
}
else
{
if(pLogicalChannel->state == OO_LOGICALCHAN_ESTABLISHED)
{
if(epCap->stopTransmitChannel)
{
epCap->stopTransmitChannel(call, pLogicalChannel);
OOTRACEINFO4("Stopped Transmit channel %d (%s, %s)\n",
channelNo, call->callType, call->callToken);
}
else{
OOTRACEERR4("ERROR:No callback registered for stopTransmitChannel"
" %d (%s, %s)\n", channelNo, call->callType,
call->callToken);
}
}
}
ooRemoveLogicalChannel(call, channelNo);/* TODO: efficiency - This causes re-search of
of logical channel in the list. Can be
easily improved.*/
return OO_OK;
}
int ooRemoveLogicalChannel(OOH323CallData *call, int ChannelNo)
{
OOLogicalChannel * temp = NULL, *prev=NULL;
if(!call->logicalChans)
{
OOTRACEERR4("ERROR:Remove Logical Channel - Channel %d not found "
"Empty channel List(%s, %s)\n", ChannelNo, call->callType,
call->callToken);
return OO_FAILED;
}
temp = call->logicalChans;
while(temp)
{
if(temp->channelNo == ChannelNo)
{
if(!prev) call->logicalChans = temp->next;
else prev->next = temp->next;
memFreePtr(call->pctxt, temp->chanCap);
memFreePtr(call->pctxt, temp);
OOTRACEDBGC4("Removed logical channel %d (%s, %s)\n", ChannelNo,
call->callType, call->callToken);
call->noOfLogicalChannels--;
return OO_OK;
}
prev = temp;
temp = temp->next;
}
OOTRACEERR4("ERROR:Remove Logical Channel - Channel %d not found "
"(%s, %s)\n", ChannelNo, call->callType, call->callToken);
return OO_FAILED;
}
/*
Change the state of the channel as established and close all other
channels with same session IDs. This is useful for handling fastStart,
as the endpoint can open multiple logical channels for same sessionID.
Once the remote endpoint confirms it's selection, all other channels for
the same sessionID must be closed.
*/
int ooOnLogicalChannelEstablished
(OOH323CallData *call, OOLogicalChannel * pChannel)
{
OOLogicalChannel * temp = NULL, *prev=NULL;
OOTRACEDBGC3("In ooOnLogicalChannelEstablished (%s, %s)\n",
call->callType, call->callToken);
pChannel->state = OO_LOGICALCHAN_ESTABLISHED;
temp = call->logicalChans;
while(temp)
{
if(temp->channelNo != pChannel->channelNo &&
temp->sessionID == pChannel->sessionID &&
!strcmp(temp->dir, pChannel->dir) )
{
prev = temp;
temp = temp->next;
ooClearLogicalChannel(call, prev->channelNo);
}
else
temp = temp->next;
}
return OO_OK;
}

View File

@ -0,0 +1,190 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooLogChan.h
* This file contains structures and functions for maintaining information
* on logical channels within the stack.
*/
#ifndef _OOLOGCHAN_H_
#define _OOLOGCHAN_H_
#include "ootypes.h"
#include "ooCapability.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup logchan H.245 logical channel management
* @{
*/
struct ooH323EpCapability;
struct OOH323CallData;
/**
* Logical channel states.
*/
typedef enum {
OO_LOGICAL_CHAN_UNKNOWN,
OO_LOGICALCHAN_IDLE,
OO_LOGICALCHAN_PROPOSED,
OO_LOGICALCHAN_ESTABLISHED
} OOLogicalChannelState;
/**
* Structure to store information on logical channels for a call.
*/
typedef struct OOLogicalChannel {
int channelNo;
int sessionID;
enum OOCapType type;
char dir[10]; /* receive/transmit */
char remoteIP[20];
int remoteMediaPort;
int remoteMediaControlPort;
int localRtpPort;
int localRtcpPort;
char localIP[20];
OOLogicalChannelState state;
struct ooH323EpCapability *chanCap;
struct OOLogicalChannel *next;
} OOLogicalChannel;
#define ooLogicalChannel OOLogicalChannel
/**
* This function is used to add a new logical channel entry into the list
* of currently active logical channels.
* @param call Pointer to the call for which new logical channel
* entry has to be created.
* @param channelNo Channel number for the new channel entry.
* @param sessionID Session identifier for the new channel.
* @param dir Direction of the channel(transmit/receive)
* @param epCap Capability to be used for the new channel.
*
* @return Pointer to logical channel, on success. NULL, on failure
*/
EXTERN ooLogicalChannel* ooAddNewLogicalChannel
(struct OOH323CallData *call, int channelNo, int sessionID,
char *dir, ooH323EpCapability *epCap);
/**
* This function is used to find a logical channel using the logical
* channel number as a key.
* @param call Pointer to the call for which logical channel is
* required.
* @param channelNo Forward Logical Channel number for the logical channel
*
* @return Pointer to the logical channel if found, NULL
* otherwise.
*/
EXTERN ooLogicalChannel* ooFindLogicalChannelByLogicalChannelNo
(struct OOH323CallData *call, int channelNo);
/**
* This function is called when a new logical channel is established. It is
* particularly useful in case of faststart. When the remote endpoint selects
* one of the proposed alternatives, other channels for the same session type
* need to be closed. This function is used for that.
*
* @param call Handle to the call which owns the logical channel.
* @param pChannel Handle to the newly established logical channel.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnLogicalChannelEstablished
(struct OOH323CallData *call, OOLogicalChannel * pChannel);
/**
* This function is used to retrieve a logical channel with a particular
* sessionID. Note that there can be two entries of logical channel, one in
* each direction. This function will return the first channel which has the
* same session ID.
* @param call Handle to the call which owns the channels to be searched.
* @param sessionID Session id of the session which is to be searched for.
* @param dir Direction of the channel.(transmit/receive)
*
* @return Returns a pointer to the logical channel if found, NULL
* otherwise.
*/
EXTERN ooLogicalChannel* ooGetLogicalChannel
(struct OOH323CallData *call, int sessionID, char *dir);
/**
* This function is used to remove a logical channel from the list of
* channels within the call structure.
* @param call Pointer to the call from which logical channel has
* to be removed.
* @param ChannelNo Forward logical channel number of the channel to be
* removed.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooRemoveLogicalChannel (struct OOH323CallData *call, int ChannelNo);
/**
* This function is used to cleanup a logical channel. It first stops media if
* it is still active and then removes the channel from the list, freeing up
* all the associated memory.
* @param call Handle to the call which owns the logical channel.
* @param channelNo Channel number identifying the channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooClearLogicalChannel (struct OOH323CallData *call, int channelNo);
/**
* This function is used to cleanup all the logical channels associated with
* the call.
* @param call Handle to the call which owns the channels.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooClearAllLogicalChannels (struct OOH323CallData *call);
/**
* This function is used to find a logical channel from a received
* H.245 Open Logical Channel (OLC) message.
* @param call Handle to the related call.
* @param olc Handle to the received OLC.
*
* @return Returns the corresponding logical channel if found,
* else returns NULL.
*/
EXTERN OOLogicalChannel * ooFindLogicalChannelByOLC
(struct OOH323CallData *call, H245OpenLogicalChannel *olc);
/**
* This function is used to find a logical channel based on session Id,
* direction of channel and datatype.
* @param call Handle to the call
* @param sessionID Session ID for the channel to be searched.
* @param dir Direction of the channel wrt local endpoint.
* (transmit/receive)
* @param dataType Handle to the data type for the channel.
*
* @return Logical channel, if found, NULL otherwise.
*/
EXTERN OOLogicalChannel * ooFindLogicalChannel
(struct OOH323CallData* call, int sessionID, char *dir, H245DataType* dataType);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,723 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooSocket.h"
#include "ootrace.h"
#if defined(_WIN32_WCE)
static int inited = 0;
#define SEND_FLAGS 0
#define SHUTDOWN_FLAGS 0
#elif defined (_WIN32)
static LPFN_SEND send;
static LPFN_SOCKET socket;
static LPFN_SETSOCKOPT setsockopt;
static LPFN_BIND bind;
static LPFN_HTONL htonl;
static LPFN_HTONS htons;
static LPFN_CONNECT connect;
static LPFN_INET_ADDR inet_addr;
static LPFN_LISTEN listen;
static LPFN_ACCEPT accept;
static LPFN_NTOHL ntohl;
static LPFN_NTOHS ntohs;
static LPFN_RECV recv;
static LPFN_SHUTDOWN shutdown;
static LPFN_IOCTLSOCKET ioctlsocket;
static LPFN_SENDTO sendto;
static LPFN_INET_NTOA inet_ntoa;
static LPFN_RECVFROM recvfrom;
static LPFN_SELECT select;
static LPFN_GETHOSTNAME gethostname;
static LPFN_GETHOSTBYNAME gethostbyname;
static LPFN_WSAGETLASTERROR WSAGetLastError;
static LPFN_WSACLEANUP WSACleanup;
static LPFN_CLOSESOCKET closesocket;
static LPFN_GETSOCKNAME getsockname;
static HMODULE ws32 = 0;
#define SEND_FLAGS 0
#define SHUTDOWN_FLAGS SD_BOTH
#else
#define SEND_FLAGS 0
#define SHUTDOWN_FLAGS SHUT_RDWR
#define closesocket close
#endif
int ooSocketsInit ()
{
#if defined(_WIN32_WCE)
WORD wVersionRequested;
WSADATA wsaData;
int err;
if (inited) return ASN_OK;
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup (wVersionRequested, &wsaData);
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return ASN_E_NOTINIT;
}
inited = 1;
#elif defined (_WIN32)
LPFN_WSASTARTUP wsaStartup = NULL;
WSADATA wsaData;
if (ws32 != 0) return ASN_OK;
// ws32 = LoadLibrary ("WSOCK32.DLL");
ws32 = LoadLibrary ("WS2_32.DLL");
if (ws32 == NULL) return ASN_E_NOTINIT;
wsaStartup = (LPFN_WSASTARTUP) GetProcAddress (ws32, "WSAStartup");
if (wsaStartup == NULL) return ASN_E_NOTINIT;
send = (LPFN_SEND) GetProcAddress (ws32, "send");
if (send == NULL) return ASN_E_NOTINIT;
socket = (LPFN_SOCKET) GetProcAddress (ws32, "socket");
if (socket == NULL) return ASN_E_NOTINIT;
setsockopt = (LPFN_SETSOCKOPT) GetProcAddress (ws32, "setsockopt");
if (setsockopt == NULL) return ASN_E_NOTINIT;
bind = (LPFN_BIND) GetProcAddress (ws32, "bind");
if (bind == NULL) return ASN_E_NOTINIT;
htonl = (LPFN_HTONL) GetProcAddress (ws32, "htonl");
if (htonl == NULL) return ASN_E_NOTINIT;
htons = (LPFN_HTONS) GetProcAddress (ws32, "htons");
if (htons == NULL) return ASN_E_NOTINIT;
connect = (LPFN_CONNECT) GetProcAddress (ws32, "connect");
if (connect == NULL) return ASN_E_NOTINIT;
listen = (LPFN_LISTEN) GetProcAddress (ws32, "listen");
if (listen == NULL) return ASN_E_NOTINIT;
accept = (LPFN_ACCEPT) GetProcAddress (ws32, "accept");
if (accept == NULL) return ASN_E_NOTINIT;
inet_addr = (LPFN_INET_ADDR) GetProcAddress (ws32, "inet_addr");
if (inet_addr == NULL) return ASN_E_NOTINIT;
ntohl = (LPFN_NTOHL) GetProcAddress (ws32, "ntohl");
if (ntohl == NULL) return ASN_E_NOTINIT;
ntohs = (LPFN_NTOHS) GetProcAddress (ws32, "ntohs");
if (ntohs == NULL) return ASN_E_NOTINIT;
recv = (LPFN_RECV) GetProcAddress (ws32, "recv");
if (recv == NULL) return ASN_E_NOTINIT;
shutdown = (LPFN_SHUTDOWN) GetProcAddress (ws32, "shutdown");
if (shutdown == NULL) return ASN_E_NOTINIT;
closesocket = (LPFN_CLOSESOCKET) GetProcAddress (ws32, "closesocket");
if (closesocket == NULL) return ASN_E_NOTINIT;
getsockname = (LPFN_GETSOCKNAME) GetProcAddress (ws32, "getsockname");
if (getsockname == NULL) return ASN_E_NOTINIT;
ioctlsocket = (LPFN_IOCTLSOCKET) GetProcAddress(ws32, "ioctlsocket");
if(ioctlsocket == NULL) return ASN_E_NOTINIT;
sendto = (LPFN_SENDTO) GetProcAddress (ws32, "sendto");
if (sendto == NULL) return ASN_E_NOTINIT;
inet_ntoa = (LPFN_INET_NTOA) GetProcAddress (ws32, "inet_ntoa");
if (inet_ntoa == NULL) return ASN_E_NOTINIT;
recvfrom = (LPFN_RECVFROM) GetProcAddress (ws32, "recvfrom");
if (recvfrom == NULL) return ASN_E_NOTINIT;
select = (LPFN_SELECT) GetProcAddress (ws32, "select");
if (select == NULL) return ASN_E_NOTINIT;
gethostname = (LPFN_GETHOSTNAME) GetProcAddress (ws32, "gethostname");
if (gethostname == NULL) return ASN_E_NOTINIT;
gethostbyname = (LPFN_GETHOSTBYNAME) GetProcAddress (ws32, "gethostbyname");
if (gethostbyname == NULL) return ASN_E_NOTINIT;
WSAGetLastError = (LPFN_WSAGETLASTERROR) GetProcAddress (ws32,
"WSAGetLastError");
if (WSAGetLastError == NULL) return ASN_E_NOTINIT;
WSACleanup = (LPFN_WSACLEANUP) GetProcAddress (ws32, "WSACleanup");
if (WSACleanup == NULL) return ASN_E_NOTINIT;
if (wsaStartup (MAKEWORD(1, 1), &wsaData) == -1) return ASN_E_NOTINIT;
#endif
return ASN_OK;
}
#if defined (_WIN32) || \
defined(_HP_UX) || defined(__hpux) || defined(_HPUX_SOURCE)
typedef int OOSOCKLEN;
#else
typedef size_t OOSOCKLEN;
#endif
int ooSocketCreate (OOSOCKET* psocket)
{
int on;
struct linger linger;
OOSOCKET sock = socket (AF_INET,
SOCK_STREAM,
0);
if (sock == OOSOCKET_INVALID){
OOTRACEERR1("Error:Failed to create TCP socket\n");
return ASN_E_INVSOCKET;
}
on = 1;
if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(const char* ) &on, sizeof (on)) == -1)
{
OOTRACEERR1("Error:Failed to set socket option SO_REUSEADDR\n");
return ASN_E_INVSOCKET;
}
linger.l_onoff = 1;
linger.l_linger = 0;
if (setsockopt (sock, SOL_SOCKET, SO_LINGER,
(const char* ) &linger, sizeof (linger)) == -1)
{
OOTRACEERR1("Error:Failed to set socket option linger\n");
return ASN_E_INVSOCKET;
}
*psocket = sock;
return ASN_OK;
}
int ooSocketCreateUDP (OOSOCKET* psocket)
{
int on;
struct linger linger;
OOSOCKET sock = socket (AF_INET,
SOCK_DGRAM,
0);
if (sock == OOSOCKET_INVALID){
OOTRACEERR1("Error:Failed to create UDP socket\n");
return ASN_E_INVSOCKET;
}
on = 1;
if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(const char* ) &on, sizeof (on)) == -1)
{
OOTRACEERR1("Error:Failed to set socket option SO_REUSEADDR\n");
return ASN_E_INVSOCKET;
}
linger.l_onoff = 1;
linger.l_linger = 0;
/*if (setsockopt (sock, SOL_SOCKET, SO_LINGER,
(const char* ) &linger, sizeof (linger)) == -1)
return ASN_E_INVSOCKET;
*/
*psocket = sock;
return ASN_OK;
}
int ooSocketClose (OOSOCKET socket)
{
shutdown (socket, SHUTDOWN_FLAGS);
if (closesocket (socket) == -1)
return ASN_E_INVSOCKET;
return ASN_OK;
}
int ooSocketBind (OOSOCKET socket, OOIPADDR addr, int port)
{
struct sockaddr_in m_addr;
if (socket == OOSOCKET_INVALID)
{
OOTRACEERR1("Error:Invalid socket passed to bind\n");
return ASN_E_INVSOCKET;
}
memset (&m_addr, 0, sizeof (m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_addr.s_addr = (addr == 0) ? INADDR_ANY : htonl (addr);
m_addr.sin_port = htons ((unsigned short)port);
if (bind (socket, (struct sockaddr *) (void*) &m_addr,
sizeof (m_addr)) == -1)
{
perror ("bind");
OOTRACEERR1("Error:Bind failed\n");
return ASN_E_INVSOCKET;
}
return ASN_OK;
}
int ooSocketGetSockName(OOSOCKET socket, struct sockaddr_in *name, int *size)
{
int ret;
ret = getsockname(socket, (struct sockaddr*)name, size);
if(ret == 0)
return ASN_OK;
else{
OOTRACEERR1("Error:ooSocketGetSockName - getsockname\n");
return ASN_E_INVSOCKET;
}
}
int ooSocketGetIpAndPort(OOSOCKET socket, char *ip, int len, int *port)
{
int ret=ASN_OK, size;
struct sockaddr_in addr;
char *host=NULL;
size = sizeof(addr);
ret = ooSocketGetSockName(socket, &addr, &size);
if(ret != 0)
return ASN_E_INVSOCKET;
host = inet_ntoa(addr.sin_addr);
if(host && strlen(host) < (unsigned)len)
strcpy(ip, host);
else{
OOTRACEERR1("Error:Insufficient buffer for ip address - "
"ooSocketGetIpAndPort\n");
return -1;
}
*port = addr.sin_port;
return ASN_OK;
}
int ooSocketListen (OOSOCKET socket, int maxConnection)
{
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
if (listen (socket, maxConnection) == -1)
return ASN_E_INVSOCKET;
return ASN_OK;
}
int ooSocketAccept (OOSOCKET socket, OOSOCKET *pNewSocket,
OOIPADDR* destAddr, int* destPort)
{
struct sockaddr_in m_addr;
OOSOCKLEN addr_length = sizeof (m_addr);
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
if (pNewSocket == 0) return ASN_E_INVPARAM;
*pNewSocket = accept (socket, (struct sockaddr *) (void*) &m_addr,
(socklen_t *) &addr_length);
if (*pNewSocket <= 0) return ASN_E_INVSOCKET;
if (destAddr != 0)
*destAddr = ntohl (m_addr.sin_addr.s_addr);
if (destPort != 0)
*destPort = ntohs (m_addr.sin_port);
return ASN_OK;
}
int ooSocketConnect (OOSOCKET socket, const char* host, int port)
{
struct sockaddr_in m_addr;
if (socket == OOSOCKET_INVALID)
{
return ASN_E_INVSOCKET;
}
memset (&m_addr, 0, sizeof (m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons ((unsigned short)port);
m_addr.sin_addr.s_addr = inet_addr (host);
if (connect (socket, (struct sockaddr *) (void*) &m_addr,
sizeof (struct sockaddr_in)) == -1)
{
return ASN_E_INVSOCKET;
}
return ASN_OK;
}
/*
// **Need to add check whether complete data was sent by checking the return
// **value of send and if complete data is not sent then add mechanism to
// **send remaining bytes. This will make ooSocketSend call atomic.
*/
int ooSocketSend (OOSOCKET socket, const ASN1OCTET* pdata, ASN1UINT size)
{
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
if (send (socket, (const char*) pdata, size, SEND_FLAGS) == -1)
return ASN_E_INVSOCKET;
return ASN_OK;
}
int ooSocketSendTo(OOSOCKET socket, const ASN1OCTET* pdata, ASN1UINT size,
const char* host, int port)
{
struct sockaddr_in m_addr;
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
memset (&m_addr, 0, sizeof (m_addr));
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons ((unsigned short)port);
m_addr.sin_addr.s_addr = inet_addr (host);
if (sendto (socket, (const char*) pdata, size, SEND_FLAGS,
(const struct sockaddr*)&m_addr,
sizeof(m_addr)) == -1)
return ASN_E_INVSOCKET;
return ASN_OK;
}
int ooSocketRecvPeek(OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize)
{
int len;
int flags = MSG_PEEK;
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
if ((len = recv (socket, (char*) pbuf, bufsize, flags)) == -1)
return ASN_E_INVSOCKET;
return len;
}
int ooSocketRecv (OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize)
{
int len;
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
if ((len = recv (socket, (char*) pbuf, bufsize, 0)) == -1)
return ASN_E_INVSOCKET;
return len;
}
int ooSocketRecvFrom (OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize,
char* remotehost, ASN1UINT hostBufLen, int * remoteport)
{
struct sockaddr_in m_addr;
int len, addrlen;
char * host=NULL;
if (socket == OOSOCKET_INVALID) return ASN_E_INVSOCKET;
addrlen = sizeof(m_addr);
memset (&m_addr, 0, sizeof (m_addr));
if ((len = recvfrom (socket, (char*) pbuf, bufsize, 0,
(struct sockaddr*)&m_addr, &addrlen)) == -1)
return ASN_E_INVSOCKET;
if(remoteport)
*remoteport = ntohs(m_addr.sin_port);
if(remotehost)
{
host = inet_ntoa(m_addr.sin_addr);
if(strlen(host) < (hostBufLen-1))
strcpy(remotehost, host);
else
return -1;
}
return len;
}
int ooSocketSelect(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval * timeout)
{
int ret;
#if defined (_WIN32)
ret = select(nfds, readfds, writefds, exceptfds,
(const struct timeval *) timeout);
#else
ret = select(nfds, readfds, writefds, exceptfds, timeout);
#endif
return ret;
}
int ooGetLocalIPAddress(char * pIPAddrs)
{
int ret;
struct hostent *phost;
struct in_addr addr;
char hostname[100];
if(pIPAddrs == NULL)
return -1; /* Need to find suitable return value */
ret = gethostname(hostname, 100);
if(ret == 0)
{
phost = gethostbyname(hostname);
if(phost == NULL)
return -1; /* Need to define a return value if made part of rtsrc */
memcpy(&addr, phost->h_addr_list[0], sizeof(struct in_addr));
strcpy(pIPAddrs, inet_ntoa(addr));
}
else{
return -1;
}
return ASN_OK;
}
int ooSocketStrToAddr (const char* pIPAddrStr, OOIPADDR* pIPAddr)
{
int b1, b2, b3, b4;
int rv = sscanf (pIPAddrStr, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
if (rv != 4 ||
(b1 < 0 || b1 > 256) || (b2 < 0 || b2 > 256) ||
(b3 < 0 || b3 > 256) || (b4 < 0 || b4 > 256))
return ASN_E_INVPARAM;
*pIPAddr = ((b1 & 0xFF) << 24) | ((b2 & 0xFF) << 16) |
((b3 & 0xFF) << 8) | (b4 & 0xFF);
return ASN_OK;
}
int ooSocketConvertIpToNwAddr(char *inetIp, char *netIp)
{
struct sockaddr_in sin = {0};
#ifdef _WIN32
sin.sin_addr.s_addr = inet_addr(inetIp);
if(sin.sin_addr.s_addr == INADDR_NONE)
{
OOTRACEERR1("Error:Failed to convert address\n");
return -1;
}
#else
if(!inet_aton(inetIp, &sin.sin_addr))
{
OOTRACEERR1("Error:Failed to convert address\n");
return -1;
}
#endif
memcpy(netIp, (char*)&sin.sin_addr.s_addr, sizeof(unsigned long));
return ASN_OK;
}
int ooSocketAddrToStr (OOIPADDR ipAddr, char* pbuf, int bufsize)
{
char buf1[5], buf2[5], buf3[5], buf4[5];
int cnt = 0;
if (bufsize < 8)
return ASN_E_BUFOVFLW;
cnt += sprintf (buf1, "%lu", (ipAddr >> 24) & 0xFF);
cnt += sprintf (buf2, "%lu", (ipAddr >> 16) & 0xFF);
cnt += sprintf (buf3, "%lu", (ipAddr >> 8) & 0xFF);
cnt += sprintf (buf4, "%lu", ipAddr & 0xFF);
if (bufsize < cnt + 4)
return ASN_E_BUFOVFLW;
sprintf (pbuf, "%s.%s.%s.%s", buf1, buf2, buf3, buf4);
return ASN_OK;
}
int ooSocketsCleanup (void)
{
#ifdef _WIN32
int ret = WSACleanup();
if(ret == 0)
return ASN_OK;
else
return ret;
#endif
return ASN_OK;
}
long ooSocketHTONL(long val)
{
return htonl(val);
}
short ooSocketHTONS(short val)
{
return htons(val);
}
#ifndef _WIN32
int ooSocketGetInterfaceList(OOCTXT *pctxt, OOInterface **ifList)
{
OOSOCKET sock;
struct ifconf ifc;
int ifNum;
OOInterface *pIf=NULL;
OOTRACEDBGA1("Retrieving local interfaces\n");
if(ooSocketCreateUDP(&sock)!= ASN_OK)
{
OOTRACEERR1("Error:Failed to create udp socket - "
"ooSocketGetInterfaceList\n");
return -1;
}
#ifdef SIOCGIFNUM
if(ioctl(sock, SIOCGIFNUM, &ifNum) >= 0)
{
OOTRACEERR1("Error: ioctl for ifNum failed\n");
return -1;
}
#else
ifNum = 50;
#endif
ifc.ifc_len = ifNum * sizeof(struct ifreq);
ifc.ifc_req = (struct ifreq *)memAlloc(pctxt, ifNum *sizeof(struct ifreq));
if(!ifc.ifc_req)
{
OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - ifc.ifc_req\n");
return -1;
}
if (ioctl(sock, SIOCGIFCONF, &ifc) >= 0) {
void * ifEndList = (char *)ifc.ifc_req + ifc.ifc_len;
struct ifreq *ifName;
struct ifreq ifReq;
int flags;
for (ifName = ifc.ifc_req; (void*)ifName < ifEndList; ifName++) {
char *pName=NULL;
char addr[50];
#ifdef ifr_netmask
char mask[50];
#endif
pIf = (struct OOInterface*)memAlloc(pctxt, sizeof(struct OOInterface));
pName = (char*)memAlloc(pctxt, strlen(ifName->ifr_name)+1);
if(!pIf)
{
OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - "
"pIf/pName\n");
return -1;
}
OOTRACEDBGA2("\tInterface name: %s\n", ifName->ifr_name);
strcpy(ifReq.ifr_name, ifName->ifr_name);
strcpy(pName, ifName->ifr_name);
pIf->name = pName;
/* Check whether the interface is up*/
if (ioctl(sock, SIOCGIFFLAGS, &ifReq) < 0) {
OOTRACEERR2("Error:Unable to determine status of interface %s\n",
pName);
memFreePtr(pctxt, pIf->name);
memFreePtr(pctxt, pIf);
continue;
}
flags = ifReq.ifr_flags;
if (!(flags & IFF_UP)) {
OOTRACEWARN2("Warn:Interface %s is not up\n", pName);
memFreePtr(pctxt, pIf->name);
memFreePtr(pctxt, pIf);
continue;
}
/* Retrieve interface address */
if (ioctl(sock, SIOCGIFADDR, &ifReq) < 0)
{
OOTRACEWARN2("Warn:Unable to determine address of interface %s\n",
pName);
memFreePtr(pctxt, pIf->name);
memFreePtr(pctxt, pIf);
continue;
}
strcpy(addr, inet_ntoa(((struct sockaddr_in*)&ifReq.ifr_addr)->sin_addr));
OOTRACEDBGA2("\tIP address is %s\n", addr);
pIf->addr = (char*)memAlloc(pctxt, strlen(addr)+1);
if(!pIf->addr)
{
OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - "
"pIf->addr\n");
memFreePtr(pctxt, pIf->name);
memFreePtr(pctxt, pIf);
return -1;
}
strcpy(pIf->addr, addr);
#ifdef ifr_netmask
if (ioctl(sock, SIOCGIFNETMASK, &ifReq) < 0)
{
OOTRACEWARN2("Warn:Unable to determine mask for interface %s\n",
pName);
memFreePtr(pctxt, pIf->name);
memFreePtr(pctxt, pIf->addr);
memFreePtr(pctxt, pIf);
continue;
}
strcpy(mask, inet_ntoa(((struct sockaddr_in *)&ifReq.ifr_netmask)->sin_addr));
OOTRACEDBGA2("\tMask is %s\n", mask);
pIf->mask = (char*)memAlloc(pctxt, strlen(mask)+1);
if(!pIf->mask)
{
OOTRACEERR1("Error:Memory - ooSocketGetInterfaceList - "
"pIf->mask\n");
memFreePtr(pctxt, pIf->name);
memFreePtr(pctxt, pIf->addr);
memFreePtr(pctxt, pIf);
return -1;
}
strcpy(pIf->mask, mask);
#endif
pIf->next = NULL;
/* Add to the list */
if(!*ifList)
{
*ifList = pIf;
pIf = NULL;
}
else{
pIf->next = *ifList;
*ifList = pIf;
pIf=NULL;
}
/*
#if defined(OO_FREEBSD) || defined(OO_OPENBSD) || defined(OO_NETBSD) || defined(OO_MACOSX) || defined(OO_VXWORKS) || defined(OO_RTEMS) || defined(OO_QNX)
#ifndef _SIZEOF_ADDR_IFREQ
#define _SIZEOF_ADDR_IFREQ(ifr) \
((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
(sizeof(struct ifreq) - sizeof(struct sockaddr) + \
(ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
#endif
ifName = (struct ifreq *)((char *)ifName + _SIZEOF_ADDR_IFREQ(*ifName));
#else
ifName++;
*/
}
}
return ASN_OK;
}
#endif

View File

@ -0,0 +1,403 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooSocket.h
* Common runtime constants, data structure definitions, and run-time functions
* to support the sockets' operations.
*/
#ifndef _OOSOCKET_H_
#define _OOSOCKET_H_
#ifdef _WIN32_WCE
#include <winsock.h>
#elif defined(_WIN32) || defined(_WIN64)
#include <sys/types.h>
#define INCL_WINSOCK_API_TYPEDEFS 1
#define INCL_WINSOCK_API_PROTOTYPES 0
#include <winsock2.h>
#else
#include <sys/types.h>
#include "sys/time.h"
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <net/if.h>
#endif
#include "ooasn1.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#elif defined (USEASN1DLL)
#define EXTERN __declspec(dllimport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* @defgroup sockets Socket Layer
* @{
*/
#if defined (_WIN64)
typedef unsigned __int64 OOSOCKET; /**< Socket's handle */
#elif defined (_WIN32)
typedef unsigned int OOSOCKET; /**< Socket's handle */
#else
typedef int OOSOCKET; /**< Socket's handle */
#endif
#define OOSOCKET_INVALID ((OOSOCKET)-1)
/**
* The IP address represented as unsigned long value. The most significant 8
* bits in this unsigned long value represent the first number of the IP
* address. The least significant 8 bits represent the last number of the IP
* address.
*/
typedef unsigned long OOIPADDR;
#define OOIPADDR_ANY ((OOIPADDR)0)
#define OOIPADDR_LOCAL ((OOIPADDR)0x7f000001UL) /* 127.0.0.1 */
typedef struct OOInterface{
char *name;
char *addr;
char *mask;
struct OOInterface *next;
}OOInterface;
/**
* This function permits an incoming connection attempt on a socket. It
* extracts the first connection on the queue of pending connections on socket.
* It then creates a new socket and returns a handle to the new socket. The
* newly created socket is the socket that will handle the actual connection
* and has the same properties as original socket. See description of 'accept'
* socket function for further details.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* function.
* @param pNewSocket The pointer to variable to receive the new socket's
* handle.
* @param destAddr Optional pointer to a buffer that receives the IP
* address of the connecting entity. It may be NULL.
* @param destPort Optional pointer to a buffer that receives the port of
* the connecting entity. It may be NULL.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketAccept (OOSOCKET socket, OOSOCKET *pNewSocket,
OOIPADDR* destAddr, int* destPort);
/**
* This function converts an IP address to its string representation.
*
* @param ipAddr The IP address to be converted.
* @param pbuf Pointer to the buffer to receive a string with the IP
* address.
* @param bufsize Size of the buffer.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketAddrToStr (OOIPADDR ipAddr, char* pbuf, int bufsize);
/**
* This function associates a local address with a socket. It is used on an
* unconnected socket before subsequent calls to the ::rtSocketConnect or
* ::rtSocketListen functions. See description of 'bind' socket function for
* further details.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* function.
* @param addr The local IP address to assign to the socket.
* @param port The local port number to assign to the socket.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketBind (OOSOCKET socket, OOIPADDR addr, int port);
/**
* This function closes an existing socket.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* or ::rtSocketAccept function.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketClose (OOSOCKET socket);
/**
* This function establishes a connection to a specified socket. It is used to
* create a connection to the specified destination. When the socket call
* completes successfully, the socket is ready to send and receive data. See
* description of 'connect' socket function for further details.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* function.
* @param host The null-terminated string with the IP address in the
* following format: "NNN.NNN.NNN.NNN", where NNN is a
* number in the range (0..255).
* @param port The destination port to connect.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketConnect (OOSOCKET socket, const char* host, int port);
/**
* This function creates a socket. The only streaming TCP/IP sockets are
* supported at the moment.
*
* @param psocket The pointer to the socket's handle variable to receive
* the handle of new socket.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketCreate (OOSOCKET* psocket);
/**
* This function creates a UDP datagram socket.
*
* @param psocket The pointer to the socket's handle variable to receive
* the handle of new socket.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketCreateUDP (OOSOCKET* psocket);
/**
* This function initiates use of sockets by an application. This function must
* be called first before use sockets.
*
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketsInit (void);
/**
* This function terminates use of sockets by an application. This function
* must be called after done with sockets.
*
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketsCleanup (void);
/**
* This function places a socket a state where it is listening for an incoming
* connection. To accept connections, a socket is first created with the
* ::rtSocketCreate function and bound to a local address with the
* ::rtSocketBind function, a maxConnection for incoming connections is
* specified with ::rtSocketListen, and then the connections are accepted with
* the ::rtSocketAccept function. See description of 'listen' socket function
* for further details.
*
* @param socket The socket's handle created by call to
* ::rtSocketCreate function.
* @param maxConnection Maximum length of the queue of pending connections.
* @return Completion status of operation: 0 (ASN_OK) =
* success, negative return value is error.
*/
EXTERN int ooSocketListen (OOSOCKET socket, int maxConnection);
/**
* This function is used to peek at the received data without actually removing
* it from the receive socket buffer. A receive call after this will get the
* same data from the socket.
* @param socket The socket's handle created by call to ::rtSocketCreate
* or ::rtSocketAccept function.
* @param pbuf Pointer to the buffer for the incoming data.
* @param bufsize Length of the buffer.
* @return If no error occurs, returns the number of bytes
* received. Otherwise, the negative value is error code.
*/
EXTERN int ooSocketRecvPeek
(OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize);
/**
* This function receives data from a connected socket. It is used to read
* incoming data on sockets. The socket must be connected before calling this
* function. See description of 'recv' socket function for further details.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* or ::rtSocketAccept function.
* @param pbuf Pointer to the buffer for the incoming data.
* @param bufsize Length of the buffer.
* @return If no error occurs, returns the number of bytes
* received. Otherwise, the negative value is error code.
*/
EXTERN int ooSocketRecv (OOSOCKET socket, ASN1OCTET* pbuf,
ASN1UINT bufsize);
/**
* This function receives data from a connected/unconnected socket. It is used
* to read incoming data on sockets. It populates the remotehost and
* remoteport parameters with information of remote host. See description of
* 'recvfrom' socket function for further details.
*
* @param socket The socket's handle created by call to ooSocketCreate
*
* @param pbuf Pointer to the buffer for the incoming data.
* @param bufsize Length of the buffer.
* @param remotehost Pointer to a buffer in which remote ip address
* will be returned.
* @param hostBufLen Length of the buffer passed for remote ip address.
* @param remoteport Pointer to an int in which remote port number
* will be returned.
*
* @return If no error occurs, returns the number of bytes
* received. Otherwise, negative value.
*/
EXTERN int ooSocketRecvFrom (OOSOCKET socket, ASN1OCTET* pbuf,
ASN1UINT bufsize, char * remotehost,
ASN1UINT hostBufLen, int * remoteport);
/**
* This function sends data on a connected socket. It is used to write outgoing
* data on a connected socket. See description of 'send' socket function for
* further details.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* or ::rtSocketAccept function.
* @param pdata Buffer containing the data to be transmitted.
* @param size Length of the data in pdata.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketSend (OOSOCKET socket, const ASN1OCTET* pdata,
ASN1UINT size);
/**
* This function sends data on a connected or unconnected socket. See
* description of 'sendto' socket function for further details.
*
* @param socket The socket's handle created by call to ::rtSocketCreate
* or ::rtSocketAccept function.
* @param pdata Buffer containing the data to be transmitted.
* @param size Length of the data in pdata.
* @param remotehost Remote host ip address to which data has to
* be sent.
* @param remoteport Remote port ip address to which data has to
* be sent.
*
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketSendTo(OOSOCKET socket, const ASN1OCTET* pdata,
ASN1UINT size, const char* remotehost,
int remoteport);
/**
* This function is used for synchronous monitoring of multiple sockets.
* For more information refer to documnetation of "select" system call.
*
* @param nfds The highest numbered descriptor to be monitored
* plus one.
* @param readfds The descriptors listed in readfds will be watched for
* whether read would block on them.
* @param writefds The descriptors listed in writefds will be watched for
* whether write would block on them.
* @param exceptfds The descriptors listed in exceptfds will be watched for
* exceptions.
* @param timeout Upper bound on amout of time elapsed before select
* returns.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketSelect(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval * timeout);
/**
* This function converts the string with IP address to a double word
* representation. The converted address may be used with the ::rtSocketBind
* function.
*
* @param pIPAddrStr The null-terminated string with the IP address in the
* following format: "NNN.NNN.NNN.NNN", where NNN is a
* number in the range (0..255).
* @param pIPAddr Pointer to the converted IP address.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketStrToAddr (const char* pIPAddrStr, OOIPADDR* pIPAddr);
/**
* This function converts an internet dotted ip address to network address
*
* @param inetIp The null-terminated string with the IP address in the
* following format: "NNN.NNN.NNN.NNN", where NNN is a
* number in the range (0..255).
* @param netIp Buffer in which the converted address will be returned.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooSocketConvertIpToNwAddr(char *inetIp, char *netIp);
/**
* This function retrives the IP address of the local host.
*
* @param pIPAddrs Pointer to a char buffer in which local IP address will be
* returned.
* @return Completion status of operation: 0 (ASN_OK) = success,
* negative return value is error.
*/
EXTERN int ooGetLocalIPAddress(char * pIPAddrs);
EXTERN int ooSocketGetSockName(OOSOCKET socket, struct sockaddr_in *name,
int *size);
EXTERN long ooSocketHTONL(long val);
EXTERN short ooSocketHTONS(short val);
/**
* This function is used to retrieve the ip and port number used by the socket
* passed as parameter. It internally uses getsockname system call for this
* purpose.
* @param socket Socket for which ip and port has to be determined.
* @param ip Buffer in which ip address will be returned.
* @param len Length of the ip address buffer.
* @param port Pointer to integer in which port number will be returned.
*
* @return ASN_OK, on success; -ve on failed.
*/
EXTERN int ooSocketGetIpAndPort(OOSOCKET socket, char *ip, int len, int *port);
EXTERN int ooSocketGetInterfaceList(OOCTXT *pctxt, OOInterface **ifList);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* _OOSOCKET_H_ */

View File

@ -0,0 +1,339 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooStackCmds.h"
#include "ooh323ep.h"
#include "ooCalls.h"
#include "ooCmdChannel.h"
extern OOSOCKET gCmdChan;
int ooGenerateOutgoingCallToken (char *callToken, size_t size)
{
static int counter = 1;
char aCallToken[200];
int ret = 0;
sprintf (aCallToken, "ooh323c_o_%d", counter++);
if (counter > OO_MAX_CALL_TOKEN)
counter = 1;
if ((strlen(aCallToken)+1) < size)
strcpy (callToken, aCallToken);
else {
ret = OO_FAILED;
}
return ret;
}
OOStkCmdStat ooMakeCall
(const char* dest, char* callToken, size_t bufsiz, ooCallOptions *opts)
{
OOStackCommand cmd;
if(!callToken)
return OO_STKCMD_INVALIDPARAM;
/* Generate call token*/
if (ooGenerateOutgoingCallToken (callToken, bufsiz) != OO_OK){
return OO_STKCMD_INVALIDPARAM;
}
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_MAKECALL;
cmd.param1 = (void*) malloc(strlen(dest)+1);
if(!cmd.param1)
{
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param1, dest);
cmd.param2 = (void*) malloc(strlen(callToken)+1);
if(!cmd.param2)
{
free(cmd.param1);
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param2, callToken);
if(!opts)
{
cmd.param3 = 0;
}
else {
cmd.param3 = (void*) malloc(sizeof(ooCallOptions));
if(!cmd.param3)
{
free(cmd.param1);
free(cmd.param2);
return OO_STKCMD_MEMERR;
}
memcpy((void*)cmd.param3, opts, sizeof(ooCallOptions));
}
if(ooWriteStackCommand(&cmd) != OO_OK)
{
free(cmd.param1);
free(cmd.param2);
if(cmd.param3) free(cmd.param3);
return OO_STKCMD_WRITEERR;
}
return OO_STKCMD_SUCCESS;
}
OOStkCmdStat ooManualRingback(const char *callToken)
{
OOStackCommand cmd;
if(!callToken)
{
return OO_STKCMD_INVALIDPARAM;
}
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_MANUALRINGBACK;
cmd.param1 = (void*) malloc(strlen(callToken)+1);
if(!cmd.param1)
{
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param1, callToken);
if(ooWriteStackCommand(&cmd) != OO_OK)
{
free(cmd.param1);
return OO_STKCMD_WRITEERR;
}
return OO_STKCMD_SUCCESS;
}
OOStkCmdStat ooAnswerCall(const char *callToken)
{
OOStackCommand cmd;
if(!callToken)
{
return OO_STKCMD_INVALIDPARAM;
}
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_ANSCALL;
cmd.param1 = (void*) malloc(strlen(callToken)+1);
if(!cmd.param1)
{
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param1, callToken);
if(ooWriteStackCommand(&cmd) != OO_OK)
{
free(cmd.param1);
return OO_STKCMD_WRITEERR;
}
return OO_STKCMD_SUCCESS;
}
OOStkCmdStat ooForwardCall(const char* callToken, char *dest)
{
OOStackCommand cmd;
if(!callToken || !dest)
{
return OO_STKCMD_INVALIDPARAM;
}
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_FWDCALL;
cmd.param1 = (void*) malloc(strlen(callToken)+1);
cmd.param2 = (void*) malloc(strlen(dest)+1);
if(!cmd.param1 || !cmd.param2)
{
if(cmd.param1) free(cmd.param1); /* Release memory */
if(cmd.param2) free(cmd.param2);
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param1, callToken);
strcpy((char*)cmd.param2, dest);
if(ooWriteStackCommand(&cmd) != OO_OK)
{
free(cmd.param1);
free(cmd.param2);
return OO_STKCMD_WRITEERR;
}
return OO_STKCMD_SUCCESS;
}
OOStkCmdStat ooHangCall(const char* callToken, OOCallClearReason reason)
{
OOStackCommand cmd;
if(!callToken)
{
return OO_STKCMD_INVALIDPARAM;
}
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_HANGCALL;
cmd.param1 = (void*) malloc(strlen(callToken)+1);
cmd.param2 = (void*) malloc(sizeof(OOCallClearReason));
if(!cmd.param1 || !cmd.param2)
{
if(cmd.param1) free(cmd.param1); /* Release memory */
if(cmd.param2) free(cmd.param2);
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param1, callToken);
*((OOCallClearReason*)cmd.param2) = reason;
if(ooWriteStackCommand(&cmd) != OO_OK)
{
free(cmd.param1);
free(cmd.param2);
return OO_STKCMD_WRITEERR;
}
return OO_STKCMD_SUCCESS;
}
OOStkCmdStat ooStopMonitor()
{
OOStackCommand cmd;
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_STOPMONITOR;
if(ooWriteStackCommand(&cmd) != OO_OK)
return OO_STKCMD_WRITEERR;
return OO_STKCMD_SUCCESS;
}
OOStkCmdStat ooSendDTMFDigit(const char *callToken, const char* dtmf)
{
OOStackCommand cmd;
if(!callToken)
{
return OO_STKCMD_INVALIDPARAM;
}
if(gCmdChan == 0)
{
if(ooCreateCmdConnection() != OO_OK)
return OO_STKCMD_CONNECTIONERR;
}
memset(&cmd, 0, sizeof(OOStackCommand));
cmd.type = OO_CMD_SENDDIGIT;
cmd.param1 = (void*) malloc(strlen(callToken)+1);
cmd.param2 = (void*) malloc(strlen(dtmf)+1);
if(!cmd.param1 || !cmd.param2)
{
if(cmd.param1) free(cmd.param1); /* Release memory */
if(cmd.param2) free(cmd.param2);
return OO_STKCMD_MEMERR;
}
strcpy((char*)cmd.param1, callToken);
strcpy((char*)cmd.param2, dtmf);
if(ooWriteStackCommand(&cmd) != OO_OK)
{
free(cmd.param1);
free(cmd.param2);
return OO_STKCMD_WRITEERR;
}
return OO_STKCMD_SUCCESS;
}
const char* ooGetStkCmdStatusCodeTxt(OOStkCmdStat stat)
{
switch(stat)
{
case OO_STKCMD_SUCCESS:
return "Stack command - successfully issued";
case OO_STKCMD_MEMERR:
return "Stack command - Memory allocation error";
case OO_STKCMD_INVALIDPARAM:
return "Stack command - Invalid parameter";
case OO_STKCMD_WRITEERR:
return "Stack command - write error";
case OO_STKCMD_CONNECTIONERR:
return "Stack command - Failed to create command channel";
default:
return "Invalid status code";
}
}

View File

@ -0,0 +1,171 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooStackCmds.h
* This file contains stack commands which an user application can use to make
* call, hang call etc.
*/
#ifndef OO_STACKCMDS_H
#define OO_STACKCMDS_H
#include "ootypes.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#if defined (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* @defgroup stackcmds Stack Control Commands
* @{
*/
/**
* This is an enumeration of Stack Command return codes.
*/
typedef enum OOStkCmdStat{
OO_STKCMD_SUCCESS,
OO_STKCMD_MEMERR,
OO_STKCMD_INVALIDPARAM,
OO_STKCMD_WRITEERR,
OO_STKCMD_CONNECTIONERR
}OOStkCmdStat;
/**
* This is an enumeration of stack command codes.
*/
typedef enum OOStackCmdID {
OO_CMD_NOOP,
OO_CMD_MAKECALL, /*!< Make call */
OO_CMD_ANSCALL, /*!< Answer call */
OO_CMD_FWDCALL, /*!< Forward call */
OO_CMD_HANGCALL, /*!< Terminate call */
OO_CMD_SENDDIGIT, /*!< Send dtmf */
OO_CMD_MANUALRINGBACK, /*!< Send Alerting - ringback */
OO_CMD_STOPMONITOR /*!< Stop the event monitor */
} OOStackCmdID;
/**
* This structure is used to queue a stack command for processing in
* the event handler loop.
*/
typedef struct OOStackCommand {
OOStackCmdID type;
void* param1;
void* param2;
void* param3;
} OOStackCommand;
#define ooCommand OOStackCommand;
/**
* This function is used by an application to place a call.
* @param dest Call Destination - IP:port / alias
* @param callToken Pointer to a buffer in which callToken will be returned
* @param bufsiz Size of the callToken buffer passed.
* @param opts These are call specific options and if passed a non-null
* value, will override global endpoint options.
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooMakeCall
(const char* dest, char *callToken, size_t bufsiz, ooCallOptions *opts);
/**
* This function is used to send a manual ringback message (alerting message)
* for a call. Effective only when manual-ringback is enabled.
* @param callToken Unique token for the call.
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooManualRingback(const char *callToken);
/**
* This function is used to answer a call
* @param callToken Unique token for the call
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooAnswerCall(const char *callToken);
/**
* This function is used to forward an existing call to third party.
* @param callToken Unique token for the call.
* @param dest Address to which the call has to be forwarded. Can be
* IP:PORT or alias.
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooForwardCall(const char* callToken, char *dest);
/**
* This function is used by an user application to terminate a call.
* @param callToken The uinque token for the call.
* @param reason Reason for hanging call.
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooHangCall(const char* callToken, OOCallClearReason reason);
/**
* This command function can be used by an user application to send a DTMF
* sequence using H.245 UserInputIndication message.
* @param callToken Unique token for the call
* @param alpha Alphanumeric string reperesenting dtmf sequence
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooSendDTMFDigit(const char *callToken, const char* alpha);
/**
* This function is used by the user application to stop stack thread.
*
* @return Returns OOStkCmdStat value indication success or failure.
*/
EXTERN OOStkCmdStat ooStopMonitor(void);
/**
* This function is used by application to obtain the text description for
* failure of tsack command.
* @param stat Status code returned by stack command api.
*
* @return Text description corresponding to the code.
*/
EXTERN const char* ooGetStkCmdStatusCodeTxt(OOStkCmdStat stat);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,193 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the LICENSE.txt file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooDateTime.h"
#include "ooTimer.h"
#include "ootrace.h"
#define USECS_IN_SECS 1000000
#define NSECS_IN_USECS 1000
#ifndef MICROSEC
#define MICROSEC USECS_IN_SECS
#endif
/**
* This is a timer list used by test application chansetup only.
*/
DList g_TimerList;
OOTimer* ooTimerCreate
(OOCTXT* pctxt, DList *pList, OOTimerCbFunc cb, OOUINT32 deltaSecs, void *data,
OOBOOL reRegister)
{
OOTimer* pTimer = (OOTimer*) memAlloc (pctxt, sizeof(OOTimer));
if (0 == pTimer) return 0;
memset (pTimer, 0, (sizeof(OOTimer)));
pTimer->timeoutCB = cb;
pTimer->cbData = data;
pTimer->reRegister = reRegister;
pTimer->timeout.tv_sec = deltaSecs;
pTimer->timeout.tv_usec = 0;
/* Compute the absolute time at which this timer should expire */
ooTimerComputeExpireTime (pTimer);
/* Insert this timer into the complete list */
if(pList)
ooTimerInsertEntry (pctxt, pList, pTimer);
else
ooTimerInsertEntry (pctxt, &g_TimerList, pTimer);
return pTimer;
}
void ooTimerComputeExpireTime (OOTimer* pTimer)
{
struct timeval tv;
ooGetTimeOfDay (&tv, 0);
/* Compute delta time to expiration */
pTimer->expireTime.tv_usec = tv.tv_usec + pTimer->timeout.tv_usec;
pTimer->expireTime.tv_sec = tv.tv_sec + pTimer->timeout.tv_sec;
while (pTimer->expireTime.tv_usec >= MICROSEC) {
pTimer->expireTime.tv_usec -= MICROSEC;
pTimer->expireTime.tv_sec++;
}
}
void ooTimerDelete (OOCTXT* pctxt, DList *pList, OOTimer* pTimer)
{
dListFindAndRemove (pList, pTimer);
memFreePtr (pctxt, pTimer);
}
OOBOOL ooTimerExpired (OOTimer* pTimer)
{
struct timeval tvstr;
ooGetTimeOfDay (&tvstr, 0);
if (tvstr.tv_sec > pTimer->expireTime.tv_sec)
return TRUE;
if ((tvstr.tv_sec == pTimer->expireTime.tv_sec) &&
(tvstr.tv_usec > pTimer->expireTime.tv_usec))
return TRUE;
return FALSE;
}
void ooTimerFireExpired (OOCTXT* pctxt, DList *pList)
{
OOTimer* pTimer;
int stat;
while (pList->count > 0) {
pTimer = (OOTimer*) pList->head->data;
if (ooTimerExpired (pTimer)) {
/*
* Re-register before calling callback function in case it is
* a long duration callback.
*/
if (pTimer->reRegister) ooTimerReset (pctxt, pList, pTimer);
stat = (*pTimer->timeoutCB)(pTimer->cbData);
if (0 != stat || !pTimer->reRegister) {
ooTimerDelete (pctxt, pList, pTimer);
}
}
else break;
}
}
int ooTimerInsertEntry (OOCTXT* pctxt, DList *pList, OOTimer* pTimer)
{ DListNode* pNode;
OOTimer* p;
int i = 0;
for (pNode = pList->head; pNode != 0; pNode = pNode->next) {
p = (OOTimer*) pNode->data;
if (pTimer->expireTime.tv_sec < p->expireTime.tv_sec) break;
if (pTimer->expireTime.tv_sec == p->expireTime.tv_sec &&
pTimer->expireTime.tv_usec <= p->expireTime.tv_usec) break;
i++;
}
dListInsertBefore (pctxt, pList, pNode, pTimer);
return i;
}
struct timeval* ooTimerNextTimeout (DList *pList, struct timeval* ptimeout)
{
OOTimer* ptimer;
struct timeval tvstr;
if (pList->count == 0) return 0;
ptimer = (OOTimer*) pList->head->data;
ooGetTimeOfDay (&tvstr, 0);
ptimeout->tv_sec =
OOMAX ((int) 0, (int) (ptimer->expireTime.tv_sec - tvstr.tv_sec));
ptimeout->tv_usec = ptimer->expireTime.tv_usec - tvstr.tv_usec;
while (ptimeout->tv_usec < 0) {
ptimeout->tv_sec--;
ptimeout->tv_usec += USECS_IN_SECS;
}
if (ptimeout->tv_sec < 0)
ptimeout->tv_sec = ptimeout->tv_usec = 0;
return (ptimeout);
}
/*
* Reregister a timer entry. This function is responsible for moving
* the current pointer in the timer list to the next element to be
* processed..
*/
void ooTimerReset (OOCTXT* pctxt, DList *pList, OOTimer* pTimer)
{
if (pTimer->reRegister) {
dListFindAndRemove (pList, pTimer);
ooTimerComputeExpireTime (pTimer);
ooTimerInsertEntry (pctxt, pList, pTimer);
}
else
ooTimerDelete (pctxt, pList, pTimer);
}
int ooCompareTimeouts(struct timeval *to1, struct timeval *to2)
{
if(to1->tv_sec > to2->tv_sec) return 1;
if(to1->tv_sec < to2->tv_sec) return -1;
if(to1->tv_usec > to2->tv_usec) return 1;
if(to1->tv_usec < to2->tv_usec) return -1;
return 0;
}

View File

@ -0,0 +1,128 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the LICENSE.txt file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooTimer.h
* Timer structures and functions.
*/
#ifndef _OOTIMER_H_
#define _OOTIMER_H_
#include "ooasn1.h"
#include "ooSocket.h" /* needed for timeval */
struct _OOTimer;
typedef int (*OOTimerCbFunc)(void *data);
typedef struct _OOTimer {
struct timeval expireTime, timeout;
void* cbData;
OOBOOL reRegister;
/* Callback functions */
OOTimerCbFunc timeoutCB;
} OOTimer;
#ifdef __cplusplus
extern "C" {
#endif
/**
* This function computes the relative expiration time from the current
* time for the given timer object.
*
* @param pTimer Pointer to timer object.
*/
EXTERN void ooTimerComputeExpireTime (OOTimer* pTimer);
/**
* This function creates and initializes a new timer object.
* @param pctxt OOCTXT structure used for timer memory allocation.
* @param pList Pointer to timer list in which newly created timer will
* be inserted.
* @param cb Timer callback function.
* @param deltaSecs Time in seconds to timer expiration.
* @param data Callback user data argument.
* @param reRegister Should timer be re-registered after it expires?
* @return Pointer to created timer object.
*/
EXTERN OOTimer* ooTimerCreate
(OOCTXT* pctxt, DList *pList, OOTimerCbFunc cb, OOUINT32 deltaSecs, void *data,
OOBOOL reRegister);
/**
* This function deletes the given timer object.
* @param pctxt Handle to OOCTXT structure used for timer memory.
* @param pList timer list to operate on
* @param pTimer Pointer to timer object.
*/
EXTERN void ooTimerDelete (OOCTXT* pctxt, DList* pList, OOTimer* pTimer);
/**
* This function checks a timer to determine if it is expired.
*
* @param pTimer Pointer to timer object.
* @return True if timer expired, false if not.
*/
EXTERN OOBOOL ooTimerExpired (OOTimer* pTimer);
/**
* This function loops through the global timer list and fires all
* expired timers by calling the registered callback functions.
*/
EXTERN void ooTimerFireExpired (OOCTXT* pctxt, DList* pList);
/**
* This function inserts the given timer object into the correct
* chronological position in the global timer list.
* @param pctxt Pointer to OOCTXT structure used for memory allocation.
* @param pList List in which timer has to be inserted.
* @param pTimer Pointer to timer object.
* @return Index to position where inserted in list.
*/
EXTERN int ooTimerInsertEntry (OOCTXT* pctxt, DList* pList, OOTimer* pTimer);
/**
* This function calculates the relative time from the current time
* that the first timer in global timer list will expire.
* @param pList Handle to timer list
* @param ptimeout timeval structure to receive timeout value.
* @return ptimeout
*/
EXTERN struct timeval* ooTimerNextTimeout (DList* pList, struct timeval* ptimeout);
/**
* This function resets the given timer object if its reregister flag
* is set. Otherwise, it is deleted.
* @param pctxt Pointer to OOCTXT structre used for memory allocation.
* @param pList Pointer to timer list.
* @param pTimer Pointer to timer object.
*/
EXTERN void ooTimerReset (OOCTXT* pctxt, DList* pList, OOTimer* pTimer);
/**
* This function is used to compare two timeout values.
* @param to1 First timeout value.
* @param to2 Second timeout value.
*
* @return 1, if to1 > to2; 0, if to1 == to2; -1, if to1 < to2
*/
int ooCompareTimeouts(struct timeval *to1, struct timeval *to2);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooUtils.h"
const char* ooUtilsGetText (OOUINT32 idx, const char** table, size_t tabsiz)
{
return (idx < tabsiz) ? table[idx] : "?";
}
OOBOOL ooUtilsIsStrEmpty (const char* str)
{
return (str == NULL || *str =='\0');
}
OOBOOL ooIsDailedDigit(const char* str)
{
if(str == NULL || *str =='\0') { return FALSE; }
while(*str != '\0')
{
if(!isdigit(*str) &&
*str != '#' && *str != '*' && *str != ',') { return FALSE; }
str++;
}
return TRUE;
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooUtils.h
* This file contains general utility functions.
*/
#ifndef _OOUTILS_H_
#define _OOUTILS_H_
#include "ootypes.h"
/**
* Get text from a text table for a given enumeration index.
*
* @param idx Index of item in table
* @param table The table containing the text items
* @param tabsiz Number of items in the table
* @return Text for item or '?' if idx outside bounds of table
*/
EXTERN const char* ooUtilsGetText
(OOUINT32 idx, const char** table, size_t tabsiz);
/**
* Test if given string value is empty. String is considered to empty
* if value is NULL or there are no characters in string (strlen == 0).
*
* @param str String to test
* @return TRUE if string empty; FALSE otherwise
*/
EXTERN OOBOOL ooUtilsIsStrEmpty (const char * str);
/**
* Test if given string value is digit string.
*
* @param str String to test
* @return TRUE if string contains all digits; FALSE otherwise
*/
EXTERN OOBOOL ooIsDailedDigit(const char* str);
#endif

1814
addons/ooh323c/src/ooasn1.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,216 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file oochannels.h
* This file contains functions to create and use channels.
*/
#ifndef _OOCHANNELS_H_
#define _OOCHANNELS_H_
#include "H323-MESSAGES.h"
#include "MULTIMEDIA-SYSTEM-CONTROL.h"
#include "ootypes.h"
#include "ooSocket.h"
#include "ooCalls.h"
#define OORECEIVER 1
#define OOTRANSMITTER 2
#define OODUPLEX 3
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
struct OOH323CallData;
struct Q931Message;
/**
* @defgroup channels Channel Management
* @{
*/
/**
* This function is used to create a listener for incoming calls.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCreateH323Listener(void);
/**
* This function is used to create a listener for incoming H.245 connections.
* @param call Pointer to call for which H.245 listener has to be created
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCreateH245Listener(struct OOH323CallData *call);
/**
* This function is used to close an H245 listener for a call.
* @param call Pointer to call for which H245 Listener has to be closed.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCloseH245Listener(struct OOH323CallData *call);
/**
* This function is used to accept incoming H.225 connections.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooAcceptH225Connection(void);
/**
* This function is used to accept an incoming H.245 connection.
* @param call Pointer to a call for which H.245 connection request has
* arrived.
*
* @return OO_OK, on succes. OO_FAILED, on failure.
*/
EXTERN int ooAcceptH245Connection(struct OOH323CallData *call);
/**
* This function is used to create an H.225 connection to the remote end point.
* @param call Pointer to the call for which H.225 connection has to be
* setup.
* @return OO_OK, on succes. OO_FAILED, on failure.
*/
EXTERN int ooCreateH225Connection(struct OOH323CallData *call);
/**
* This function is used to setup an H.245 connection with the remote endpoint
* for control negotiations.
* @param call Pointer to call for which H.245 connection has to be setup.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCreateH245Connection(struct OOH323CallData *call);
/**
* This function is used to close an H.225 connection
* @param call Pointer to the call for which H.225 connection has to be
* closed.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCloseH225Connection(struct OOH323CallData *call);
/**
* This function is used to close an H.245 connection for a call.
*
* @param call Pointer to call for which H.245 connection has
* to be closed.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCloseH245Connection(struct OOH323CallData *call);
/**
* This function is used to start monitoring channels for the calls. It has
* an infinite loop which uses select to monitor various channels.
*
*/
EXTERN int ooMonitorChannels(void);
/**
* This function is called to stop the monitor channels event loop.
* It cleans up all the active calls before stopping the monitor.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooStopMonitorCalls(void);
/**
* This function is used to receive an H.2250 message received on a calls
* H.225 channel. It receives the message, decodes it and calls
* 'ooHandleH2250Message' to process the message.
* @param call Pointer to the call for which the message has to be
* received.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH2250Receive(struct OOH323CallData *call);
/**
* This function is used to receive an H.245 message received on a calls
* H.245 channel. It receives the message, decodes it and calls
* 'ooHandleH245Message' to process it.
* @param call Pointer to the call for which the message has to be
* received.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH245Receive(struct OOH323CallData *call);
/**
* This function is used to enqueue an H.225 message into an outgoing queue for
* the call.
* @param call Pointer to call for which message has to be enqueued.
* @param msg Pointer to the H.225 message to be sent.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendH225Msg(struct OOH323CallData *call, struct Q931Message *msg);
/**
* This function is used to Send a message on the channel, when channel is
* available for write.
* @param call Pointer to call for which message has to be sent.
* @param type Type of the message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendMsg(struct OOH323CallData *call, int type);
/**
* This function is called after a message is sent on the call's channel.
* It can be used to some followup action after message has been sent.
* @param call Pointer to call for which message has been sent.
* @param msgType Type of message
* @param tunneledMsgType If this message is carrying a tunneled message, then
* type of the tunneled message.
* @param associatedChan The channel number associated with the message sent,
* or tunneled message. 0, if no channel is associated.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooOnSendMsg
(struct OOH323CallData *call, int msgType, int tunneledMsgType,
int associatedChan);
/**
* This function is used to check the status of tcp connection.
* @param call Handle to the call to which connection belongs.
* @param sock Connected socket.
*
* @return True if connection is ok, false otherwise.
*/
EXTERN OOBOOL ooChannelsIsConnectionOK(OOH323CallData *call, OOSOCKET sock);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

3686
addons/ooh323c/src/ooh245.c Normal file

File diff suppressed because it is too large Load Diff

636
addons/ooh323c/src/ooh245.h Normal file
View File

@ -0,0 +1,636 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooh245.h
* This file contains functions to support H245 negotiations.
*/
#ifndef _OOH245HDR_H_
#define _OOH245HDR_H_
#include "ooasn1.h"
#include "ooCapability.h"
#include "oochannels.h"
#include "ootrace.h"
#include "ooq931.h"
#include "MULTIMEDIA-SYSTEM-CONTROL.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
struct OOH323CallData;
/**
* @defgroup h245 H.245 Message Handling
* @{
*/
/**
* Defines the H.245 message structure. All request/response
* and command messages are represented using this structure.
*/
typedef struct H245Message {
H245MultimediaSystemControlMessage h245Msg;
ASN1UINT msgType;
ASN1INT logicalChannelNo;
} H245Message;
/**
* Creates an outgoing H245 message of the type specified by the type
* argument for the Application context.
*
* @param msg A pointer to pointer to message which will be assigned to
* allocated memory.
* @param type Type of the message to be created.
* (Request/Response/Command/Indication)
*
* @return Completion status of operation: 0 (OO_OK) = success,
* negative return value is error.
*/
EXTERN int ooCreateH245Message(H245Message **msg, int type);
/**
* Frees up the memory used by the H245 message.
*
* @param call Handle to the call
* @param pmsg Pointer to an H245 message structure.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooFreeH245Message(struct OOH323CallData *call, H245Message *pmsg);
/**
* This function is used to enqueue an H.245 message into an outgoing queue for
* the call.
* @param call Pointer to call for which message has to be enqueued.
* @param msg Pointer to the H.245 message to be sent.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendH245Msg(struct OOH323CallData *call, H245Message *msg);
/**
* This function is used to retrieve an H.245 message enqueued in the outgoing
* queue.
* @param call Pointer to the call for which message has to be retrieved.
* @param msgbuf Pointer to a buffer in which the message will be returned.
* @param len Pointer to an int variable which will contain length of
* the message data after returning.
* @param msgType Pointer to an int variable, which will contain message type
* on return from the function.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGetOutgoingH245Msgbuf(struct OOH323CallData *call,
ASN1OCTET *msgbuf,
int *len, int *msgType);
/**
* This function is used to send out a terminal capability set message.
*
* @param call Pointer to a call for which TerminalCapabilitySet message
* will be sent.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendTermCapMsg(struct OOH323CallData *call);
/**
* This function is used to generate a random status determination number
* for MSD procedure.
*
* @return Generated status determination number.
*/
EXTERN ASN1UINT ooGenerateStatusDeterminationNumber();
/**
* This fuction is used to handle received MasterSlaveDetermination procedure
* messages.
* @param call Pointer to the call for which a message is received.
* @param pmsg Pointer to MSD message
* @param msgType Message type indicating whether received message is MSD,
* MSDAck, MSDReject etc...
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooHandleMasterSlave
(struct OOH323CallData *call, void * pmsg, int msgType);
/**
* This function is used to send MSD message.
* @param call Pointer to call for which MasterSlaveDetermination has to
* be sent.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendMasterSlaveDetermination(struct OOH323CallData *call);
/**
* This function is used to send a MasterSlaveDeterminationAck message.
* @param call Pointer to call for which MasterSlaveDeterminationAck has
* to be sent.
* @param status Result of the determination process(Master/Slave as it
* applies to remote endpoint)
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendMasterSlaveDeterminationAck
(struct OOH323CallData* call, char * status);
/**
* This function is used to send a MasterSlaveDeterminationReject message.
* @param call Pointer to call for which message is to be sent.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendMasterSlaveDeterminationReject (struct OOH323CallData* call);
/**
* This function is used to handle MasterSlaveReject message. If number of
* retries is less than max allowed, then it restarts the
* MasterSlaveDetermination procedure.
* @param call Handle to the call for which MasterSlaveReject is
* received.
* @param reject Poinetr to the received reject message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooHandleMasterSlaveReject
(struct OOH323CallData *call, H245MasterSlaveDeterminationReject* reject);
/**
* This function is used to handle received OpenLogicalChannel message.
* @param call Pointer to call for which OpenLogicalChannel message is
* received.
* @param olc Pointer to the received OpenLogicalChannel message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooHandleOpenLogicalChannel
(struct OOH323CallData* call, H245OpenLogicalChannel *olc);
/**
* This is a helper function used to handle a received OpenLogicalChannel
* message. It builds an OpenLogicalChannelAck message and sends it.
*
* @param call Pointer to cll for which OLC was received.
* @param olc The received OpenLogicalChannel message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooHandleOpenLogicalChannel_helper
(struct OOH323CallData *call, H245OpenLogicalChannel*olc);
/**
* This function is used to build and send OpenLogicalChannelReject message.
* @param call Pointer to call for which OLCReject has to be sent.
* @param channelNum LogicalChannelNumber to be rejected.
* @param cause Cause of rejection.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooSendOpenLogicalChannelReject
(struct OOH323CallData *call, ASN1UINT channelNum, ASN1UINT cause);
/**
* This function is used to handle a received OpenLogicalChannelAck message.
* @param call Pointer to call for which OLCAck is received
* @param olcAck Pointer to received olcAck message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedOpenLogicalChannelAck(struct OOH323CallData *call,
H245OpenLogicalChannelAck *olcAck);
/**
* This function is used to handle the received OpenLogicalChannelReject
* message.
* @param call Handle to the call for which the message is received.
* @param olcRejected Pointer to received OpenLogicalChannelReject message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooOnReceivedOpenLogicalChannelRejected(struct OOH323CallData *call,
H245OpenLogicalChannelReject *olcRejected);
/**
* This message is used to send an EndSession command. It builds a EndSession
* command message and queues it into the calls outgoing queue.
* @param call Pointer to call for which EndSession command has to be
* sent.
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendEndSessionCommand(struct OOH323CallData *call);
/**
* This function is used to handle a received H245Command message.
* @param call Pointer to call for which an H245Command is received.
* @param command Pointer to a command message.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooHandleH245Command
(struct OOH323CallData *call, H245CommandMessage *command);
/**
* This function is used to handle a received UserInput Indication message.
* It extracts the dtmf received through user-input message and calls endpoints
* onReceivedDTMF callback function, if such a function is registered by the
* endpoint.
* @param call Handle to the call for which user-input indication
* message is received.
* @param indication Handle to the received user-input indication message.
*
* @return OO_OK, on success; OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedUserInputIndication
(OOH323CallData *call, H245UserInputIndication *indication);
/**
* This function is called on receiving a TreminalCapabilitySetAck message.
* If the MasterSlaveDetermination process is also over, this function
* initiates the process of opening logical channels.
* @param call Pointer to call for which TCSAck is received.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedTerminalCapabilitySetAck(struct OOH323CallData* call);
/**
* This function is called to close all the open logical channels. It sends
* CloseLogicalChannel message for all the forward channels and sends
* RequestCloseLogicalChannel message for all the reverse channels.
* @param call Pointer to call for which logical channels have to be
* closed.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooCloseAllLogicalChannels(struct OOH323CallData *call);
/**
* This function is used to send out a CloseLogicalChannel message for a particular
* logical channel.
* @param call Pointer to a call, to which logical channel to be closed belongs.
* @param logicalChan Pointer to the logical channel to be closed.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendCloseLogicalChannel
(struct OOH323CallData *call, ooLogicalChannel *logicalChan);
/**
* This function is used to process a received closeLogicalChannel request. It closes the
* logical channel and removes the logical channel entry from the list. It also, sends
* closeLogicalChannelAck message to the remote endpoint.
* @param call Pointer to call for which CloseLogicalChannel message is received.
* @param clc Pointer to received CloseLogicalChannel message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedCloseLogicalChannel(struct OOH323CallData *call,
H245CloseLogicalChannel* clc);
/**
* This function is used to process a received CloseLogicalChannelAck message. It closes the
* channel and removes it from the list of active logical channels.
* @param call Pointer to call for which CLCAck message is received.
* @param clcAck Pointer to the received CloseLogicalChannelAck message.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooOnReceivedCloseChannelAck(struct OOH323CallData* call,
H245CloseLogicalChannelAck* clcAck);
/**
* This function is used to handle received H245 message. Based on the type of message received,
* it calls helper functions to process those messages.
* @param call Pointer to call for which a message is received.
* @param pmsg Pointer to the received H245 message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooHandleH245Message
(struct OOH323CallData *call, H245Message * pmsg);
/**
* This function is used to process received TCS message. It builds TCSAck message and queues it
* into the calls outgoing queue. Also, starts Logical channel opening procedure if TCS and MSD
* procedures have finished.
* @param call Pointer to call for which TCS is received.
* @param pmsg Pointer to the received message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedTerminalCapabilitySet
(struct OOH323CallData *call, H245Message *pmsg);
/**
* This function is used to send a TCSAck message to remote endpoint.
* @param call Pointer to call on which TCSAck has to be sent.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH245AcknowledgeTerminalCapabilitySet(struct OOH323CallData *call);
/**
* This function is used to start OpenLogicalChannel procedure for all the
* channels to be opened for the call.
* @param call Pointer to call for which logical channels have to be opened.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOpenLogicalChannels(struct OOH323CallData *call);
/**
* This function is used to send OpenLogicalChannel message for audio/video
* channel.
* @param call Pointer to call for which channel has to be opened.
* @param capType Type of media channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOpenLogicalChannel(struct OOH323CallData *call,
enum OOCapType capType);
/**
* This function is used to build and send OpenLogicalChannel message using
* capability passed as parameter.
* @param call Pointer to call for which OpenLogicalChannel message
* has to be built.
* @param epCap Pointer to capability
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOpenChannel
(struct OOH323CallData* call, ooH323EpCapability *epCap);
/**
* This function is used to send dtmf digits as user input indication message
* contating alphanumeric string.
* @param call Handle to the call for which dtmf has to be sent.
* @param data DTMF data
*
* @return OO_OK, on success; OO_FAILED, on failure.
*/
EXTERN int ooSendH245UserInputIndication_alphanumeric
(OOH323CallData *call, const char *data);
/**
* This function is used to send dtmf digits as user input indication message
* contating dtmf signal type.
* @param call Handle to the call for which dtmf has to be sent.
* @param data DTMF data
*
* @return OO_OK, on success; OO_FAILED, on failure.
*/
EXTERN int ooSendH245UserInputIndication_signal
(OOH323CallData *call, const char *data);
/**
* This function is used to request a remote end point to close a logical
* channel.
* @param call Pointer to call for which the logical channel has to
* be closed.
* @param logicalChan Pointer to the logical channel structure which needs
* to be closed.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendRequestCloseLogicalChannel(struct OOH323CallData *call,
ooLogicalChannel *logicalChan);
/**
* This function is used to send a RequestChannelCloseRelease message when the
* corresponding timer has expired.
* @param call Handle to the call
* @param channelNum Channel number.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooSendRequestChannelCloseRelease
(struct OOH323CallData *call, int channelNum);
/**
* This function handles the received RequestChannelClose message, verifies
* that the requested channel is forward channel. It sends an acknowledgement
* for the message followed by CloseLogicalChannel message.
* @param call Pointer to the call for which RequestChannelClose is
* received.
* @param rclc Pointer to the received message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedRequestChannelClose(struct OOH323CallData *call,
H245RequestChannelClose *rclc);
/**
* This function is used to handle a received RequestChannelCloseReject
* response message.
* @param call Handle to the call.
* @param rccReject Pointer to the received reject response message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooOnReceivedRequestChannelCloseReject
(struct OOH323CallData *call, H245RequestChannelCloseReject *rccReject);
/**
* This function is used to handle a received RequestChannelCloseAck
* response message.
* @param call Handle to the call.
* @param rccAck Pointer to the received ack response message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooOnReceivedRequestChannelCloseAck
(struct OOH323CallData *call, H245RequestChannelCloseAck *rccAck);
/**
* Builds an OLC for faststart with an audio/video capability passed as
* parameter.
* @param call Handle to call for which OLC has to be built.
* @param olc Pointer to an OLC structure which will be populated.
* @param epCap Pointer to the capability which will be used to
* build OLC.
* @param pctxt Pointer to an OOCTXT structure which will be used
* to allocate additional memory for OLC.
* @param dir Direction of OLC
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooBuildFastStartOLC(struct OOH323CallData *call,
H245OpenLogicalChannel *olc,
ooH323EpCapability *epCap,
OOCTXT*pctxt, int dir);
/**
* Prepares a faststart response olc from the olc received in SETUP message.
* This function just changes the mediaChannel and mediaControl channel part
* of the olc received in SETUP.
* @param call Handle to call for which OLC has to be built.
* @param olc Pointer to an received OLC structure.
* @param epCap Pointer to the capability which will be used for
* this channel.
* @param pctxt Pointer to an OOCTXT structure which will be used
* to allocate additional memory for OLC.
* @param dir Direction of channel OORX, OOTX etc.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooPrepareFastStartResponseOLC
(OOH323CallData *call, H245OpenLogicalChannel *olc,
ooH323EpCapability *epCap, OOCTXT*pctxt, int dir);
/**
* This function is used to encode an H245 message and return encoded data
* into the buffer passed as a parameter to the function.
* @param call Handle to the call
* @param ph245Msg Handle to the message to be encoded.
* @param msgbuf buffer in which encoded message will be returned.
* @param size Size of the buffer.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooEncodeH245Message
(struct OOH323CallData *call, H245Message *ph245Msg, char *msgbuf, int size);
/**
* This function is used to send a master-slave determination release message.
* @param call Handle to call, for which MSDRelease message has
* to be sent.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooSendMasterSlaveDeterminationRelease(struct OOH323CallData * call);
/**
* This function is used to send a terminal capability set reject message
* to the remote endpoint.
* @param call Handle to the call for which reject message has to
* be sent.
* @param seqNo Sequence number of the TCS message to be rejected.
* @param cause Cause for rejecting a TCS message.
*
* @return OO_OK, on success; OO_FAILED, otherwise.
*/
int ooSendTerminalCapabilitySetReject
(struct OOH323CallData *call, int seqNo, ASN1UINT cause);
/**
* This function is used to send a TerminalCapabilitySetRelease message after
* capability exchange timer has expired.
* @param call Handle to call for which release message has to be
* sent.
*
* @return OO_OK, on success; OO_FAILED, on failure.
*/
int ooSendTerminalCapabilitySetRelease(struct OOH323CallData * call);
/**
* This is an helper function used to extract ip address and port info from
* H245TransportAddress structure.
* @param call Handle to associated call.
* @param h245Address Handle to H245TransportAddress structure from which
* information has to be extracted.
* @param ip Pointer to buffer in which ip address will be
* returned. Make sure that buffer has sufficient length.
* @param port Pointer to integer in which port number will be
* returned.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooGetIpPortFromH245TransportAddress
(OOH323CallData *call, H245TransportAddress *h245Address, char *ip,
int *port);
/**
* This is a callback function for handling an expired master-slave
* determination timer.
* @param data Callback data registered at the time of creation of
* the timer.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooMSDTimerExpired(void *data);
/**
* This is a callback function for handling an expired capability exchange
* timer.
* @param data Callback data registered at the time of creation of
* the timer.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooTCSTimerExpired(void *data);
/**
* This is a callback function for handling an expired OpenLogicalChannel
* timer.
* @param pdata Callback data registered at the time of creation of
* the timer.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooOpenLogicalChannelTimerExpired(void *pdata);
/**
* This is a callback function for handling an expired CloseLogicalChannel
* timer.
* @param pdata Callback data registered at the time of creation of
* the timer.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooCloseLogicalChannelTimerExpired(void *pdata);
/**
* This is a callback function for handling an expired RequestChannelClose
* timer.
* @param pdata Callback data registered at the time of creation of
* the timer.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooRequestChannelCloseTimerExpired(void *pdata);
/**
* This is a callback function for handling an expired EndSession timer.
* @param pdata Callback data registered at the time of creation of
* the timer.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
int ooSessionTimerExpired(void *pdata);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

1843
addons/ooh323c/src/ooh323.c Normal file

File diff suppressed because it is too large Load Diff

182
addons/ooh323c/src/ooh323.h Normal file
View File

@ -0,0 +1,182 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooh323.h
* This file contains functions to support H.225 messages.
*/
#ifndef _OOH323HDR_H_
#define _OOH323HDR_H_
#include "ooasn1.h"
#include "ootypes.h"
#include "ootrace.h"
#include "ooq931.h"
#include "MULTIMEDIA-SYSTEM-CONTROL.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
struct OOH323CallData;
/**
* @addtogroup q931
* @{
*/
/**
* This function is used to process a received SETUP message.
* @param call Pointer to call for which SETUP message is received.
* @param q931Msg Pointer to the received SETUP message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedSetup
(struct OOH323CallData *call, Q931Message *q931Msg);
/**
* This function is used to process a received CONNECT message.
* It creates H.245 negotiation channel, and starts TCS and MSD
* procedures.
* @param call Pointer to call for which CONNECT message is received.
* @param q931Msg Pointer to the received q931Msg
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedSignalConnect
(struct OOH323CallData* call, Q931Message *q931Msg);
/**
* This function is used to handle received H.2250 messages. It
* calls helper functions based on the type of message received.
* @param call Pointer to the call for which a H.2250 message is received
* @param q931Msg Pointer to the received q931Msg
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooHandleH2250Message
(struct OOH323CallData *call, Q931Message *q931Msg);
/**
* This function is used to process a received Facility message.
* @param call Handle to the call for which message has been received.
* @param pQ931Msg Pointer the the received Facility message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooOnReceivedFacility
(struct OOH323CallData *call, Q931Message * pQ931Msg);
/**
* This function is used to process tunneled H245 messages
* @param call Handle to the call
* @param pH323UUPdu Pointer to the pdu containing tunneled messages.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooHandleTunneledH245Messages(struct OOH323CallData *call,
H225H323_UU_PDU * pH323UUPdu);
/**
* This is a helper function used to handle an startH245 Facility message.
* @param call Handle to the call
* @param facility Pointer to the facility message.
*/
EXTERN int ooHandleStartH245FacilityMessage(struct OOH323CallData *call,
H225Facility_UUIE *facility);
/**
* This function is used to retrieve the aliases from Sequence of alias
* addresses.
* @param call Handle to the call.Null when retrieving registered
* aliases.
* @param pAddresses Pointer to the sequence of alias addresses.
* @param aliasList Handle to alias list to be populated with retrieved
* aliases.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323RetrieveAliases
(struct OOH323CallData *call, H225_SeqOfH225AliasAddress *pAddresses,
OOAliases **aliasList);
/**
* This is a helper function used to populate alias list using aliases.
* @param pctxt Pointer to OOCTXT structure which will be used for memory
* allocations.
* @param pAliases Pointer to aliases to be used for populating list.
* @param pAliasList Pointer to alias list to be populated.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooPopulateAliasList(OOCTXT *pctxt, OOAliases *pAliases,
H225_SeqOfH225AliasAddress *pAliasList);
/**
* This function is used to search a particular alias in the alias list. The
* search can be on the basis of alias type or value or both.
* @param aliasList Handle to the alias list to be searched.
* @param type Type of the alias, if search has to consider type as
* criterion, otherwise 0.
* @param value Value of the alias, if the search has to consider value as
* criterion, NULL otherwise.
*/
EXTERN OOAliases* ooH323GetAliasFromList
(OOAliases *aliasList, int type, char *value);
/**
* This function is used to add a new alias to alias list.
* @param pAliasList Pointer to Alias list.
* @param pctxt Pointer to OOCTXT structure to be used for memory
* allocation.
* @param pAliasAddress New alias address to be added.
*
* @return Handle to newly added alias or NULL in case of failure.
*/
EXTERN OOAliases* ooH323AddAliasToList
(OOAliases **pAliasList, OOCTXT *pctxt, H225AliasAddress *pAliasAddress);
/**
* This function is used to retrieve ip address and port number from an
* H225TransportAddress structure.
* @param call Handle to the associated call.
* @param h225Address Pointer to H225TransportAddress structure
* @param ip Pointer to the buffer in which dotted ip address will
* be returned.
* @param port Pointer to the integer in which port value will be
* returned.
*
* @return OO_OK, on success; OO_FAILED, on failure.
*/
int ooH323GetIpPortFromH225TransportAddress(struct OOH323CallData *call,
H225TransportAddress *h225Address, char *ip, int *port);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,789 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooh323ep.h"
#include "ootrace.h"
#include "ooCalls.h"
#include "ooCapability.h"
#include "ooGkClient.h"
#include "ooStackCmds.h"
#include "ooCmdChannel.h"
/** Global endpoint structure */
ooEndPoint gH323ep;
extern DList g_TimerList;
int ooH323EpInitialize
(enum OOCallMode callMode, const char* tracefile)
{
memset(&gH323ep, 0, sizeof(ooEndPoint));
initContext(&(gH323ep.ctxt));
initContext(&(gH323ep.msgctxt));
if(tracefile)
{
if(strlen(tracefile)>= MAXFILENAME)
{
printf("Error:File name longer than allowed maximum %d\n",
MAXFILENAME-1);
return OO_FAILED;
}
strcpy(gH323ep.traceFile, tracefile);
}
else{
strcpy(gH323ep.traceFile, DEFAULT_TRACEFILE);
}
gH323ep.fptraceFile = fopen(gH323ep.traceFile, "w");
if(gH323ep.fptraceFile == NULL)
{
printf("Error:Failed to open trace file %s for write.\n",
gH323ep.traceFile);
return OO_FAILED;
}
/* Initialize default port ranges that will be used by stack.
Apps can override these by explicitely setting port ranges
*/
gH323ep.tcpPorts.start = TCPPORTSSTART;
gH323ep.tcpPorts.max = TCPPORTSEND;
gH323ep.tcpPorts.current=TCPPORTSSTART;
gH323ep.udpPorts.start = UDPPORTSSTART;
gH323ep.udpPorts.max = UDPPORTSEND;
gH323ep.udpPorts.current = UDPPORTSSTART;
gH323ep.rtpPorts.start = RTPPORTSSTART;
gH323ep.rtpPorts.max = RTPPORTSEND;
gH323ep.rtpPorts.current = RTPPORTSSTART;
OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART);
OO_SETFLAG(gH323ep.flags, OO_M_TUNNELING);
OO_SETFLAG(gH323ep.flags, OO_M_AUTOANSWER);
OO_CLRFLAG(gH323ep.flags, OO_M_GKROUTED);
gH323ep.aliases = NULL;
gH323ep.termType = DEFAULT_TERMTYPE;
gH323ep.t35CountryCode = DEFAULT_T35COUNTRYCODE;
gH323ep.t35Extension = DEFAULT_T35EXTENSION;
gH323ep.manufacturerCode = DEFAULT_MANUFACTURERCODE;
gH323ep.productID = DEFAULT_PRODUCTID;
gH323ep.versionID = OOH323C_VERSION;
gH323ep.callType = T_H225CallType_pointToPoint;
ooGetLocalIPAddress(gH323ep.signallingIP);
gH323ep.listenPort = DEFAULT_H323PORT;
gH323ep.listener = NULL;
ooH323EpSetCallerID(DEFAULT_CALLERID);
gH323ep.myCaps = NULL;
gH323ep.noOfCaps = 0;
gH323ep.callList = NULL;
gH323ep.dtmfmode = 0;
gH323ep.callingPartyNumber[0]='\0';
gH323ep.callMode = callMode;
gH323ep.isGateway = FALSE;
dListInit(&g_TimerList);/* This is for test application chansetup only*/
gH323ep.callEstablishmentTimeout = DEFAULT_CALLESTB_TIMEOUT;
gH323ep.msdTimeout = DEFAULT_MSD_TIMEOUT;
gH323ep.tcsTimeout = DEFAULT_TCS_TIMEOUT;
gH323ep.logicalChannelTimeout = DEFAULT_LOGICALCHAN_TIMEOUT;
gH323ep.sessionTimeout = DEFAULT_ENDSESSION_TIMEOUT;
gH323ep.ifList = NULL;
ooSetTraceThreshold(OOTRCLVLINFO);
OO_SETFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED);
gH323ep.cmdSock = 0;
return OO_OK;
}
EXTERN int ooH323EpSetAsGateway()
{
gH323ep.isGateway = TRUE;
return OO_OK;
}
int ooH323EpSetLocalAddress(const char* localip, int listenport)
{
if(localip)
{
strcpy(gH323ep.signallingIP, localip);
OOTRACEINFO2("Signalling IP address is set to %s\n", localip);
}
if(listenport)
{
gH323ep.listenPort = listenport;
OOTRACEINFO2("Listen port number is set to %d\n", listenport);
}
return OO_OK;
}
int ooH323EpAddAliasH323ID(const char *h323id)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
OOTRACEERR1("Error: Failed to allocate memory for new H323-ID alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_h323_ID;
psNewAlias->registered = FALSE;
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(h323id)+1);
if(!psNewAlias->value)
{
OOTRACEERR1("Error: Failed to allocate memory for the new H323-ID alias "
"value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
strcpy(psNewAlias->value, h323id);
psNewAlias->next = gH323ep.aliases;
gH323ep.aliases = psNewAlias;
OOTRACEDBGA2("Added alias: H323ID - %s\n", h323id);
return OO_OK;
}
int ooH323EpAddAliasDialedDigits(const char* dialedDigits)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
OOTRACEERR1("Error: Failed to allocate memory for new DialedDigits "
"alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_dialedDigits;
psNewAlias->registered = FALSE;
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(dialedDigits)+1);
if(!psNewAlias->value)
{
OOTRACEERR1("Error: Failed to allocate memory for the new DialedDigits"
" alias value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
strcpy(psNewAlias->value, dialedDigits);
psNewAlias->next = gH323ep.aliases;
gH323ep.aliases = psNewAlias;
OOTRACEDBGA2("Added alias: DialedDigits - %s\n", dialedDigits);
return OO_OK;
}
int ooH323EpAddAliasURLID(const char * url)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
OOTRACEERR1("Error: Failed to allocate memory for new URL-ID alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_url_ID;
psNewAlias->registered = FALSE;
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(url)+1);
if(!psNewAlias->value)
{
OOTRACEERR1("Error: Failed to allocate memory for the new URL-ID alias"
" value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
strcpy(psNewAlias->value, url);
psNewAlias->next = gH323ep.aliases;
gH323ep.aliases = psNewAlias;
OOTRACEDBGA2("Added alias: URL-ID - %s\n", url);
return OO_OK;
}
int ooH323EpAddAliasEmailID(const char * email)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
OOTRACEERR1("Error: Failed to allocate memory for new Email-ID alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_email_ID;
psNewAlias->registered = FALSE;
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(email)+1);
if(!psNewAlias->value)
{
OOTRACEERR1("Error: Failed to allocate memory for the new Email-ID alias"
" value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
strcpy(psNewAlias->value, email);
psNewAlias->next = gH323ep.aliases;
gH323ep.aliases = psNewAlias;
OOTRACEDBGA2("Added alias: Email-ID - %s\n", email);
return OO_OK;
}
int ooH323EpAddAliasTransportID(const char * ipaddress)
{
ooAliases * psNewAlias=NULL;
psNewAlias = (ooAliases*)memAlloc(&gH323ep.ctxt, sizeof(ooAliases));
if(!psNewAlias)
{
OOTRACEERR1("Error: Failed to allocate memory for new Transport-ID "
"alias\n");
return OO_FAILED;
}
psNewAlias->type = T_H225AliasAddress_transportID;
psNewAlias->registered = FALSE;
psNewAlias->value = (char*) memAlloc(&gH323ep.ctxt, strlen(ipaddress)+1);
if(!psNewAlias->value)
{
OOTRACEERR1("Error: Failed to allocate memory for the new Transport-ID "
"alias value\n");
memFreePtr(&gH323ep.ctxt, psNewAlias);
return OO_FAILED;
}
strcpy(psNewAlias->value, ipaddress);
psNewAlias->next = gH323ep.aliases;
gH323ep.aliases = psNewAlias;
OOTRACEDBGA2("Added alias: Transport-ID - %s\n", ipaddress);
return OO_OK;
}
int ooH323EpClearAllAliases(void)
{
ooAliases *pAlias = NULL, *pTemp;
if(gH323ep.aliases)
{
pAlias = gH323ep.aliases;
while(pAlias)
{
pTemp = pAlias;
pAlias = pAlias->next;
memFreePtr(&gH323ep.ctxt, pTemp);
}
gH323ep.aliases = NULL;
}
return OO_OK;
}
int ooH323EpSetH225MsgCallbacks(OOH225MsgCallbacks h225Callbacks)
{
gH323ep.h225Callbacks.onReceivedSetup = h225Callbacks.onReceivedSetup;
gH323ep.h225Callbacks.onReceivedConnect = h225Callbacks.onReceivedConnect;
gH323ep.h225Callbacks.onBuiltSetup = h225Callbacks.onBuiltSetup;
gH323ep.h225Callbacks.onBuiltConnect = h225Callbacks.onBuiltConnect;
return OO_OK;
}
int ooH323EpSetH323Callbacks(OOH323CALLBACKS h323Callbacks)
{
gH323ep.h323Callbacks.onNewCallCreated = h323Callbacks.onNewCallCreated;
gH323ep.h323Callbacks.onAlerting = h323Callbacks.onAlerting;
gH323ep.h323Callbacks.onIncomingCall = h323Callbacks.onIncomingCall;
gH323ep.h323Callbacks.onOutgoingCall = h323Callbacks.onOutgoingCall;
gH323ep.h323Callbacks.onCallEstablished = h323Callbacks.onCallEstablished;
gH323ep.h323Callbacks.onCallForwarded = h323Callbacks.onCallForwarded;
gH323ep.h323Callbacks.onCallCleared = h323Callbacks.onCallCleared;
gH323ep.h323Callbacks.openLogicalChannels = h323Callbacks.openLogicalChannels;
gH323ep.h323Callbacks.onReceivedDTMF = h323Callbacks.onReceivedDTMF;
return OO_OK;
}
int ooH323EpDestroy(void)
{
/* free any internal memory allocated
close trace file free context structure
*/
OOH323CallData * cur, *temp;
if(OO_TESTFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED))
{
OOTRACEINFO1("Destroying H323 Endpoint\n");
if(gH323ep.callList)
{
cur = gH323ep.callList;
while(cur)
{
temp = cur;
cur = cur->next;
temp->callEndReason = OO_REASON_LOCAL_CLEARED;
ooCleanCall(temp);
}
gH323ep.callList = NULL;
}
if(gH323ep.listener)
{
ooSocketClose(*(gH323ep.listener));
gH323ep.listener = NULL;
}
ooGkClientDestroy();
if(gH323ep.fptraceFile)
{
fclose(gH323ep.fptraceFile);
gH323ep.fptraceFile = NULL;
}
freeContext(&(gH323ep.ctxt));
OO_CLRFLAG(gH323ep.flags, OO_M_ENDPOINTCREATED);
}
return OO_OK;
}
int ooH323EpEnableGkRouted(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_GKROUTED);
return OO_OK;
}
int ooH323EpDisableGkRouted(void)
{
OO_CLRFLAG(gH323ep.flags, OO_M_GKROUTED);
return OO_OK;
}
int ooH323EpEnableAutoAnswer(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_AUTOANSWER);
return OO_OK;
}
int ooH323EpDisableAutoAnswer(void)
{
OO_CLRFLAG(gH323ep.flags, OO_M_AUTOANSWER);
return OO_OK;
}
int ooH323EpEnableManualRingback(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_MANUALRINGBACK);
return OO_OK;
}
int ooH323EpDisableManualRingback(void)
{
OO_CLRFLAG(gH323ep.flags, OO_M_MANUALRINGBACK);
return OO_OK;
}
int ooH323EpEnableMediaWaitForConnect(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN);
return OO_OK;
}
int ooH323EpDisableMediaWaitForConnect(void)
{
OO_CLRFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN);
return OO_OK;
}
int ooH323EpEnableFastStart(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_FASTSTART);
return OO_OK;
}
int ooH323EpDisableFastStart(void)
{
OO_CLRFLAG(gH323ep.flags, OO_M_FASTSTART);
return OO_OK;
}
int ooH323EpEnableH245Tunneling(void)
{
OO_SETFLAG(gH323ep.flags, OO_M_TUNNELING);
return OO_OK;
}
int ooH323EpDisableH245Tunneling(void)
{
OO_CLRFLAG(gH323ep.flags, OO_M_TUNNELING);
return OO_OK;
}
int ooH323EpSetTermType(int value)
{
gH323ep.termType = value;
return OO_OK;
}
int ooH323EpSetProductID (const char* productID)
{
if (0 != productID) {
char* pstr = (char*) memAlloc (&gH323ep.ctxt, strlen(productID)+1);
strcpy (pstr, productID);
if(gH323ep.productID)
memFreePtr(&gH323ep.ctxt, gH323ep.productID);
gH323ep.productID = pstr;
return OO_OK;
}
else return OO_FAILED;
}
int ooH323EpSetVersionID (const char* versionID)
{
if (0 != versionID) {
char* pstr = (char*) memAlloc (&gH323ep.ctxt, strlen(versionID)+1);
strcpy (pstr, versionID);
if(gH323ep.versionID)
memFreePtr(&gH323ep.ctxt, gH323ep.versionID);
gH323ep.versionID = pstr;
return OO_OK;
}
else return OO_FAILED;
}
int ooH323EpSetCallerID (const char* callerID)
{
if (0 != callerID) {
char* pstr = (char*) memAlloc (&gH323ep.ctxt, strlen(callerID)+1);
strcpy (pstr, callerID);
if(gH323ep.callerid)
memFreePtr(&gH323ep.ctxt, gH323ep.callerid);
gH323ep.callerid = pstr;
return OO_OK;
}
else return OO_FAILED;
}
int ooH323EpSetCallingPartyNumber(const char* number)
{
int ret=OO_OK;
if(number)
{
strncpy(gH323ep.callingPartyNumber, number,
sizeof(gH323ep.callingPartyNumber)-1);
ret = ooH323EpAddAliasDialedDigits((char*)number);
return ret;
}
else return OO_FAILED;
}
int ooH323EpSetTraceLevel(int traceLevel)
{
ooSetTraceThreshold(traceLevel);
return OO_OK;
}
void ooH323EpPrintConfig(void)
{
OOTRACEINFO1("H.323 Endpoint Configuration is as follows:\n");
OOTRACEINFO2("\tTrace File: %s\n", gH323ep.traceFile);
if(!OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART))
{
OOTRACEINFO1("\tFastStart - disabled\n");
}
else{
OOTRACEINFO1("\tFastStart - enabled\n");
}
if(!OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING))
{
OOTRACEINFO1("\tH245 Tunneling - disabled\n");
}
else{
OOTRACEINFO1("\tH245 Tunneling - enabled\n");
}
if(!OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN))
{
OOTRACEINFO1("\tMediaWaitForConnect - disabled\n");
}
else{
OOTRACEINFO1("\tMediaWaitForConnect - enabled\n");
}
if(OO_TESTFLAG(gH323ep.flags, OO_M_AUTOANSWER))
OOTRACEINFO1("\tAutoAnswer - enabled\n");
else
OOTRACEINFO1("\tAutoAnswer - disabled\n");
OOTRACEINFO2("\tTerminal Type - %d\n", gH323ep.termType);
OOTRACEINFO2("\tT35 CountryCode - %d\n", gH323ep.t35CountryCode);
OOTRACEINFO2("\tT35 Extension - %d\n", gH323ep.t35Extension);
OOTRACEINFO2("\tManufacturer Code - %d\n", gH323ep.manufacturerCode);
OOTRACEINFO2("\tProductID - %s\n", gH323ep.productID);
OOTRACEINFO2("\tVersionID - %s\n", gH323ep.versionID);
OOTRACEINFO2("\tLocal signalling IP address - %s\n", gH323ep.signallingIP);
OOTRACEINFO2("\tH225 ListenPort - %d\n", gH323ep.listenPort);
OOTRACEINFO2("\tCallerID - %s\n", gH323ep.callerid);
OOTRACEINFO2("\tCall Establishment Timeout - %d seconds\n",
gH323ep.callEstablishmentTimeout);
OOTRACEINFO2("\tMasterSlaveDetermination Timeout - %d seconds\n",
gH323ep.msdTimeout);
OOTRACEINFO2("\tTerminalCapabilityExchange Timeout - %d seconds\n",
gH323ep.tcsTimeout);
OOTRACEINFO2("\tLogicalChannel Timeout - %d seconds\n",
gH323ep.logicalChannelTimeout);
OOTRACEINFO2("\tSession Timeout - %d seconds\n", gH323ep.sessionTimeout);
return;
}
int ooH323EpAddG711Capability(int cap, int txframes, int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
int ooH323EpAddG728Capability(int cap, int txframes, int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
int ooH323EpAddG729Capability(int cap, int txframes, int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, FALSE,
dir, startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel, FALSE);
}
int ooH323EpAddG7231Capability(int cap, int txframes, int rxframes,
OOBOOL silenceSuppression, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes,
silenceSuppression, dir, startReceiveChannel,
startTransmitChannel, stopReceiveChannel,
stopTransmitChannel, FALSE);
}
int ooH323EpAddGSMCapability(int cap, ASN1USINT framesPerPkt,
OOBOOL comfortNoise, OOBOOL scrambled, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddGSMCapability(NULL, cap, framesPerPkt, comfortNoise,
scrambled, dir, startReceiveChannel,
startTransmitChannel, stopReceiveChannel,
stopTransmitChannel, FALSE);
}
int ooH323EpAddH263VideoCapability(int cap, unsigned sqcifMPI,
unsigned qcifMPI, unsigned cifMPI,
unsigned cif4MPI, unsigned cif16MPI,
unsigned maxBitRate, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel)
{
return ooCapabilityAddH263VideoCapability(NULL, sqcifMPI, qcifMPI, cifMPI,
cif4MPI, cif16MPI, maxBitRate,dir,
startReceiveChannel, startTransmitChannel,
stopReceiveChannel, stopTransmitChannel,
FALSE);
}
int ooH323EpEnableDTMFRFC2833(int dynamicRTPPayloadType)
{
return ooCapabilityEnableDTMFRFC2833(NULL, dynamicRTPPayloadType);
}
int ooH323EpDisableDTMFRFC2833(void)
{
return ooCapabilityDisableDTMFRFC2833(NULL);
}
int ooH323EpEnableDTMFH245Alphanumeric()
{
return ooCapabilityEnableDTMFH245Alphanumeric(NULL);
}
int ooH323EpDisableDTMFH245Alphanumeric()
{
return ooCapabilityDisableDTMFH245Alphanumeric(NULL);
}
int ooH323EpEnableDTMFH245Signal()
{
return ooCapabilityEnableDTMFH245Signal(NULL);
}
int ooH323EpDisableDTMFH245Signal()
{
return ooCapabilityDisableDTMFH245Signal(NULL);
}
int ooH323EpEnableDTMFQ931Keypad()
{
return ooCapabilityEnableDTMFQ931Keypad(NULL);
}
int ooH323EpDisableDTMFQ931Keypad()
{
return ooCapabilityDisableDTMFQ931Keypad(NULL);
}
int ooH323EpSetGkClientCallbacks(OOGKCLIENTCALLBACKS gkClientCallbacks)
{
if(gH323ep.gkClient)
{
return ooGkClientSetCallbacks(gH323ep.gkClient, gkClientCallbacks);
}
else{
OOTRACEERR1("Error:Gk Client hasn't been initialized yet\n");
return OO_FAILED;
}
}
/* 0-1024 are reserved for well known services */
int ooH323EpSetTCPPortRange(int base, int max)
{
if(base <= 1024)
gH323ep.tcpPorts.start = 1025;
else
gH323ep.tcpPorts.start = base;
if(max > 65500)
gH323ep.tcpPorts.max = 65500;
else
gH323ep.tcpPorts.max = max;
if(gH323ep.tcpPorts.max<gH323ep.tcpPorts.start)
{
OOTRACEERR1("Error: Failed to set tcp ports- "
"Max port number less than Start port number\n");
return OO_FAILED;
}
gH323ep.tcpPorts.current = gH323ep.tcpPorts.start;
OOTRACEINFO1("TCP port range initialize - successful\n");
return OO_OK;
}
int ooH323EpSetUDPPortRange(int base, int max)
{
if(base <= 1024)
gH323ep.udpPorts.start = 1025;
else
gH323ep.udpPorts.start = base;
if(max > 65500)
gH323ep.udpPorts.max = 65500;
else
gH323ep.udpPorts.max = max;
if(gH323ep.udpPorts.max<gH323ep.udpPorts.start)
{
OOTRACEERR1("Error: Failed to set udp ports- Max port number"
" less than Start port number\n");
return OO_FAILED;
}
gH323ep.udpPorts.current = gH323ep.udpPorts.start;
OOTRACEINFO1("UDP port range initialize - successful\n");
return OO_OK;
}
int ooH323EpSetRTPPortRange(int base, int max)
{
if(base <= 1024)
gH323ep.rtpPorts.start = 1025;
else
gH323ep.rtpPorts.start = base;
if(max > 65500)
gH323ep.rtpPorts.max = 65500;
else
gH323ep.rtpPorts.max = max;
if(gH323ep.rtpPorts.max<gH323ep.rtpPorts.start)
{
OOTRACEERR1("Error: Failed to set rtp ports- Max port number"
" less than Start port number\n");
return OO_FAILED;
}
gH323ep.rtpPorts.current = gH323ep.rtpPorts.start;
OOTRACEINFO1("RTP port range initialize - successful\n");
return OO_OK;
}

View File

@ -0,0 +1,634 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooh323ep.h
* This file contains H323 endpoint related functions.
*/
#ifndef OO_H323EP_H_
#define OO_H323EP_H_
#include "ooCapability.h"
#include "ooCalls.h"
#include "ooGkClient.h"
#include "ooports.h"
#include "ooq931.h"
#define DEFAULT_TRACEFILE "trace.log"
#define DEFAULT_TERMTYPE 50
#define DEFAULT_PRODUCTID "objsys"
#define DEFAULT_CALLERID "objsyscall"
#define DEFAULT_T35COUNTRYCODE 1
#define DEFAULT_T35EXTENSION 0
#define DEFAULT_MANUFACTURERCODE 71
#define DEFAULT_H245CONNECTION_RETRYTIMEOUT 2
#define DEFAULT_CALLESTB_TIMEOUT 60
#define DEFAULT_MSD_TIMEOUT 30
#define DEFAULT_TCS_TIMEOUT 30
#define DEFAULT_LOGICALCHAN_TIMEOUT 30
#define DEFAULT_ENDSESSION_TIMEOUT 15
#define DEFAULT_H323PORT 1720
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
struct OOCapPrefs;
/**
* @defgroup h323ep H323 Endpoint management functions
* @{
*/
/* Default port ranges */
#define TCPPORTSSTART 12030 /*!< Starting TCP port number */
#define TCPPORTSEND 12230 /*!< Ending TCP port number */
#define UDPPORTSSTART 13030 /*!< Starting UDP port number */
#define UDPPORTSEND 13230 /*!< Ending UDP port number */
#define RTPPORTSSTART 14030 /*!< Starting RTP port number */
#define RTPPORTSEND 14230 /*!< Ending RTP port number */
/**
* This structure is used to define the port ranges to be used
* by the application.
*/
typedef struct OOH323Ports {
int start; /*!< Starting port number. */
int max; /*!< Maximum port number. */
int current; /*!< Current port number. */
} OOH323Ports;
/**
* Structure to store all configuration information related to the
* endpoint created by an application
*/
typedef struct OOH323EndPoint {
/**
* This context should be used for allocation of memory for
* items within the endpoint structure.
*/
OOCTXT ctxt;
/**
* This context should be used for allocation of memory for
* message structures.
*/
OOCTXT msgctxt;
char traceFile[MAXFILENAME];
FILE * fptraceFile;
/** Range of port numbers to be used for TCP connections */
OOH323Ports tcpPorts;
/** Range of port numbers to be used for UDP connections */
OOH323Ports udpPorts;
/** Range of port numbers to be used for RTP connections */
OOH323Ports rtpPorts;
ASN1UINT flags;
int termType; /* 50 - Terminal entity with No MC,
60 - Gateway entity with no MC,
70 - Terminal Entity with MC, but no MP etc.*/
int t35CountryCode;
int t35Extension;
int manufacturerCode;
const char *productID;
const char *versionID;
const char *callerid;
char callingPartyNumber[50];
OOSOCKET *stackSocket;
OOAliases *aliases;
int callType;
struct ooH323EpCapability *myCaps;
OOCapPrefs capPrefs;
int noOfCaps;
OOH225MsgCallbacks h225Callbacks;
OOH323CALLBACKS h323Callbacks;
char signallingIP[20];
int listenPort;
OOSOCKET *listener;
OOH323CallData *callList;
OOCallMode callMode; /* audio/audiorx/audiotx/video/fax */
int dtmfmode;
ASN1UINT callEstablishmentTimeout;
ASN1UINT msdTimeout;
ASN1UINT tcsTimeout;
ASN1UINT logicalChannelTimeout;
ASN1UINT sessionTimeout;
int cmdPipe[2];
struct ooGkClient *gkClient;
OOInterface *ifList; /* interface list for the host we are running on*/
OOBOOL isGateway;
OOSOCKET cmdSock;
} OOH323EndPoint;
#define ooEndPoint OOH323EndPoint
/**
* This function is the first function to be invoked before using stack. It
* initializes the H323 Endpoint.
* @param callMode Type of calls to be made(audio/video/fax).
* (OO_CALLMODE_AUDIO, OO_CALLMODE_VIDEO)
* @param tracefile Trace file name.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooH323EpInitialize
(enum OOCallMode callMode, const char* tracefile);
/**
* This function is used to represent the H.323 application endpoint as
* gateway, instead of an H.323 phone endpoint.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetAsGateway();
/**
* This function is used to assign a local ip address to be used for call
* signalling.
* @param localip Dotted IP address to be used for call signalling.
* @param listenport Port to be used for listening for incoming calls.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetLocalAddress(const char* localip, int listenport);
/**
* This function is used to set the range of tcp ports the application will
* use for tcp transport.
* @param base Starting port number for the range
* @param max Ending port number for the range.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetTCPPortRange(int base, int max);
/**
* This function is used to set the range of udp ports the application will
* use for udp transport.
* @param base Starting port number for the range
* @param max Ending port number for the range.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetUDPPortRange(int base, int max);
/**
* This function is used to set the range of rtp ports the application will
* use for media streams.
* @param base Starting port number for the range
* @param max Ending port number for the range.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetRTPPortRange(int base, int max);
/**
* This function is used to set the trace level for the H.323 endpoint.
* @param traceLevel Level of tracing.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/
EXTERN int ooH323EpSetTraceLevel(int traceLevel);
/**
* This function is used to add the h323id alias for the endpoint.
* @param h323id H323-ID to be set as alias.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddAliasH323ID(const char* h323id);
/**
* This function is used to add the dialed digits alias for the
* endpoint.
* @param dialedDigits Dialed-Digits to be set as alias.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddAliasDialedDigits(const char* dialedDigits);
/**
* This function is used to add the url alias for the endpoint.
* @param url URL to be set as an alias.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddAliasURLID(const char* url);
/**
* This function is used to add an email id as an alias for the endpoint.
* @param email Email id to be set as an alias.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddAliasEmailID(const char* email);
/**
* This function is used to add an ip address as an alias.
* @param ipaddress IP address to be set as an alias.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddAliasTransportID(const char* ipaddress);
/**
* This function is used to clear all the aliases used by the
* H323 endpoint.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpClearAllAliases(void);
/**
* This function is used to set the H225 message callbacks for the
* endpoint.
* @param h225Callbacks Callback structure containing various callbacks.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetH225MsgCallbacks(OOH225MsgCallbacks h225Callbacks);
/**
* This function is used to set high level H.323 callbacks for the endpoint.
* Make sure all unused callbacks in the structure are set to NULL before
* calling this function.
* @param h323Callbacks Callback structure containing various high level
* callbacks.
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooH323EpSetH323Callbacks(OOH323CALLBACKS h323Callbacks);
/**
* This function is the last function to be invoked after done using the
* stack. It closes the H323 Endpoint for an application, releasing all
* the associated memory.
*
* @return OO_OK on success
* OO_FAILED on failure
*/
EXTERN int ooH323EpDestroy(void);
/**
* This function is used to enable the auto answer feature for
* incoming calls
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpEnableAutoAnswer(void);
/**
* This function is used to disable the auto answer feature for
* incoming calls.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpDisableAutoAnswer(void);
/**
* This function is used to enable manual ringback. By default the stack sends
* alerting message automatically on behalf of the endpoint application.
* However, if endpoint application wants to do alerting user part first before
* sending out alerting message, it can enable this feature.
*
* @return OO_OK on success, OO_FAILED on failure
*/
EXTERN int ooH323EpEnableManualRingback(void);
/**
* This function is used to disable manual ringback. By default the
* manual ringback feature is disabled, i.e, the stack sends alerting on behalf
* of the application automatically.
*
* @return OO_OK on success, OO_FAILED on failure
*/
EXTERN int ooH323EpDisableManualRingback(void);
/**
* This function is used to enable MediaWaitForConnect.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpDisableMediaWaitForConnect(void);
/**
* This function is used to disable MediaWaitForConnect.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpDisableMediaWaitForConnect(void);
/**
* This function is used to enable faststart.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpEnableFastStart(void);
/**
* This function is used to disable faststart.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpDisableFastStart(void);
/**
* This function is used to enable tunneling.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpEnableH245Tunneling(void);
/**
* This function is used to disable tunneling.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpDisableH245Tunneling(void);
/**
* This function is used to enable GkRouted calls.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpEnableGkRouted(void);
/**
* This function is used to disable Gkrouted calls.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpDisableGkRouted(void);
/**
* This function is used to set the product ID.
* @param productID New value for the product id.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetProductID (const char * productID);
/**
* This function is used to set version id.
* @param versionID New value for the version id.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetVersionID (const char * versionID);
/**
* This function is used to set callerid to be used for outbound
* calls.
* @param callerID New value for the caller id.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetCallerID (const char * callerID);
/**
* This function is used to set calling party number to be used for outbound
* calls.Note, you can override it for a specific call by using
* ooCallSetCallingPartyNumber function.
* @param number e164 number to be used as calling party number.
*
* @return OO_OK, on success; OO_FAILED, otherwise.
*/
EXTERN int ooH323EpSetCallingPartyNumber(const char * number);
/**
* This function is used to print the current configuration information of
* the H323 endpoint to log file.
*/
void ooH323EpPrintConfig(void);
/**
* This function is used to add G728 capability to the H323 endpoint.
* @param cap Type of G728 capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddG728Capability
(int cap, int txframes, int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add G729 capability to the H323 endpoint.
* @param cap Type of G729 capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddG729Capability
(int cap, int txframes, int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add G7231 capability to the H323 endpoint.
* @param cap Type of G7231 capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param silenceSuppression Silence Suppression support
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddG7231Capability(int cap, int txframes, int rxframes,
OOBOOL silenceSuppression, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add G711 capability to the H323 endpoint.
* @param cap Type of G711 capability to be added.
* @param txframes Number of frames per packet for transmission.
* @param rxframes Number of frames per packet for reception.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddG711Capability
(int cap, int txframes, int rxframes, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add a new GSM capability to the endpoint.
* @param cap Type of GSM capability to be added.
* @param framesPerPkt Number of GSM frames pre packet.
* @param comfortNoise Comfort noise spec for the capability.
* @param scrambled Scrambled enabled/disabled for the capability.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddGSMCapability(int cap, ASN1USINT framesPerPkt,
OOBOOL comfortNoise,OOBOOL scrambled,int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to add H263 video capability to the H323 endpoint.
* @param cap Capability type - OO_H263VIDEO
* @param sqcifMPI Minimum picture interval for encoding/decoding
* of SQCIF pictures.
* @param qcifMPI Minimum picture interval for encoding/decoding
* of QCIF pictures.
* @param cifMPI Minimum picture interval for encoding/decoding
* of CIF pictures.
* @param cif4MPI Minimum picture interval for encoding/decoding
* of CIF4 pictures.
* @param cif16MPI Minimum picture interval for encoding/decoding
* of CIF16 pictures.
* @param maxBitRate Maximum bit rate in units of 100 bits/s at
* which a transmitter can transmit video or a
* receiver can receive video.
* @param dir Direction of capability.OORX, OOTX, OORXANDTX
* @param startReceiveChannel Callback function to start receive channel.
* @param startTransmitChannel Callback function to start transmit channel.
* @param stopReceiveChannel Callback function to stop receive channel.
* @param stopTransmitChannel Callback function to stop transmit channel.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpAddH263VideoCapability(int cap, unsigned sqcifMPI,
unsigned qcifMPI, unsigned cifMPI,
unsigned cif4MPI, unsigned cif16MPI,
unsigned maxBitRate, int dir,
cb_StartReceiveChannel startReceiveChannel,
cb_StartTransmitChannel startTransmitChannel,
cb_StopReceiveChannel stopReceiveChannel,
cb_StopTransmitChannel stopTransmitChannel);
/**
* This function is used to enable rfc 2833 support for the endpoint.
* @param dynamicRTPPayloadType Payload type value to use.
*
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooH323EpEnableDTMFRFC2833(int dynamicRTPPayloadType);
/**
* This function is used to disable rfc 2833 support for the endpoint.
*
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooH323EpDisableDTMFRFC2833(void);
/**
* This function is used to enable the H245(alphanumeric) dtmf capability for
* the endpoint.
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooH323EpEnableDTMFH245Alphanumeric();
/**
* This function is used to disable the H245(alphanumeric) dtmf capability for
* the endpoint.
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooH323EpDisableDTMFH245Alphanumeric();
/**
* This function is used to enable the H245(signal) dtmf capability for
* the endpoint.
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooH323EpEnableDTMFH245Signal();
/**
* This function is used to disable the H245(signal) dtmf capability for
* the endpoint.
* @return OO_OK, on success; OO_FAILED, on failure
*/
EXTERN int ooH323EpDisableDTMFH245Signal();
/**
* This function is used to add callbacks to the gatekeeper client. If user
* application wants to do some special processing of various gatekeeper client
* events, that can be done through these callbacks.
* @param gkClientCallbacks Handle to the callback structure.Make sure all
* the members of the structure are appropriately
* initialized.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323EpSetGkClientCallbacks(OOGKCLIENTCALLBACKS gkClientCallbacks);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,15 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#ifndef _OOPER_H_
#define _OOPER_H_
#endif

View File

@ -0,0 +1,106 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooports.h"
#include "ooh323ep.h"
#include "ootrace.h"
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
/* Get the next port of type TCP/UDP/RTP */
int ooGetNextPort (OOH323PortType type)
{
if(type==OOTCP)
{
if(gH323ep.tcpPorts.current <= gH323ep.tcpPorts.max)
return gH323ep.tcpPorts.current++;
else
{
gH323ep.tcpPorts.current = gH323ep.tcpPorts.start;
return gH323ep.tcpPorts.current++;
}
}
if(type==OOUDP)
{
if(gH323ep.udpPorts.current <= gH323ep.udpPorts.max)
return gH323ep.udpPorts.current++;
else
{
gH323ep.udpPorts.current = gH323ep.udpPorts.start;
return gH323ep.udpPorts.current++;
}
}
if(type==OORTP)
{
if(gH323ep.rtpPorts.current <= gH323ep.rtpPorts.max)
return gH323ep.rtpPorts.current++;
else
{
gH323ep.rtpPorts.current = gH323ep.rtpPorts.start;
return gH323ep.rtpPorts.current++;
}
}
return OO_FAILED;
}
int ooBindPort (OOH323PortType type, OOSOCKET socket, char *ip)
{
int initialPort, bindPort, ret;
OOIPADDR ipAddrs;
initialPort = ooGetNextPort (type);
bindPort = initialPort;
ret= ooSocketStrToAddr (ip, &ipAddrs);
while(1)
{
if((ret=ooSocketBind(socket, ipAddrs, bindPort))==0)
{
return bindPort;
}
else
{
bindPort = ooGetNextPort (type);
if (bindPort == initialPort) return OO_FAILED;
}
}
}
#ifdef _WIN32
int ooBindOSAllocatedPort(OOSOCKET socket, char *ip)
{
OOIPADDR ipAddrs;
int size, ret;
struct sockaddr_in name;
size = sizeof(struct sockaddr_in);
ret= ooSocketStrToAddr (ip, &ipAddrs);
if((ret=ooSocketBind(socket, ipAddrs,
0))==ASN_OK)
{
ret = ooSocketGetSockName(socket, &name, &size);
if(ret == ASN_OK)
{
return name.sin_port;
}
}
return OO_FAILED;
}
#endif

View File

@ -0,0 +1,91 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooports.h
* This file contains functions to manage ports used by the stack.
*/
#ifndef _OOPORTS_H_
#define _OOPORTS_H_
#include "ootypes.h"
typedef enum OOH323PortType {
OOTCP, OOUDP, OORTP
} OOH323PortType;
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* Get the next port of type TCP/UDP/RTP from the corresponding range.
* When max value for the range is reached, it starts again from the
* first port number of the range.
*
* @param ep Reference to the H323 Endpoint structure.
* @param type Type of the port to be retrieved(OOTCP/OOUDP/OORTP).
*
* @return The next port number for the specified type is returned.
*/
EXTERN int ooGetNextPort (OOH323PortType type);
/**
* Bind socket to a port within the port range specified by the
* application at the startup.
*
* @param ep Reference to H323 Endpoint structure.
* @param type Type of the port required for the socket.
* @param socket The socket to be bound.
* @param ip Dotted Ip address to bind to.
*
* @return In case of success returns the port number to which
* socket is bound and in case of failure just returns
* a negative value.
*/
EXTERN int ooBindPort (OOH323PortType type, OOSOCKET socket, char *ip);
/**
* This function is supported for windows version only.
* Windows sockets have problem in reusing the addresses even after
* setting SO_REUSEADDR, hence in windows we just allow os to bind
* to any random port.
* @param socket Socket to be bound.
* @param ip Dotted ip address to bind to.
*
* @return In case of success returns the port number to which
* socket is bound and in case of failure just returns
* a negative value.
*/
#ifdef _WIN32
EXTERN int ooBindOSAllocatedPort(OOSOCKET socket, char *ip);
#endif
#ifdef __cplusplus
}
#endif
#endif

3448
addons/ooh323c/src/ooq931.c Normal file

File diff suppressed because it is too large Load Diff

766
addons/ooh323c/src/ooq931.h Normal file
View File

@ -0,0 +1,766 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ooq931.h
* This file contains functions to support call signalling.
*/
#ifndef _OOQ931HDR_H_
#define _OOQ931HDR_H_
#include "ooasn1.h"
#include "ootypes.h"
#include "H323-MESSAGES.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* @defgroup q931 Q.931/H.2250 Message Handling
* @{
*/
/* Maximum length of the Calling/Called party number number */
#define OO_MAX_NUMBER_LENGTH 50
/* Maximum value for a call token identifier */
#define OO_MAX_CALL_TOKEN 9999
/* Q.931 packet must be at least 5 bytes long */
#define Q931_E_TOOSHORT (-1001)
/* callReference field must be 2 bytes long */
#define Q931_E_INVCALLREF (-1002)
/* invalid length of message */
#define Q931_E_INVLENGTH (-1003)
enum Q931MsgTypes {
Q931NationalEscapeMsg = 0x00,
Q931AlertingMsg = 0x01,
Q931CallProceedingMsg = 0x02,
Q931ConnectMsg = 0x07,
Q931ConnectAckMsg = 0x0f,
Q931ProgressMsg = 0x03,
Q931SetupMsg = 0x05,
Q931SetupAckMsg = 0x0d,
Q931ResumeMsg = 0x26,
Q931ResumeAckMsg = 0x2e,
Q931ResumeRejectMsg = 0x22,
Q931SuspendMsg = 0x25,
Q931SuspendAckMsg = 0x2d,
Q931SuspendRejectMsg = 0x21,
Q931UserInformationMsg = 0x20,
Q931DisconnectMsg = 0x45,
Q931ReleaseMsg = 0x4d,
Q931ReleaseCompleteMsg = 0x5a,
Q931RestartMsg = 0x46,
Q931RestartAckMsg = 0x4e,
Q931SegmentMsg = 0x60,
Q931CongestionCtrlMsg = 0x79,
Q931InformationMsg = 0x7b,
Q931NotifyMsg = 0x6e,
Q931StatusMsg = 0x7d,
Q931StatusEnquiryMsg = 0x75,
Q931FacilityMsg = 0x62
};
enum Q931IECodes {
Q931BearerCapabilityIE = 0x04,
Q931CauseIE = 0x08,
Q931FacilityIE = 0x1c,
Q931ProgressIndicatorIE = 0x1e,
Q931CallStateIE = 0x14,
Q931DisplayIE = 0x28,
Q931SignalIE = 0x34,
Q931CallingPartyNumberIE = 0x6c,
Q931CalledPartyNumberIE = 0x70,
Q931RedirectingNumberIE = 0x74,
Q931UserUserIE = 0x7e,
Q931KeypadIE = 0x2c
};
enum Q931InformationTransferCapability {
Q931TransferSpeech,
Q931TransferUnrestrictedDigital = 8,
Q931TransferRestrictedDigital = 9,
Q931Transfer3_1kHzAudio = 16,
Q931TrasnferUnrestrictedDigitalWithTones = 17,
Q931TransferVideo = 24
};
enum Q931CauseValues {
Q931UnallocatedNumber = 0x01,
Q931NoRouteToNetwork = 0x02,
Q931NoRouteToDestination = 0x03,
Q931ChannelUnacceptable = 0x06,
Q931NormalCallClearing = 0x10,
Q931UserBusy = 0x11,
Q931NoResponse = 0x12,
Q931NoAnswer = 0x13,
Q931SubscriberAbsent = 0x14,
Q931CallRejected = 0x15,
Q931NumberChanged = 0x16,
Q931Redirection = 0x17,
Q931DestinationOutOfOrder = 0x1b,
Q931InvalidNumberFormat = 0x1c,
Q931NormalUnspecified = 0x1f,
Q931StatusEnquiryResponse = 0x1e,
Q931NoCircuitChannelAvailable = 0x22,
Q931NetworkOutOfOrder = 0x26,
Q931TemporaryFailure = 0x29,
Q931Congestion = 0x2a,
Q931RequestedCircuitUnAvailable = 0x2c,
Q931ResourcesUnavailable = 0x2f,
Q931IncompatibleDestination = 0x58,
Q931ProtocolErrorUnspecified = 0x6f,
Q931RecoveryOnTimerExpiry = 0x66,
Q931InvalidCallReference = 0x51,
Q931ErrorInCauseIE = 0
};
enum Q931SignalInfo {
Q931SignalDialToneOn,
Q931SignalRingBackToneOn,
Q931SignalInterceptToneOn,
Q931SignalNetworkCongestionToneOn,
Q931SignalBusyToneOn,
Q931SignalConfirmToneOn,
Q931SignalAnswerToneOn,
Q931SignalCallWaitingTone,
Q931SignalOffhookWarningTone,
Q931SignalPreemptionToneOn,
Q931SignalTonesOff = 0x3f,
Q931SignalAlertingPattern0 = 0x40,
Q931SignalAlertingPattern1,
Q931SignalAlertingPattern2,
Q931SignalAlertingPattern3,
Q931SignalAlertingPattern4,
Q931SignalAlertingPattern5,
Q931SignalAlertingPattern6,
Q931SignalAlertingPattern7,
Q931SignalAlretingOff = 0x4f,
Q931SignalErrorInIE = 0x100
};
enum Q931NumberingPlanCodes {
Q931UnknownPlan = 0x00,
Q931ISDNPlan = 0x01,
Q931DataPlan = 0x03,
Q931TelexPlan = 0x04,
Q931NationalStandardPlan = 0x08,
Q931PrivatePlan = 0x09,
Q931ReservedPlan = 0x0f
};
enum Q931TypeOfNumberCodes {
Q931UnknownType = 0x00,
Q931InternationalType = 0x01,
Q931NationalType = 0x02,
Q931NetworkSpecificType = 0x03,
Q931SubscriberType = 0x04,
Q931AbbreviatedType = 0x06,
Q931ReservedType = 0x07
};
enum Q931CodingStandard{
Q931CCITTStd = 0,
Q931ReservedInternationalStd,
Q931NationalStd,
Q931NetworkStd
};
enum Q931TransferMode {
Q931TransferCircuitMode = 0, /* 00 */
Q931TransferPacketMode = 2 /* 10 */
};
enum Q931TransferRate{
Q931TransferRatePacketMode = 0x00, /* 00000 */
Q931TransferRate64Kbps = 0x10, /* 10000 */
Q931TransferRate128kbps = 0x11, /* 10001 */
Q931TransferRate384kbps = 0x13, /* 10011 */
Q931TransferRate1536kbps = 0x15, /* 10101 */
Q931TransferRate1920kbps = 0x17 /* 10111 */
};
enum Q931UserInfoLayer1Protocol{
Q931UserInfoLayer1CCITTStdRate = 1,
Q931UserInfoLayer1G711ULaw,
Q931UserInfoLayer1G711ALaw,
Q931UserInfoLayer1G721ADPCM,
Q931UserInfoLayer1G722G725,
Q931UserInfoLayer1H261,
Q931UserInfoLayer1NonCCITTStdRate,
Q931UserInfoLayer1CCITTStdRateV120,
Q931UserInfoLayer1X31
};
/*
Structure to build store outgoing encoded UUIE
The different fields in the structure have octet lengths
as specified in the spec.
*/
typedef struct Q931InformationElement {
int discriminator;
int offset;
int length;
ASN1OCTET data[1];
} Q931InformationElement;
/**
* Q.931 message structure. Contains context for memory allocation,
* protocol discriminator, call reference, meesage type and list of
* user-user information elements (IEs).
*/
typedef struct Q931Message {
ASN1UINT protocolDiscriminator;
ASN1UINT callReference;
ASN1BOOL fromDestination;
ASN1UINT messageType; /* Q931MsgTypes */
ASN1UINT tunneledMsgType; /* The H245 message this message is tunneling*/
ASN1INT logicalChannelNo; /* channel number associated with tunneled */
/* message, 0 if no channel */
DList ies;
Q931InformationElement *bearerCapabilityIE;
Q931InformationElement *callingPartyNumberIE;
Q931InformationElement *calledPartyNumberIE;
Q931InformationElement *causeIE;
Q931InformationElement *keypadIE;
H225H323_UserInformation *userInfo;
} Q931Message;
/**
* This structure is used to hold an H.323 alias address.
*/
typedef struct OOAliases {
int type; /*!< H.225 AliasAddress choice option (t value) */
char *value; /*!< H.225 AliasAddress value */
OOBOOL registered;
struct OOAliases *next;
} OOAliases;
#define ooAliases OOAliases
struct OOH323CallData;
/*
* These are message callbacks which can be used by user applications
* to perform application specific things on receiving a particular
* message or before sending a particular message. For ex. user application
* can change values of some parameters of setup message before it is actually
* sent out.
*/
/**
* This callback is triggered when an H.225 SETUP message is received by
* the application.
* @param call The call the message is associated with.
* @param pmsg Q.931 message structure.
* @return OO_OK if message processing successful or OO_FAILED if not.
*/
typedef int (*cb_OnReceivedSetup)
(struct OOH323CallData *call, struct Q931Message *pmsg);
/**
* This callback is triggered when an H.225 CONNECT message is received by
* the application.
* @param call The call the message is associated with.
* @param pmsg Q.931 message structure.
* @return OO_OK if message processing successful or OO_FAILED if not.
*/
typedef int (*cb_OnReceivedConnect)
(struct OOH323CallData *call, struct Q931Message *pmsg);
/**
* This callback is triggered after an H.225 SETUP message has been
* constructed and is ready to be sent out. It provides the application
* with an opportunity to add additional non-standard information.
* @param call The call the message is associated with.
* @param pmsg Q.931 message structure.
* @return OO_OK if message processing successful or OO_FAILED if not.
*/
typedef int (*cb_OnBuiltSetup)
(struct OOH323CallData *call, struct Q931Message *pmsg);
/**
* This callback is triggered after an H.225 CONNECT message has been
* constructed and is ready to be sent out. It provides the application
* with an opportunity to add additional non-standard information.
* @param call The call the message is associated with.
* @param pmsg Q.931 message structure.
* @return OO_OK if message processing successful or OO_FAILED if not.
*/
typedef int (*cb_OnBuiltConnect)
(struct OOH323CallData *call, struct Q931Message *pmsg);
/**
* This structure holds the various callback functions that are
* triggered when H.225 messages are received or constructed.
* @see ooH323EpSetH225MsgCallbacks
*/
typedef struct OOH225MsgCallbacks {
cb_OnReceivedSetup onReceivedSetup;
cb_OnReceivedConnect onReceivedConnect;
cb_OnBuiltSetup onBuiltSetup;
cb_OnBuiltConnect onBuiltConnect;
} OOH225MsgCallbacks;
/**
* This function is invoked to decode a Q931 message.
*
* @param call Handle to call which owns the message.
* @param msg Pointer to the Q931 message
* @param length Length of the encoded data
* @param data Pointer to the data to be decoded
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooQ931Decode
(struct OOH323CallData *call, Q931Message* msg, int length, ASN1OCTET *data);
/**
* This function is used to decode the UUIE of the message from the list of
* ies. It decodes the User-User ie and populates the userInfo field of the
* message.
* @param q931Msg Pointer to the message whose User-User ie has to be
* decoded.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooDecodeUUIE(Q931Message *q931Msg);
/**
* This function is used to encode the UUIE field of the Q931 message.
* It encodes UUIE and adds the encoded data to the list of ies.
* @param q931msg Pointer to the Q931 message whose UUIE field has to be
* encoded.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooEncodeUUIE(Q931Message *q931msg);
/**
* This function is invoked to retrieve an IE element from a Q931 message.
*
* @param q931msg Pointer to the Q931 message
* @param ieCode IE code for the IE element to be retrieved
*
* @return Pointer to a Q931InformationElement contating
* the IE element.
*/
EXTERN Q931InformationElement* ooQ931GetIE (const Q931Message* q931msg,
int ieCode);
/**
* This function is invoked to print a Q931 message.
*
* @param q931msg Pointer to the Q931 message
*
* @return - none
*/
EXTERN void ooQ931Print (const Q931Message* q931msg);
/**
* This function is invoked to create an outgoing Q931 message.
*
* @param msg Reference to the pointer of type Q931 message.
* @param msgType Type of Q931 message to be created
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooCreateQ931Message(Q931Message **msg, int msgType);
/**
* This function is invoked to generate a unique call reference number.
*
* @return - call reference number
*/
EXTERN ASN1USINT ooGenerateCallReference(void);
/**
* This function is used to generate a unique call identifier for the call.
* @param callid Pointer to the callid structure, which will be populated
* with the generated callid.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooGenerateCallIdentifier(H225CallIdentifier *callid);
/**
* This function is invoked to release the memory used up by a Q931 message
*
* @param q931Msg Pointer to a Q931 message which has to be freed.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooFreeQ931Message(Q931Message *q931Msg);
/**
* This function is invoked to retrive the outgoing message buffer for
* Q931 message
*
* @param call Pointer to call for which outgoing Q931 message has to be
* retrieved.
* @param msgbuf Pointer to a buffer in which retrieved message will
* be returned.
* @param len Pointer to int in which length of the buffer will
* be returned.
* @param msgType Pointer to integer in which message type of the ougoing
* message is returned.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooGetOutgoingQ931Msgbuf
(struct OOH323CallData *call, ASN1OCTET * msgbuf, int* len, int *msgType);
/**
* This function is invoked to send a ReleaseComplete message for
* the currently active call.
*
* @param call Pointer to the call for which ReleaseComplete message have
* to be sent.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooSendReleaseComplete(struct OOH323CallData *call);
/**
* This function is invoked to send a call proceeding message in response to
* received setup message.
*
* @param call Pointer to the call for which CallProceeding message have to
* be sent.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooSendCallProceeding(struct OOH323CallData *call);
/**
* This function is invoked to send alerting message in response to received
* setup message.
*
* @param call Pointer to the call for which Alerting message have to be
* sent.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooSendAlerting(struct OOH323CallData *call);
/**
* This function is invoked to send Facility message.
*
* @param call Pointer to the call for which Facility message have to be
* sent.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooSendFacility(struct OOH323CallData *call);
/**
* This function is used to send dtmf data as Q931 keypad information element
* as part of information message.
* @param call Pointer to the call for dtmf data has to be sent.
* @param data Dtmf data to be sent.
*
* @return OO_OK, on success; OO_FAILED, on failure.
*/
EXTERN int ooQ931SendDTMFAsKeyPadIE
(struct OOH323CallData *call, const char* data);
/**
* This function is invoked to send a Connect message in response to received
* setup message.
*
* @param call Pointer to the call for which connect message has to be
* sent.
*
* @return Completion status - 0 on success, -1 on failure
*/
EXTERN int ooSendConnect(struct OOH323CallData *call);
/**
* This function is used to send a SETUP message for outgoing call. It first
* creates an H.225 TCP connection with the remote end point and then sends
* SETUP message over this connection.
* @param dest Destination - IP:Port/alias.
* @param callToken Unique token for the new call.
* @param opts Call specific options. If passed a non-null value, these
* options will override global endpoint settings.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
EXTERN int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts);
/**
* Helper function used to make a call once it is approved by the Gk.
* In case of no gk, this function is directly called to make a call.
* @param call Handle to the new call.
*
* @return OO_OK, on success. OO_FAILED, on failure
*/
int ooH323CallAdmitted( struct OOH323CallData *call);
/**
* This function is used to handle a call forward request sent to local
* endpoint by remote endpoint.
* @param call Handle to the call which is being forwarded
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323HandleCallFwdRequest(struct OOH323CallData *call);
/**
* This function is used for forwarding/redirecting a call to third party.
* @param callToken callToken for the call which has to be redirected.
* @param dest Address to which call has to be forwarded. Can be
* IP:Port or alias.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323ForwardCall(char* callToken, char *dest);
/**
* This function is used to hangup a currently active call. It sets the call
* state to CLEARING and initiates closing of all logical channels.
* @param callToken Unique token of the call to be hanged.
* @param reason Reason for ending call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323HangCall(char * callToken, OOCallClearReason reason);
/**
* Function to accept a call by sending connect. This function is used
* as a helper function to ooSendConnect.
* @param call Pointer to the call for which connect has to be sent
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooAcceptCall(struct OOH323CallData *call);
/*
* An helper function to ooMakeCall.
* @param call Pointer to the new call.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooH323MakeCall_helper(struct OOH323CallData *call);
/**
* This function is used to parse the destination
* @param call Handle to related call.
* @param dest Destination string to be parsed.
* @param parsedIP Pointer to buffer in which parsed ip:port will be returned.
* @param len Length of the buffer passed.
* @param aliasList Aliase List in which new aliases will be added.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooParseDestination
(struct OOH323CallData *call, char *dest, char *parsedIP, unsigned len,
OOAliases** aliasList);
/**
* This function is used to generate a new call token
* @param callToken Handle to the buffer in which new call token will be
* returned
* @param size size of the buffer
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooGenerateCallToken (char *callToken, size_t size);
/**
* This function sends an encoded H.245 message buffer as a tunneled
* H.245 Facility message.
* @param call Pointer to the call for which H.245 message has to
* be tunneled.
* @param msgbuf Pointer to the encoded H.245 message to be tunneled.
*
* @param h245Len Length of the encoded H.245 message buffer.
* @param h245MsgType Type of the H245 message
* @param associatedChan The logical channel number with which the tunneled
* message is associated. In case of no channel, this
* value should be 0.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooSendAsTunneledMessage
(struct OOH323CallData *call, ASN1OCTET* msgbuf,
int h245Len, int h245MsgType, int associatedChan);
/**
* This function is used to encode an H.225 message.
* @param call Handle to the call.
* @param pq931Msg Pointer to the message to be encoded.
* @param msgbuf Pointer to the buffer in which encoded message will
* be returned.
* @param size Size of the buffer passed.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooEncodeH225Message(struct OOH323CallData *call, Q931Message *pq931Msg,
char *msgbuf, int size);
/**
* This is a callback function which is called when there is no CONNECT
* response from the remote endpoint after the SETUP has been sent and timeout
* period has passed.
* @param data The callback data registered at the time of timer
* creation.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
int ooCallEstbTimerExpired(void *data);
/**
* This function is used to add a keypad IE to a Q931 message for sending dtmf.
* @param pmsg Q931 message to which keypad ie has to be
* added.
* @param data DTMF data to be sent.
*
* @return OO_OK on success, OO_FAILED, on failure.
*/
EXTERN int ooQ931SetKeypadIE(Q931Message *pmsg, const char* data);
/**
* This function is used to add a bearer capability IE to a Q931 message.
* @param pmsg Q931 message to which bearer capability ie has to be
* added.
* @param codingStandard Coding standard to be used.
* @param capability Information transfer capability
* @param transferMode Information transfer mode.(circuit/packet modes).
* @param transferRate Information transfer rate.
* @param userInfoLayer1 User information layer 1 protocol.
*
* @return OO_OK on success, OO_FAILED, on failure.
*/
EXTERN int ooSetBearerCapabilityIE
(Q931Message *pmsg, enum Q931CodingStandard codingStandard,
enum Q931InformationTransferCapability capability,
enum Q931TransferMode transferMode, enum Q931TransferRate transferRate,
enum Q931UserInfoLayer1Protocol userInfoLayer1);
/**
* This function is used to add a called party number ie to a q931 message.
* @param pmsg Q931 message to which CalledPartyNumber IE has to be
* added.
* @param number Number for called party.
* @param plan Numbering Plan used
* @param type Type of number
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooQ931SetCalledPartyNumberIE
(Q931Message *pmsg, const char *number, unsigned plan, unsigned type);
/**
* This function is used to add a CallingPartyNumber ie to a q931 message.
* @param pmsg Q931 message to which CallingPartyNumber IE has to be
* added.
* @param number Number for calling party.
* @param plan Numbering Plan used
* @param type Type of number
* @param presentation Presentation of the address is allowed or restricted.
* @param screening Whether address was provided by endpoint or screened
* by gatekeeper.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooQ931SetCallingPartyNumberIE
(Q931Message *pmsg, const char *number, unsigned plan, unsigned type,
unsigned presentation, unsigned screening);
/**
* This function is used to set a cause ie for a q931 message.
* @param pmsg Valid Q931 Message
* @param cause Q931 Cause Value
* @param coding coding standard used. 0 for ITU-T standard coding
* @param location location. 0 for user.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooQ931SetCauseIE
(Q931Message *pmsg,enum Q931CauseValues cause, unsigned coding,
unsigned location);
/**
* This function is used to convert a call clear reason to cause and
* reason code. It is used when local user is endoing the call and
* sending releaseComplete.
* @param clearReason Reason for ending call.
* @param cause Pointer to Q931CauseVaules enum in which cause
* will be returned.
* @param reasonCode Pointer to unsigned int in which reasonCode will
* be returned.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
EXTERN int ooQ931GetCauseAndReasonCodeFromCallClearReason
(OOCallClearReason clearReason, enum Q931CauseValues *cause,
unsigned *reasonCode);
/**
* This function is used to convert a cause value and reason code received
* in ReleaseComplete message from remote endpoint into a CallClearReason.
* @param cause cause value received.
* @param reasonCode reasonCode received.
*
* @return Returns a CallClearReason.
*/
EXTERN OOCallClearReason ooGetCallClearReasonFromCauseAndReasonCode
(enum Q931CauseValues cause, unsigned reasonCode);
/**
* This function is used to retrieve the description text for a
* message type.
*
* @param msgType Message type.
* @return The text description string.
*/
EXTERN const char* ooGetMsgTypeText (int msgType);
/**
* This function is used to retrieve the text description for a Q931 Cause
* value in Cause IE.
* @param val Q931 Cause value
* @return The text description string
*/
EXTERN const char* ooGetQ931CauseValueText (int val);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __Q931HDR_H */

View File

@ -0,0 +1,131 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "ootypes.h"
#include "ootrace.h"
#include "ooCommon.h"
#include "ooCapability.h"
#include "ooq931.h"
#include "ooh245.h"
#include "ooh323ep.h"
/** Global endpoint structure */
extern OOH323EndPoint gH323ep;
static OOUINT32 gs_traceLevel = TRACELVL;
void ooSetTraceThreshold(OOUINT32 traceLevel)
{
gs_traceLevel = traceLevel;
}
void ooTrace(OOUINT32 traceLevel, const char * fmtspec, ...)
{
va_list arglist;
char logMessage[MAXLOGMSGLEN];
if(traceLevel > gs_traceLevel) return;
va_start (arglist, fmtspec);
/* memset(logMessage, 0, MAXLOGMSGLEN);*/
vsprintf(logMessage, fmtspec, arglist);
va_end(arglist);
ooTraceLogMessage(logMessage);
}
void ooTraceLogMessage(const char * logMessage)
{
char timeString[100];
char currtime[3];
static int lasttime=25;
int printDate =0;
static int printTime=1;
#ifdef _WIN32
SYSTEMTIME systemTime;
GetLocalTime(&systemTime);
GetTimeFormat(LOCALE_SYSTEM_DEFAULT,0, &systemTime, "HH':'mm':'ss",
timeString, 100);
GetTimeFormat(LOCALE_SYSTEM_DEFAULT,0, &systemTime, "H", currtime, 3);
if(lasttime> atoi(currtime))
printDate=1;
lasttime = atoi(currtime);
#else
struct tm *ptime;
char dateString[15];
time_t t = time(NULL);
ptime = localtime(&t);
strftime(timeString, 100, "%H:%M:%S", ptime);
strftime(currtime, 3, "%H", ptime);
if(lasttime>atoi(currtime))
printDate = 1;
lasttime = atoi(currtime);
#endif
#ifdef _WIN32
if(printDate)
{
printDate = 0;
fprintf(gH323ep.fptraceFile, "---------Date %d/%d/%d---------\n",
systemTime.wMonth, systemTime.wDay, systemTime.wYear);
}
if(printTime) {
fprintf(gH323ep.fptraceFile, "%s:%03d %s", timeString,
systemTime.wMilliseconds, logMessage);
}
else
fprintf(gH323ep.fptraceFile, "%s", logMessage);
fflush(gH323ep.fptraceFile);
#else
if(printDate)
{
printDate = 0;
strftime(dateString, 15, "%m/%d/%Y", ptime);
fprintf(gH323ep.fptraceFile, "---------Date %s---------\n",
dateString);
}
if(printTime) {
struct timeval systemTime;
gettimeofday(&systemTime, NULL);
fprintf(gH323ep.fptraceFile, "%s:%03ld %s", timeString,
systemTime.tv_usec/1000, logMessage);
}
else
fprintf(gH323ep.fptraceFile, "%s", logMessage);
fflush(gH323ep.fptraceFile);
#endif
if(strchr(logMessage, '\n'))
printTime = 1;
else
printTime = 0;
}
int ooLogAsn1Error(int stat, const char * fname, int lno)
{
OOTRACEERR4("Asn1Error: %d at %s:%d\n", stat, fname, lno);
return stat;
}

View File

@ -0,0 +1,152 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file ootrace.h
* This file defines the trace functionality
*/
#include "ooCommon.h"
#ifndef _OOTRACE_H_
#define _OOTRACE_H_
/* tracing */
#define OOTRCLVLERR 1
#define OOTRCLVLWARN 2
#define OOTRCLVLINFO 3
#define OOTRCLVLDBGA 4
#define OOTRCLVLDBGB 5
#define OOTRCLVLDBGC 6
#ifdef _OOWARNING
#define TRACELVL OOTRCLVLWARN
#endif
#ifdef _OOINFO
#define TRACELVL OOTRCLVLINFO
#endif
#ifdef _OODEBUGA
#define TRACELVL OOTRCLVLDBGA
#endif
#ifdef _OODEBUGB
#define TRACELVL OOTRCLVLDBGB
#endif
#ifdef _OODEBUGC
#define TRACELVL OOTRCLVLDBGC
#endif
/* Ensure we always log error messages */
#ifndef TRACELVL
#define TRACELVL 1
#endif
#define OOTRACEERR1(a) ooTrace(OOTRCLVLERR,"%s", a)
#define OOTRACEERR2(a,b) ooTrace(OOTRCLVLERR,a,b)
#define OOTRACEERR3(a,b,c) ooTrace(OOTRCLVLERR,a,b,c)
#define OOTRACEERR4(a,b,c,d) ooTrace(OOTRCLVLERR,a,b,c,d)
#define OOTRACEWARN1(a) ooTrace(OOTRCLVLWARN,a)
#define OOTRACEWARN2(a,b) ooTrace(OOTRCLVLWARN,a,b)
#define OOTRACEWARN3(a,b,c) ooTrace(OOTRCLVLWARN,a,b,c)
#define OOTRACEWARN4(a,b,c,d) ooTrace(OOTRCLVLWARN,a,b,c,d)
#define OOTRACEINFO1(a) ooTrace(OOTRCLVLINFO, a)
#define OOTRACEINFO2(a,b) ooTrace(OOTRCLVLINFO,a,b)
#define OOTRACEINFO3(a,b,c) ooTrace(OOTRCLVLINFO,a,b,c)
#define OOTRACEINFO4(a,b,c,d) ooTrace(OOTRCLVLINFO,a,b,c,d)
#define OOTRACEINFO5(a,b,c,d,e) ooTrace(OOTRCLVLINFO,a,b,c,d,e)
#define OOTRACEINFO6(a,b,c,d,e,f) ooTrace(OOTRCLVLINFO,a,b,c,d,e, f)
#ifndef _COMPACT
#define OOTRACEDBGA1(a) ooTrace(OOTRCLVLDBGA,a)
#define OOTRACEDBGA2(a,b) ooTrace(OOTRCLVLDBGA,a,b)
#define OOTRACEDBGA3(a,b,c) ooTrace(OOTRCLVLDBGA,a,b,c)
#define OOTRACEDBGA4(a,b,c,d) ooTrace(OOTRCLVLDBGA,a,b,c,d)
#define OOTRACEDBGA5(a,b,c,d,e) ooTrace(OOTRCLVLDBGA,a,b,c,d,e)
#define OOTRACEDBGB1(a) ooTrace(OOTRCLVLDBGB,"%s",a)
#define OOTRACEDBGB2(a,b) ooTrace(OOTRCLVLDBGB,a,b)
#define OOTRACEDBGB3(a,b,c) ooTrace(OOTRCLVLDBGB,a,b,c)
#define OOTRACEDBGB4(a,b,c,d) ooTrace(OOTRCLVLDBGB,a,b,c,d)
#define OOTRACEDBGC1(a) ooTrace(OOTRCLVLDBGC,a)
#define OOTRACEDBGC2(a,b) ooTrace(OOTRCLVLDBGC,a,b)
#define OOTRACEDBGC3(a,b,c) ooTrace(OOTRCLVLDBGC,a,b,c)
#define OOTRACEDBGC4(a,b,c,d) ooTrace(OOTRCLVLDBGC,a,b,c,d)
#define OOTRACEDBGC5(a,b,c,d,e) ooTrace(OOTRCLVLDBGC,a,b,c,d,e)
#else
#define OOTRACEDBGA1(a)
#define OOTRACEDBGA2(a,b)
#define OOTRACEDBGA3(a,b,c)
#define OOTRACEDBGA4(a,b,c,d)
#define OOTRACEDBGA5(a,b,c,d,e)
#define OOTRACEDBGB1(a)
#define OOTRACEDBGB2(a,b)
#define OOTRACEDBGB3(a,b,c)
#define OOTRACEDBGB4(a,b,c,d)
#define OOTRACEDBGC1(a)
#define OOTRACEDBGC2(a,b)
#define OOTRACEDBGC3(a,b,c)
#define OOTRACEDBGC4(a,b,c,d)
#define OOTRACEDBGC5(a,b,c,d,e)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* This function is used to set the trace level.
* @param traceLevel New trace level. Various values are: OOTRCLVLERR,
* OOTRCLVLWARN, OOTRCLVLINFO, OOTRCLVLDBGA, OOTRCLVLDBGB,
* OOTRCLVLDBGC
*
* @return None
*/
EXTERN void ooSetTraceThreshold(OOUINT32 traceLevel);
/**
* This function is used to write the messages to the trace file.
*
* @param traceLevel Trace level for the message.
* @param fmtspec Printf style format spec.
* @param ... Printf style variable list of arguments
*
* @return - none
*/
EXTERN void ooTrace(OOUINT32 traceLevel, const char * fmtspec, ...)__attribute__((format(printf, 2, 3)));
/**
* Helper function for the trace function. This function performs actual
* writing to file.
* @param logMessage Log message to be writted to file.
*
* @return - none
*/
void ooTraceLogMessage(const char * logMessage);
/**
*
*/
void ooChangeIPToNWOrder(char * internetIP, char* networkIP);
int ooLogAsn1Error(int stat, const char * fname, int lno);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,256 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/*! \mainpage
* <H1>ooH323c Stack Functions</H1>
*
* The <B>Objective Open H.323 for C (ooH323c)</B> protocol stack is an
* open source applications program interface (API) for building H.323 based
* applications. The stack implements Q.931/H.225 call signaling procedures,
* H.245 logical channel operations, and Registration, Admission, and Status
* (RAS) messaging for Gatekeeper communications.
*
* The categories of user functions provided are as follows:
* <UL>
* <LI>Stack command functions. These are high level functions used to
* initiate common H.323 telephony operations (for example, to make a
* call).</LI>
* <LI>Gatekeeper functions. These are high level functions for
* managing communications with a gatekeeper using RAS messages.</LI>
* <LI>H.323 endpoint management functions. These are function for
* used for managing the global H.323 endpoint.</LI>
* <LI>Call management functions. These are functions used to manage
* active calls within the stack.</LI>
* <LI>Capability management functions. These functions are used for
* negotiating capabilities between two different terminals.</LI>
* <LI>H.225 and H.245 message handling functions. Functions for
* creating and handling H.323 standard ASN.1 messages.</LI>
* <LI>Q.931 functions. Functions for the execution of various
* standard Q.931 operations.</LI>
* <LI>TCP/IP and UDP socket communication functions. Low-level
* functions for writing data to and receiving data from sockets.</LI>
* </UL>
*/
/**
* @file ootypes.h
* This file contains definitions of common constants and data structures.
*/
#ifndef _OOTYPES_H_
#define _OOTYPES_H_
#include "ooSocket.h"
#include "MULTIMEDIA-SYSTEM-CONTROL.h"
#include "H323-MESSAGES.h"
#include "ooasn1.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define OOH323C_VERSION "v0.8.3"
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/**
* @defgroup ootypes Common type and constant definitions.
* @{
*/
/* Function return codes */
#define OO_FAILED -1
#define OO_OK 0
/* TODO: States for both local and remote initiation should be maintained
separately */
/**
* States defined for master/slave determination procedure.
*/
typedef enum OOMasterSlaveState {
OO_MasterSlave_Idle,
OO_MasterSlave_DetermineSent,
OO_MasterSlave_AckReceived,
OO_MasterSlave_Master,
OO_MasterSlave_Slave
} OOMasterSlaveState;
/**
* States defined for the capability exchange procedure.
*/
typedef enum {
OO_LocalTermCapExchange_Idle,
OO_LocalTermCapSetSent,
OO_LocalTermCapSetAckRecvd,
OO_RemoteTermCapExchange_Idle,
OO_RemoteTermCapSetRecvd,
OO_RemoteTermCapSetAckSent
} OOCapExchangeState;
/**
* Call clear reason codes.
*/
typedef enum OOCallClearReason {
OO_REASON_UNKNOWN=0,
OO_REASON_INVALIDMESSAGE,
OO_REASON_TRANSPORTFAILURE,
OO_REASON_NOROUTE,
OO_REASON_NOUSER,
OO_REASON_NOBW,
OO_REASON_GK_NOCALLEDUSER,
OO_REASON_GK_NOCALLERUSER,
OO_REASON_GK_NORESOURCES,
OO_REASON_GK_UNREACHABLE,
OO_REASON_GK_CLEARED,
OO_REASON_NOCOMMON_CAPABILITIES,
OO_REASON_REMOTE_FWDED,
OO_REASON_LOCAL_FWDED,
OO_REASON_REMOTE_CLEARED,
OO_REASON_LOCAL_CLEARED,
OO_REASON_REMOTE_BUSY,
OO_REASON_LOCAL_BUSY,
OO_REASON_REMOTE_NOANSWER,
OO_REASON_LOCAL_NOTANSWERED,
OO_REASON_REMOTE_REJECTED,
OO_REASON_LOCAL_REJECTED,
OO_REASON_REMOTE_CONGESTED,
OO_REASON_LOCAL_CONGESTED
} OOCallClearReason;
/** Terminal type of the endpoint. Default is 60. */
#define OOTERMTYPE 60
/** Maximum length of an IP address (xxx.xxx.xxx.xxx). */
#define MAX_IP_LENGTH 15
/** Maximum length of a log file message */
#define MAXLOGMSGLEN 2048
/** Number of times to retry a failed operation. */
#define DEFAULT_MAX_RETRIES 3
/**
Various message types for H225 and H245 messages
*/
#define OO_MSGTYPE_MIN 101
#define OOQ931MSG 101
#define OOH245MSG 102
#define OOSetup 103
#define OOCallProceeding 104
#define OOAlert 105
#define OOConnect 106
#define OOReleaseComplete 107
#define OOFacility 108
#define OOInformationMessage 109
#define OOMasterSlaveDetermination 110
#define OOMasterSlaveAck 111
#define OOMasterSlaveReject 112
#define OOMasterSlaveRelease 113
#define OOTerminalCapabilitySet 114
#define OOTerminalCapabilitySetAck 115
#define OOTerminalCapabilitySetReject 116
#define OOTerminalCapabilitySetRelease 117
#define OOOpenLogicalChannel 118
#define OOOpenLogicalChannelAck 119
#define OOOpenLogicalChannelReject 120
#define OOOpenLogicalChannelRelease 121
#define OOOpenLogicalChannelConfirm 122
#define OOCloseLogicalChannel 123
#define OOCloseLogicalChannelAck 124
#define OORequestChannelClose 125
#define OORequestChannelCloseAck 126
#define OORequestChannelCloseReject 127
#define OORequestChannelCloseRelease 128
#define OOEndSessionCommand 129
#define OOUserInputIndication 130
#define OO_MSGTYPE_MAX 130
/* Timer types */
#define OO_CALLESTB_TIMER (1<<0)
#define OO_MSD_TIMER (1<<1)
#define OO_TCS_TIMER (1<<2)
#define OO_OLC_TIMER (1<<3)
#define OO_CLC_TIMER (1<<4)
#define OO_RCC_TIMER (1<<5)
#define OO_SESSION_TIMER (1<<6)
#define OO_H245CONNECT_TIMER (1<<7)
/** Maximum length for received messages */
#define MAXMSGLEN 4096
/** Maximum length of a filename */
#define MAXFILENAME 256
/**
* Endpoint call modes. The call mode of the endpoint dictates what type
* of channels are created for the calls placed by the endpoint or received
* by the endpoint.
*/
typedef enum OOCallMode {
OO_CALLMODE_AUDIOCALL, /*!< Audio call */
OO_CALLMODE_AUDIORX, /*!< Audio call - receive only */
OO_CALLMODE_AUDIOTX, /*!< Audio call - transmit only */
OO_CALLMODE_VIDEOCALL, /*!< Video call */
OO_CALLMODE_FAX /*!< Fax transmission */
} OOCallMode;
/*
* Flag macros - these operate on bit mask flags using mask values
*/
/** This macro sets a flag within a bit mask */
#define OO_SETFLAG(flags,mask) (flags |= (ASN1UINT)mask)
/** This macro clears a flag within a bit mask */
#define OO_CLRFLAG(flags,mask) (flags &= ~(ASN1UINT)mask)
/** This macro tests a flag with a bit mask */
#define OO_TESTFLAG(flags,mask) (((ASN1UINT)flags & (ASN1UINT)mask) != 0)
/*TODO: Should add caller-id, callername etc. So that they can be changed per
call basis*/
/**
* This structure defines options that can be set at the level of an
* individual call. They override options set in the H.323 endpoint
* structure.
*/
typedef struct ooCallOptions {
OOBOOL fastStart; /*!< Use FastStart signaling */
OOBOOL tunneling; /*!< Use H.245 tunneling */
OOBOOL disableGk; /*!< Disable use of gatekeeper */
OOCallMode callMode; /*!< Type of channel to setup with FastStart */
}ooCallOptions;
struct OOH323CallData;
typedef struct ooTimerCallback{
struct OOH323CallData* call;
ASN1UINT timerType;
ASN1UINT channelNumber;
} ooTimerCallback;
/**
* @}
*/
#endif

View File

@ -0,0 +1,287 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooasn1.h"
#include "ooper.h"
ASN1BOOL isExtendableSize (Asn1SizeCnst* pSizeList);
static ASN1BOOL isFixedSize (Asn1SizeCnst* pSizeList);
ASN1BOOL alignCharStr
(OOCTXT* pctxt, ASN1UINT len, ASN1UINT nbits, Asn1SizeCnst* pSize)
{
if (TRUE) {
ASN1UINT lower, upper;
ASN1BOOL doAlign = (len > 0), extendable;
pSize = checkSize (pSize, len, &extendable);
if (0 != pSize) {
lower = pSize->lower;
upper = pSize->upper;
}
else {
lower = 0;
upper = ASN1UINT_MAX;
}
if (!extendable && upper < 65536) {
ASN1UINT bitRange = upper * nbits;
if (upper == lower) {
/* X.691, clause 26.5.6 */
if (bitRange <= 16) doAlign = FALSE;
}
else {
/* X.691, clause 26.5.7 */
if (bitRange < 16) doAlign = FALSE;
}
}
return doAlign;
}
else
return FALSE;
}
int bitAndOctetStringAlignmentTest (Asn1SizeCnst* pSizeList,
ASN1UINT itemCount,
ASN1BOOL bitStrFlag,
ASN1BOOL* pAlignFlag)
{
ASN1UINT threshold = (bitStrFlag) ? 16 : 2;
if (pSizeList == 0 || itemCount > threshold)
*pAlignFlag = TRUE;
else if (isFixedSize(pSizeList))
*pAlignFlag = FALSE;
else {
/* Variable length case: check size.. no alignment required if */
/* lower == upper and not extended.. */
ASN1BOOL extended;
Asn1SizeCnst* pSize = checkSize (pSizeList, itemCount, &extended);
if (pSize != 0)
*pAlignFlag = ((pSize->upper != pSize->lower) || pSize->extended);
else {
/* Note: we never should get here because constraint */
/* violation should have been caught when length was encoded */
/* or decoded.. */
return (ASN_E_CONSVIO);
}
}
return (ASN_OK);
}
Asn1SizeCnst* checkSize (Asn1SizeCnst* pSizeList,
ASN1UINT value,
ASN1BOOL* pExtendable)
{
Asn1SizeCnst* lpSize = pSizeList;
*pExtendable = isExtendableSize (lpSize);
while (lpSize) {
if (value >= lpSize->lower && value <= lpSize->upper) {
return (lpSize);
}
else lpSize = lpSize->next;
}
return 0;
}
int getPERMsgLen (OOCTXT* pctxt)
{
return (pctxt->buffer.bitOffset == 8) ?
pctxt->buffer.byteIndex : pctxt->buffer.byteIndex + 1;
}
int addSizeConstraint (OOCTXT* pctxt, Asn1SizeCnst* pSize)
{
Asn1SizeCnst* lpSize;
int stat = ASN_OK;
/* If constraint does not already exist, add it */
if (!pctxt->pSizeConstraint) {
pctxt->pSizeConstraint = pSize;
}
/* Otherwise, check to make sure given constraint is larger than */
/* the existing constraint.. */
else {
lpSize = pSize;
while (lpSize) {
if (pctxt->pSizeConstraint->lower <= lpSize->lower ||
pctxt->pSizeConstraint->upper >= lpSize->upper)
{
/* Set the extension flag to the value of the size */
/* constraint structure that the item falls within.. */
/* pctxt->pSizeConstraint->extended = lpSize->extended; */
break;
}
lpSize = lpSize->next;
}
if (!lpSize)
stat = ASN_E_CONSVIO;
}
return stat;
}
Asn1SizeCnst* getSizeConstraint (OOCTXT* pctxt, ASN1BOOL extbit)
{
Asn1SizeCnst* lpSize = pctxt->pSizeConstraint;
while (lpSize) {
if (lpSize->extended == extbit)
return lpSize;
else
lpSize = lpSize->next;
}
return NULL;
}
int checkSizeConstraint(OOCTXT* pctxt, int size)
{
Asn1SizeCnst* pSize;
ASN1UINT lower, upper;
ASN1BOOL extbit;
int stat;
/* If size constraint is present and extendable, decode extension */
/* bit.. */
if (isExtendableSize(pctxt->pSizeConstraint)) {
stat = DE_BIT (pctxt, &extbit);
if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat);
}
else extbit = 0;
/* Now use the value of the extension bit to select the proper */
/* size constraint range specification.. */
pSize = getSizeConstraint (pctxt, extbit);
lower = (pSize) ? pSize->lower : 0;
upper = (pSize) ? pSize->upper : ASN1UINT_MAX;
if (upper < (ASN1UINT)size) {
return LOG_ASN1ERR (pctxt, ASN_E_CONSVIO);
}
return ASN_OK;
}
ASN1UINT getUIntBitCount (ASN1UINT value)
{
/* Binary search - decision tree (5 tests, rarely 6) */
return
((value < 1<<15) ?
((value < 1<<7) ?
((value < 1<<3) ?
((value < 1<<1) ? ((value < 1<<0) ? 0 : 1) :
((value < 1<<2) ? 2 : 3)) :
((value < 1<<5) ? ((value < 1<<4) ? 4 : 5) :
((value < 1<<6) ? 6 : 7))) :
((value < 1<<11) ?
((value < 1<<9) ? ((value < 1<<8) ? 8 : 9) :
((value < 1<<10) ? 10 : 11)) :
((value < 1<<13) ? ((value < 1<<12) ? 12 : 13) :
((value < 1<<14) ? 14 : 15)))) :
((value < 1<<23) ?
((value < 1<<19) ?
((value < 1<<17) ? ((value < 1<<16) ? 16 : 17) :
((value < 1<<18) ? 18 : 19)) :
((value < 1<<21) ? ((value < 1<<20) ? 20 : 21) :
((value < 1<<22) ? 22 : 23))) :
((value < 1<<27) ?
((value < 1<<25) ? ((value < 1<<24) ? 24 : 25) :
((value < 1<<26) ? 26 : 27)) :
((value < 1<<29) ? ((value < 1<<28) ? 28 : 29) :
((value < 1<<30) ? 30 :
((value < 1UL<<31) ? 31 : 32))))));
}
void init16BitCharSet (Asn116BitCharSet* pCharSet, ASN116BITCHAR first,
ASN116BITCHAR last, ASN1UINT abits, ASN1UINT ubits)
{
pCharSet->charSet.nchars = 0;
pCharSet->charSet.data = 0;
pCharSet->firstChar = first;
pCharSet->lastChar = last;
pCharSet->unalignedBits = ubits;
pCharSet->alignedBits = abits;
}
ASN1BOOL isExtendableSize (Asn1SizeCnst* pSizeList)
{
Asn1SizeCnst* lpSize = pSizeList;
while (lpSize) {
if (lpSize->extended)
return TRUE;
else
lpSize = lpSize->next;
}
return FALSE;
}
static ASN1BOOL isFixedSize (Asn1SizeCnst* pSizeList)
{
Asn1SizeCnst* lpSize = pSizeList;
if (lpSize && !lpSize->extended && !lpSize->next) {
return (ASN1BOOL) (lpSize->lower == lpSize->upper);
}
return FALSE;
}
void set16BitCharSet
(OOCTXT* pctxt, Asn116BitCharSet* pCharSet, Asn116BitCharSet* pAlphabet)
{
/* Permitted alphabet range can either be specified as a range of */
/* characters or as a discrete set.. */
if (pAlphabet->charSet.data) {
int nocts = pAlphabet->charSet.nchars * 2;
pCharSet->charSet.nchars = pAlphabet->charSet.nchars;
pCharSet->charSet.data =
(ASN116BITCHAR*) ASN1MALLOC (pctxt, nocts);
if (pCharSet->charSet.data != NULL)
memcpy (pCharSet->charSet.data, pAlphabet->charSet.data, nocts);
}
else {
pCharSet->firstChar = pAlphabet->firstChar;
pCharSet->lastChar = pAlphabet->lastChar;
pCharSet->charSet.nchars = pCharSet->lastChar - pCharSet->firstChar;
}
pCharSet->unalignedBits = getUIntBitCount (pCharSet->charSet.nchars);
pCharSet->alignedBits = 1;
while (pCharSet->unalignedBits > pCharSet->alignedBits)
pCharSet->alignedBits <<= 1;
}

View File

@ -0,0 +1,273 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/* This is an implementation of a simple print handler. It outputs
the fields of an encoded PER message to stdout in a structured output
format..
*/
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include "printHandler.h"
#include "ootypes.h"
#include "rtctype.h"
#include "ootrace.h"
EventHandler printHandler;
static const char* pVarName;
static int gIndentSpaces;
static const char* bitStrToString
(ASN1UINT numbits, const ASN1OCTET* data, char* buffer, size_t bufsiz);
static const char* octStrToString
(ASN1UINT numocts, const ASN1OCTET* data, char* buffer, size_t bufsiz);
void initializePrintHandler(EventHandler *printHandler, char * varname)
{
printHandler->startElement = &printStartElement;
printHandler->endElement = &printEndElement;
printHandler->boolValue = &printBoolValue;
printHandler->intValue = &printIntValue;
printHandler->uIntValue = &printuIntValue ;
printHandler->bitStrValue = &printBitStrValue;
printHandler->octStrValue = &printOctStrValue;
printHandler->charStrValue = &printCharStrValue;
printHandler->charStr16BitValue = &printCharStr16BitValue ;
printHandler->nullValue = &printNullValue;
printHandler->oidValue = &printOidValue;
printHandler->enumValue = &printEnumValue;
printHandler->openTypeValue = &printOpenTypeValue;
pVarName = varname;
OOTRACEDBGB2("%s = {\n", pVarName);
gIndentSpaces += 3;
}
void finishPrint()
{
OOTRACEDBGB1 ("}\n");
gIndentSpaces -= 3;
if (gIndentSpaces != 0) {
OOTRACEDBGB1 ("ERROR: unbalanced structure\n");
}
}
void indent ()
{
int i=0;
for (i = 0; i < gIndentSpaces; i++) OOTRACEDBGB1 (" ");
}
void printStartElement (const char* name, int index)
{
indent ();
OOTRACEDBGB1 (name);
if (index >= 0) OOTRACEDBGB2 ("[%d]", index);
OOTRACEDBGB1 (" = {\n");
gIndentSpaces += 3;
}
void printEndElement (const char* name, int index)
{
gIndentSpaces -= 3;
indent ();
OOTRACEDBGB1 ("}\n");
}
void printBoolValue (ASN1BOOL value)
{
const char* s = value ? "TRUE" : "FALSE";
indent ();
OOTRACEDBGB2 ("%s\n", s);
}
void printIntValue (ASN1INT value)
{
indent ();
OOTRACEDBGB2 ("%d\n", value);
}
void printuIntValue (ASN1UINT value)
{
indent ();
OOTRACEDBGB2 ("%u\n", value);
}
void printBitStrValue (ASN1UINT numbits, const ASN1OCTET* data)
{
#ifdef __MINGW32__
char s[numbits + 8];
indent ();
OOTRACEDBGB2("%s\n", bitStrToString (numbits, data, s, numbits+8));
#else
char* s = (char*)malloc(numbits + 8);
indent ();
OOTRACEDBGB2("%s\n", bitStrToString (numbits, data, s, numbits+8));
free(s);
#endif
}
void printOctStrValue (ASN1UINT numocts, const ASN1OCTET* data)
{
int bufsiz = (numocts * 2) + 8;
#ifdef __MINGW32__
char s[bufsiz];
indent ();
OOTRACEDBGB2 ("%s\n", octStrToString (numocts, data, s, bufsiz));
#else
char* s = (char*)malloc(bufsiz);
indent ();
OOTRACEDBGB2 ("%s\n", octStrToString (numocts, data, s, bufsiz));
free(s);
#endif
}
void printCharStrValue (const char* value)
{
indent ();
OOTRACEDBGB2 ("\"%s\"\n", value);
}
void printCharStr16BitValue (ASN1UINT nchars, ASN116BITCHAR* data)
{
ASN1UINT ui;
indent ();
for (ui = 0; ui < nchars; ui++) {
if (data[ui] >= 32 && data[ui] <= 127)
OOTRACEDBGB2 ("%c", (char)data[ui]);
else
OOTRACEDBGB1 ("?");
}
OOTRACEDBGB1 ("\n");
}
void printCharStr32BitValue (ASN1UINT nchars, ASN132BITCHAR* data)
{
ASN1UINT ui;
indent ();
for ( ui = 0; ui < nchars; ui++) {
if (data[ui] >= 32 && data[ui] <= 127)
OOTRACEDBGB2 ("%c", (char)data[ui]);
else
OOTRACEDBGB2 ("\\%d", data[ui]);
}
OOTRACEDBGB1 ("\n");
}
void printNullValue ()
{
indent ();
OOTRACEDBGB1 ("NULL\n");
}
void ooPrintOIDValue (ASN1OBJID* pOID)
{
ASN1UINT ui;
OOTRACEDBGB1 ("{ \n");
for (ui = 0; ui < pOID->numids; ui++) {
OOTRACEDBGB2 ("%d ", pOID->subid[ui]);
}
OOTRACEDBGB1 ("}\n");
}
void printOidValue (ASN1UINT numSubIds, ASN1UINT* pSubIds)
{
ASN1UINT ui;
ASN1OBJID oid;
oid.numids = numSubIds;
for ( ui = 0; ui < numSubIds; ui++)
oid.subid[ui] = pSubIds[ui];
indent ();
ooPrintOIDValue (&oid);
}
void printRealValue (double value)
{
indent ();
OOTRACEDBGB2 ("%f\n", value);
}
void printEnumValue (ASN1UINT value)
{
indent ();
OOTRACEDBGB2 ("%u\n", value);
}
void printOpenTypeValue (ASN1UINT numocts, const ASN1OCTET* data)
{
indent ();
OOTRACEDBGB1 ("< encoded data >\n");
}
static const char* bitStrToString
(ASN1UINT numbits, const ASN1OCTET* data, char* buffer, size_t bufsiz)
{
size_t i;
unsigned char mask = 0x80;
if (bufsiz > 0) {
buffer[0] = '\'';
for (i = 0; i < numbits; i++) {
if (i < bufsiz - 1) {
buffer[i+1] = (char) (((data[i/8] & mask) != 0) ? '1' : '0');
mask >>= 1;
if (0 == mask) mask = 0x80;
}
else break;
}
i++;
if (i < bufsiz - 1) buffer[i++] = '\'';
if (i < bufsiz - 1) buffer[i++] = 'B';
if (i < bufsiz - 1) buffer[i] = '\0';
else buffer[bufsiz - 1] = '\0';
}
return buffer;
}
static const char* octStrToString
(ASN1UINT numocts, const ASN1OCTET* data, char* buffer, size_t bufsiz)
{
size_t i;
char lbuf[4];
if (bufsiz > 0) {
buffer[0] = '\'';
if (bufsiz > 1) buffer[1] = '\0';
for (i = 0; i < numocts; i++) {
if (i < bufsiz - 1) {
sprintf (lbuf, "%02x", data[i]);
strcat (&buffer[(i*2)+1], lbuf);
}
else break;
}
i = i*2 + 1;
if (i < bufsiz - 1) buffer[i++] = '\'';
if (i < bufsiz - 1) buffer[i++] = 'H';
if (i < bufsiz - 1) buffer[i] = '\0';
else buffer[bufsiz - 1] = '\0';
}
return buffer;
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
@file printHandler.h
This is an implementation of a simple print handler. It outputs
the fields of an encoded PER message to stdout in a structured output
format..
*/
#ifndef _PRINTHANDLER_H_
#define _PRINTHANDLER_H_
#include "eventHandler.h"
extern EventHandler printHandler;
void initializePrintHandler(EventHandler *printHandler, char * varname);
void finishPrint();
void indent ();
void printStartElement (const char* name, int index );
void printEndElement (const char* name, int index );
void printBoolValue (ASN1BOOL value);
void printIntValue (ASN1INT value);
void printuIntValue (ASN1UINT value);
void printBitStrValue (ASN1UINT numbits, const ASN1OCTET* data);
void printOctStrValue (ASN1UINT numocts, const ASN1OCTET* data);
void printCharStrValue (const char* value);
void printCharStr16BitValue (ASN1UINT nchars, ASN116BITCHAR* data);
void printNullValue ();
void printOidValue (ASN1UINT numSubIds, ASN1UINT* pSubIds);
void printEnumValue (ASN1UINT value);
void printOpenTypeValue (ASN1UINT numocts, const ASN1OCTET* data);
#endif

View File

@ -0,0 +1,168 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/* Run-time ctype substitution */
#include "ooasn1.h"
#include "rtctype.h"
const ASN1OCTET rtCtypeTable[256] = {
OS_CTYPE_CTRL, /* 00 (NUL) */
OS_CTYPE_CTRL, /* 01 (SOH) */
OS_CTYPE_CTRL, /* 02 (STX) */
OS_CTYPE_CTRL, /* 03 (ETX) */
OS_CTYPE_CTRL, /* 04 (EOT) */
OS_CTYPE_CTRL, /* 05 (ENQ) */
OS_CTYPE_CTRL, /* 06 (ACK) */
OS_CTYPE_CTRL, /* 07 (BEL) */
OS_CTYPE_CTRL, /* 08 (BS) */
OS_CTYPE_CTRL|OS_CTYPE_SPACE, /* 09 (HT) */
OS_CTYPE_CTRL|OS_CTYPE_SPACE, /* 0A (LF) */
OS_CTYPE_CTRL|OS_CTYPE_SPACE, /* 0B (VT) */
OS_CTYPE_CTRL|OS_CTYPE_SPACE, /* 0C (FF) */
OS_CTYPE_CTRL|OS_CTYPE_SPACE, /* 0D (CR) */
OS_CTYPE_CTRL, /* 0E (SI) */
OS_CTYPE_CTRL, /* 0F (SO) */
OS_CTYPE_CTRL, /* 10 (DLE) */
OS_CTYPE_CTRL, /* 11 (DC1) */
OS_CTYPE_CTRL, /* 12 (DC2) */
OS_CTYPE_CTRL, /* 13 (DC3) */
OS_CTYPE_CTRL, /* 14 (DC4) */
OS_CTYPE_CTRL, /* 15 (NAK) */
OS_CTYPE_CTRL, /* 16 (SYN) */
OS_CTYPE_CTRL, /* 17 (ETB) */
OS_CTYPE_CTRL, /* 18 (CAN) */
OS_CTYPE_CTRL, /* 19 (EM) */
OS_CTYPE_CTRL, /* 1A (SUB) */
OS_CTYPE_CTRL, /* 1B (ESC) */
OS_CTYPE_CTRL, /* 1C (FS) */
OS_CTYPE_CTRL, /* 1D (GS) */
OS_CTYPE_CTRL, /* 1E (RS) */
OS_CTYPE_CTRL, /* 1F (US) */
OS_CTYPE_SPACE|OS_CTYPE_BLANK, /* 20 SPACE */
OS_CTYPE_PUNCT, /* 21 ! */
OS_CTYPE_PUNCT, /* 22 " */
OS_CTYPE_PUNCT, /* 23 # */
OS_CTYPE_PUNCT, /* 24 $ */
OS_CTYPE_PUNCT, /* 25 % */
OS_CTYPE_PUNCT, /* 26 & */
OS_CTYPE_PUNCT, /* 27 ' */
OS_CTYPE_PUNCT, /* 28 ( */
OS_CTYPE_PUNCT, /* 29 ) */
OS_CTYPE_PUNCT, /* 2A * */
OS_CTYPE_PUNCT, /* 2B + */
OS_CTYPE_PUNCT, /* 2C , */
OS_CTYPE_PUNCT, /* 2D - */
OS_CTYPE_PUNCT, /* 2E . */
OS_CTYPE_PUNCT, /* 2F / */
OS_CTYPE_NUMBER, /* 30 0 */
OS_CTYPE_NUMBER, /* 31 1 */
OS_CTYPE_NUMBER, /* 32 2 */
OS_CTYPE_NUMBER, /* 33 3 */
OS_CTYPE_NUMBER, /* 34 4 */
OS_CTYPE_NUMBER, /* 35 5 */
OS_CTYPE_NUMBER, /* 36 6 */
OS_CTYPE_NUMBER, /* 37 7 */
OS_CTYPE_NUMBER, /* 38 8 */
OS_CTYPE_NUMBER, /* 39 9 */
OS_CTYPE_PUNCT, /* 3A : */
OS_CTYPE_PUNCT, /* 3B ; */
OS_CTYPE_PUNCT, /* 3C < */
OS_CTYPE_PUNCT, /* 3D = */
OS_CTYPE_PUNCT, /* 3E > */
OS_CTYPE_PUNCT, /* 3F ? */
OS_CTYPE_PUNCT, /* 40 @ */
OS_CTYPE_UPPER|OS_CTYPE_HEX, /* 41 A */
OS_CTYPE_UPPER|OS_CTYPE_HEX, /* 42 B */
OS_CTYPE_UPPER|OS_CTYPE_HEX, /* 43 C */
OS_CTYPE_UPPER|OS_CTYPE_HEX, /* 44 D */
OS_CTYPE_UPPER|OS_CTYPE_HEX, /* 45 E */
OS_CTYPE_UPPER|OS_CTYPE_HEX, /* 46 F */
OS_CTYPE_UPPER, /* 47 G */
OS_CTYPE_UPPER, /* 48 H */
OS_CTYPE_UPPER, /* 49 I */
OS_CTYPE_UPPER, /* 4A J */
OS_CTYPE_UPPER, /* 4B K */
OS_CTYPE_UPPER, /* 4C L */
OS_CTYPE_UPPER, /* 4D M */
OS_CTYPE_UPPER, /* 4E N */
OS_CTYPE_UPPER, /* 4F O */
OS_CTYPE_UPPER, /* 50 P */
OS_CTYPE_UPPER, /* 51 Q */
OS_CTYPE_UPPER, /* 52 R */
OS_CTYPE_UPPER, /* 53 S */
OS_CTYPE_UPPER, /* 54 T */
OS_CTYPE_UPPER, /* 55 U */
OS_CTYPE_UPPER, /* 56 V */
OS_CTYPE_UPPER, /* 57 W */
OS_CTYPE_UPPER, /* 58 X */
OS_CTYPE_UPPER, /* 59 Y */
OS_CTYPE_UPPER, /* 5A Z */
OS_CTYPE_PUNCT, /* 5B [ */
OS_CTYPE_PUNCT, /* 5C \ */
OS_CTYPE_PUNCT, /* 5D ] */
OS_CTYPE_PUNCT, /* 5E ^ */
OS_CTYPE_PUNCT, /* 5F _ */
OS_CTYPE_PUNCT, /* 60 ` */
OS_CTYPE_LOWER|OS_CTYPE_HEX, /* 61 a */
OS_CTYPE_LOWER|OS_CTYPE_HEX, /* 62 b */
OS_CTYPE_LOWER|OS_CTYPE_HEX, /* 63 c */
OS_CTYPE_LOWER|OS_CTYPE_HEX, /* 64 d */
OS_CTYPE_LOWER|OS_CTYPE_HEX, /* 65 e */
OS_CTYPE_LOWER|OS_CTYPE_HEX, /* 66 f */
OS_CTYPE_LOWER, /* 67 g */
OS_CTYPE_LOWER, /* 68 h */
OS_CTYPE_LOWER, /* 69 i */
OS_CTYPE_LOWER, /* 6A j */
OS_CTYPE_LOWER, /* 6B k */
OS_CTYPE_LOWER, /* 6C l */
OS_CTYPE_LOWER, /* 6D m */
OS_CTYPE_LOWER, /* 6E n */
OS_CTYPE_LOWER, /* 6F o */
OS_CTYPE_LOWER, /* 70 p */
OS_CTYPE_LOWER, /* 71 q */
OS_CTYPE_LOWER, /* 72 r */
OS_CTYPE_LOWER, /* 73 s */
OS_CTYPE_LOWER, /* 74 t */
OS_CTYPE_LOWER, /* 75 u */
OS_CTYPE_LOWER, /* 76 v */
OS_CTYPE_LOWER, /* 77 w */
OS_CTYPE_LOWER, /* 78 x */
OS_CTYPE_LOWER, /* 79 y */
OS_CTYPE_LOWER, /* 7A z */
OS_CTYPE_PUNCT, /* 7B { */
OS_CTYPE_PUNCT, /* 7C | */
OS_CTYPE_PUNCT, /* 7D } */
OS_CTYPE_PUNCT, /* 7E ~ */
OS_CTYPE_CTRL, /* 7F (DEL) */
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 1997-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
/**
* @file rtctype.h
*/
#ifndef _RTCTYPE_H_
#define _RTCTYPE_H_
#include "ooasn1.h"
/* Ctype module constants */
#define OS_CTYPE_UPPER 0x1
#define OS_CTYPE_LOWER 0x2
#define OS_CTYPE_NUMBER 0x4
#define OS_CTYPE_SPACE 0x8
#define OS_CTYPE_PUNCT 0x10
#define OS_CTYPE_CTRL 0x20
#define OS_CTYPE_HEX 0x40
#define OS_CTYPE_BLANK 0x80
/* Ctype substitution macros */
#define OS_ISALPHA(c) \
(rtCtypeTable[(unsigned)(c)]&(OS_CTYPE_UPPER|OS_CTYPE_LOWER))
#define OS_ISUPPER(c) \
(rtCtypeTable[(unsigned)(c)]&OS_CTYPE_UPPER)
#define OS_ISLOWER(c) \
(rtCtypeTable[(unsigned)(c)]&OS_CTYPE_LOWER)
#define OS_ISDIGIT(c) \
(rtCtypeTable[(unsigned)(c)]&OS_CTYPE_NUMBER)
#define OS_ISXDIGIT(c) \
(rtCtypeTable[(unsigned)(c)]&(OS_CTYPE_HEX|OS_CTYPE_NUMBER))
#define OS_ISSPACE(c) \
(rtCtypeTable[(unsigned)(c)]&OS_CTYPE_SPACE)
#define OS_ISPUNCT(c) \
(rtCtypeTable[(unsigned)(c)]&OS_CTYPE_PUNCT)
#define OS_ISALNUM(c) \
(rtCtypeTable[(unsigned)(c)]&(OS_CTYPE_UPPER|OS_CTYPE_LOWER|OS_CTYPE_NUMBER))
#define OS_ISPRINT(c) \
(rtCtypeTable[(unsigned)(c)]& \
(OS_CTYPE_PUNCT|OS_CTYPE_UPPER|OS_CTYPE_LOWER|OS_CTYPE_NUMBER|OS_CTYPE_BLANK))
#define OS_ISGRAPH(c) \
(rtCtypeTable[(unsigned)(c)]& \
(OS_CTYPE_PUNCT|OS_CTYPE_UPPER|OS_CTYPE_LOWER|OS_CTYPE_NUMBER))
#define OS_ISCNTRL(c) \
(rtCtypeTable[(unsigned)(c)]&OS_CTYPE_CTRL)
#define OS_TOLOWER(c) (OS_ISUPPER(c) ? (c) - 'A' + 'a' : (c))
#define OS_TOUPPER(c) (OS_ISLOWER(c) ? (c) - 'a' + 'A' : (c))
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXTERN
#ifdef MAKE_DLL
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */
/* ctype module table */
extern EXTERN const ASN1OCTET rtCtypeTable[256];
#ifdef __cplusplus
}
#endif
#endif /* _RTCTYPE_H_ */

361
addons/ooh323cDriver.c Normal file
View File

@ -0,0 +1,361 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#include "ooh323cDriver.h"
#include <asterisk/pbx.h>
#include <asterisk/logger.h>
#include <asterisk/options.h>
extern OOBOOL gH323Debug;
/* ooh323c stack thread. */
static pthread_t ooh323c_thread = AST_PTHREADT_NULL;
static int grxframes = 240;
static int gtxframes = 20;
int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel);
int ooh323c_start_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel);
int ooh323c_stop_receive_channel(ooCallData *call, ooLogicalChannel *pChannel);
int ooh323c_stop_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel);
void* ooh323c_stack_thread(void* dummy)
{
ooMonitorChannels();
return dummy;
}
int ooh323c_start_stack_thread()
{
if(ast_pthread_create(&ooh323c_thread, NULL, ooh323c_stack_thread, NULL) < 0)
{
ast_log(LOG_ERROR, "Unable to start ooh323c thread.\n");
return -1;
}
return 0;
}
int ooh323c_stop_stack_thread(void)
{
if(ooh323c_thread != AST_PTHREADT_NULL)
{
ooStopMonitor();
pthread_join(ooh323c_thread, NULL);
ooh323c_thread = AST_PTHREADT_NULL;
}
return 0;
}
int ooh323c_set_capability
(struct ast_codec_pref *prefs, int capability, int dtmf)
{
int ret, x, format=0;
if(gH323Debug)
ast_verbose("\tAdding capabilities to H323 endpoint\n");
for(x=0; 0 != (format=ast_codec_pref_index(prefs, x)); x++)
{
if(format & AST_FORMAT_ULAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 ulaw capability to H323 endpoint\n");
ret= ooH323EpAddG711Capability(OO_G711ULAW64K, gtxframes, grxframes,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_ALAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 alaw capability to H323 endpoint\n");
ret= ooH323EpAddG711Capability(OO_G711ALAW64K, gtxframes, grxframes,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_G729A)
{
if(gH323Debug)
ast_verbose("\tAdding g729A capability to H323 endpoint\n");
ret = ooH323EpAddG729Capability(OO_G729A, 2, 24,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
if(gH323Debug)
ast_verbose("\tAdding g729 capability to H323 endpoint\n");
ret |= ooH323EpAddG729Capability(OO_G729, 2, 24,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_G723_1)
{
if(gH323Debug)
ast_verbose("\tAdding g7231 capability to H323 endpoint\n");
ret = ooH323EpAddG7231Capability(OO_G7231, 4, 7, FALSE,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_H263)
{
if(gH323Debug)
ast_verbose("\tAdding h263 capability to H323 endpoint\n");
ret = ooH323EpAddH263VideoCapability(OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_GSM)
{
if(gH323Debug)
ast_verbose("\tAdding gsm capability to H323 endpoint\n");
ret = ooH323EpAddGSMCapability(OO_GSMFULLRATE, 4, FALSE, FALSE,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
}
if(dtmf & H323_DTMF_RFC2833)
ret |= ooH323EpEnableDTMFRFC2833(0);
else if(dtmf & H323_DTMF_H245ALPHANUMERIC)
ret |= ooH323EpEnableDTMFH245Alphanumeric();
else if(dtmf & H323_DTMF_H245SIGNAL)
ret |= ooH323EpEnableDTMFH245Signal();
return ret;
}
int ooh323c_set_capability_for_call
(ooCallData *call, struct ast_codec_pref *prefs, int capability, int dtmf)
{
int ret, x, txframes;
int format=0;
if(gH323Debug)
ast_verbose("\tAdding capabilities to call(%s, %s)\n", call->callType,
call->callToken);
if(dtmf & H323_DTMF_RFC2833)
ret |= ooCallEnableDTMFRFC2833(call,0);
else if(dtmf & H323_DTMF_H245ALPHANUMERIC)
ret |= ooCallEnableDTMFH245Alphanumeric(call);
else if(dtmf & H323_DTMF_H245SIGNAL)
ret |= ooCallEnableDTMFH245Signal(call);
for(x=0; 0 !=(format=ast_codec_pref_index(prefs, x)); x++)
{
if(format & AST_FORMAT_ULAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 ulaw capability to call(%s, %s)\n",
call->callType, call->callToken);
txframes = prefs->framing[x];
ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes,
grxframes, OORXANDTX,
&ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_ALAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 alaw capability to call(%s, %s)\n",
call->callType, call->callToken);
txframes = prefs->framing[x];
ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes,
grxframes, OORXANDTX,
&ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_G729A)
{
if(gH323Debug)
ast_verbose("\tAdding g729A capability to call(%s, %s)\n",
call->callType, call->callToken);
txframes = (prefs->framing[x])/10;
ret= ooCallAddG729Capability(call, OO_G729A, txframes, 24,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
if(gH323Debug)
ast_verbose("\tAdding g729 capability to call(%s, %s)\n",
call->callType, call->callToken);
ret|= ooCallAddG729Capability(call, OO_G729, txframes, 24,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_G723_1)
{
if(gH323Debug)
ast_verbose("\tAdding g7231 capability to call (%s, %s)\n",
call->callType, call->callToken);
ret = ooCallAddG7231Capability(call, OO_G7231, 4, 7, FALSE,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_H263)
{
if(gH323Debug)
ast_verbose("\tAdding h263 capability to call (%s, %s)\n",
call->callType, call->callToken);
ret = ooCallAddH263VideoCapability(call, OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
if(format & AST_FORMAT_GSM)
{
if(gH323Debug)
ast_verbose("\tAdding gsm capability to call(%s, %s)\n",
call->callType, call->callToken);
ret = ooCallAddGSMCapability(call, OO_GSMFULLRATE, 4, FALSE, FALSE,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
}
}
int ooh323c_set_aliases(ooAliases * aliases)
{
ooAliases *cur = aliases;
while(cur)
{
switch(cur->type)
{
case T_H225AliasAddress_dialedDigits:
ooH323EpAddAliasDialedDigits(cur->value);
break;
case T_H225AliasAddress_h323_ID:
ooH323EpAddAliasH323ID(cur->value);
break;
case T_H225AliasAddress_url_ID:
ooH323EpAddAliasURLID(cur->value);
break;
case T_H225AliasAddress_email_ID:
ooH323EpAddAliasEmailID(cur->value);
break;
default:
ast_debug(1, "Ignoring unknown alias type\n");
}
cur = cur->next;
}
return 1;
}
int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
int fmt=-1;
fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
if(fmt>0)
ooh323_set_read_format(call, fmt);
else{
ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
call->callToken);
return -1;
}
return 1;
}
int ooh323c_start_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
int fmt=-1;
fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
if(fmt>0)
ooh323_set_write_format(call, fmt);
else{
ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
call->callToken);
return -1;
}
setup_rtp_connection(call, pChannel->remoteIP, pChannel->remoteMediaPort);
return 1;
}
int ooh323c_stop_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
return 1;
}
int ooh323c_stop_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
close_rtp_connection(call);
return 1;
}
int convertH323CapToAsteriskCap(int cap)
{
switch(cap)
{
case OO_G711ULAW64K:
return AST_FORMAT_ULAW;
case OO_G711ALAW64K:
return AST_FORMAT_ALAW;
case OO_GSMFULLRATE:
return AST_FORMAT_GSM;
case OO_G729:
return AST_FORMAT_G729A;
case OO_G729A:
return AST_FORMAT_G729A;
case OO_G7231:
return AST_FORMAT_G723_1;
case OO_H263VIDEO:
return AST_FORMAT_H263;
default:
ast_debug(1, "Cap %d is not supported by driver yet\n", cap);
return -1;
}
return -1;
}

39
addons/ooh323cDriver.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2004-2005 by Objective Systems, Inc.
*
* This software is furnished under an open source license and may be
* used and copied only in accordance with the terms of this license.
* The text of the license may generally be found in the root
* directory of this installation in the COPYING file. It
* can also be viewed online at the following URL:
*
* http://www.obj-sys.com/open/license.html
*
* Any redistributions of this file including modified versions must
* maintain this copyright notice.
*
*****************************************************************************/
#ifndef _OO_H323CDRIVER_H_
#define __OO_H323DRIVER_H_
#include "chan_ooh323.h"
#include "ootypes.h"
#include "ooh323ep.h"
#include "oochannels.h"
#include "ooCalls.h"
#include "ooCapability.h"
#include "ooStackCmds.h"
#define H323_DTMF_RFC2833 (1 << 0)
#define H323_DTMF_Q931 (1 << 1)
#define H323_DTMF_H245ALPHANUMERIC (1 << 2)
#define H323_DTMF_H245SIGNAL (1 << 3)
#define H323_DTMF_INBAND (1 << 4)
struct h323_pvt;
int ooh323c_start_stack_thread(void);
int ooh323c_stop_stack_thread(void);
int ooh323c_set_capability
(struct ast_codec_pref *prefs, int capability, int dtmf);
int convertH323CapToAsteriskCap(int cap);
int ooh323c_set_capability_for_call
(ooCallData *call, struct ast_codec_pref *prefs, int capability, int dtmf);
#endif

1752
addons/res_config_mysql.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ AC_DEFUN([AST_EXT_TOOL_CHECK],
[
if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
PBX_$1=0
AC_CHECK_TOOL(CONFIG_$1, $2-config, No)
AC_CHECK_TOOL(CONFIG_$1, $2, No)
if test ! "x${CONFIG_$1}" = xNo; then
if test x"$3" = x ; then A=--cflags ; else A="$3" ; fi
$1_INCLUDE=$(${CONFIG_$1} $A)

View File

@ -1,4 +1,5 @@
ALSA=@PBX_ALSA@
BLUETOOTH=@PBX_BLUETOOTH@
CRYPTO=@PBX_CRYPTO@
CURL=@PBX_CURL@
DAHDI=@PBX_DAHDI@
@ -24,6 +25,7 @@ LIBXML2=@PBX_LIBXML2@
LTDL=@PBX_LTDL@
LUA=@PBX_LUA@
MISDN=@PBX_MISDN@
MYSQLCLIENT=@PBX_MYSQLCLIENT@
NBS=@PBX_NBS@
NETSNMP=@PBX_NETSNMP@
NEWT=@PBX_NEWT@

View File

@ -0,0 +1,58 @@
;
; Note - if the database server is hosted on the same machine as the
; asterisk server, you can achieve a local Unix socket connection by
; setting hostname=localhost
;
; port and sock are both optional parameters. If hostname is specified
; and is not "localhost" (you can use address 127.0.0.1 instead), then
; cdr_mysql will attempt to connect to the port specified or use the
; default port. If hostname is not specified or if hostname is
; "localhost", then cdr_mysql will attempt to connect to the socket file
; specified by sock or otherwise use the default socket file.
;
;[global]
;hostname=database.host.name
;dbname=asteriskcdrdb
;table=cdr
;password=password
;user=asteriskcdruser
;port=3306
;sock=/tmp/mysql.sock
;
; If your system's locale differs from mysql database character set,
; cdr_mysql can damage non-latin characters in CDR variables. Use this
; option to protect your data.
;charset=koi8r
;
; Older versions of cdr_mysql set the calldate field to whenever the
; record was posted, rather than the start date of the call. This flag
; reverts to the old (incorrect) behavior. Note that you'll also need
; to comment out the "start=calldate" alias, below, to use this.
;compat=no
;
; ssl connections (optional)
;ssl_ca=<path to CA cert>
;ssl_cert=<path to cert>
;ssl_key=<path to keyfile>
;
; You may also configure the field names used in the CDR table.
;
[columns]
;static "<value>" => <column>
;alias <cdrvar> => <column>
alias start => calldate
alias callerid => clid
;alias src => src
;alias dst => dst
;alias dcontext => dcontext
;alias channel => channel
;alias dstchannel => dstchannel
;alias lastapp => lastapp
;alias lastdata => lastdata
;alias duration => duration
;alias billsec => billsec
;alias disposition => disposition
;alias amaflags => amaflags
;alias accountcode => accountcode
;alias userfield => userfield
;alias uniqueid => uniqueid

View File

@ -0,0 +1,68 @@
;
; mobile.conf
; configuration file for chan_mobile
;
[general]
interval=30 ; Number of seconds between trying to connect to devices.
; The following is a list of adapters we use.
; id must be unique and address is the bdaddr of the adapter from hciconfig.
; Each adapter may only have one device (headset or phone) connected at a time.
; Add an [adapter] entry for each adapter you have.
[adapter]
id=blue
address=00:09:DD:60:01:A3
;forcemaster=yes ; attempt to force adapter into master mode. default is no.
;alignmentdetection=yes ; enable this if you sometimes get 'white noise' on asterisk side of the call
; its a bug in the bluetooth adapter firmware, enabling this will compensate for it.
; default is no.
[adapter]
id=dlink
address=00:80:C8:35:52:78
; The following is a list of the devices we deal with.
; Every device listed below will be available for calls in and out of Asterisk.
; Each device needs an adapter=xxxx entry which determines which bluetooth adapter is used.
; Use the CLI command 'mobile search' to discover devices.
; Use the CLI command 'mobile show devices' to see device status.
;
; To place a call out through a mobile phone use Dial(Mobile/[device]/NNN.....) or Dial(Mobile/gn/NNN......) in your dialplan.
; To call a headset use Dial(Mobile/[device]).
[LGTU550]
address=00:E0:91:7F:46:44 ; the address of the phone
port=4 ; the rfcomm port number (from mobile search)
context=incoming-mobile ; dialplan context for incoming calls
adapter=dlink ; adapter to use
group=1 ; this phone is in channel group 1
;nocallsetup=yes ; set this only if your phone reports that it supports call progress notification, but does not do it. Motorola L6 for example.
[blackberry]
address=00:60:57:32:7E:B2
port=2
context=incoming-mobile
adapter=dlink
group=1
;blackberry=yes ; set this if you are using a blackberry device
[6310i]
address=00:60:57:32:7E:B1
port=13
context=incoming-mobile
adapter=dlink
group=1 ; this phone is in channel group 1 also.
[headset]
address=00:0B:9E:11:AE:C6
port=1
type=headset ; This is a headset, not a Phone !
adapter=blue
[headset1]
address=00:0B:9E:11:74:A5
port=1
type=headset
adapter=dlink

Some files were not shown because too many files have changed in this diff Show More